vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <[email protected]> | Thu Sep 25 21:50:56 2014 +0300| [5d3891a441817d0ebb9f9749d1c4104dceff1917] | committer: Jean-Baptiste Kempf
rtp: hand-over the data block reference to the packetization function (cherry picked from commit a1222364b5f81c9f6e819c001394858bc3f4cea4) Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=5d3891a441817d0ebb9f9749d1c4104dceff1917 --- modules/stream_out/rtp.c | 6 ++--- modules/stream_out/rtpfmt.c | 61 +++++++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c index 4031d18..bfdabb9 100644 --- a/modules/stream_out/rtp.c +++ b/modules/stream_out/rtp.c @@ -1265,14 +1265,13 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_sys_t *id ) static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id, block_t *p_buffer ) { - block_t *p_next; - assert( p_stream->p_sys->p_mux == NULL ); (void)p_stream; while( p_buffer != NULL ) { - p_next = p_buffer->p_next; + block_t *p_next = p_buffer->p_next; + p_buffer->p_next = NULL; /* Send a Vorbis/Theora Packed Configuration packet (RFC 5215 §3.1) * as the first packet of the stream */ @@ -1288,7 +1287,6 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id, if( id->rtp_fmt.pf_packetize( id, p_buffer ) ) break; - block_Release( p_buffer ); p_buffer = p_next; } return VLC_SUCCESS; diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c index 633fa19..75b4143 100644 --- a/modules/stream_out/rtpfmt.c +++ b/modules/stream_out/rtpfmt.c @@ -681,6 +681,7 @@ static int rtp_packetize_xiph( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -716,6 +717,7 @@ static int rtp_packetize_mpa( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -815,6 +817,7 @@ static int rtp_packetize_mpv( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -851,6 +854,7 @@ static int rtp_packetize_ac3( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -883,6 +887,7 @@ static int rtp_packetize_split( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -916,6 +921,7 @@ static int rtp_packetize_swab( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -969,6 +975,7 @@ static int rtp_packetize_mp4a_latm( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1008,6 +1015,7 @@ static int rtp_packetize_mp4a( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1030,10 +1038,12 @@ static int rtp_packetize_h263( sout_stream_id_sys_t *id, block_t *in ) if( i_data < 2 ) { + block_Release(in); return VLC_EGENERIC; } if( p_data[0] || p_data[1] ) { + block_Release(in); return VLC_EGENERIC; } /* remove 2 leading 0 bytes */ @@ -1070,6 +1080,7 @@ static int rtp_packetize_h263( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1182,6 +1193,8 @@ static int rtp_packetize_h264( sout_stream_id_sys_t *id, block_t *in ) i_buffer -= i_skip; p_buffer += i_skip; } + + block_Release(in); return VLC_SUCCESS; } @@ -1220,6 +1233,7 @@ static int rtp_packetize_amr( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1242,15 +1256,20 @@ static int rtp_packetize_t140( sout_stream_id_sys_t *id, block_t *in ) while( ( p_data[i_payload] & 0xC0 ) == 0x80 ) { if( i_payload == 0 ) + { + block_Release(in); return VLC_SUCCESS; /* fishy input! */ - + } i_payload--; } } block_t *out = block_Alloc( 12 + i_payload ); if( out == NULL ) + { + block_Release(in); return VLC_SUCCESS; + } rtp_packetize_common( id, out, 0, in->i_pts + i_packet ); memcpy( out->p_buffer + 12, p_data, i_payload ); @@ -1265,6 +1284,7 @@ static int rtp_packetize_t140( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1278,7 +1298,10 @@ static int rtp_packetize_spx( sout_stream_id_sys_t *id, block_t *in ) block_t *p_out; if ( in->i_buffer > rtp_mtu (id) ) + { + block_Release(in); return VLC_SUCCESS; + } /* RFC for Speex in RTP says that each packet must end on an octet @@ -1337,6 +1360,7 @@ static int rtp_packetize_spx( sout_stream_id_sys_t *id, block_t *in ) p_out->i_buffer = 12 + i_payload_size; p_out->i_dts = in->i_dts; p_out->i_length = in->i_length; + block_Release(in); /* Queue the buffer for actual transmission. */ rtp_packetize_send( id, p_out ); @@ -1372,6 +1396,8 @@ static int rtp_packetize_g726( sout_stream_id_sys_t *id, block_t *in, int i_pad p_data += i_payload; i_data -= i_payload; } + + block_Release(in); return VLC_SUCCESS; } @@ -1407,14 +1433,20 @@ static int rtp_packetize_vp8( sout_stream_id_sys_t *id, block_t *in ) int i_data = in->i_buffer; if ( i_max <= 0 ) + { + block_Release(in); return VLC_EGENERIC; + } for( int i = 0; i < i_count; i++ ) { int i_payload = __MIN( i_max, i_data ); block_t *out = block_Alloc( RTP_VP8_PAYLOAD_START + i_payload ); if ( out == NULL ) + { + block_Release(in); return VLC_ENOMEM; + } /* VP8 payload header */ /* All frames are marked as reference ones */ @@ -1438,6 +1470,7 @@ static int rtp_packetize_vp8( sout_stream_id_sys_t *id, block_t *in ) i_data -= i_payload; } + block_Release(in); return VLC_SUCCESS; } @@ -1463,7 +1496,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) // Skip SOI if (GetWBE(p_data) != 0xffd8) - return VLC_EGENERIC; + goto error; p_data += 2; i_data -= 2; @@ -1475,17 +1508,14 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) int section_size = GetWBE(section); uint8_t *section_body = p_data + 4; if (section + section_size > bufend) - return VLC_EGENERIC; + goto error; assert((marker & 0xff00) == 0xff00); switch (marker) { case 0xffdb /*DQT*/: if (section_body[0]) - { - // Only 8-bit precision is supported - return VLC_EGENERIC; - } + goto error; // Only 8-bit precision is supported /* a quantization table is 64 bytes long */ nb_qtables = section_size / 65; @@ -1498,7 +1528,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) if (width > 2040 || height > 2040) { // larger than limit supported by RFC 2435 - return VLC_EGENERIC; + goto error; } // Round up by 8, divide by 8 w = ((width+7)&~7) >> 3; @@ -1512,7 +1542,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) // Only 3 components are supported by RFC 2435 if (section_body[5] != 3) // Number of components - return VLC_EGENERIC; + goto error; for (int j = 0; j < 3; j++) { if (section_body[6 + j * 3] == 1 /* Y */) @@ -1522,7 +1552,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) else if (section_body[6 + j * 3 + 1] != 0x11) { // Sampling factor is unsupported by RFC 2435 - return VLC_EGENERIC; + goto error; } } break; @@ -1541,9 +1571,9 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) i_data -= 2 + section_size; } if (!header_finished) - return VLC_EGENERIC; + goto error; if (!w || !h) - return VLC_EGENERIC; + goto error; switch (y_sampling_factor) { @@ -1554,8 +1584,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) type = 0; break; default: - // Sampling format unsupported by RFC 2435 - return VLC_EGENERIC; + goto error; // Sampling format unsupported by RFC 2435 } if (dri_found) @@ -1628,5 +1657,9 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in ) off += i_payload; } + block_Release(in); return VLC_SUCCESS; +error: + block_Release(in); + return VLC_EGENERIC; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
