FFmpeg
rtpdec.c
Go to the documentation of this file.
1 /*
2  * RTP input format
3  * Copyright (c) 2002 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/mathematics.h"
23 #include "libavutil/avstring.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/time.h"
26 
27 #include "avformat.h"
28 #include "network.h"
29 #include "srtp.h"
30 #include "url.h"
31 #include "rtpdec.h"
32 #include "rtpdec_formats.h"
33 
34 #define MIN_FEEDBACK_INTERVAL 200000 /* 200 ms in us */
35 
37  .enc_name = "L24",
38  .codec_type = AVMEDIA_TYPE_AUDIO,
39  .codec_id = AV_CODEC_ID_PCM_S24BE,
40 };
41 
43  .enc_name = "GSM",
44  .codec_type = AVMEDIA_TYPE_AUDIO,
45  .codec_id = AV_CODEC_ID_GSM,
46 };
47 
49  .enc_name = "X-MP3-draft-00",
50  .codec_type = AVMEDIA_TYPE_AUDIO,
51  .codec_id = AV_CODEC_ID_MP3ADU,
52 };
53 
55  .enc_name = "speex",
56  .codec_type = AVMEDIA_TYPE_AUDIO,
57  .codec_id = AV_CODEC_ID_SPEEX,
58 };
59 
61  .enc_name = "opus",
62  .codec_type = AVMEDIA_TYPE_AUDIO,
63  .codec_id = AV_CODEC_ID_OPUS,
64 };
65 
67  .enc_name = "t140",
68  .codec_type = AVMEDIA_TYPE_SUBTITLE,
69  .codec_id = AV_CODEC_ID_TEXT,
70 };
71 
76 
78  /* rtp */
127  /* rdt */
132  NULL,
133 };
134 
136 {
137  uintptr_t i = (uintptr_t)*opaque;
139 
140  if (r)
141  *opaque = (void*)(i + 1);
142 
143  return r;
144 }
145 
147  enum AVMediaType codec_type)
148 {
149  void *i = 0;
151  while (handler = ff_rtp_handler_iterate(&i)) {
152  if (handler->enc_name &&
153  !av_strcasecmp(name, handler->enc_name) &&
154  codec_type == handler->codec_type)
155  return handler;
156  }
157  return NULL;
158 }
159 
161  enum AVMediaType codec_type)
162 {
163  void *i = 0;
165  while (handler = ff_rtp_handler_iterate(&i)) {
166  if (handler->static_payload_id && handler->static_payload_id == id &&
167  codec_type == handler->codec_type)
168  return handler;
169  }
170  return NULL;
171 }
172 
173 static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
174  int len)
175 {
176  int payload_len;
177  while (len >= 4) {
178  payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);
179 
180  switch (buf[1]) {
181  case RTCP_SR:
182  if (payload_len < 20) {
183  av_log(s->ic, AV_LOG_ERROR, "Invalid RTCP SR packet length\n");
184  return AVERROR_INVALIDDATA;
185  }
186 
187  s->last_rtcp_reception_time = av_gettime_relative();
188  s->last_rtcp_ntp_time = AV_RB64(buf + 8);
189  s->last_rtcp_timestamp = AV_RB32(buf + 16);
190  if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
191  s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
192  if (!s->base_timestamp)
193  s->base_timestamp = s->last_rtcp_timestamp;
194  s->rtcp_ts_offset = (int32_t)(s->last_rtcp_timestamp - s->base_timestamp);
195  }
196 
197  break;
198  case RTCP_BYE:
199  return -RTCP_BYE;
200  }
201 
202  buf += payload_len;
203  len -= payload_len;
204  }
205  return -1;
206 }
207 
208 #define RTP_SEQ_MOD (1 << 16)
209 
210 static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
211 {
212  memset(s, 0, sizeof(RTPStatistics));
213  s->max_seq = base_sequence;
214  s->probation = 1;
215 }
216 
217 /*
218  * Called whenever there is a large jump in sequence numbers,
219  * or when they get out of probation...
220  */
221 static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
222 {
223  s->max_seq = seq;
224  s->cycles = 0;
225  s->base_seq = seq - 1;
226  s->bad_seq = RTP_SEQ_MOD + 1;
227  s->received = 0;
228  s->expected_prior = 0;
229  s->received_prior = 0;
230  s->jitter = 0;
231  s->transit = 0;
232 }
233 
234 /* Returns 1 if we should handle this packet. */
235 static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
236 {
237  uint16_t udelta = seq - s->max_seq;
238  const int MAX_DROPOUT = 3000;
239  const int MAX_MISORDER = 100;
240  const int MIN_SEQUENTIAL = 2;
241 
242  /* source not valid until MIN_SEQUENTIAL packets with sequence
243  * seq. numbers have been received */
244  if (s->probation) {
245  if (seq == s->max_seq + 1) {
246  s->probation--;
247  s->max_seq = seq;
248  if (s->probation == 0) {
249  rtp_init_sequence(s, seq);
250  s->received++;
251  return 1;
252  }
253  } else {
254  s->probation = MIN_SEQUENTIAL - 1;
255  s->max_seq = seq;
256  }
257  } else if (udelta < MAX_DROPOUT) {
258  // in order, with permissible gap
259  if (seq < s->max_seq) {
260  // sequence number wrapped; count another 64k cycles
261  s->cycles += RTP_SEQ_MOD;
262  }
263  s->max_seq = seq;
264  } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {
265  // sequence made a large jump...
266  if (seq == s->bad_seq) {
267  /* two sequential packets -- assume that the other side
268  * restarted without telling us; just resync. */
269  rtp_init_sequence(s, seq);
270  } else {
271  s->bad_seq = (seq + 1) & (RTP_SEQ_MOD - 1);
272  return 0;
273  }
274  } else {
275  // duplicate or reordered packet...
276  }
277  s->received++;
278  return 1;
279 }
280 
281 static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp,
282  uint32_t arrival_timestamp)
283 {
284  // Most of this is pretty straight from RFC 3550 appendix A.8
285  uint32_t transit = arrival_timestamp - sent_timestamp;
286  uint32_t prev_transit = s->transit;
287  int32_t d = transit - prev_transit;
288  // Doing the FFABS() call directly on the "transit - prev_transit"
289  // expression doesn't work, since it's an unsigned expression. Doing the
290  // transit calculation in unsigned is desired though, since it most
291  // probably will need to wrap around.
292  d = FFABS(d);
293  s->transit = transit;
294  if (!prev_transit)
295  return;
296  s->jitter += d - (int32_t) ((s->jitter + 8) >> 4);
297 }
298 
300  AVIOContext *avio, int count)
301 {
302  AVIOContext *pb;
303  uint8_t *buf;
304  int len;
305  int rtcp_bytes;
306  RTPStatistics *stats = &s->statistics;
307  uint32_t lost;
308  uint32_t extended_max;
309  uint32_t expected_interval;
310  uint32_t received_interval;
311  int32_t lost_interval;
312  uint32_t expected;
313  uint32_t fraction;
314 
315  if ((!fd && !avio) || (count < 1))
316  return -1;
317 
318  /* TODO: I think this is way too often; RFC 1889 has algorithm for this */
319  /* XXX: MPEG pts hardcoded. RTCP send every 0.5 seconds */
320  s->octet_count += count;
321  rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
323  rtcp_bytes /= 50; // mmu_man: that's enough for me... VLC sends much less btw !?
324  if (rtcp_bytes < 28)
325  return -1;
326  s->last_octet_count = s->octet_count;
327 
328  if (!fd)
329  pb = avio;
330  else if (avio_open_dyn_buf(&pb) < 0)
331  return -1;
332 
333  // Receiver Report
334  avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
335  avio_w8(pb, RTCP_RR);
336  avio_wb16(pb, 7); /* length in words - 1 */
337  // our own SSRC: we use the server's SSRC + 1 to avoid conflicts
338  avio_wb32(pb, s->ssrc + 1);
339  avio_wb32(pb, s->ssrc); // server SSRC
340  // some placeholders we should really fill...
341  // RFC 1889/p64
342  extended_max = stats->cycles + stats->max_seq;
343  expected = extended_max - stats->base_seq;
344  lost = expected - stats->received;
345  lost = FFMIN(lost, 0xffffff); // clamp it since it's only 24 bits...
346  expected_interval = expected - stats->expected_prior;
347  stats->expected_prior = expected;
348  received_interval = stats->received - stats->received_prior;
349  stats->received_prior = stats->received;
350  lost_interval = expected_interval - received_interval;
351  if (expected_interval == 0 || lost_interval <= 0)
352  fraction = 0;
353  else
354  fraction = (lost_interval << 8) / expected_interval;
355 
356  fraction = (fraction << 24) | lost;
357 
358  avio_wb32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */
359  avio_wb32(pb, extended_max); /* max sequence received */
360  avio_wb32(pb, stats->jitter >> 4); /* jitter */
361 
362  if (s->last_rtcp_ntp_time == AV_NOPTS_VALUE) {
363  avio_wb32(pb, 0); /* last SR timestamp */
364  avio_wb32(pb, 0); /* delay since last SR */
365  } else {
366  uint32_t middle_32_bits = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special?
367  uint32_t delay_since_last = av_rescale(av_gettime_relative() - s->last_rtcp_reception_time,
368  65536, AV_TIME_BASE);
369 
370  avio_wb32(pb, middle_32_bits); /* last SR timestamp */
371  avio_wb32(pb, delay_since_last); /* delay since last SR */
372  }
373 
374  // CNAME
375  avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
376  avio_w8(pb, RTCP_SDES);
377  len = strlen(s->hostname);
378  avio_wb16(pb, (7 + len + 3) / 4); /* length in words - 1 */
379  avio_wb32(pb, s->ssrc + 1);
380  avio_w8(pb, 0x01);
381  avio_w8(pb, len);
382  avio_write(pb, s->hostname, len);
383  avio_w8(pb, 0); /* END */
384  // padding
385  for (len = (7 + len) % 4; len % 4; len++)
386  avio_w8(pb, 0);
387 
388  avio_flush(pb);
389  if (!fd)
390  return 0;
391  len = avio_close_dyn_buf(pb, &buf);
392  if ((len > 0) && buf) {
393  int av_unused result;
394  av_log(s->ic, AV_LOG_TRACE, "sending %d bytes of RR\n", len);
395  result = ffurl_write(fd, buf, len);
396  av_log(s->ic, AV_LOG_TRACE, "result from ffurl_write: %d\n", result);
397  av_free(buf);
398  }
399  return 0;
400 }
401 
403 {
404  AVIOContext *pb;
405  uint8_t *buf;
406  int len;
407 
408  /* Send a small RTP packet */
409  if (avio_open_dyn_buf(&pb) < 0)
410  return;
411 
412  avio_w8(pb, (RTP_VERSION << 6));
413  avio_w8(pb, 0); /* Payload type */
414  avio_wb16(pb, 0); /* Seq */
415  avio_wb32(pb, 0); /* Timestamp */
416  avio_wb32(pb, 0); /* SSRC */
417 
418  len = avio_close_dyn_buf(pb, &buf);
419  if ((len > 0) && buf)
420  ffurl_write(rtp_handle, buf, len);
421  av_free(buf);
422 
423  /* Send a minimal RTCP RR */
424  if (avio_open_dyn_buf(&pb) < 0)
425  return;
426 
427  avio_w8(pb, (RTP_VERSION << 6));
428  avio_w8(pb, RTCP_RR); /* receiver report */
429  avio_wb16(pb, 1); /* length in words - 1 */
430  avio_wb32(pb, 0); /* our own SSRC */
431 
432  len = avio_close_dyn_buf(pb, &buf);
433  if ((len > 0) && buf)
434  ffurl_write(rtp_handle, buf, len);
435  av_free(buf);
436 }
437 
438 static int find_missing_packets(RTPDemuxContext *s, uint16_t *first_missing,
439  uint16_t *missing_mask)
440 {
441  int i;
442  uint16_t next_seq = s->seq + 1;
443  RTPPacket *pkt = s->queue;
444 
445  if (!pkt || pkt->seq == next_seq)
446  return 0;
447 
448  *missing_mask = 0;
449  for (i = 1; i <= 16; i++) {
450  uint16_t missing_seq = next_seq + i;
451  while (pkt) {
452  int16_t diff = pkt->seq - missing_seq;
453  if (diff >= 0)
454  break;
455  pkt = pkt->next;
456  }
457  if (!pkt)
458  break;
459  if (pkt->seq == missing_seq)
460  continue;
461  *missing_mask |= 1 << (i - 1);
462  }
463 
464  *first_missing = next_seq;
465  return 1;
466 }
467 
469  AVIOContext *avio)
470 {
471  int len, need_keyframe, missing_packets;
472  AVIOContext *pb;
473  uint8_t *buf;
474  int64_t now;
475  uint16_t first_missing = 0, missing_mask = 0;
476 
477  if (!fd && !avio)
478  return -1;
479 
480  need_keyframe = s->handler && s->handler->need_keyframe &&
481  s->handler->need_keyframe(s->dynamic_protocol_context);
482  missing_packets = find_missing_packets(s, &first_missing, &missing_mask);
483 
484  if (!need_keyframe && !missing_packets)
485  return 0;
486 
487  /* Send new feedback if enough time has elapsed since the last
488  * feedback packet. */
489 
490  now = av_gettime_relative();
491  if (s->last_feedback_time &&
492  (now - s->last_feedback_time) < MIN_FEEDBACK_INTERVAL)
493  return 0;
494  s->last_feedback_time = now;
495 
496  if (!fd)
497  pb = avio;
498  else if (avio_open_dyn_buf(&pb) < 0)
499  return -1;
500 
501  if (need_keyframe) {
502  avio_w8(pb, (RTP_VERSION << 6) | 1); /* PLI */
503  avio_w8(pb, RTCP_PSFB);
504  avio_wb16(pb, 2); /* length in words - 1 */
505  // our own SSRC: we use the server's SSRC + 1 to avoid conflicts
506  avio_wb32(pb, s->ssrc + 1);
507  avio_wb32(pb, s->ssrc); // server SSRC
508  }
509 
510  if (missing_packets) {
511  avio_w8(pb, (RTP_VERSION << 6) | 1); /* NACK */
512  avio_w8(pb, RTCP_RTPFB);
513  avio_wb16(pb, 3); /* length in words - 1 */
514  avio_wb32(pb, s->ssrc + 1);
515  avio_wb32(pb, s->ssrc); // server SSRC
516 
517  avio_wb16(pb, first_missing);
518  avio_wb16(pb, missing_mask);
519  }
520 
521  avio_flush(pb);
522  if (!fd)
523  return 0;
524  len = avio_close_dyn_buf(pb, &buf);
525  if (len > 0 && buf) {
526  ffurl_write(fd, buf, len);
527  av_free(buf);
528  }
529  return 0;
530 }
531 
532 /**
533  * open a new RTP parse context for stream 'st'. 'st' can be NULL for
534  * MPEG-2 TS streams.
535  */
537  int payload_type, int queue_size)
538 {
540 
541  s = av_mallocz(sizeof(RTPDemuxContext));
542  if (!s)
543  return NULL;
544  s->payload_type = payload_type;
545  s->last_rtcp_ntp_time = AV_NOPTS_VALUE;
546  s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
547  s->ic = s1;
548  s->st = st;
549  s->queue_size = queue_size;
550 
551  av_log(s->ic, AV_LOG_VERBOSE, "setting jitter buffer size to %d\n",
552  s->queue_size);
553 
554  rtp_init_statistics(&s->statistics, 0);
555  if (st) {
556  switch (st->codecpar->codec_id) {
558  /* According to RFC 3551, the stream clock rate is 8000
559  * even if the sample rate is 16000. */
560  if (st->codecpar->sample_rate == 8000)
561  st->codecpar->sample_rate = 16000;
562  break;
563  default:
564  break;
565  }
566  }
567  // needed to send back RTCP RR in RTSP sessions
568  gethostname(s->hostname, sizeof(s->hostname));
569  return s;
570 }
571 
574 {
575  s->dynamic_protocol_context = ctx;
576  s->handler = handler;
577 }
578 
580  const char *params)
581 {
582  if (!ff_srtp_set_crypto(&s->srtp, suite, params))
583  s->srtp_enabled = 1;
584 }
585 
586 /**
587  * This was the second switch in rtp_parse packet.
588  * Normalizes time, if required, sets stream_index, etc.
589  */
590 static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
591 {
592  if (pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE)
593  return; /* Timestamp already set by depacketizer */
594  if (timestamp == RTP_NOTS_VALUE)
595  return;
596 
597  if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) {
598  int64_t addend;
599  int delta_timestamp;
600 
601  /* compute pts from timestamp with received ntp_time */
602  delta_timestamp = timestamp - s->last_rtcp_timestamp;
603  /* convert to the PTS timebase */
604  addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time,
605  s->st->time_base.den,
606  (uint64_t) s->st->time_base.num << 32);
607  pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend +
608  delta_timestamp;
609  return;
610  }
611 
612  if (!s->base_timestamp)
613  s->base_timestamp = timestamp;
614  /* assume that the difference is INT32_MIN < x < INT32_MAX,
615  * but allow the first timestamp to exceed INT32_MAX */
616  if (!s->timestamp)
617  s->unwrapped_timestamp += timestamp;
618  else
619  s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp);
620  s->timestamp = timestamp;
621  pkt->pts = s->unwrapped_timestamp + s->range_start_offset -
622  s->base_timestamp;
623 }
624 
626  const uint8_t *buf, int len)
627 {
628  unsigned int ssrc;
629  int payload_type, seq, flags = 0;
630  int ext, csrc;
631  AVStream *st;
632  uint32_t timestamp;
633  int rv = 0;
634 
635  csrc = buf[0] & 0x0f;
636  ext = buf[0] & 0x10;
637  payload_type = buf[1] & 0x7f;
638  if (buf[1] & 0x80)
640  seq = AV_RB16(buf + 2);
641  timestamp = AV_RB32(buf + 4);
642  ssrc = AV_RB32(buf + 8);
643  /* store the ssrc in the RTPDemuxContext */
644  s->ssrc = ssrc;
645 
646  /* NOTE: we can handle only one payload type */
647  if (s->payload_type != payload_type)
648  return -1;
649 
650  st = s->st;
651  // only do something with this if all the rtp checks pass...
652  if (!rtp_valid_packet_in_sequence(&s->statistics, seq)) {
653  av_log(s->ic, AV_LOG_ERROR,
654  "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
655  payload_type, seq, ((s->seq + 1) & 0xffff));
656  return -1;
657  }
658 
659  if (buf[0] & 0x20) {
660  int padding = buf[len - 1];
661  if (len >= 12 + padding)
662  len -= padding;
663  }
664 
665  s->seq = seq;
666  len -= 12;
667  buf += 12;
668 
669  len -= 4 * csrc;
670  buf += 4 * csrc;
671  if (len < 0)
672  return AVERROR_INVALIDDATA;
673 
674  /* RFC 3550 Section 5.3.1 RTP Header Extension handling */
675  if (ext) {
676  if (len < 4)
677  return -1;
678  /* calculate the header extension length (stored as number
679  * of 32-bit words) */
680  ext = (AV_RB16(buf + 2) + 1) << 2;
681 
682  if (len < ext)
683  return -1;
684  // skip past RTP header extension
685  len -= ext;
686  buf += ext;
687  }
688 
689  if (s->handler && s->handler->parse_packet) {
690  rv = s->handler->parse_packet(s->ic, s->dynamic_protocol_context,
691  s->st, pkt, &timestamp, buf, len, seq,
692  flags);
693  } else if (st) {
694  if ((rv = av_new_packet(pkt, len)) < 0)
695  return rv;
696  memcpy(pkt->data, buf, len);
697  pkt->stream_index = st->index;
698  } else {
699  return AVERROR(EINVAL);
700  }
701 
702  // now perform timestamp things....
703  finalize_packet(s, pkt, timestamp);
704 
705  return rv;
706 }
707 
709 {
710  while (s->queue) {
711  RTPPacket *next = s->queue->next;
712  av_freep(&s->queue->buf);
713  av_freep(&s->queue);
714  s->queue = next;
715  }
716  s->seq = 0;
717  s->queue_len = 0;
718  s->prev_ret = 0;
719 }
720 
721 static int enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
722 {
723  uint16_t seq = AV_RB16(buf + 2);
724  RTPPacket **cur = &s->queue, *packet;
725 
726  /* Find the correct place in the queue to insert the packet */
727  while (*cur) {
728  int16_t diff = seq - (*cur)->seq;
729  if (diff < 0)
730  break;
731  cur = &(*cur)->next;
732  }
733 
734  packet = av_mallocz(sizeof(*packet));
735  if (!packet)
736  return AVERROR(ENOMEM);
737  packet->recvtime = av_gettime_relative();
738  packet->seq = seq;
739  packet->len = len;
740  packet->buf = buf;
741  packet->next = *cur;
742  *cur = packet;
743  s->queue_len++;
744 
745  return 0;
746 }
747 
749 {
750  return s->queue && s->queue->seq == (uint16_t) (s->seq + 1);
751 }
752 
754 {
755  return s->queue ? s->queue->recvtime : 0;
756 }
757 
759 {
760  int rv;
761  RTPPacket *next;
762 
763  if (s->queue_len <= 0)
764  return -1;
765 
766  if (!has_next_packet(s))
767  av_log(s->ic, AV_LOG_WARNING,
768  "RTP: missed %d packets\n", s->queue->seq - s->seq - 1);
769 
770  /* Parse the first packet in the queue, and dequeue it */
771  rv = rtp_parse_packet_internal(s, pkt, s->queue->buf, s->queue->len);
772  next = s->queue->next;
773  av_freep(&s->queue->buf);
774  av_freep(&s->queue);
775  s->queue = next;
776  s->queue_len--;
777  return rv;
778 }
779 
781  uint8_t **bufptr, int len)
782 {
783  uint8_t *buf = bufptr ? *bufptr : NULL;
784  int flags = 0;
785  uint32_t timestamp;
786  int rv = 0;
787 
788  if (!buf) {
789  /* If parsing of the previous packet actually returned 0 or an error,
790  * there's nothing more to be parsed from that packet, but we may have
791  * indicated that we can return the next enqueued packet. */
792  if (s->prev_ret <= 0)
793  return rtp_parse_queued_packet(s, pkt);
794  /* return the next packets, if any */
795  if (s->handler && s->handler->parse_packet) {
796  /* timestamp should be overwritten by parse_packet, if not,
797  * the packet is left with pts == AV_NOPTS_VALUE */
798  timestamp = RTP_NOTS_VALUE;
799  rv = s->handler->parse_packet(s->ic, s->dynamic_protocol_context,
800  s->st, pkt, &timestamp, NULL, 0, 0,
801  flags);
802  finalize_packet(s, pkt, timestamp);
803  return rv;
804  }
805  }
806 
807  if (len < 12)
808  return -1;
809 
810  if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
811  return -1;
812  if (RTP_PT_IS_RTCP(buf[1])) {
813  return rtcp_parse_packet(s, buf, len);
814  }
815 
816  if (s->st) {
817  int64_t received = av_gettime_relative();
818  uint32_t arrival_ts = av_rescale_q(received, AV_TIME_BASE_Q,
819  s->st->time_base);
820  timestamp = AV_RB32(buf + 4);
821  // Calculate the jitter immediately, before queueing the packet
822  // into the reordering queue.
823  rtcp_update_jitter(&s->statistics, timestamp, arrival_ts);
824  }
825 
826  if ((s->seq == 0 && !s->queue) || s->queue_size <= 1) {
827  /* First packet, or no reordering */
828  return rtp_parse_packet_internal(s, pkt, buf, len);
829  } else {
830  uint16_t seq = AV_RB16(buf + 2);
831  int16_t diff = seq - s->seq;
832  if (diff < 0) {
833  /* Packet older than the previously emitted one, drop */
834  av_log(s->ic, AV_LOG_WARNING,
835  "RTP: dropping old packet received too late\n");
836  return -1;
837  } else if (diff <= 1) {
838  /* Correct packet */
839  rv = rtp_parse_packet_internal(s, pkt, buf, len);
840  return rv;
841  } else {
842  /* Still missing some packet, enqueue this one. */
843  rv = enqueue_packet(s, buf, len);
844  if (rv < 0)
845  return rv;
846  *bufptr = NULL;
847  /* Return the first enqueued packet if the queue is full,
848  * even if we're missing something */
849  if (s->queue_len >= s->queue_size) {
850  av_log(s->ic, AV_LOG_WARNING, "jitter buffer full\n");
851  return rtp_parse_queued_packet(s, pkt);
852  }
853  return -1;
854  }
855  }
856 }
857 
858 /**
859  * Parse an RTP or RTCP packet directly sent as a buffer.
860  * @param s RTP parse context.
861  * @param pkt returned packet
862  * @param bufptr pointer to the input buffer or NULL to read the next packets
863  * @param len buffer len
864  * @return 0 if a packet is returned, 1 if a packet is returned and more can follow
865  * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
866  */
868  uint8_t **bufptr, int len)
869 {
870  int rv;
871  if (s->srtp_enabled && bufptr && ff_srtp_decrypt(&s->srtp, *bufptr, &len) < 0)
872  return -1;
873  rv = rtp_parse_one_packet(s, pkt, bufptr, len);
874  s->prev_ret = rv;
875  while (rv < 0 && has_next_packet(s))
877  return rv ? rv : has_next_packet(s);
878 }
879 
881 {
883  ff_srtp_free(&s->srtp);
884  av_free(s);
885 }
886 
888  AVStream *stream, PayloadContext *data, const char *p,
889  int (*parse_fmtp)(AVFormatContext *s,
890  AVStream *stream,
892  const char *attr, const char *value))
893 {
894  char attr[256];
895  char *value;
896  int res;
897  int value_size = strlen(p) + 1;
898 
899  if (!(value = av_malloc(value_size))) {
900  av_log(s, AV_LOG_ERROR, "Failed to allocate data for FMTP.\n");
901  return AVERROR(ENOMEM);
902  }
903 
904  // remove protocol identifier
905  while (*p && *p == ' ')
906  p++; // strip spaces
907  while (*p && *p != ' ')
908  p++; // eat protocol identifier
909  while (*p && *p == ' ')
910  p++; // strip trailing spaces
911 
912  while (ff_rtsp_next_attr_and_value(&p,
913  attr, sizeof(attr),
914  value, value_size)) {
915  res = parse_fmtp(s, stream, data, attr, value);
916  if (res < 0 && res != AVERROR_PATCHWELCOME) {
917  av_free(value);
918  return res;
919  }
920  }
921  av_free(value);
922  return 0;
923 }
924 
925 int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
926 {
927  int ret;
929 
930  pkt->size = avio_close_dyn_buf(*dyn_buf, &pkt->data);
931  pkt->stream_index = stream_idx;
932  *dyn_buf = NULL;
933  if ((ret = av_packet_from_data(pkt, pkt->data, pkt->size)) < 0) {
934  av_freep(&pkt->data);
935  return ret;
936  }
937  return pkt->size;
938 }
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
av_gettime_relative
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
ff_h263_rfc2190_dynamic_handler
const RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler
Definition: rtpdec_h263_rfc2190.c:186
RTPStatistics
Definition: rtpdec.h:79
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
ff_quicktime_rtp_aud_handler
const RTPDynamicProtocolHandler ff_quicktime_rtp_aud_handler
ff_amr_nb_dynamic_handler
const RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler
Definition: rtpdec_amr.c:185
r
const char * r
Definition: vf_curves.c:114
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
ff_h261_dynamic_handler
const RTPDynamicProtocolHandler ff_h261_dynamic_handler
Definition: rtpdec_h261.c:165
ff_rtp_send_rtcp_feedback
int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd, AVIOContext *avio)
Definition: rtpdec.c:468
stats
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
Definition: vp9_superframe_bsf.c:34
RTP_VERSION
#define RTP_VERSION
Definition: rtp.h:78
parse_fmtp
static int parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value)
Definition: rtpdec_latm.c:130
rtpdec_formats.h
ff_parse_fmtp
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))
Definition: rtpdec.c:887
enqueue_packet
static int enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
Definition: rtpdec.c:721
ff_rtp_handler_iterate
const RTPDynamicProtocolHandler * ff_rtp_handler_iterate(void **opaque)
Iterate over all registered rtp dynamic protocol handlers.
Definition: rtpdec.c:135
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
ff_hevc_dynamic_handler
const RTPDynamicProtocolHandler ff_hevc_dynamic_handler
Definition: rtpdec_hevc.c:343
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:213
av_unused
#define av_unused
Definition: attributes.h:131
RTP_FLAG_MARKER
#define RTP_FLAG_MARKER
RTP marker bit was set for this packet.
Definition: rtpdec.h:93
AVPacket::data
uint8_t * data
Definition: packet.h:355
ff_vp8_dynamic_handler
const RTPDynamicProtocolHandler ff_vp8_dynamic_handler
Definition: rtpdec_vp8.c:279
srtp.h
data
const char data[16]
Definition: mxf.c:91
ff_g726le_24_dynamic_handler
const RTPDynamicProtocolHandler ff_g726le_24_dynamic_handler
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
AV_CODEC_ID_ADPCM_G722
@ AV_CODEC_ID_ADPCM_G722
Definition: codec_id.h:368
t140_dynamic_handler
static RTPDynamicProtocolHandler t140_dynamic_handler
Definition: rtpdec.c:66
mathematics.h
ff_rtp_check_and_send_back_rr
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...
Definition: rtpdec.c:299
codec_type
enum AVMediaType codec_type
Definition: rtp.c:37
ff_h263_2000_dynamic_handler
const RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler
Definition: rtpdec_h263.c:100
rtp_dynamic_protocol_handler_list
static const RTPDynamicProtocolHandler * rtp_dynamic_protocol_handler_list[]
Definition: rtpdec.c:77
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
ff_rtp_finalize_packet
int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
Close the dynamic buffer and make a packet from it.
Definition: rtpdec.c:925
AV_CODEC_ID_MP3ADU
@ AV_CODEC_ID_MP3ADU
Definition: codec_id.h:423
ff_rtp_send_punch_packets
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,...
Definition: rtpdec.c:402
RTPDynamicProtocolHandler::enc_name
const char * enc_name
Definition: rtpdec.h:116
ff_rdt_live_video_handler
RTPDynamicProtocolHandler ff_rdt_live_video_handler
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: codec_id.h:445
ff_srtp_decrypt
int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
Definition: srtp.c:126
ff_rdt_audio_handler
RTPDynamicProtocolHandler ff_rdt_audio_handler
ff_rtp_parse_set_crypto
void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, const char *params)
Definition: rtpdec.c:579
ff_vc2hq_dynamic_handler
const RTPDynamicProtocolHandler ff_vc2hq_dynamic_handler
Definition: rtpdec_vc2hq.c:219
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1401
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:202
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1356
intreadwrite.h
RTCP_TX_RATIO_NUM
#define RTCP_TX_RATIO_NUM
Definition: rtp.h:82
s
#define s(width, name)
Definition: cbs_vp9.c:257
RTPPacket::next
struct RTPPacket * next
Definition: rtpdec.h:146
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:88
ff_ilbc_dynamic_handler
const RTPDynamicProtocolHandler ff_ilbc_dynamic_handler
Definition: rtpdec_ilbc.c:69
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_qdm2_dynamic_handler
const RTPDynamicProtocolHandler ff_qdm2_dynamic_handler
Definition: rtpdec_qdm2.c:303
s1
#define s1
Definition: regdef.h:38
RTCP_TX_RATIO_DEN
#define RTCP_TX_RATIO_DEN
Definition: rtp.h:83
RTP_NOTS_VALUE
#define RTP_NOTS_VALUE
Definition: rtpdec.h:40
finalize_packet
static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
This was the second switch in rtp_parse packet.
Definition: rtpdec.c:590
ff_mp4v_es_dynamic_handler
const RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler
Definition: rtpdec_mpeg4.c:349
ff_rfc4175_rtp_handler
const RTPDynamicProtocolHandler ff_rfc4175_rtp_handler
Definition: rtpdec_rfc4175.c:229
ff_dv_dynamic_handler
const RTPDynamicProtocolHandler ff_dv_dynamic_handler
Definition: rtpdec_dv.c:134
rtp_init_statistics
static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
Definition: rtpdec.c:210
ctx
AVFormatContext * ctx
Definition: movenc.c:48
has_next_packet
static int has_next_packet(RTPDemuxContext *s)
Definition: rtpdec.c:748
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
ff_mpeg_audio_robust_dynamic_handler
const RTPDynamicProtocolHandler ff_mpeg_audio_robust_dynamic_handler
Definition: rtpdec_mpa_robust.c:192
ff_rtp_handler_find_by_id
const RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
Find a registered rtp dynamic protocol handler with a matching codec ID.
Definition: rtpdec.c:160
handler
static void handler(vbi_event *ev, void *user_data)
Definition: libzvbi-teletextdec.c:507
int32_t
int32_t
Definition: audio_convert.c:194
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:233
rtp_valid_packet_in_sequence
static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
Definition: rtpdec.c:235
ff_qt_rtp_vid_handler
const RTPDynamicProtocolHandler ff_qt_rtp_vid_handler
AVFormatContext
Format I/O context.
Definition: avformat.h:1335
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1012
MIN_FEEDBACK_INTERVAL
#define MIN_FEEDBACK_INTERVAL
Definition: rtpdec.c:34
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
find_missing_packets
static int find_missing_packets(RTPDemuxContext *s, uint16_t *first_missing, uint16_t *missing_mask)
Definition: rtpdec.c:438
ff_rtsp_next_attr_and_value
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
ff_mp4a_latm_dynamic_handler
const RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler
Definition: rtpdec_latm.c:164
NULL
#define NULL
Definition: coverity.c:32
RTCP_SDES
@ RTCP_SDES
Definition: rtp.h:99
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
ff_h264_dynamic_handler
const RTPDynamicProtocolHandler ff_h264_dynamic_handler
Definition: rtpdec_h264.c:411
ff_rtp_queued_packet_time
int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s)
Definition: rtpdec.c:753
ff_qt_rtp_aud_handler
const RTPDynamicProtocolHandler ff_qt_rtp_aud_handler
time.h
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:191
RTCP_PSFB
@ RTCP_PSFB
Definition: rtp.h:103
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
rtpdec.h
RTCP_RR
@ RTCP_RR
Definition: rtp.h:98
AV_CODEC_ID_GSM
@ AV_CODEC_ID_GSM
as in Berlin toast format
Definition: codec_id.h:428
RTPPacket
Definition: rtpdec.h:141
ff_mpeg_audio_dynamic_handler
const RTPDynamicProtocolHandler ff_mpeg_audio_dynamic_handler
Definition: rtpdec_mpeg12.c:52
suite
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test suite
Definition: build_system.txt:28
ff_rtp_parse_close
void ff_rtp_parse_close(RTPDemuxContext *s)
Definition: rtpdec.c:880
RTP_PT_IS_RTCP
#define RTP_PT_IS_RTCP(x)
Definition: rtp.h:110
ff_rtp_parse_open
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
Definition: rtpdec.c:536
av_packet_from_data
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
Definition: avpacket.c:155
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVMediaType
AVMediaType
Definition: avutil.h:199
AVPacket::size
int size
Definition: packet.h:356
ff_g726_16_dynamic_handler
const RTPDynamicProtocolHandler ff_g726_16_dynamic_handler
ff_rdt_live_audio_handler
RTPDynamicProtocolHandler ff_rdt_live_audio_handler
opus_dynamic_handler
static RTPDynamicProtocolHandler opus_dynamic_handler
Definition: rtpdec.c:60
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AV_RB32
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
Definition: bytestream.h:92
ff_ac3_dynamic_handler
const RTPDynamicProtocolHandler ff_ac3_dynamic_handler
Definition: rtpdec_ac3.c:125
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: codec_id.h:470
l24_dynamic_handler
static RTPDynamicProtocolHandler l24_dynamic_handler
Definition: rtpdec.c:36
ff_g726le_16_dynamic_handler
const RTPDynamicProtocolHandler ff_g726le_16_dynamic_handler
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:354
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:213
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:375
ff_srtp_free
void ff_srtp_free(struct SRTPContext *s)
Definition: srtp.c:31
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
ff_rtp_handler_find_by_name
const RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
Find a registered rtp dynamic protocol handler with the specified name.
Definition: rtpdec.c:146
rtp_parse_packet_internal
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt, const uint8_t *buf, int len)
Definition: rtpdec.c:625
ff_g726_40_dynamic_handler
const RTPDynamicProtocolHandler ff_g726_40_dynamic_handler
gsm_dynamic_handler
static RTPDynamicProtocolHandler gsm_dynamic_handler
Definition: rtpdec.c:42
URLContext
Definition: url.h:38
rtcp_parse_packet
static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
Definition: rtpdec.c:173
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:348
ff_vorbis_dynamic_handler
const RTPDynamicProtocolHandler ff_vorbis_dynamic_handler
Definition: rtpdec_xiph.c:379
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
ff_rtp_parse_packet
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.
Definition: rtpdec.c:867
ff_mpeg_video_dynamic_handler
const RTPDynamicProtocolHandler ff_mpeg_video_dynamic_handler
Definition: rtpdec_mpeg12.c:60
RTCP_BYE
@ RTCP_BYE
Definition: rtp.h:100
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
speex_dynamic_handler
static RTPDynamicProtocolHandler speex_dynamic_handler
Definition: rtpdec.c:54
url.h
uint8_t
uint8_t
Definition: audio_convert.c:194
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
len
int len
Definition: vorbis_enc_data.h:452
ff_srtp_set_crypto
int ff_srtp_set_crypto(struct SRTPContext *s, const char *suite, const char *params)
Definition: srtp.c:65
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
RTPDemuxContext
Definition: rtpdec.h:149
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:865
ff_g726_32_dynamic_handler
const RTPDynamicProtocolHandler ff_g726_32_dynamic_handler
ff_amr_wb_dynamic_handler
const RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler
Definition: rtpdec_amr.c:195
avformat.h
RTCP_RTPFB
@ RTCP_RTPFB
Definition: rtp.h:102
AV_CODEC_ID_TEXT
@ AV_CODEC_ID_TEXT
raw UTF-8 text
Definition: codec_id.h:510
network.h
ff_quicktime_rtp_vid_handler
const RTPDynamicProtocolHandler ff_quicktime_rtp_vid_handler
ff_mpeg4_generic_dynamic_handler
const RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler
Definition: rtpdec_mpeg4.c:358
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:866
rtp_parse_one_packet
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
Definition: rtpdec.c:780
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
ff_rdt_video_handler
RTPDynamicProtocolHandler ff_rdt_video_handler
rtcp_update_jitter
static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32_t arrival_timestamp)
Definition: rtpdec.c:281
ffurl_write
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:423
RTCP_SR
@ RTCP_SR
Definition: rtp.h:97
ff_vp9_dynamic_handler
const RTPDynamicProtocolHandler ff_vp9_dynamic_handler
Definition: rtpdec_vp9.c:333
ff_svq3_dynamic_handler
const RTPDynamicProtocolHandler ff_svq3_dynamic_handler
Definition: rtpdec_svq3.c:109
AVPacket::stream_index
int stream_index
Definition: packet.h:357
ff_g726le_40_dynamic_handler
const RTPDynamicProtocolHandler ff_g726le_40_dynamic_handler
ff_mpegts_dynamic_handler
const RTPDynamicProtocolHandler ff_mpegts_dynamic_handler
Definition: rtpdec_mpegts.c:92
rtp_init_sequence
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
Definition: rtpdec.c:221
ff_ms_rtp_asf_pfv_handler
const RTPDynamicProtocolHandler ff_ms_rtp_asf_pfv_handler
ff_g726le_32_dynamic_handler
const RTPDynamicProtocolHandler ff_g726le_32_dynamic_handler
RTP_SEQ_MOD
#define RTP_SEQ_MOD
Definition: rtpdec.c:208
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:136
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
ff_rtp_parse_set_dynamic_protocol
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, const RTPDynamicProtocolHandler *handler)
Definition: rtpdec.c:572
AVPacket
This structure stores compressed data.
Definition: packet.h:332
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ff_jpeg_dynamic_handler
const RTPDynamicProtocolHandler ff_jpeg_dynamic_handler
Definition: rtpdec_jpeg.c:382
ff_rtp_reset_packet_queue
void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
Definition: rtpdec.c:708
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:453
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ff_g726_24_dynamic_handler
const RTPDynamicProtocolHandler ff_g726_24_dynamic_handler
ff_qcelp_dynamic_handler
const RTPDynamicProtocolHandler ff_qcelp_dynamic_handler
Definition: rtpdec_qcelp.c:212
avstring.h
ff_h263_1998_dynamic_handler
const RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler
Definition: rtpdec_h263.c:92
PayloadContext
RTP/JPEG specific private data.
Definition: rdt.c:83
rtp_parse_queued_packet
static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt)
Definition: rtpdec.c:758
ff_theora_dynamic_handler
const RTPDynamicProtocolHandler ff_theora_dynamic_handler
Definition: rtpdec_xiph.c:369
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:314
ff_ms_rtp_asf_pfa_handler
const RTPDynamicProtocolHandler ff_ms_rtp_asf_pfa_handler
realmedia_mp3_dynamic_handler
static RTPDynamicProtocolHandler realmedia_mp3_dynamic_handler
Definition: rtpdec.c:48
AV_RB64
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
Definition: bytestream.h:91
RTPDynamicProtocolHandler
Definition: rtpdec.h:115
AV_RB16
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
Definition: bytestream.h:94
av_init_packet
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:35