FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
rtpdec.c File Reference
#include "libavutil/mathematics.h"
#include "libavutil/avstring.h"
#include "libavutil/time.h"
#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "mpegts.h"
#include "network.h"
#include "url.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"

Go to the source code of this file.

Macros

#define RTP_SEQ_MOD   (1 << 16)
 

Functions

void ff_register_dynamic_payload_handler (RTPDynamicProtocolHandler *handler)
 
void av_register_rtp_dynamic_payload_handlers (void)
 
RTPDynamicProtocolHandlerff_rtp_handler_find_by_name (const char *name, enum AVMediaType codec_type)
 
RTPDynamicProtocolHandlerff_rtp_handler_find_by_id (int id, enum AVMediaType codec_type)
 
static int rtcp_parse_packet (RTPDemuxContext *s, const unsigned char *buf, int len)
 
static void rtp_init_statistics (RTPStatistics *s, uint16_t base_sequence)
 
static void rtp_init_sequence (RTPStatistics *s, uint16_t seq)
 
static int rtp_valid_packet_in_sequence (RTPStatistics *s, uint16_t seq)
 
int ff_rtp_check_and_send_back_rr (RTPDemuxContext *s, URLContext *fd, AVIOContext *avio, int count)
 some rtp servers assume client is dead if they don't hear from them...
 
void ff_rtp_send_punch_packets (URLContext *rtp_handle)
 Send a dummy packet on both port pairs to set up the connection state in potential NAT routers, so that we're able to receive packets.
 
