Commit c32cb1d1 authored by Rafaël Carré's avatar Rafaël Carré

rtp: g726 packetization

parent 09cffd83
...@@ -1064,6 +1064,28 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1064,6 +1064,28 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->psz_enc = "MPV"; id->psz_enc = "MPV";
id->pf_packetize = rtp_packetize_mpv; id->pf_packetize = rtp_packetize_mpv;
break; break;
case VLC_FOURCC( 'G', '7', '2', '6' ):
case VLC_FOURCC( 'g', '7', '2', '6' ):
switch( p_fmt->i_bitrate / 1000 )
{
case 16:
id->psz_enc = "G726-16";
id->pf_packetize = rtp_packetize_g726_16;
break;
case 24:
id->psz_enc = "G726-24";
id->pf_packetize = rtp_packetize_g726_24;
break;
case 32:
id->psz_enc = "G726-32";
id->pf_packetize = rtp_packetize_g726_32;
break;
case 40:
id->psz_enc = "G726-40";
id->pf_packetize = rtp_packetize_g726_40;
break;
}
break;
case VLC_FOURCC( 'a', '5', '2', ' ' ): case VLC_FOURCC( 'a', '5', '2', ' ' ):
id->psz_enc = "ac3"; id->psz_enc = "ac3";
id->pf_packetize = rtp_packetize_ac3; id->pf_packetize = rtp_packetize_ac3;
......
...@@ -58,6 +58,10 @@ int rtp_packetize_h264 (sout_stream_id_t *, block_t *); ...@@ -58,6 +58,10 @@ int rtp_packetize_h264 (sout_stream_id_t *, block_t *);
int rtp_packetize_amr (sout_stream_id_t *, block_t *); int rtp_packetize_amr (sout_stream_id_t *, block_t *);
int rtp_packetize_spx (sout_stream_id_t *, block_t *); int rtp_packetize_spx (sout_stream_id_t *, block_t *);
int rtp_packetize_t140 (sout_stream_id_t *, block_t *); int rtp_packetize_t140 (sout_stream_id_t *, block_t *);
int rtp_packetize_g726_16 (sout_stream_id_t *, block_t *);
int rtp_packetize_g726_24 (sout_stream_id_t *, block_t *);
int rtp_packetize_g726_32 (sout_stream_id_t *, block_t *);
int rtp_packetize_g726_40 (sout_stream_id_t *, block_t *);
/* RTCP */ /* RTCP */
typedef struct rtcp_sender_t rtcp_sender_t; typedef struct rtcp_sender_t rtcp_sender_t;
......
...@@ -668,3 +668,55 @@ int rtp_packetize_spx( sout_stream_id_t *id, block_t *in ) ...@@ -668,3 +668,55 @@ int rtp_packetize_spx( sout_stream_id_t *id, block_t *in )
rtp_packetize_send( id, p_out ); rtp_packetize_send( id, p_out );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int rtp_packetize_g726( sout_stream_id_t *id, block_t *in, int i_pad )
{
int i_max = (rtp_mtu( id )- 12 + i_pad - 1) & ~i_pad;
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_packet = 0;
while( i_data > 0 )
{
int i_payload = __MIN( i_max, i_data );
block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, 0,
(in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload );
out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i_packet++ * 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;
}
int rtp_packetize_g726_16( sout_stream_id_t *id, block_t *in )
{
return rtp_packetize_g726( id, in, 16 );
}
int rtp_packetize_g726_24( sout_stream_id_t *id, block_t *in )
{
return rtp_packetize_g726( id, in, 24 );
}
int rtp_packetize_g726_32( sout_stream_id_t *id, block_t *in )
{
return rtp_packetize_g726( id, in, 32 );
}
int rtp_packetize_g726_40( sout_stream_id_t *id, block_t *in )
{
return rtp_packetize_g726( id, in, 40 );
}
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