Commit d3811079 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

RTP out: convert s16l to s16b on the fly

parent 90e78daa
......@@ -1066,6 +1066,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
rtp_set_ptime (id, 20, 1);
break;
case VLC_CODEC_S16B:
case VLC_CODEC_S16L:
if( p_fmt->audio.i_channels == 1 && p_fmt->audio.i_rate == 44100 )
{
id->i_payload_type = 11;
......@@ -1076,7 +1077,10 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->i_payload_type = 10;
}
id->psz_enc = "L16";
id->pf_packetize = rtp_packetize_split;
if( p_fmt->i_codec == VLC_CODEC_S16B )
id->pf_packetize = rtp_packetize_split;
else
id->pf_packetize = rtp_packetize_swab;
rtp_set_ptime (id, 20, 2);
break;
case VLC_CODEC_U8:
......
......@@ -51,6 +51,7 @@ int rtp_packetize_mpa (sout_stream_id_t *, block_t *);
int rtp_packetize_mpv (sout_stream_id_t *, block_t *);
int rtp_packetize_ac3 (sout_stream_id_t *, block_t *);
int rtp_packetize_split(sout_stream_id_t *, block_t *);
int rtp_packetize_swab (sout_stream_id_t *, block_t *);
int rtp_packetize_mp4a (sout_stream_id_t *, block_t *);
int rtp_packetize_mp4a_latm (sout_stream_id_t *, block_t *);
int rtp_packetize_h263 (sout_stream_id_t *, block_t *);
......
......@@ -240,6 +240,39 @@ int rtp_packetize_split( sout_stream_id_t *id, block_t *in )
return VLC_SUCCESS;
}
/* split and convert from little endian to network byte order */
int rtp_packetize_swab( sout_stream_id_t *id, block_t *in )
{
int i_max = rtp_mtu (id); /* payload max in one packet */
int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
int i_data = in->i_buffer;
int i;
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
block_t *out = block_Alloc( 12 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1),
(in->i_pts > 0 ? in->i_pts : in->i_dts) );
swab( p_data, out->p_buffer + 12, i_payload );
out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
rtp_packetize_send( id, out );
p_data += i_payload;
i_data -= i_payload;
}
return VLC_SUCCESS;
}
/* rfc3016 */
int rtp_packetize_mp4a_latm( sout_stream_id_t *id, block_t *in )
{
......
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