65#define RTP_HEADER_SIZE 12
66#define RTP_PAYLOAD (TS_PER_RTP * TS_SIZE)
71#define PES_STREAM_ID 0xe0
77#define PES_TS_PACKETS 17
78#define PES_ES_LEN ((TS_PAYLOAD - PES_HDR_SIZE) + (PES_TS_PACKETS - 1) * TS_PAYLOAD)
86#define NB_TS_PACKETS 35
87#define NB_RTP_PACKETS (NB_TS_PACKETS / TS_PER_RTP)
105 const uint8_t *payload)
108 dst[1] = (pusi ? 0x40 : 0x00) | ((
ES_PID >> 8) & 0x1f);
110 dst[3] = 0x10 | (cc & 0x0f);
115static void add_pes(uint8_t *ts,
int *off,
int *cc,
int *es_counter,
int es_len)
122 int es_done = 0, first = 1;
124 while (es_done < es_len) {
133 for (
i = 0;
i < chunk;
i++)
134 payload[p +
i] = (uint8_t)((*es_counter)++ & 0xff);
138 *cc = (*cc + 1) & 0x0f;
146 int off = 0, cc = 0, es_counter = 0;
159 out->total +
pkt->size <= (
int)
sizeof(
out->bytes)) {
176 uint8_t *bufptr = buf;
207 memset(
out, 0,
sizeof(*
out));
214 if (!
s || !pc || !
pkt) {
247 fprintf(stderr,
" %-9s %d packet(s), %d bytes, sizes:",
label, o->
nb, o->
total);
248 for (
i = 0;
i < o->
nb;
i++)
249 fprintf(stderr,
" %d", o->
sizes[
i]);
250 fprintf(stderr,
"\n");
265 if (
run(ts_stream, in_order, &
ref) < 0 ||
266 run(ts_stream, reordered, &got) < 0) {
267 fprintf(stderr,
"test setup failed\n");
275 "FAIL: reordering an RTP packet with a mid-payload PUSI dropped "
278 dump(
"reordered:", &got);
282 printf(
"OK: %d PES packets (%d bytes) recovered identically with and "
283 "without reordering\n",
ref.nb,
ref.total);
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
__device__ int printf(const char *,...)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Memory handling functions.
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
void ff_rtp_parse_close(RTPDemuxContext *s)
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, const RTPDynamicProtocolHandler *handler)
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.
#define FF_ARRAY_ELEMS(a)
This structure stores compressed data.
RTP/AV1 specific private data.
static int ref[MAX_W *MAX_W]
static void collect(AVPacket *pkt, Output *out)
static void feed(RTPDemuxContext *s, AVPacket *pkt, const uint8_t *ts_stream, int block, Output *out)
static void put_ts_packet(uint8_t *dst, int pusi, int cc, const uint8_t *payload)
static void build_ts_stream(uint8_t *ts)
static void add_pes(uint8_t *ts, int *off, int *cc, int *es_counter, int es_len)
static void dump(const char *label, const Output *o)