diff options
author | phintuka <phintuka> | 2006-12-14 12:57:24 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2006-12-14 12:57:24 +0000 |
commit | 26af298ebd040fdfe9357f54479da1ef54fbd3bb (patch) | |
tree | f216e93e8a44d46ebf1f0444b3f2de49e323596f | |
parent | f880a1bb1d8ea6a8fdc586b89e6fe6bcef7a05b6 (diff) | |
download | xineliboutput-26af298ebd040fdfe9357f54479da1ef54fbd3bb.tar.gz xineliboutput-26af298ebd040fdfe9357f54479da1ef54fbd3bb.tar.bz2 |
Detect RTP headers
-rw-r--r-- | xine_input_vdr.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/xine_input_vdr.c b/xine_input_vdr.c index d5d48998..70910e5d 100644 --- a/xine_input_vdr.c +++ b/xine_input_vdr.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: xine_input_vdr.c,v 1.60 2006-12-03 00:32:17 phintuka Exp $ + * $Id: xine_input_vdr.c,v 1.61 2006-12-14 12:57:24 phintuka Exp $ * */ @@ -3672,6 +3672,7 @@ static int vdr_plugin_read_net_udp(vdr_input_plugin_t *this) socklen_t address_len = sizeof(server_address); udp_data_t *udp = this->udp_data; stream_udp_header_t *pkt; + stream_rtp_header_impl_t *rtp_pkt; uint8_t *pkt_data; int result = XIO_ERROR, n, current_seq, timeouts = 0; buf_element_t *read_buffer = NULL; @@ -3773,11 +3774,37 @@ static int vdr_plugin_read_net_udp(vdr_input_plugin_t *this) LOGMSG("received too large UDP packet ; part of data was discarded"); n = read_buffer->max_size; } + read_buffer->size = n; read_buffer->type = BUF_MAJOR_MASK; pkt = (stream_udp_header_t*)read_buffer->mem; pkt_data = read_buffer->mem + sizeof(stream_udp_header_t); + + if(this->rtp) { + if(n < sizeof(stream_rtp_header_impl_t)) { + LOGMSG("received invalid RTP packet (too short)"); + continue; + } + + /* check if RTP header is valid. If not, assume UDP without RTP. */ + rtp_pkt = (stream_rtp_header_impl_t*)read_buffer->mem; + if(rtp_pkt->rtp_hdr.raw[0] == (RTP_VERSION_BYTE | RTP_HDREXT_BIT) && + rtp_pkt->rtp_hdr.raw[1] == RTP_PAYLOAD_TYPE && + rtp_pkt->hdr_ext.hdr.size == htons(RTP_HEADER_EXT_X_SIZE) && + rtp_pkt->hdr_ext.hdr.type == htons(RTP_HEADER_EXT_X_TYPE)) { + + /* strip RTP header but leave UDP header (carried inside RTP header extension) */ + pkt = (stream_udp_header_t*)(read_buffer->mem + + sizeof(stream_rtp_header_impl_t) - + sizeof(stream_udp_header_t)); + pkt_data = read_buffer->mem + sizeof(stream_rtp_header_impl_t); + + read_buffer->content += sizeof(stream_rtp_header_impl_t) - sizeof(stream_udp_header_t); + read_buffer->size -= sizeof(stream_rtp_header_impl_t) - sizeof(stream_udp_header_t); + } + } + pkt->seq = ntohs(pkt->seq); pkt->pos = ntohull(pkt->pos); |