57 rtp_first_dynamic_payload_handler = handler;
101 for (handler = rtp_first_dynamic_payload_handler;
102 handler; handler = handler->
next)
113 for (handler = rtp_first_dynamic_payload_handler;
114 handler; handler = handler->
next)
130 if (payload_len < 20) {
132 "Invalid length for RTCP SR packet\n");
156 #define RTP_SEQ_MOD (1 << 16)
185 uint16_t udelta = seq - s->
max_seq;
186 const int MAX_DROPOUT = 3000;
187 const int MAX_MISORDER = 100;
188 const int MIN_SEQUENTIAL = 2;
205 }
else if (udelta < MAX_DROPOUT) {
207 if (seq < s->max_seq) {
238 uint32_t extended_max;
239 uint32_t expected_interval;
240 uint32_t received_interval;
241 uint32_t lost_interval;
246 if ((!fd && !avio) || (count < 1))
274 expected = extended_max - stats->
base_seq + 1;
276 lost =
FFMIN(lost, 0xffffff);
281 lost_interval = expected_interval - received_interval;
282 if (expected_interval == 0 || lost_interval <= 0)
285 fraction = (lost_interval << 8) / expected_interval;
287 fraction = (fraction << 24) | lost;
314 for (len = (6 + len) % 4; len % 4; len++)
321 if ((len > 0) && buf) {
323 av_dlog(s->
ic,
"sending %d bytes of RR\n", len);
325 av_dlog(s->
ic,
"result from ffurl_write: %d\n", result);
349 if ((len > 0) && buf)
364 if ((len > 0) && buf)
375 int payload_type,
int queue_size)
473 unsigned int ssrc, h;
474 int payload_type, seq, ret,
flags = 0;
481 payload_type = buf[1] & 0x7f;
498 "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
499 payload_type, seq, ((s->
seq + 1) & 0xffff));
504 int padding = buf[len - 1];
505 if (len >= 12 + padding)
519 ext = (
AV_RB16(buf + 2) + 1) << 2;
545 s->
st, pkt, ×tamp, buf, len, seq, flags);
559 memcpy(pkt->
data, buf, len);
577 memcpy(pkt->
data, buf, len);
581 memcpy(pkt->
data, buf, len);
609 uint16_t seq =
AV_RB16(buf + 2);
614 int16_t diff = seq - cur->
seq;
656 "RTP: missed %d packets\n", s->
queue->
seq - s->
seq - 1);
688 s->
st, pkt, ×tamp,
NULL, 0, 0,
721 uint16_t seq =
AV_RB16(buf + 2);
722 int16_t diff = seq - s->
seq;
726 "RTP: dropping old packet received too late\n");
728 }
else if (diff <= 1) {
776 char *attr,
char *value))
781 int value_size = strlen(p) + 1;
789 while (*p && *p ==
' ')
791 while (*p && *p !=
' ')
793 while (*p && *p ==
' ')
798 value, value_size)) {
int queue_size
The size of queue, or 0 if reordering is disabled.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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...
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int64_t range_start_offset
int prev_ret
Fields for packet reordering.
RTP/JPEG specific private data.
unsigned int last_octet_count
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, const uint8_t *buf, int len)
RTPPacket * queue
A sorted queue of buffered packets not yet returned.
int index
stream index in AVFormatContext
void av_register_rtp_dynamic_payload_handlers(void)
#define RTCP_TX_RATIO_NUM
enum AVMediaType codec_type
static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
struct MpegTSContext * ts
RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler
uint32_t cycles
shifted count of sequence number cycles
#define RTCP_TX_RATIO_DEN
static RTPDynamicProtocolHandler speex_dynamic_handler
const char * ff_rtp_enc_name(int payload_type)
Return the encoding name (as defined in http://www.iana.org/assignments/rtp-parameters) for a given p...
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
enum AVMediaType codec_type
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
PayloadContext * dynamic_protocol_context
DynamicPayloadPacketHandlerProc parse_packet
uint32_t base_seq
base sequence number
void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
enum AVStreamParseType need_parsing
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt)
bitstream reader API header.
int received
packets received
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void(* destruct)(struct AVPacket *)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define RTP_FLAG_MARKER
RTP marker bit was set for this packet.
int probation
sequence packets till source is valid
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
preferred ID for decoding MPEG audio layer 1, 2 or 3
void av_log(void *avcl, int level, const char *fmt,...)
DynamicPayloadPacketHandlerProc parse_packet
Parse handler for this dynamic packet.
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
AVCodecContext * codec
Codec context associated with this stream.
MpegTSContext * ff_mpegts_parse_open(AVFormatContext *s)
uint32_t transit
relative transit time for previous packet
uint32_t jitter
estimated jitter.
int queue_len
The number of packets in queue.
unsigned int nb_streams
A list of all streams in the file.
int void avio_flush(AVIOContext *s)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t first_rtcp_ntp_time
int av_strcasecmp(const char *a, const char *b)
static RTPDynamicProtocolHandler * rtp_first_dynamic_payload_handler
int64_t last_rtcp_ntp_time
uint8_t buf[RTP_MAX_PACKET_LENGTH]
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
preferred ID for MPEG-1/2 video decoding
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
int64_t av_gettime(void)
Get the current time in microseconds.
int sample_rate
samples per second
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
int64_t unwrapped_timestamp
uint32_t last_rtcp_timestamp
void av_destruct_packet(AVPacket *pkt)
Default packet destructor.
static int parse_fmtp(AVStream *stream, PayloadContext *data, char *attr, char *value)
static int has_next_packet(RTPDemuxContext *s)
void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
void avio_w8(AVIOContext *s, int b)
RTPStatistics statistics
Statistics for this stream (used by RTCP receiver reports)
uint32_t bad_seq
last bad sequence number + 1
int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s)
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...
static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
This was the second switch in rtp_parse packet.
uint16_t max_seq
highest sequence number seen
#define RTP_PT_IS_RTCP(x)
void avio_wb16(AVIOContext *s, unsigned int val)
void ff_mpegts_parse_close(MpegTSContext *ts)
static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
#define AVERROR_INVALIDDATA
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AVERROR_PATCHWELCOME
int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
Close the dynamic buffer and make a packet from it.
void ff_rtp_parse_close(RTPDemuxContext *s)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int received_prior
packets received in last interval
void avio_wb32(AVIOContext *s, unsigned int val)
int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVStream *stream, PayloadContext *data, char *attr, char *value))
unbuffered private I/O API
static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
static RTPDynamicProtocolHandler opus_dynamic_handler
int expected_prior
packets expected in last interval
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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.
RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
struct RTPDynamicProtocolHandler * next
static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)