- uint8_t *p_data = in->p_buffer;
- int i_data = in->i_buffer;
- int i;
- int i_max = id->i_mtu - 12 - RTP_H263_HEADER_SIZE; /* payload max in one packet */
- int i_count;
- int b_p_bit;
- int b_v_bit = 0; // no pesky error resilience
- int i_plen = 0; // normally plen=0 for PSC packet
- int i_pebit = 0; // because plen=0
- uint16_t h;
-
- if( i_data < 2 )
- {
- return VLC_EGENERIC;
- }
- if( p_data[0] || p_data[1] )
- {
- return VLC_EGENERIC;
- }
- /* remove 2 leading 0 bytes */
- p_data += 2;
- i_data -= 2;
- i_count = ( i_data + i_max - 1 ) / i_max;
-
- for( i = 0; i < i_count; i++ )
- {
- int i_payload = __MIN( i_max, i_data );
- block_t *out = block_New( p_stream,
- RTP_H263_PAYLOAD_START + i_payload );
- b_p_bit = (i == 0) ? 1 : 0;
- h = ( b_p_bit << 10 )|
- ( b_v_bit << 9 )|
- ( i_plen << 3 )|
- i_pebit;
-
- /* 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 );
-
- /* h263 header */
- out->p_buffer[12] = ( h >> 8 )&0xff;
- out->p_buffer[13] = ( h )&0xff;
- memcpy( &out->p_buffer[RTP_H263_PAYLOAD_START], p_data, i_payload );
-
- out->i_buffer = RTP_H263_PAYLOAD_START + 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;
-}
-
-/* rfc3984 */
-static int
-rtp_packetize_h264_nal( sout_stream_t *p_stream, sout_stream_id_t *id,
- const uint8_t *p_data, int i_data, int64_t i_pts,
- int64_t i_dts, vlc_bool_t b_last, int64_t i_length )
-{
- const int i_max = id->i_mtu - 12; /* payload max in one packet */
- int i_nal_hdr;
- int i_nal_type;
-
- if( i_data < 5 )
- return VLC_SUCCESS;
-
- i_nal_hdr = p_data[3];
- i_nal_type = i_nal_hdr&0x1f;
- if( i_nal_type == 7 || i_nal_type == 8 )
- {
- /* XXX Why do you want to remove them ? It will break streaming with
- * SPS/PPS change (broadcast) ? */
- return VLC_SUCCESS;
- }
-
- /* Skip start code */
- p_data += 3;
- i_data -= 3;
-
- /* */
- if( i_data <= i_max )
- {
- /* Single NAL unit packet */
- block_t *out = block_New( p_stream, 12 + i_data );
- out->i_dts = i_dts;
- out->i_length = i_length;
-
- /* */
- rtp_packetize_common( id, out, b_last, i_pts );
- out->i_buffer = 12 + i_data;
-
- memcpy( &out->p_buffer[12], p_data, i_data );
-
- rtp_packetize_send( id, out );
- }
- else
- {
- /* FU-A Fragmentation Unit without interleaving */
- const int i_count = ( i_data-1 + i_max-2 - 1 ) / (i_max-2);
- int i;
-
- p_data++;
- i_data--;