Commit c892bd7b authored by Pierre Ynard's avatar Pierre Ynard

rtp sout: hard code dynamic payload types to 96

Payload types are scoped to the RTP session, and we put each ES in its
own session, so no risk of conflict
parent ec1c77f9
......@@ -152,8 +152,6 @@ struct vod_media_t
char *psz_rtsp_control_v6;
char *psz_rtsp_path;
int i_payload_type;
vlc_mutex_t lock;
/* ES list */
......@@ -438,8 +436,6 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
vlc_mutex_init( &p_media->lock );
p_media->i_payload_type = 96;
p_media->i_length = input_item_GetDuration( p_item );
vlc_mutex_lock( &p_item->lock );
......@@ -490,12 +486,6 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
{
char *psz_urlc;
if( p_media->i_payload_type >= 128 )
{
msg_Err( p_vod, "too many elementary streams");
return VLC_EGENERIC;
}
media_es_t *p_es = calloc( 1, sizeof(media_es_t) );
if( !p_es )
return VLC_ENOMEM;
......@@ -511,6 +501,9 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
}
msg_Dbg( p_vod, " - ES %4.4s (%s)", (char *)&p_fmt->i_codec, psz_urlc );
/* Dynamic payload. No conflict since we put each ES in its own
* RTP session */
p_es->i_payload_type = 96;
p_es->i_clock_rate = 90000;
p_es->i_channels = 1;
......@@ -526,16 +519,11 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
{
p_es->i_payload_type = 10;
}
else
{
p_es->i_payload_type = p_media->i_payload_type++;
}
p_es->psz_ptname = "L16";
p_es->i_clock_rate = p_fmt->audio.i_rate;
p_es->i_channels = p_fmt->audio.i_channels;
break;
case VLC_CODEC_U8:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "L8";
p_es->i_clock_rate = p_fmt->audio.i_rate;
p_es->i_channels = p_fmt->audio.i_channels;
......@@ -549,16 +537,13 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
p_es->psz_ptname = "MPV";
break;
case VLC_CODEC_A52:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "ac3";
p_es->i_clock_rate = p_fmt->audio.i_rate;
break;
case VLC_CODEC_H263:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "H263-1998";
break;
case VLC_CODEC_H264:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "H264";
p_es->psz_fmtp = NULL;
/* FIXME AAAAAAAAAAAARRRRRRRRGGGG copied from stream_out/rtp.c */
......@@ -649,7 +634,6 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
p_es->psz_fmtp = strdup( "packetization-mode=1" );
break;
case VLC_CODEC_MP4V:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "MP4V-ES";
if( p_fmt->i_extra > 0 )
{
......@@ -662,7 +646,6 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
}
break;
case VLC_CODEC_MP4A:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "mpeg4-generic";
p_es->i_clock_rate = p_fmt->audio.i_rate;
if( p_fmt->i_extra > 0 )
......@@ -684,11 +667,9 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
break;
case VLC_FOURCC( 'm', 'p', '2', 'p' ):
p_media->psz_mux = "ps";
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "MP2P";
break;
case VLC_CODEC_AMR_NB:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "AMR";
p_es->i_clock_rate = 8000;
if(p_fmt->audio.i_channels == 2 )
......@@ -696,7 +677,6 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
p_es->psz_fmtp = strdup( "octet-align=1" );
break;
case VLC_CODEC_AMR_WB:
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_ptname = "AMR-WB";
p_es->i_clock_rate = 16000;
if(p_fmt->audio.i_channels == 2 )
......
......@@ -281,7 +281,6 @@ struct sout_stream_sys_t
/* */
char *psz_destination;
uint32_t payload_bitmap;
uint16_t i_port;
uint16_t i_port_audio;
uint16_t i_port_video;
......@@ -472,7 +471,6 @@ static int Open( vlc_object_t *p_this )
p_sys->i_npt_zero = VLC_TS_INVALID;
p_sys->i_pts_zero = mdate(); /* arbitrary value, could probably be
* random */
p_sys->payload_bitmap = 0xFFFFFFFF;
p_sys->i_es = 0;
p_sys->es = NULL;
p_sys->rtsp = NULL;
......@@ -909,20 +907,15 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
sout_stream_sys_t *p_sys = p_stream->p_sys;
char *psz_sdp;
if (0 == p_sys->payload_bitmap)
{
msg_Err (p_stream, "too many RTP elementary streams");
return NULL;
}
sout_stream_id_t *id = malloc( sizeof( *id ) );
if( unlikely(id == NULL) )
return NULL;
id->p_stream = p_stream;
/* Look for free dymanic payload type */
id->i_payload_type = 96 + clz32 (p_sys->payload_bitmap);
assert (id->i_payload_type < 128);
/* Dynamic payload type. Payload types are scoped to the RTP
* session, and we put each ES in its own session, so no risk of
* conflict. */
id->i_payload_type = 96;
vlc_rand_bytes (&id->i_sequence, sizeof (id->i_sequence));
vlc_rand_bytes (id->ssrc, sizeof (id->ssrc));
......@@ -1357,9 +1350,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
"codec: %4.4s)", (char*)&p_fmt->i_codec );
goto error;
}
if (id->i_payload_type >= 96)
/* Mark dynamic payload type in use */
p_sys->payload_bitmap &= ~(1 << (127 - id->i_payload_type));
#if 0 /* No payload formats sets this at the moment */
int cscov = -1;
......@@ -1431,10 +1421,6 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
block_FifoRelease( id->p_fifo );
}
/* Release dynamic payload type */
if (id->i_payload_type >= 96)
p_sys->payload_bitmap |= 1 << (127 - id->i_payload_type);
free( id->psz_fmtp );
if( id->rtsp_id )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment