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

As yet untested T.140 RTP packetization

parent 86a25b2c
......@@ -741,6 +741,7 @@ static int rtp_packetize_mp4a_latm ( sout_stream_t *, sout_stream_id_t *, block_
static int rtp_packetize_h263 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_h264 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_amr ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_t140 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static void sprintf_hexa( char *s, uint8_t *p_data, int i_data )
{
......@@ -1066,6 +1067,11 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->i_clock_rate = p_fmt->audio.i_rate;
id->pf_packetize = rtp_packetize_amr;
break;
case VLC_FOURCC( 't', '1', '4', '0' ):
id->psz_rtpmap = strdup( "t140/1000" );
id->i_clock_rate = 1000;
id->pf_packetize = rtp_packetize_t140;
break;
default:
msg_Err( p_stream, "cannot add this stream (unsupported "
......@@ -1991,6 +1997,52 @@ static int rtp_packetize_amr( sout_stream_t *p_stream, sout_stream_id_t *id,
return VLC_SUCCESS;
}
static int rtp_packetize_t140( sout_stream_t *p_stream, sout_stream_id_t *id,
block_t *in )
{
const size_t i_max = id->i_mtu - 12;
const uint8_t *p_data = in->p_buffer;
size_t i_data = in->i_buffer;
for( unsigned i_packet = 0; i_data > 0; i_packet++ )
{
size_t i_payload = i_data;
/* Make sure we stop on an UTF-8 character boundary
* (assuming the input is valid UTF-8) */
if( i_data > i_max )
{
i_payload = i_max;
while( ( p_data[i_payload] & 0xC0 ) == 0x80 )
{
if( i_payload == 0 )
return VLC_SUCCESS; /* fishy input! */
i_payload--;
}
}
block_t *out = block_New( p_stream, 12 + i_payload );
if( out == NULL )
return VLC_SUCCESS;
rtp_packetize_common( id, out, 0, in->i_pts + i_packet );
memcpy( out->p_buffer + 12, p_data, i_payload );
out->i_buffer = 12 + i_payload;
out->i_dts = out->i_pts;
out->i_length = 0;
rtp_packetize_send( id, out );
p_data += i_payload;
i_data -= i_payload;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* Non-RTP mux
*****************************************************************************/
......
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