28
28
#ifndef GPAC_DISABLE_STREAMING
30
#define RTP_DEFAULT_TIMEOUT 10000
31
#define RTSP_DEFAULT_TIMEOUT 2000
30
33
static void RT_LoadPrefs(GF_InputService *plug, RTPClient *rtp)
388
391
/*this should not happen, the sdp must describe all streams in the service*/
389
392
if (!ch) return GF_STREAM_NOT_FOUND;
394
/*search for next stream*/
396
for (i = 0; i < gf_list_count(priv->channels); i++) {
397
next_ch = (RTPStream *)gf_list_get(priv->channels, i);
398
if (next_ch->prev_stream == ch->mid)
400
ch->next_stream = next_ch->mid;
391
405
/*assign app channel*/
392
406
ch->channel = channel;
467
static void gf_rtp_switch_quality(RTPClient *rtp, Bool switch_up)
470
RTPStream *ch, *cur_ch;
471
GF_NetworkCommand com;
473
count = gf_list_count(rtp->channels);
474
/*find the current stream*/
476
for (i = 0; i < count; i++) {
477
cur_ch = (RTPStream *) gf_list_get(rtp->channels, i);
478
if (cur_ch->mid != rtp->cur_mid) {
488
/*this is the highest stream*/
489
if (!cur_ch->next_stream)
491
cur_ch->status = RTP_Running;
496
for (i = 0; i < count; i++) {
497
ch = (RTPStream *) gf_list_get(rtp->channels, i);
498
if (ch->mid == cur_ch->next_stream)
500
/*resume streaming next channel*/
502
RP_InitStream(ch, 0);
504
ch->status = RTP_Running;
505
rtp->cur_mid = ch->mid;
514
/*this is the lowest stream i.e base layer*/
515
if (!cur_ch->prev_stream)
517
cur_ch->status = RTP_Running;
522
for (i = 0; i < count; i++) {
523
ch = (RTPStream *) gf_list_get(rtp->channels, i);
524
if (ch->mid == cur_ch->prev_stream)
526
/*stop streaming current channel*/
527
gf_rtp_stop(cur_ch->rtp_ch);
528
cur_ch->status = RTP_Connected;
529
com.command_type = GF_NET_CHAN_RESET;
530
com.base.on_channel = cur_ch;
531
gf_term_on_command(rtp->service, &com, GF_OK);
532
rtp->cur_mid = ch->mid;
538
GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("Switch from ES%d to ES %d\n", cur_ch->mid, ch->mid));
453
542
static GF_Err RP_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com)
470
559
priv->session_migration=1;
471
560
if (priv->session_state_data) {
472
561
com->migrate.data = priv->session_state_data;
473
com->migrate.data_len = strlen(priv->session_state_data);
562
com->migrate.data_len = (u32) strlen(priv->session_state_data);
476
565
return GF_NOT_SUPPORTED;
568
if (com->command_type == GF_NET_SERVICE_QUALITY_SWITCH)
570
gf_rtp_switch_quality(priv, com->switch_quality.up);
479
574
/*ignore commands other than channels one*/
480
575
if (!com->base.on_channel) {
481
576
if (com->command_type==GF_NET_IS_CACHABLE) return GF_OK;
544
639
RP_UserCommand(ch->rtsp, ch, com);
546
641
ch->status = RTP_Running;
642
if (!ch->next_stream)
643
priv->cur_mid = ch->mid;
547
645
if (ch->rtp_ch) {
548
646
/*technically we shouldn't attempt to synchronize streams based on RTP, we should use RTCP/ However it
549
647
may happen that the RTCP traffic is absent ...*/
550
ch->check_rtp_time = RTP_SET_TIME_RTP;
648
//ch->check_rtp_time = RTP_SET_TIME_RTP;
551
649
ch->rtcp_init = 0;
552
650
gf_mx_p(priv->mx);
553
651
RP_InitStream(ch, (ch->flags & RTP_CONNECTED) ? 1 : 0);
648
748
data = strstr(data, ",");
650
*out_data_size = gf_base64_decode(data, strlen(data), ch->buffer, RTP_BUFFER_SIZE);
750
*out_data_size = gf_base64_decode(data, (u32) strlen(data), ch->buffer, RTP_BUFFER_SIZE);
651
751
/*FIXME - currently only support for empty SL header*/
652
752
*out_data_ptr = ch->buffer;
653
753
ch->flags &= ~GF_RTP_NEW_AU;