58 RTPFirstDynamicPayloadHandler= handler;
97 for (handler = RTPFirstDynamicPayloadHandler;
98 handler; handler = handler->
next)
109 for (handler = RTPFirstDynamicPayloadHandler;
110 handler; handler = handler->
next)
125 if (payload_len < 20) {
150 #define RTP_SEQ_MOD (1<<16)
183 uint16_t udelta= seq - s->
max_seq;
184 const int MAX_DROPOUT= 3000;
185 const int MAX_MISORDER = 100;
186 const int MIN_SEQUENTIAL = 2;
203 }
else if (udelta < MAX_DROPOUT) {
205 if(seq < s->max_seq) {
234 uint32_t extended_max;
235 uint32_t expected_interval;
236 uint32_t received_interval;
237 uint32_t lost_interval;
242 if (!s->
rtp_ctx || (count < 1))
268 expected= extended_max - stats->
base_seq + 1;
270 lost=
FFMIN(lost, 0xffffff);
275 lost_interval= expected_interval - received_interval;
276 if (expected_interval==0 || lost_interval<=0) fraction= 0;
277 else fraction = (lost_interval<<8)/expected_interval;
279 fraction= (fraction<<24) | lost;
307 for (len = (6 + len) % 4; len % 4; len++) {
313 if ((len > 0) && buf) {
315 av_dlog(s->
ic,
"sending %d bytes of RR\n", len);
317 av_dlog(s->
ic,
"result from ffurl_write: %d\n", result);
341 if ((len > 0) && buf)
356 if ((len > 0) && buf)
457 const uint8_t *buf,
int len)
459 unsigned int ssrc, h;
460 int payload_type, seq, ret,
flags = 0;
467 payload_type = buf[1] & 0x7f;
485 payload_type, seq, ((s->
seq + 1) & 0xffff));
490 int padding = buf[len - 1];
491 if (len >= 12 + padding)
505 ext = (
AV_RB16(buf + 2) + 1) << 2;
531 s->
st, pkt, ×tamp, buf, len, flags);
544 memcpy(pkt->
data, buf, len);
562 memcpy(pkt->
data, buf, len);
566 memcpy(pkt->
data, buf, len);
594 uint16_t seq =
AV_RB16(buf + 2);
599 int16_t diff = seq - cur->
seq;
641 "RTP: missed %d packets\n", s->
queue->
seq - s->
seq - 1);
654 uint8_t **bufptr,
int len)
656 uint8_t* buf = bufptr ? *bufptr :
NULL;
673 s->
st, pkt, ×tamp,
NULL, 0, flags);
705 uint16_t seq =
AV_RB16(buf + 2);
706 int16_t diff = seq - s->
seq;
710 "RTP: dropping old packet received too late\n");
712 }
else if (diff <= 1) {
739 uint8_t **bufptr,
int len)
760 char *attr,
char *value))
765 int value_size = strlen(p) + 1;
773 while (*p && *p ==
' ') p++;
774 while (*p && *p !=
' ') p++;
775 while (*p && *p ==
' ') p++;
779 value, value_size)) {
int queue_size
The size of queue, or 0 if reordering is disabled.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
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...
AV_WL32 AV_WL24 AV_WL16 AV_RB32
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int64_t range_start_offset
int prev_ret
Fields for packet reordering.
#define AV_LOG_WARNING
Something somehow does not look correct.
RTP/H264 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.
enum AVMediaType codec_type
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)
struct MpegTSContext * ts
RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler
uint32_t cycles
shifted count of sequence number cycles
#define RTCP_TX_RATIO_DEN
DynamicPayloadPacketHandlerProc parse_packet
parse handler for this dynamic packet.
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.
PayloadContext * dynamic_protocol_context
This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
DynamicPayloadPacketHandlerProc parse_packet
This is also copied from the dynamic protocol handler structure.
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)
from rtsp.c, but used by rtp dynamic protocol handlers.
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)
preferred ID for MPEG-1/2 video decoding
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
int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
some rtp servers assume client is dead if they don't hear from them...
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
called whenever there is a large jump in sequence numbers, or when they get out of probation...
void av_log(void *avcl, int level, const char *fmt,...)
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
AVCodecContext * codec
codec context
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)
int64_t last_rtcp_ntp_time
uint8_t buf[RTP_MAX_PACKET_LENGTH]
uint64_t count
number of bytes in buffer
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
static RTPDynamicProtocolHandler * RTPFirstDynamicPayloadHandler
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
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
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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)
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
void avio_wb16(AVIOContext *s, unsigned int val)
struct RTPDynamicProtocolHandler_s * next
void ff_mpegts_parse_close(MpegTSContext *ts)
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
void ff_rtp_parse_close(RTPDemuxContext *s)
static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler
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)
called on parse open packet
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
static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
returns 1 if we should handle this packet.
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.
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t av_gettime(void)
Get the current time in microseconds.
static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)