RTPDemuxContextff_rtp_parse_open (AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
 open a new RTP parse context for stream 'st'.
 
void ff_rtp_parse_set_dynamic_protocol (RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
 
static void finalize_packet (RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
 This was the second switch in rtp_parse packet.
 
static int rtp_parse_packet_internal (RTPDemuxContext *s, AVPacket *pkt, const uint8_t *buf, int len)
 
void ff_rtp_reset_packet_queue (RTPDemuxContext *s)
 
static void enqueue_packet (RTPDemuxContext *s, uint8_t *buf, int len)
 
static int has_next_packet (RTPDemuxContext *s)
 
int64_t ff_rtp_queued_packet_time (RTPDemuxContext *s)
 
static int rtp_parse_queued_packet (RTPDemuxContext *s, AVPacket *pkt)
 
static int rtp_parse_one_packet (RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
 
int ff_rtp_parse_packet (RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
 Parse an RTP or RTCP packet directly sent as a buffer.
 
void ff_rtp_parse_close (RTPDemuxContext *s)
 
int ff_parse_fmtp (AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVStream *stream, PayloadContext *data, char *attr, char *value))
 
int ff_rtp_finalize_packet (AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
 Close the dynamic buffer and make a packet from it.
 

Variables

static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler
 
static RTPDynamicProtocolHandler speex_dynamic_handler
 
static RTPDynamicProtocolHandler opus_dynamic_handler
 
static RTPDynamicProtocolHandlerrtp_first_dynamic_payload_handler = NULL
 

Macro Definition Documentation

#define RTP_SEQ_MOD   (1 << 16)

Definition at line 156 of file rtpdec.c.

Referenced by rtp_init_sequence(), and rtp_valid_packet_in_sequence().

Function Documentation

void ff_register_dynamic_payload_handler ( RTPDynamicProtocolHandler handler)
void av_register_rtp_dynamic_payload_handlers ( void  )

Definition at line 60 of file rtpdec.c.

Referenced by av_register_all().

RTPDynamicProtocolHandler* ff_rtp_handler_find_by_name ( const char *  name,
enum AVMediaType  codec_type 
)

Definition at line 97 of file rtpdec.c.

RTPDynamicProtocolHandler* ff_rtp_handler_find_by_id ( int  id,
enum AVMediaType  codec_type 
)

Definition at line 109 of file rtpdec.c.

static int rtcp_parse_packet ( RTPDemuxContext s,
const unsigned char *  buf,
int  len 
)
static

Definition at line 121 of file rtpdec.c.

Referenced by rtp_parse_one_packet().

static void rtp_init_statistics ( RTPStatistics s,
uint16_t  base_sequence 
)
static

Definition at line 158 of file rtpdec.c.

Referenced by ff_rtp_parse_open().

static void rtp_init_sequence ( RTPStatistics s,
uint16_t  seq 
)
static

Definition at line 169 of file rtpdec.c.

Referenced by rtp_valid_packet_in_sequence().

static int rtp_valid_packet_in_sequence ( RTPStatistics s,
uint16_t  seq 
)
static

Definition at line 183 of file rtpdec.c.

Referenced by rtp_parse_packet_internal().

int ff_rtp_check_and_send_back_rr ( RTPDemuxContext s,
URLContext fd,
AVIOContext avio,
int  count 
)

some rtp servers assume client is dead if they don't hear from them...

so we send a Receiver Report to the provided URLContext or AVIOContext (we don't have access to the rtcp handle from here)

Definition at line 229 of file rtpdec.c.

void ff_rtp_send_punch_packets ( URLContext rtp_handle)

Send a dummy packet on both port pairs to set up the connection state in potential NAT routers, so that we're able to receive packets.

Note, this only works if the NAT router doesn't remap ports. This isn't a standardized procedure, but it works in many cases in practice.

The same routine is used with RDT too, even if RDT doesn't use normal RTP packets otherwise.

Definition at line 331 of file rtpdec.c.

RTPDemuxContext* ff_rtp_parse_open ( AVFormatContext s1,
AVStream st,
int  payload_type,
int  queue_size 
)

open a new RTP parse context for stream 'st'.

'st' can be NULL for MPEG2-TS streams to indicate that they should be demuxed inside the rtp demux (otherwise AV_CODEC_ID_MPEG2TS packets are returned)

Definition at line 374 of file rtpdec.c.

Referenced by ff_rtsp_open_transport_ctx().

void ff_rtp_parse_set_dynamic_protocol ( RTPDemuxContext s,
PayloadContext ctx,
RTPDynamicProtocolHandler handler 
)

Definition at line 424 of file rtpdec.c.

Referenced by ff_rtsp_open_transport_ctx().

static void finalize_packet ( RTPDemuxContext s,
AVPacket pkt,
uint32_t  timestamp 
)
static

This was the second switch in rtp_parse packet.

Normalizes time, if required, sets stream_index, etc.

Definition at line 435 of file rtpdec.c.

Referenced by rtp_parse_one_packet(), and rtp_parse_packet_internal().

static int rtp_parse_packet_internal ( RTPDemuxContext s,
AVPacket pkt,
const uint8_t buf,
int  len 
)
static

Definition at line 470 of file rtpdec.c.

Referenced by rtp_parse_one_packet(), and rtp_parse_queued_packet().

void ff_rtp_reset_packet_queue ( RTPDemuxContext s)

Definition at line 597 of file rtpdec.c.

Referenced by ff_rtp_parse_close(), and rtsp_read_play().

static void enqueue_packet ( RTPDemuxContext s,
uint8_t buf,
int  len 
)
static

Definition at line 610 of file rtpdec.c.

Referenced by rtp_parse_one_packet().

static int has_next_packet ( RTPDemuxContext s)
static

Definition at line 639 of file rtpdec.c.

Referenced by ff_rtp_parse_packet(), and rtp_parse_queued_packet().

int64_t ff_rtp_queued_packet_time ( RTPDemuxContext s)

Definition at line 644 of file rtpdec.c.

static int rtp_parse_queued_packet ( RTPDemuxContext s,
AVPacket pkt 
)
static

Definition at line 649 of file rtpdec.c.

Referenced by ff_rtp_parse_packet(), and rtp_parse_one_packet().

static int rtp_parse_one_packet ( RTPDemuxContext s,
AVPacket pkt,
uint8_t **  bufptr,
int  len 
)
static

Definition at line 671 of file rtpdec.c.

Referenced by ff_rtp_parse_packet().

int ff_rtp_parse_packet ( RTPDemuxContext s,
AVPacket pkt,
uint8_t **  bufptr,
int  len 
)

Parse an RTP or RTCP packet directly sent as a buffer.

Parameters
sRTP parse context.
pktreturned packet
bufptrpointer to the input buffer or NULL to read the next packets
lenbuffer len
Returns
0 if a packet is returned, 1 if a packet is returned and more can follow (use buf as NULL to read the next). -1 if no packet (error or no more packet).

Definition at line 757 of file rtpdec.c.

void ff_rtp_parse_close ( RTPDemuxContext s)

Definition at line 767 of file rtpdec.c.

Referenced by ff_rtsp_undo_setup().

int ff_parse_fmtp ( AVStream stream,
PayloadContext data,
const char *  p,
int(*)(AVStream *stream, PayloadContext *data, char *attr, char *value parse_fmtp 
)
int ff_rtp_finalize_packet ( AVPacket pkt,
AVIOContext **  dyn_buf,
int  stream_idx 
)

Close the dynamic buffer and make a packet from it.

Definition at line 812 of file rtpdec.c.

Referenced by h263_handle_packet(), jpeg_parse_packet(), svq3_parse_packet(), vp8_handle_packet(), and xiph_handle_packet().

Variable Documentation

RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler
static
Initial value:
= {
.enc_name = "X-MP3-draft-00",
.codec_type = AVMEDIA_TYPE_AUDIO,
.codec_id = AV_CODEC_ID_MP3ADU,
}

Definition at line 33 of file rtpdec.c.

RTPDynamicProtocolHandler speex_dynamic_handler
static
Initial value:
= {
.enc_name = "speex",
.codec_type = AVMEDIA_TYPE_AUDIO,
.codec_id = AV_CODEC_ID_SPEEX,
}

Definition at line 39 of file rtpdec.c.

RTPDynamicProtocolHandler opus_dynamic_handler
static
Initial value:
= {
.enc_name = "opus",
.codec_type = AVMEDIA_TYPE_AUDIO,
.codec_id = AV_CODEC_ID_OPUS,
}

Definition at line 45 of file rtpdec.c.

RTPDynamicProtocolHandler* rtp_first_dynamic_payload_handler = NULL
static

Definition at line 52 of file rtpdec.c.

Referenced by ff_register_dynamic_payload_handler().