FFmpeg
Data Structures | Macros | Typedefs | Functions
rtpdec.h File Reference
#include "libavcodec/avcodec.h"
#include "avformat.h"
#include "rtp.h"
#include "url.h"
#include "srtp.h"

Go to the source code of this file.

Data Structures

struct  RTPStatistics
 
struct  RTPDynamicProtocolHandler
 
struct  RTPPacket
 
struct  RTPDemuxContext
 

Macros

#define RTP_MIN_PACKET_LENGTH   12
 
#define RTP_MAX_PACKET_LENGTH   8192
 
#define RTP_REORDER_QUEUE_DEFAULT_SIZE   500
 
#define RTP_NOTS_VALUE   ((uint32_t)-1)
 
#define RTP_FLAG_KEY   0x1
 RTP packet contains a keyframe. More...
 
#define RTP_FLAG_MARKER   0x2
 RTP marker bit was set for this packet. More...
 

Typedefs

typedef int(* DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx, PayloadContext *s, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
 Packet parsing for "private" payloads in the RTP specs. More...
 

Functions

RTPDemuxContextff_rtp_parse_open (AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
 open a new RTP parse context for stream 'st'. More...
 
void ff_rtp_parse_set_dynamic_protocol (RTPDemuxContext *s, PayloadContext *ctx, const RTPDynamicProtocolHandler *handler)
 
void ff_rtp_parse_set_crypto (RTPDemuxContext *s, const char *suite, const char *params)
 
int ff_rtp_parse_packet (RTPDemuxContext *s, AVPacket *pkt, uint8_t **buf, int len)
 Parse an RTP or RTCP packet directly sent as a buffer. More...
 
void ff_rtp_parse_close (RTPDemuxContext *s)
 
int64_t ff_rtp_queued_packet_time (RTPDemuxContext *s)
 
void ff_rtp_reset_packet_queue (RTPDemuxContext *s)
 
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. More...
 
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... More...
 
int ff_rtp_send_rtcp_feedback (RTPDemuxContext *s, URLContext *fd, AVIOContext *avio)
 
const RTPDynamicProtocolHandlerff_rtp_handler_iterate (void **opaque)
 Iterate over all registered rtp dynamic protocol handlers. More...
 
const RTPDynamicProtocolHandlerff_rtp_handler_find_by_name (const char *name, enum AVMediaType codec_type)
 Find a registered rtp dynamic protocol handler with the specified name. More...
 
const RTPDynamicProtocolHandlerff_rtp_handler_find_by_id (int id, enum AVMediaType codec_type)
 Find a registered rtp dynamic protocol handler with a matching codec ID. More...
 
int ff_rtsp_next_attr_and_value (const char **p, char *attr, int attr_size, char *value, int value_size)
 
int ff_parse_fmtp (AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const 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. More...
 

Macro Definition Documentation

◆ RTP_MIN_PACKET_LENGTH

#define RTP_MIN_PACKET_LENGTH   12

Definition at line 35 of file rtpdec.h.

◆ RTP_MAX_PACKET_LENGTH

#define RTP_MAX_PACKET_LENGTH   8192

Definition at line 36 of file rtpdec.h.

◆ RTP_REORDER_QUEUE_DEFAULT_SIZE

#define RTP_REORDER_QUEUE_DEFAULT_SIZE   500

Definition at line 38 of file rtpdec.h.

◆ RTP_NOTS_VALUE

#define RTP_NOTS_VALUE   ((uint32_t)-1)

Definition at line 40 of file rtpdec.h.

◆ RTP_FLAG_KEY

#define RTP_FLAG_KEY   0x1

RTP packet contains a keyframe.

Definition at line 92 of file rtpdec.h.

◆ RTP_FLAG_MARKER

#define RTP_FLAG_MARKER   0x2

RTP marker bit was set for this packet.

Definition at line 93 of file rtpdec.h.

Typedef Documentation

◆ DynamicPayloadPacketHandlerProc

typedef int(* DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx, PayloadContext *s, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)

Packet parsing for "private" payloads in the RTP specs.

Parameters
ctxRTSP demuxer context
sstream context
ststream that this packet belongs to
pktpacket in which to write the parsed data
timestamppointer to the RTP timestamp of the input data, can be updated by the function if returning older, buffered data
bufpointer to raw RTP packet data
lenlength of buf
seqRTP sequence number of the packet
flagsflags from the RTP packet header (RTP_FLAG_*)

Definition at line 108 of file rtpdec.h.

Function Documentation

◆ ff_rtp_parse_open()

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 MPEG-2 TS streams.

Definition at line 538 of file rtpdec.c.

Referenced by ff_rtsp_open_transport_ctx().

◆ ff_rtp_parse_set_dynamic_protocol()

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

Definition at line 574 of file rtpdec.c.

Referenced by ff_rtsp_open_transport_ctx().

◆ ff_rtp_parse_set_crypto()

void ff_rtp_parse_set_crypto ( RTPDemuxContext s,
const char *  suite,
const char *  params 
)

Definition at line 581 of file rtpdec.c.

Referenced by ff_rtsp_open_transport_ctx().

◆ 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 869 of file rtpdec.c.

◆ ff_rtp_parse_close()

void ff_rtp_parse_close ( RTPDemuxContext s)

Definition at line 882 of file rtpdec.c.

Referenced by ff_rtsp_undo_setup().

◆ ff_rtp_queued_packet_time()

int64_t ff_rtp_queued_packet_time ( RTPDemuxContext s)

Definition at line 755 of file rtpdec.c.

◆ ff_rtp_reset_packet_queue()

void ff_rtp_reset_packet_queue ( RTPDemuxContext s)

Definition at line 710 of file rtpdec.c.

Referenced by ff_rtp_parse_close(), and rtsp_read_play().

◆ ff_rtp_send_punch_packets()

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 402 of file rtpdec.c.

Referenced by rtsp_read_play().

◆ ff_rtp_check_and_send_back_rr()

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 299 of file rtpdec.c.

◆ ff_rtp_send_rtcp_feedback()

int ff_rtp_send_rtcp_feedback ( RTPDemuxContext s,
URLContext fd,
AVIOContext avio 
)

Definition at line 470 of file rtpdec.c.

◆ ff_rtp_handler_iterate()

const RTPDynamicProtocolHandler* ff_rtp_handler_iterate ( void **  opaque)

Iterate over all registered rtp dynamic protocol handlers.

Parameters
opaquea pointer where libavformat will store the iteration state. Must point to NULL to start the iteration.
Returns
the next registered rtp dynamic protocol handler or NULL when the iteration is finished

Definition at line 135 of file rtpdec.c.

Referenced by ff_rtp_handler_find_by_id(), and ff_rtp_handler_find_by_name().

◆ ff_rtp_handler_find_by_name()

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

Find a registered rtp dynamic protocol handler with the specified name.

Parameters
namename of the requested rtp dynamic protocol handler
Returns
A rtp dynamic protocol handler if one was found, NULL otherwise.

Definition at line 146 of file rtpdec.c.

◆ ff_rtp_handler_find_by_id()

const RTPDynamicProtocolHandler* ff_rtp_handler_find_by_id ( int  id,
enum AVMediaType  codec_type 
)

Find a registered rtp dynamic protocol handler with a matching codec ID.

Parameters
idAVCodecID of the requested rtp dynamic protocol handler.
Returns
A rtp dynamic protocol handler if one was found, NULL otherwise.

Definition at line 160 of file rtpdec.c.

◆ ff_rtsp_next_attr_and_value()

int ff_rtsp_next_attr_and_value ( const char **  p,
char *  attr,
int  attr_size,
char *  value,
int  value_size 
)

Referenced by ff_parse_fmtp().

◆ ff_parse_fmtp()

int ff_parse_fmtp ( AVFormatContext s,
AVStream stream,
PayloadContext data,
const char *  p,
int(*)(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value parse_fmtp 
)

◆ ff_rtp_finalize_packet()

int ff_rtp_finalize_packet ( AVPacket pkt,
AVIOContext **  dyn_buf,
int  stream_idx 
)