X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Frtpfmt.c;h=482db7d4fc4708eb3416ce7b49e18ddc40d94b9c;hb=23566858e9dae7083730cb5525c4342a1e8dbaf4;hp=680f7456b18ea969b119696da27f51aaf161bdbb;hpb=dd4e4a5e2f5b61e183adcc992eae262b39f717f9;p=vlc diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c index 680f7456b1..482db7d4fc 100644 --- a/modules/stream_out/rtpfmt.c +++ b/modules/stream_out/rtpfmt.c @@ -153,7 +153,7 @@ int rtp_packetize_mpv( sout_stream_id_t *id, block_t *in ) /* rtp common header */ rtp_packetize_common( id, out, (i == i_count - 1)?1:0, - in->i_pts > 0 ? in->i_pts : in->i_dts ); + in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts ); SetDWBE( out->p_buffer + 12, h ); @@ -224,7 +224,7 @@ int rtp_packetize_split( sout_stream_id_t *id, block_t *in ) /* rtp common header */ rtp_packetize_common( id, out, (i == i_count - 1), - (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); memcpy( &out->p_buffer[12], p_data, i_payload ); out->i_buffer = 12 + i_payload; @@ -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 > VLC_TS_INVALID ? 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 ) { @@ -262,7 +295,7 @@ int rtp_packetize_mp4a_latm( sout_stream_id_t *id, block_t *in ) /* rtp common header */ rtp_packetize_common( id, out, ((i == i_count - 1) ? 1 : 0), - (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); if( i == 0 ) { @@ -309,7 +342,7 @@ int rtp_packetize_mp4a( sout_stream_id_t *id, block_t *in ) /* rtp common header */ rtp_packetize_common( id, out, ((i == i_count - 1)?1:0), - (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); /* AU headers */ /* AU headers length (bits) */ out->p_buffer[12] = 0; @@ -375,7 +408,7 @@ int rtp_packetize_h263( sout_stream_id_t *id, block_t *in ) /* rtp common header */ //b_m_bit = 1; // always contains end of frame rtp_packetize_common( id, out, (i == i_count - 1)?1:0, - in->i_pts > 0 ? in->i_pts : in->i_dts ); + in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts ); /* h263 header */ SetWBE( out->p_buffer + 12, h ); @@ -447,7 +480,8 @@ rtp_packetize_h264_nal( sout_stream_id_t *id, out->i_length = i_length / i_count; /* */ - rtp_packetize_common( id, out, (b_last && i_payload == i_data), i_pts ); + rtp_packetize_common( id, out, (b_last && i_payload == i_data), + i_pts ); out->i_buffer = 14 + i_payload; /* FU indicator */ @@ -496,8 +530,8 @@ int rtp_packetize_h264( sout_stream_id_t *id, block_t *in ) } /* TODO add STAP-A to remove a lot of overhead with small slice/sei/... */ rtp_packetize_h264_nal( id, p_buffer, i_size, - (in->i_pts > 0 ? in->i_pts : in->i_dts), in->i_dts, - (i_size >= i_buffer), in->i_length * i_size / in->i_buffer ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts), in->i_dts, + (i_size >= i_buffer), in->i_length * i_size / in->i_buffer ); i_buffer -= i_skip; p_buffer += i_skip; @@ -522,7 +556,7 @@ int rtp_packetize_amr( sout_stream_id_t *id, block_t *in ) /* rtp common header */ rtp_packetize_common( id, out, ((i == i_count - 1)?1:0), - (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); /* Payload header */ out->p_buffer[12] = 0xF0; /* CMR */ out->p_buffer[13] = p_data[0]&0x7C; /* ToC */ /* FIXME: frame type */ @@ -649,7 +683,8 @@ int rtp_packetize_spx( sout_stream_id_t *id, block_t *in ) } /* Add the RTP header to our p_output buffer. */ - rtp_packetize_common( id, p_out, 0, (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + rtp_packetize_common( id, p_out, 0, + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); /* Copy the Speex payload to the p_output buffer */ memcpy( &p_out->p_buffer[12], p_buffer, i_data_size ); @@ -678,7 +713,7 @@ static int rtp_packetize_g726( sout_stream_id_t *id, block_t *in, int i_pad ) /* rtp common header */ rtp_packetize_common( id, out, 0, - (in->i_pts > 0 ? in->i_pts : in->i_dts) ); + (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) ); memcpy( &out->p_buffer[12], p_data, i_payload );