Commit 0ffc325f authored by Laurent Aimar's avatar Laurent Aimar

* udp: mp3/rtp is now correctly working.

parent 30410626
......@@ -2,7 +2,7 @@
* udp.c: raw UDP & RTP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.24 2003/10/23 14:30:26 jpsaman Exp $
* $Id: udp.c,v 1.25 2003/11/07 18:32:55 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Tristan Leteurtre <tooney@via.ecp.fr>
......@@ -395,6 +395,7 @@ static ssize_t RTPRead( input_thread_t * p_input, byte_t * p_buffer,
int i_rtp_version;
int i_CSRC_count;
int i_payload_type;
int i_skip = 0;
byte_t * p_tmp_buffer = alloca( p_input->i_mtu );
......@@ -414,12 +415,18 @@ static ssize_t RTPRead( input_thread_t * p_input, byte_t * p_buffer,
if ( i_rtp_version != 2 )
msg_Dbg( p_input, "RTP version is %u, should be 2", i_rtp_version );
if ( i_payload_type != 33 && i_payload_type != 14
&& i_payload_type != 32 )
if( i_payload_type == 14 )
{
i_skip = 4;
}
else if( i_payload_type != 33 && i_payload_type != 32 )
{
msg_Dbg( p_input, "unsupported RTP payload type (%u)", i_payload_type );
}
i_skip += RTP_HEADER_LEN + 4*i_CSRC_count;
/* A CSRC extension field is 32 bits in size (4 bytes) */
if ( i_ret < (RTP_HEADER_LEN + 4*i_CSRC_count) )
if ( i_ret < i_skip )
{
/* Packet is not big enough to hold the complete RTP_HEADER with
* CSRC extensions.
......@@ -429,7 +436,7 @@ static ssize_t RTPRead( input_thread_t * p_input, byte_t * p_buffer,
}
/* Return the packet without the RTP header. */
i_ret -= ( RTP_HEADER_LEN + 4 * i_CSRC_count );
i_ret -= i_skip;
if ( (size_t)i_ret > i_len )
{
......@@ -438,9 +445,7 @@ static ssize_t RTPRead( input_thread_t * p_input, byte_t * p_buffer,
i_ret = i_len;
}
p_input->p_vlc->pf_memcpy( p_buffer,
p_tmp_buffer + RTP_HEADER_LEN + 4 * i_CSRC_count,
i_ret );
p_input->p_vlc->pf_memcpy( p_buffer, &p_tmp_buffer[i_skip], i_ret );
return i_ret;
}
......@@ -495,6 +500,10 @@ static ssize_t RTPChoose( input_thread_t * p_input, byte_t * p_buffer,
case 14:
msg_Dbg( p_input, "detected MPEG audio over RTP" );
if( !p_input->psz_demux || *p_input->psz_demux == '\0' )
{
p_input->psz_demux = "mp3";
}
break;
case 32:
......@@ -511,7 +520,7 @@ static ssize_t RTPChoose( input_thread_t * p_input, byte_t * p_buffer,
p_input->pf_read = RTPRead;
/* A CSRC extension field is 32 bits in size (4 bytes) */
if ( i_ret < (RTP_HEADER_LEN + 4*i_CSRC_count) )
if( i_ret < RTP_HEADER_LEN + 4*i_CSRC_count )
{
/* Packet is not big enough to hold the complete RTP_HEADER with
* CSRC extensions.
......@@ -521,7 +530,7 @@ static ssize_t RTPChoose( input_thread_t * p_input, byte_t * p_buffer,
}
/* Return the packet without the RTP header. */
i_ret -= ( RTP_HEADER_LEN + 4 * i_CSRC_count );
i_ret -= RTP_HEADER_LEN + 4*i_CSRC_count;
if ( (size_t)i_ret > i_len )
{
......@@ -530,9 +539,7 @@ static ssize_t RTPChoose( input_thread_t * p_input, byte_t * p_buffer,
i_ret = i_len;
}
p_input->p_vlc->pf_memcpy( p_buffer,
p_tmp_buffer + RTP_HEADER_LEN + 4 * i_CSRC_count,
i_ret );
p_input->p_vlc->pf_memcpy( p_buffer, &p_tmp_buffer[RTP_HEADER_LEN + 4*i_CSRC_count], i_ret );
return i_ret;
}
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