~ubuntu-branches/ubuntu/intrepid/gpac/intrepid-proposed

« back to all changes in this revision

Viewing changes to modules/rtp_in/rtp_signaling.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2007-01-24 23:34:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070124233457-zzlls8afkt0nyakj
Tags: 0.4.2~rc2-0ubuntu1
* New upstream release
  * Most notably MP4 tagging support via MP4Box -itags
* debian/patches/01_64bits.dpatch: dropped; included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
Bool channel_is_valid(RTPClient *rtp, RTPStream *ch)
29
29
{
30
 
        u32 i;
31
 
        for (i=0; i<gf_list_count(rtp->channels); i++) {
32
 
                if (gf_list_get(rtp->channels, i) == ch) return 1;
 
30
        u32 i=0;
 
31
        RTPStream *st;
 
32
        while ((st = gf_list_enum(rtp->channels, &i))) {
 
33
                if (st == ch) return 1;
33
34
        }
34
35
        return 0;
35
36
}
38
39
{
39
40
        if (!ch || !ch->rtsp) return;
40
41
 
41
 
        ch->flags &= ~CH_Idle;
 
42
        ch->flags &= ~CH_SkipNextCommand;
42
43
        ch->status = RTP_Disconnected;
43
44
        //remove interleaved
44
45
        if (gf_rtp_is_interleaved(ch->rtp_ch)) {
49
50
/*this prevent sending teardown on session with running channels*/
50
51
Bool RP_SessionActive(RTPStream *ch)
51
52
{
52
 
        u32 i, count, idle;
53
 
        idle = count = 0;
54
 
        for (i=0; i<gf_list_count(ch->owner->channels); i++) {
55
 
                RTPStream *ach = gf_list_get(ch->owner->channels, i);
 
53
        RTPStream *ach;
 
54
        u32 i, count;
 
55
        i = count = 0;
 
56
        while ((ach = gf_list_enum(ch->owner->channels, &i))) {
56
57
                if (ach->rtsp != ch->rtsp) continue;
57
58
                /*count only active channels*/
58
 
                if (ach->status == RTP_Running) continue;
59
 
                count++;
60
 
                if (ach->flags & CH_Idle) idle++;
 
59
                if (ach->status == RTP_Running) count++;
61
60
        }
62
 
        return (count==idle) ? 0 : 1;
 
61
        return count ? 1 : 0;
63
62
}
64
63
 
65
64
 
141
140
        u32 i;
142
141
        GF_RTSPTransport *trans;
143
142
        
144
 
        
145
143
        ch = com->user_data;
146
144
        if (e) goto exit;
147
145
 
159
157
        if (!ch) goto exit;
160
158
 
161
159
        /*transport setup: break at the first correct transport */
162
 
        for (i=0; i<gf_list_count(sess->rtsp_rsp->Transports); i++) {
163
 
                trans = gf_list_get(sess->rtsp_rsp->Transports, 0);
 
160
        i=0;
 
161
        while ((trans = gf_list_enum(sess->rtsp_rsp->Transports, &i))) {
 
162
                /*copy over prev ports*/
 
163
                if (ch->owner->force_client_ports)
 
164
                        gf_rtp_get_ports(ch->rtp_ch, &trans->client_port_first, &trans->client_port_last);
 
165
                
164
166
                e = gf_rtp_setup_transport(ch->rtp_ch, trans, gf_rtsp_get_server_name(sess->session));
165
167
                if (!e) break;
166
168
        }
215
217
}
216
218
 
217
219
/*process describe reply*/
218
 
void RP_ProcessDescribe(RTPSession *sess, GF_RTSPCommand *com, GF_Err e)
 
220
Bool RP_ProcessDescribe(RTPSession *sess, GF_RTSPCommand *com, GF_Err e)
219
221
{
220
222
        RTPStream *ch;
221
223
        ChannelDescribe *ch_desc;
258
260
        e = RP_SetupChannel(ch, ch_desc);
259
261
 
260
262
exit:
 
263
        com->user_data = NULL;
261
264
        if (e) {
262
265
                if (!ch_desc) {
 
266
                        /*THIS MAY DESTROY THE WHOLE PLUGIN*/
263
267
                        gf_term_on_connect(sess->owner->service, NULL, e);
 
268
                        return 0;
264
269
                } else if (ch) {
265
270
                        RP_ConfirmChannelConnect(ch, e);
266
271
                } else {
268
273
                }
269
274
        }
270
275
        if (ch_desc) free(ch_desc);
271
 
        com->user_data = NULL;
 
276
        return 1;
272
277
}
273
278
 
274
279
/*send describe*/
356
361
                skip_it = 1;
357
362
        }
358
363
        /*check if aggregation discards this command*/
359
 
        if ((ch->flags & CH_Idle) || skip_it || (sess->has_aggregated_control && (ch->flags & CH_SkipNextCommand) )) {
 
364
        if (skip_it || (sess->has_aggregated_control && (ch->flags & CH_SkipNextCommand) )) {
360
365
                ch->flags &= ~CH_SkipNextCommand;
361
 
                ch->flags &= ~CH_Idle;
362
366
                gf_term_on_command(sess->owner->service, &ch_ctrl->com, GF_OK);
363
367
                free(ch_ctrl);
364
368
                com->user_data = NULL;
379
383
static void SkipCommandOnSession(RTPStream *ch)
380
384
{
381
385
        u32 i;
 
386
        RTPStream *a_ch;
382
387
        if (!ch || (ch->flags & CH_SkipNextCommand) || !ch->rtsp->has_aggregated_control) return;
383
 
        for (i=0; i<gf_list_count(ch->owner->channels); i++) {
384
 
                RTPStream *a_ch = gf_list_get(ch->owner->channels, i);
385
 
                if ((a_ch->flags & CH_Idle) || (ch == a_ch) || (a_ch->rtsp != ch->rtsp) ) continue;
 
388
        i=0;
 
389
        while ((a_ch = gf_list_enum(ch->owner->channels, &i))) {
 
390
                if ((ch == a_ch) || (a_ch->rtsp != ch->rtsp) ) continue;
386
391
                a_ch->flags |= CH_SkipNextCommand;
387
392
        }
388
393
}
392
397
{
393
398
        ChannelControl *ch_ctrl;
394
399
        RTPStream *ch, *agg_ch;
395
 
        u32 i;
 
400
        u32 i, count;
396
401
        GF_RTPInfo *info;
397
402
 
398
403
 
444
449
                }
445
450
 
446
451
                //process all RTP infos
447
 
                for (i=0;i<gf_list_count(sess->rtsp_rsp->RTP_Infos); i++) {
 
452
                count = gf_list_count(sess->rtsp_rsp->RTP_Infos);
 
453
                for (i=0;i<count; i++) {
448
454
                        info = gf_list_get(sess->rtsp_rsp->RTP_Infos, i);
449
455
                        agg_ch = RP_FindChannel(sess->owner, NULL, 0, info->url, 0);
450
456
 
548
554
        if ( (command->command_type==GF_NET_CHAN_PLAY) || (command->command_type==GF_NET_CHAN_RESUME) || (command->command_type==GF_NET_CHAN_PAUSE)) {
549
555
                if (ch->status == RTP_Disconnected) {
550
556
                        if (sess->has_aggregated_control) {
551
 
                                for (i=0; i<gf_list_count(sess->owner->channels); i++) {
552
 
                                        a_ch = gf_list_get(sess->owner->channels, i);
 
557
                                i=0;
 
558
                                while ((a_ch = gf_list_enum(sess->owner->channels, &i))) {
553
559
                                        if (a_ch->rtsp != sess) continue;
554
560
                                        RP_Setup(a_ch);
555
561
                                }
627
633
        //but let's be nice to the server
628
634
        else if (command->command_type==GF_NET_CHAN_STOP) {
629
635
                ch->current_start = 0;
630
 
                ch->flags |= CH_Idle;
631
 
 
632
636
                ch->stat_stop_time = gf_sys_clock();
 
637
                RP_StopChannel(ch);
 
638
                if (com) gf_rtsp_command_del(com);
633
639
 
634
640
                /*last stream running*/
635
 
                if (!RP_SessionActive(ch)) {
636
 
                        ch->flags &= ~CH_Idle;
637
 
                        RP_StopChannel(ch);
638
 
                        SkipCommandOnSession(ch);
639
 
                        ch->flags &= ~CH_SkipNextCommand;
640
 
                        gf_rtsp_command_del(com);
641
 
                        RP_FlushAndTearDown(sess);
642
 
                } else {
643
 
                        ch->flags &= ~CH_SkipNextCommand;
644
 
                        if (com) gf_rtsp_command_del(com);
645
 
                }
 
641
                if (!RP_SessionActive(ch)) RP_FlushAndTearDown(sess);
646
642
                return;
647
643
        } else {
648
644
                gf_term_on_command(sess->owner->service, command, GF_NOT_SUPPORTED);