34 #define MIN_FEEDBACK_INTERVAL 200000
77 rtp_first_dynamic_payload_handler =
handler;
136 for (handler = rtp_first_dynamic_payload_handler;
149 for (handler = rtp_first_dynamic_payload_handler;
166 if (payload_len < 20) {
192 #define RTP_SEQ_MOD (1 << 16)
221 uint16_t udelta = seq - s->
max_seq;
222 const int MAX_DROPOUT = 3000;
223 const int MAX_MISORDER = 100;
224 const int MIN_SEQUENTIAL = 2;
241 }
else if (udelta < MAX_DROPOUT) {
243 if (seq < s->max_seq) {
266 uint32_t arrival_timestamp)
269 uint32_t transit = arrival_timestamp - sent_timestamp;
270 uint32_t prev_transit = s->
transit;
271 int32_t d = transit - prev_transit;
292 uint32_t extended_max;
293 uint32_t expected_interval;
294 uint32_t received_interval;
299 if ((!fd && !avio) || (count < 1))
327 expected = extended_max - stats->
base_seq;
329 lost =
FFMIN(lost, 0xffffff);
334 lost_interval = expected_interval - received_interval;
335 if (expected_interval == 0 || lost_interval <= 0)
338 fraction = (lost_interval << 8) / expected_interval;
340 fraction = (fraction << 24) | lost;
369 for (len = (7 + len) % 4; len % 4; len++)
376 if ((len > 0) && buf) {
404 if ((len > 0) && buf)
419 if ((len > 0) && buf)
425 uint16_t *missing_mask)
428 uint16_t next_seq = s->
seq + 1;
431 if (!pkt || pkt->
seq == next_seq)
435 for (i = 1; i <= 16; i++) {
436 uint16_t missing_seq = next_seq + i;
438 int16_t
diff = pkt->
seq - missing_seq;
445 if (pkt->
seq == missing_seq)
447 *missing_mask |= 1 << (i - 1);
450 *first_missing = next_seq;
457 int len, need_keyframe, missing_packets;
461 uint16_t first_missing = 0, missing_mask = 0;
470 if (!need_keyframe && !missing_packets)
496 if (missing_packets) {
511 if (len > 0 && buf) {
523 int payload_type,
int queue_size)
615 int payload_type, seq,
flags = 0;
621 csrc = buf[0] & 0x0f;
623 payload_type = buf[1] & 0x7f;
640 "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
641 payload_type, seq, ((s->
seq + 1) & 0xffff));
646 int padding = buf[len - 1];
647 if (len >= 12 + padding)
666 ext = (
AV_RB16(buf + 2) + 1) << 2;
677 s->
st, pkt, ×tamp, buf, len, seq,
682 memcpy(pkt->
data, buf, len);
709 uint16_t seq =
AV_RB16(buf + 2);
714 int16_t
diff = seq - (*cur)->seq;
754 "RTP: missed %d packets\n", s->
queue->
seq - s->
seq - 1);
786 s->
st, pkt, ×tamp,
NULL, 0, 0,
816 uint16_t seq =
AV_RB16(buf + 2);
821 "RTP: dropping old packet received too late\n");
823 }
else if (diff <= 1) {
878 const char *attr,
const char *
value))
883 int value_size = strlen(p) + 1;
891 while (*p && *p ==
' ')
893 while (*p && *p !=
' ')
895 while (*p && *p ==
' ')
900 value, value_size)) {
901 res =
parse_fmtp(s, stream, data, attr, value);
int queue_size
The size of queue, or 0 if reordering is disabled.
void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, const char *params)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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.
ptrdiff_t const GLvoid * data
#define AV_LOG_WARNING
Something somehow does not look correct.
static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32_t arrival_timestamp)
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.
int64_t last_feedback_time
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.
static int parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int index
stream index in AVFormatContext
#define RTCP_TX_RATIO_NUM
const RTPDynamicProtocolHandler * handler
enum AVMediaType codec_type
static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static RTPDynamicProtocolHandler l24_dynamic_handler
RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler
uint64_t last_rtcp_ntp_time
uint32_t cycles
shifted count of sequence number cycles
#define RTCP_TX_RATIO_DEN
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static RTPDynamicProtocolHandler speex_dynamic_handler
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static int find_missing_packets(RTPDemuxContext *s, uint16_t *first_missing, uint16_t *missing_mask)
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
uint64_t first_rtcp_ntp_time
static RTPDynamicProtocolHandler gsm_dynamic_handler
uint32_t base_seq
base sequence number
void ff_srtp_free(struct SRTPContext *s)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
static void handler(vbi_event *ev, void *user_data)
RTPDynamicProtocolHandler ff_dv_dynamic_handler
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void ff_register_rtp_dynamic_payload_handlers(void)
static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt)
#define AV_LOG_VERBOSE
Detailed information.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
uint32_t expected_prior
packets expected in last interval
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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)
RTPDynamicProtocolHandler ff_ac3_dynamic_handler
DynamicPayloadPacketHandlerProc parse_packet
Parse handler for this dynamic packet.
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
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
Number of elements in AVFormatContext.streams.
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static RTPDynamicProtocolHandler * rtp_first_dynamic_payload_handler
GLsizei GLboolean const GLfloat * value
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd, AVIOContext *avio)
uint32_t received
packets received
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int64_t last_rtcp_reception_time
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
int64_t unwrapped_timestamp
uint32_t last_rtcp_timestamp
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 received_prior
packets received in last interval
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...
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))
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)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int sample_rate
Audio only.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
Close the dynamic buffer and make a packet from it.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
as in Berlin toast format
int ff_srtp_set_crypto(struct SRTPContext *s, const char *suite, const char *params)
void ff_rtp_parse_close(RTPDemuxContext *s)
static RTPDynamicProtocolHandler t140_dynamic_handler
static void stats(const struct CachedBuf *in, int n_in, unsigned *_max, unsigned *_sum)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
void avio_wb32(AVIOContext *s, unsigned int val)
static int enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
unbuffered private I/O API
static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
AVCodecParameters * codecpar
int(* need_keyframe)(PayloadContext *context)
static RTPDynamicProtocolHandler opus_dynamic_handler
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.
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...
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define MIN_FEEDBACK_INTERVAL
struct RTPDynamicProtocolHandler * next