45 const uint8_t *buf,
int len,
46 unsigned *adu_size,
unsigned *cont)
55 *cont = !!(buf[0] & 0x80);
56 if (!(buf[0] & 0x40)) {
58 *adu_size = buf[0] & ~0xc0;
61 *adu_size =
AV_RB16(buf) & ~0xc000;
69 uint32_t *timestamp,
const uint8_t *buf,
72 unsigned adu_size, continuation;
76 buf = &
data->split_buf[
data->split_pos];
81 if (header_size < 0) {
88 if (continuation || adu_size >
len) {
100 memcpy(
pkt->data, buf, adu_size);
102 data->split_pos += header_size + adu_size;
104 if (
data->split_pos ==
data->split_buf_size) {
121 if (!continuation && adu_size <=
len) {
130 memcpy(
pkt->data, buf, adu_size);
138 if (!
data->split_buf) {
143 memcpy(
data->split_buf, buf,
data->split_buf_size);
147 }
else if (!continuation) {
151 data->adu_size = adu_size;
153 data->timestamp = *timestamp;
165 if (!
data->fragment) {
167 "Received packet without a start fragment; dropping.\n");
170 if (adu_size !=
data->adu_size ||
171 data->timestamp != *timestamp) {
180 if (
data->cur_size <
data->adu_size)
186 "Error occurred when getting fragment buffer.\n");
194 .enc_name =
"mpa-robust",
static AVFormatContext * ctx
static av_cold void close(AVCodecParserContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
#define flags(name, subs,...)
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
Parse a packet, add all split parts to parse_queue.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Macro definitions for various function/variable attributes.
Memory handling functions.
int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
Close the dynamic buffer and make a packet from it.
static void mpa_robust_close_context(PayloadContext *data)
static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
static int mpa_robust_parse_rtp_header(AVFormatContext *ctx, const uint8_t *buf, int len, unsigned *adu_size, unsigned *cont)
This structure stores compressed data.
int index
stream index in AVFormatContext
RTP/AV1 specific private data.
AVIOContext * fragment
buffer for split payloads
uint32_t timestamp
last received timestamp for frame