FFmpeg
rtpenc.c
Go to the documentation of this file.
1 /*
2  * RTP output 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 "avformat.h"
23 #include "mpegts.h"
24 #include "internal.h"
25 #include "mux.h"
26 #include "libavutil/mathematics.h"
27 #include "libavutil/mem.h"
28 #include "libavutil/random_seed.h"
29 #include "libavutil/opt.h"
30 
31 #include "rtpenc.h"
32 
33 static const AVOption options[] = {
35  { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM },
36  { "ssrc", "Stream identifier", offsetof(RTPMuxContext, ssrc), AV_OPT_TYPE_UINT, { .i64 = 0 }, 0, UINT32_MAX, AV_OPT_FLAG_ENCODING_PARAM },
37  { "cname", "CNAME to include in RTCP SR packets", offsetof(RTPMuxContext, cname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
38  { "seq", "Starting sequence number", offsetof(RTPMuxContext, seq), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 65535, AV_OPT_FLAG_ENCODING_PARAM },
39  { NULL },
40 };
41 
42 static const AVClass rtp_muxer_class = {
43  .class_name = "RTP muxer",
44  .item_name = av_default_item_name,
45  .option = options,
46  .version = LIBAVUTIL_VERSION_INT,
47 };
48 
49 #define RTCP_SR_SIZE 28
50 
51 static int is_supported(enum AVCodecID id)
52 {
53  switch(id) {
54  case AV_CODEC_ID_DIRAC:
55  case AV_CODEC_ID_H261:
56  case AV_CODEC_ID_H263:
57  case AV_CODEC_ID_H263P:
58  case AV_CODEC_ID_H264:
59  case AV_CODEC_ID_HEVC:
62  case AV_CODEC_ID_MPEG4:
63  case AV_CODEC_ID_AAC:
64  case AV_CODEC_ID_MP2:
65  case AV_CODEC_ID_MP3:
68  case AV_CODEC_ID_PCM_S8:
74  case AV_CODEC_ID_PCM_U8:
76  case AV_CODEC_ID_AMR_NB:
77  case AV_CODEC_ID_AMR_WB:
78  case AV_CODEC_ID_VORBIS:
79  case AV_CODEC_ID_THEORA:
80  case AV_CODEC_ID_VP8:
81  case AV_CODEC_ID_VP9:
82  case AV_CODEC_ID_AV1:
86  case AV_CODEC_ID_ILBC:
87  case AV_CODEC_ID_MJPEG:
88  case AV_CODEC_ID_SPEEX:
89  case AV_CODEC_ID_OPUS:
92  case AV_CODEC_ID_G728:
93  return 1;
94  default:
95  return 0;
96  }
97 }
98 
100 {
101  RTPMuxContext *s = s1->priv_data;
102  int n, ret = AVERROR(EINVAL);
103  AVStream *st;
104 
105  if (s1->nb_streams != 1) {
106  av_log(s1, AV_LOG_ERROR, "Only one stream supported in the RTP muxer\n");
107  return AVERROR(EINVAL);
108  }
109  st = s1->streams[0];
110  if (!is_supported(st->codecpar->codec_id)) {
111  av_log(s1, AV_LOG_ERROR, "Unsupported codec %s\n", avcodec_get_name(st->codecpar->codec_id));
112 
113  return -1;
114  }
115 
116  if (s->payload_type < 0) {
117  /* Re-validate non-dynamic payload types */
118  if (st->id < RTP_PT_PRIVATE)
119  st->id = ff_rtp_get_payload_type(s1, st->codecpar, -1);
120 
121  s->payload_type = st->id;
122  } else {
123  /* private option takes priority */
124  st->id = s->payload_type;
125  }
126 
127  s->base_timestamp = av_get_random_seed();
128  s->timestamp = s->base_timestamp;
129  s->cur_timestamp = 0;
130  if (!s->ssrc)
131  s->ssrc = av_get_random_seed();
132  s->first_packet = 1;
133  s->first_rtcp_ntp_time = ff_ntp_time();
135  /* Round the NTP time to whole milliseconds. */
136  s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 +
138  // Pick a random sequence start number, but in the lower end of the
139  // available range, so that any wraparound doesn't happen immediately.
140  // (Immediate wraparound would be an issue for SRTP.)
141  if (s->seq < 0) {
142  if (s1->flags & AVFMT_FLAG_BITEXACT) {
143  s->seq = 0;
144  } else
145  s->seq = av_get_random_seed() & 0x0fff;
146  } else
147  s->seq &= 0xffff; // Use the given parameter, wrapped to the right interval
148 
149  if (s1->packet_size) {
150  if (s1->pb->max_packet_size)
151  s1->packet_size = FFMIN(s1->packet_size,
152  s1->pb->max_packet_size);
153  } else
154  s1->packet_size = s1->pb->max_packet_size;
155  if (s1->packet_size <= 12) {
156  av_log(s1, AV_LOG_ERROR, "Max packet size %u too low\n", s1->packet_size);
157  return AVERROR(EIO);
158  }
159  s->buf = av_malloc(s1->packet_size);
160  if (!s->buf) {
161  return AVERROR(ENOMEM);
162  }
163  s->max_payload_size = s1->packet_size - 12;
164 
165  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
166  avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
167  } else {
168  avpriv_set_pts_info(st, 32, 1, 90000);
169  }
170  s->buf_ptr = s->buf;
171  switch(st->codecpar->codec_id) {
172  case AV_CODEC_ID_MP2:
173  case AV_CODEC_ID_MP3:
174  s->buf_ptr = s->buf + 4;
175  avpriv_set_pts_info(st, 32, 1, 90000);
176  break;
179  break;
180  case AV_CODEC_ID_MPEG2TS:
181  if (s->max_payload_size < TS_PACKET_SIZE) {
182  av_log(s1, AV_LOG_ERROR,
183  "RTP payload size %u too small for MPEG-TS "
184  "(minimum %d bytes required)\n",
185  s->max_payload_size, TS_PACKET_SIZE);
186  ret = AVERROR(EINVAL);
187  goto fail;
188  }
189 
190  n = s->max_payload_size / TS_PACKET_SIZE;
191  s->max_payload_size = n * TS_PACKET_SIZE;
192  break;
193  case AV_CODEC_ID_DIRAC:
196  "Packetizing VC-2 is experimental and does not use all values "
197  "of the specification "
198  "(even though most receivers may handle it just fine). "
199  "Please set -strict experimental in order to enable it.\n");
201  goto fail;
202  }
203  break;
204  case AV_CODEC_ID_H261:
207  "Packetizing H.261 is experimental and produces incorrect "
208  "packetization for cases where GOBs don't fit into packets "
209  "(even though most receivers may handle it just fine). "
210  "Please set -f_strict experimental in order to enable it.\n");
212  goto fail;
213  }
214  break;
215  case AV_CODEC_ID_H264:
216  /* check for H.264 MP4 syntax */
217  if (st->codecpar->extradata_size > 4 && st->codecpar->extradata[0] == 1) {
218  s->nal_length_size = (st->codecpar->extradata[4] & 0x03) + 1;
219  }
220  break;
221  case AV_CODEC_ID_HEVC:
222  /* Only check for the standardized hvcC version of extradata, keeping
223  * things simple and similar to the avcC/H.264 case above, instead
224  * of trying to handle the pre-standardization versions (as in
225  * libavcodec/hevc.c). */
226  if (st->codecpar->extradata_size > 21 && st->codecpar->extradata[0] == 1) {
227  s->nal_length_size = (st->codecpar->extradata[21] & 0x03) + 1;
228  }
229  break;
230  case AV_CODEC_ID_MJPEG:
233  if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
234  av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
235  return AVERROR(EINVAL);
236  }
237  break;
238  case AV_CODEC_ID_VP9:
241  "Packetizing VP9 is experimental and its specification is "
242  "still in draft state. "
243  "Please set -strict experimental in order to enable it.\n");
245  goto fail;
246  }
247  break;
248  case AV_CODEC_ID_AV1:
251  "Packetizing AV1 is experimental and its specification is "
252  "still in draft state. "
253  "Please set -strict experimental in order to enable it.\n");
255  goto fail;
256  }
257  break;
258  case AV_CODEC_ID_VORBIS:
259  case AV_CODEC_ID_THEORA:
260  s->max_frames_per_packet = 15;
261  break;
263  /* Due to a historical error, the clock rate for G722 in RTP is
264  * 8000, even if the sample rate is 16000. See RFC 3551. */
265  avpriv_set_pts_info(st, 32, 1, 8000);
266  break;
267  case AV_CODEC_ID_OPUS:
268  if (st->codecpar->ch_layout.nb_channels > 2) {
269  av_log(s1, AV_LOG_ERROR, "Multistream opus not supported in RTP\n");
270  goto fail;
271  }
272  /* The opus RTP RFC says that all opus streams should use 48000 Hz
273  * as clock rate, since all opus sample rates can be expressed in
274  * this clock rate, and sample rate changes on the fly are supported. */
275  avpriv_set_pts_info(st, 32, 1, 48000);
276  break;
277  case AV_CODEC_ID_ILBC:
278  if (st->codecpar->block_align != 38 && st->codecpar->block_align != 50) {
279  av_log(s1, AV_LOG_ERROR, "Incorrect iLBC block size specified\n");
280  goto fail;
281  }
282  s->max_frames_per_packet = s->max_payload_size / st->codecpar->block_align;
283  break;
284  case AV_CODEC_ID_AMR_NB:
285  case AV_CODEC_ID_AMR_WB:
286  s->max_frames_per_packet = 50;
288  n = 31;
289  else
290  n = 61;
291  /* max_header_toc_size + the largest AMR payload must fit */
292  if (1 + s->max_frames_per_packet + n > s->max_payload_size) {
293  av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n");
294  goto fail;
295  }
296  if (st->codecpar->ch_layout.nb_channels != 1) {
297  av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
298  goto fail;
299  }
300  break;
301  case AV_CODEC_ID_AAC:
302  s->max_frames_per_packet = 50;
303  break;
304  default:
305  break;
306  }
307 
308  return 0;
309 
310 fail:
311  av_freep(&s->buf);
312  return ret;
313 }
314 
315 /* send an rtcp sender report packet */
316 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time, int bye)
317 {
318  RTPMuxContext *s = s1->priv_data;
319  uint32_t rtp_ts;
320 
321  av_log(s1, AV_LOG_TRACE, "RTCP: %02x %"PRIx64" %"PRIx32"\n", s->payload_type, ntp_time, s->timestamp);
322 
323  s->last_rtcp_ntp_time = ntp_time;
324  rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
325  s1->streams[0]->time_base) + s->base_timestamp;
326  avio_w8(s1->pb, RTP_VERSION << 6);
327  avio_w8(s1->pb, RTCP_SR);
328  avio_wb16(s1->pb, 6); /* length in words - 1 */
329  avio_wb32(s1->pb, s->ssrc);
330  avio_wb32(s1->pb, ntp_time / 1000000);
331  avio_wb32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
332  avio_wb32(s1->pb, rtp_ts);
333  avio_wb32(s1->pb, s->packet_count);
334  avio_wb32(s1->pb, s->octet_count);
335 
336  if (s->cname) {
337  int len = FFMIN(strlen(s->cname), 255);
338  avio_w8(s1->pb, (RTP_VERSION << 6) + 1);
339  avio_w8(s1->pb, RTCP_SDES);
340  avio_wb16(s1->pb, (7 + len + 3) / 4); /* length in words - 1 */
341 
342  avio_wb32(s1->pb, s->ssrc);
343  avio_w8(s1->pb, 0x01); /* CNAME */
344  avio_w8(s1->pb, len);
345  avio_write(s1->pb, s->cname, len);
346  avio_w8(s1->pb, 0); /* END */
347  for (len = (7 + len) % 4; len % 4; len++)
348  avio_w8(s1->pb, 0);
349  }
350 
351  if (bye) {
352  avio_w8(s1->pb, (RTP_VERSION << 6) | 1);
353  avio_w8(s1->pb, RTCP_BYE);
354  avio_wb16(s1->pb, 1); /* length in words - 1 */
355  avio_wb32(s1->pb, s->ssrc);
356  }
357 
358  avio_flush(s1->pb);
359 }
360 
361 /* send an rtp packet. sequence number is incremented, but the caller
362  must update the timestamp itself */
363 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
364 {
365  RTPMuxContext *s = s1->priv_data;
366 
367  av_log(s1, AV_LOG_TRACE, "rtp_send_data size=%d\n", len);
368 
369  /* build the RTP header */
370  avio_w8(s1->pb, RTP_VERSION << 6);
371  avio_w8(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
372  avio_wb16(s1->pb, s->seq);
373  avio_wb32(s1->pb, s->timestamp);
374  avio_wb32(s1->pb, s->ssrc);
375 
376  avio_write(s1->pb, buf1, len);
377  avio_flush(s1->pb);
378 
379  s->seq = (s->seq + 1) & 0xffff;
380  s->octet_count += len;
381  s->packet_count++;
382 }
383 
384 /* send an integer number of samples and compute time stamp and fill
385  the rtp send buffer before sending. */
387  const uint8_t *buf1, int size, int sample_size_bits)
388 {
389  RTPMuxContext *s = s1->priv_data;
390  int len, max_packet_size, n;
391  /* Calculate the number of bytes to get samples aligned on a byte border */
392  int aligned_samples_size = sample_size_bits/av_gcd(sample_size_bits, 8);
393 
394  max_packet_size = (s->max_payload_size / aligned_samples_size) * aligned_samples_size;
395  /* Not needed, but who knows. Don't check if samples aren't an even number of bytes. */
396  if ((sample_size_bits % 8) == 0 && ((8 * size) % sample_size_bits) != 0)
397  return AVERROR(EINVAL);
398  n = 0;
399  while (size > 0) {
400  s->buf_ptr = s->buf;
401  len = FFMIN(max_packet_size, size);
402 
403  /* copy data */
404  memcpy(s->buf_ptr, buf1, len);
405  s->buf_ptr += len;
406  buf1 += len;
407  size -= len;
408  s->timestamp = s->cur_timestamp + n * 8 / sample_size_bits;
409  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
410  n += (s->buf_ptr - s->buf);
411  }
412  return 0;
413 }
414 
416  const uint8_t *buf1, int size)
417 {
418  RTPMuxContext *s = s1->priv_data;
419  int len, count, max_packet_size;
420 
421  max_packet_size = s->max_payload_size;
422 
423  /* test if we must flush because not enough space */
424  len = (s->buf_ptr - s->buf);
425  if ((len + size) > max_packet_size) {
426  if (len > 4) {
427  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
428  s->buf_ptr = s->buf + 4;
429  }
430  }
431  if (s->buf_ptr == s->buf + 4) {
432  s->timestamp = s->cur_timestamp;
433  }
434 
435  /* add the packet */
436  if (size > max_packet_size) {
437  /* big packet: fragment */
438  count = 0;
439  while (size > 0) {
440  len = max_packet_size - 4;
441  if (len > size)
442  len = size;
443  /* build fragmented packet */
444  s->buf[0] = 0;
445  s->buf[1] = 0;
446  s->buf[2] = count >> 8;
447  s->buf[3] = count;
448  memcpy(s->buf + 4, buf1, len);
449  ff_rtp_send_data(s1, s->buf, len + 4, 0);
450  size -= len;
451  buf1 += len;
452  count += len;
453  }
454  } else {
455  if (s->buf_ptr == s->buf + 4) {
456  /* no fragmentation possible */
457  s->buf[0] = 0;
458  s->buf[1] = 0;
459  s->buf[2] = 0;
460  s->buf[3] = 0;
461  }
462  memcpy(s->buf_ptr, buf1, size);
463  s->buf_ptr += size;
464  }
465 }
466 
468  const uint8_t *buf1, int size)
469 {
470  RTPMuxContext *s = s1->priv_data;
471  int len, max_packet_size;
472 
473  max_packet_size = s->max_payload_size;
474 
475  while (size > 0) {
476  len = max_packet_size;
477  if (len > size)
478  len = size;
479 
480  s->timestamp = s->cur_timestamp;
481  ff_rtp_send_data(s1, buf1, len, (len == size));
482 
483  buf1 += len;
484  size -= len;
485  }
486 }
487 
488 /* NOTE: size is assumed to be an integer multiple of TS_PACKET_SIZE */
490  const uint8_t *buf1, int size)
491 {
492  RTPMuxContext *s = s1->priv_data;
493  int len, out_len;
494 
495  s->timestamp = s->cur_timestamp;
496  while (size >= TS_PACKET_SIZE) {
497  len = s->max_payload_size - (s->buf_ptr - s->buf);
498  if (len > size)
499  len = size;
500  memcpy(s->buf_ptr, buf1, len);
501  buf1 += len;
502  size -= len;
503  s->buf_ptr += len;
504 
505  out_len = s->buf_ptr - s->buf;
506  if (out_len >= s->max_payload_size) {
507  ff_rtp_send_data(s1, s->buf, out_len, 0);
508  s->buf_ptr = s->buf;
509  }
510  }
511 }
512 
513 static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
514 {
515  RTPMuxContext *s = s1->priv_data;
516  AVStream *st = s1->streams[0];
517  int frame_duration = av_get_audio_frame_duration2(st->codecpar, 0);
518  int frame_size = st->codecpar->block_align;
519  int frames = size / frame_size;
520 
521  while (frames > 0) {
522  if (s->num_frames > 0 &&
523  av_compare_ts(s->cur_timestamp - s->timestamp, st->time_base,
524  s1->max_delay, AV_TIME_BASE_Q) >= 0) {
525  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
526  s->num_frames = 0;
527  }
528 
529  if (!s->num_frames) {
530  s->buf_ptr = s->buf;
531  s->timestamp = s->cur_timestamp;
532  }
533  memcpy(s->buf_ptr, buf, frame_size);
534  frames--;
535  s->num_frames++;
536  s->buf_ptr += frame_size;
537  buf += frame_size;
538  s->cur_timestamp += frame_duration;
539 
540  if (s->num_frames == s->max_frames_per_packet) {
541  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
542  s->num_frames = 0;
543  }
544  }
545  return 0;
546 }
547 
549 {
550  RTPMuxContext *s = s1->priv_data;
551  AVStream *st = s1->streams[0];
552  int rtcp_bytes;
553  int size= pkt->size;
554 
555  av_log(s1, AV_LOG_TRACE, "%d: write len=%d\n", pkt->stream_index, size);
556 
557  rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
559  if ((s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
560  (ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) &&
561  !(s->flags & FF_RTP_FLAG_SKIP_RTCP)) {
562  rtcp_send_sr(s1, ff_ntp_time(), 0);
563  s->last_octet_count = s->octet_count;
564  s->first_packet = 0;
565  }
566  s->cur_timestamp = s->base_timestamp + pkt->pts;
567 
568  switch(st->codecpar->codec_id) {
571  case AV_CODEC_ID_PCM_U8:
572  case AV_CODEC_ID_PCM_S8:
573  return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->ch_layout.nb_channels);
578  return rtp_send_samples(s1, pkt->data, size, 16 * st->codecpar->ch_layout.nb_channels);
580  return rtp_send_samples(s1, pkt->data, size, 24 * st->codecpar->ch_layout.nb_channels);
582  /* The actual sample size is half a byte per sample, but since the
583  * stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
584  * the correct parameter for send_samples_bits is 8 bits per stream
585  * clock. */
586  return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->ch_layout.nb_channels);
589  return rtp_send_samples(s1, pkt->data, size,
591  case AV_CODEC_ID_MP2:
592  case AV_CODEC_ID_MP3:
594  break;
598  break;
599  case AV_CODEC_ID_AAC:
600  if (s->flags & FF_RTP_FLAG_MP4A_LATM)
601  ff_rtp_send_latm(s1, pkt->data, size);
602  else
603  ff_rtp_send_aac(s1, pkt->data, size);
604  break;
605  case AV_CODEC_ID_AMR_NB:
606  case AV_CODEC_ID_AMR_WB:
607  ff_rtp_send_amr(s1, pkt->data, size);
608  break;
609  case AV_CODEC_ID_AV1:
610  ff_rtp_send_av1(s1, pkt->data, size, (pkt->flags & AV_PKT_FLAG_KEY) ? 1 : 0);
611  break;
612  case AV_CODEC_ID_MPEG2TS:
614  break;
615  case AV_CODEC_ID_DIRAC:
617  break;
618  case AV_CODEC_ID_H264:
620  break;
621  case AV_CODEC_ID_H261:
622  ff_rtp_send_h261(s1, pkt->data, size);
623  break;
624  case AV_CODEC_ID_H263:
625  if (s->flags & FF_RTP_FLAG_RFC2190) {
626  size_t mb_info_size;
627  const uint8_t *mb_info =
629  &mb_info_size);
630  ff_rtp_send_h263_rfc2190(s1, pkt->data, size, mb_info, mb_info_size);
631  break;
632  }
633  /* Fallthrough */
634  case AV_CODEC_ID_H263P:
635  ff_rtp_send_h263(s1, pkt->data, size);
636  break;
637  case AV_CODEC_ID_HEVC:
639  break;
640  case AV_CODEC_ID_VORBIS:
641  case AV_CODEC_ID_THEORA:
642  ff_rtp_send_xiph(s1, pkt->data, size);
643  break;
644  case AV_CODEC_ID_VP8:
645  ff_rtp_send_vp8(s1, pkt->data, size);
646  break;
647  case AV_CODEC_ID_VP9:
648  ff_rtp_send_vp9(s1, pkt->data, size);
649  break;
650  case AV_CODEC_ID_ILBC:
651  rtp_send_ilbc(s1, pkt->data, size);
652  break;
653  case AV_CODEC_ID_MJPEG:
654  ff_rtp_send_jpeg(s1, pkt->data, size);
655  break;
657  case AV_CODEC_ID_RAWVIDEO: {
659 
661  if (interlaced)
663  break;
664  }
665  case AV_CODEC_ID_OPUS:
666  if (size > s->max_payload_size) {
667  av_log(s1, AV_LOG_ERROR,
668  "Packet size %d too large for max RTP payload size %d\n",
669  size, s->max_payload_size);
670  return AVERROR(EINVAL);
671  }
672  /* Intentional fallthrough */
673  default:
674  /* better than nothing : send the codec raw data */
675  rtp_send_raw(s1, pkt->data, size);
676  break;
677  }
678  return 0;
679 }
680 
682 {
683  RTPMuxContext *s = s1->priv_data;
684 
685  /* If the caller closes and recreates ->pb, this might actually
686  * be NULL here even if it was successfully allocated at the start. */
687  if (s1->pb && (s->flags & FF_RTP_FLAG_SEND_BYE))
688  rtcp_send_sr(s1, ff_ntp_time(), 1);
689 
690  return 0;
691 }
692 
693 static void rtp_deinit(AVFormatContext *s1)
694 {
695  RTPMuxContext *s = s1->priv_data;
696 
697  av_freep(&s->buf);
698 }
699 
701  .p.name = "rtp",
702  .p.long_name = NULL_IF_CONFIG_SMALL("RTP output"),
703  .priv_data_size = sizeof(RTPMuxContext),
704  .p.audio_codec = AV_CODEC_ID_PCM_MULAW,
705  .p.video_codec = AV_CODEC_ID_MPEG4,
706  .write_header = rtp_write_header,
707  .write_packet = rtp_write_packet,
708  .write_trailer = rtp_write_trailer,
709  .deinit = rtp_deinit,
710  .p.priv_class = &rtp_muxer_class,
712 };
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:338
flags
const SwsFlags flags[]
Definition: swscale.c:61
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
ff_rtp_send_aac
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_aac.c:27
AVERROR_EXPERIMENTAL
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:74
rtp_write_header
static int rtp_write_header(AVFormatContext *s1)
Definition: rtpenc.c:99
ff_ntp_time
uint64_t ff_ntp_time(void)
Get the current time since NTP epoch in microseconds.
Definition: utils.c:257
FF_RTP_FLAG_MP4A_LATM
#define FF_RTP_FLAG_MP4A_LATM
Definition: rtpenc.h:68
AVOutputFormat::name
const char * name
Definition: avformat.h:506
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
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
ff_rtp_send_jpeg
void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_jpeg.c:28
mpegts.h
av_compare_ts
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
Definition: mathematics.c:147
AVFMT_NODIMENSIONS
#define AVFMT_NODIMENSIONS
Format does not need width/height.
Definition: avformat.h:482
ff_rtp_send_h263_rfc2190
void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf1, int size, const uint8_t *mb_info, int mb_info_size)
Definition: rtpenc_h263_rfc2190.c:101
ff_rtp_send_h261
void ff_rtp_send_h261(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc_h261.c:39
RTP_VERSION
#define RTP_VERSION
Definition: rtp.h:80
AV_FIELD_PROGRESSIVE
@ AV_FIELD_PROGRESSIVE
Definition: defs.h:213
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:263
AV_CODEC_ID_DIRAC
@ AV_CODEC_ID_DIRAC
Definition: codec_id.h:168
int64_t
long long int64_t
Definition: coverity.c:34
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
ff_rtp_send_av1
void ff_rtp_send_av1(AVFormatContext *s1, const uint8_t *buf1, int size, int is_keyframe)
Definition: rtpenc_av1.c:42
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1331
AVFormatContext::strict_std_compliance
int strict_std_compliance
Allow non-standard and experimental extension.
Definition: avformat.h:1617
AVPacket::data
uint8_t * data
Definition: packet.h:588
AVOption
AVOption.
Definition: opt.h:429
AV_CODEC_ID_AMR_NB
@ AV_CODEC_ID_AMR_NB
Definition: codec_id.h:441
AV_CODEC_ID_ADPCM_G722
@ AV_CODEC_ID_ADPCM_G722
Definition: codec_id.h:405
ff_rtp_send_data
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
Definition: rtpenc.c:363
AVIOContext::max_packet_size
int max_packet_size
Definition: avio.h:241
mathematics.h
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: defs.h:62
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:329
FF_RTP_FLAG_RFC2190
#define FF_RTP_FLAG_RFC2190
Definition: rtpenc.h:69
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:643
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:65
FF_RTP_FLAG_OPTS
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
Definition: rtpenc.h:74
AV_CODEC_ID_AMR_WB
@ AV_CODEC_ID_AMR_WB
Definition: codec_id.h:442
AV_CODEC_ID_H261
@ AV_CODEC_ID_H261
Definition: codec_id.h:55
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:196
av_gcd
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
ff_rtp_send_mpegvideo
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc_mpv.c:29
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:781
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: codec_id.h:495
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:339
fail
#define fail()
Definition: checkasm.h:220
frames
if it could not because there are no more frames
Definition: filter_design.txt:267
rtp_write_trailer
static int rtp_write_trailer(AVFormatContext *s1)
Definition: rtpenc.c:681
ff_rtp_send_latm
void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_latm.c:25
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:461
ff_rtp_send_raw_rfc4175
void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size, int interlaced, int field)
Definition: rtpenc_rfc4175.c:24
FF_RTP_FLAG_SKIP_RTCP
#define FF_RTP_FLAG_SKIP_RTCP
Definition: rtpenc.h:70
rtp_send_ilbc
static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
Definition: rtpenc.c:513
is_supported
static int is_supported(enum AVCodecID id)
Definition: rtpenc.c:51
options
static const AVOption options[]
Definition: rtpenc.c:33
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:342
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:236
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
AV_CODEC_ID_ADPCM_G726
@ AV_CODEC_ID_ADPCM_G726
Definition: codec_id.h:388
RTCP_TX_RATIO_NUM
#define RTCP_TX_RATIO_NUM
Definition: rtp.h:84
s
#define s(width, name)
Definition: cbs_vp9.c:198
rtp_deinit
static void rtp_deinit(AVFormatContext *s1)
Definition: rtpenc.c:693
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1414
frame_size
int frame_size
Definition: mxfenc.c:2487
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:201
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:222
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition: codec_id.h:460
RTCP_TX_RATIO_DEN
#define RTCP_TX_RATIO_DEN
Definition: rtp.h:85
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
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: codec_id.h:344
AV_CODEC_ID_PCM_U16BE
@ AV_CODEC_ID_PCM_U16BE
Definition: codec_id.h:341
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:228
AVFormatContext
Format I/O context.
Definition: avformat.h:1263
AV_CODEC_ID_PCM_ALAW
@ AV_CODEC_ID_PCM_ALAW
Definition: codec_id.h:345
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:767
RTP_PT_PRIVATE
#define RTP_PT_PRIVATE
Definition: rtp.h:79
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:783
NULL
#define NULL
Definition: coverity.c:32
RTCP_SDES
@ RTCP_SDES
Definition: rtp.h:101
rtp_send_raw
static void rtp_send_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:467
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:284
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition: avformat.h:1305
options
Definition: swscale.c:43
FFOutputFormat
Definition: mux.h:61
AV_CODEC_ID_MPEG2TS
@ AV_CODEC_ID_MPEG2TS
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
Definition: codec_id.h:621
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:184
RTPMuxContext
Definition: rtpenc.h:27
AV_OPT_TYPE_UINT
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
Definition: opt.h:335
AV_CODEC_ID_G728
@ AV_CODEC_ID_G728
Definition: codec_id.h:567
rtp_muxer_class
static const AVClass rtp_muxer_class
Definition: rtpenc.c:42
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:352
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
AV_CODEC_ID_MPEG1VIDEO
@ AV_CODEC_ID_MPEG1VIDEO
Definition: codec_id.h:53
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1319
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:462
rtp_send_samples
static int rtp_send_samples(AVFormatContext *s1, const uint8_t *buf1, int size, int sample_size_bits)
Definition: rtpenc.c:386
AVPacket::size
int size
Definition: packet.h:589
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: codec_id.h:56
size
int size
Definition: twinvq_data.h:10344
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:247
NTP_OFFSET_US
#define NTP_OFFSET_US
Definition: internal.h:419
av_get_audio_frame_duration2
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
Definition: utils.c:816
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: codec_id.h:520
rtp_send_mpegts_raw
static void rtp_send_mpegts_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:489
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:206
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:368
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:594
AV_CODEC_ID_BITPACKED
@ AV_CODEC_ID_BITPACKED
Definition: codec_id.h:285
RTCP_SR_SIZE
#define RTCP_SR_SIZE
Definition: rtpenc.c:49
rtcp_send_sr
static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time, int bye)
Definition: rtpenc.c:316
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:406
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:59
interlaced
uint8_t interlaced
Definition: mxfenc.c:2334
AV_PKT_DATA_H263_MB_INFO
@ AV_PKT_DATA_H263_MB_INFO
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition: packet.h:90
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:581
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: packet.c:252
AV_CODEC_ID_THEORA
@ AV_CODEC_ID_THEORA
Definition: codec_id.h:82
ff_rtp_send_vp8
void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_vp8.c:26
AVCodecParameters::height
int height
Definition: codec_par.h:135
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:191
FF_RTP_FLAG_SEND_BYE
#define FF_RTP_FLAG_SEND_BYE
Definition: rtpenc.h:72
RTCP_BYE
@ RTCP_BYE
Definition: rtp.h:102
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:228
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVFormatContext::max_delay
int max_delay
Definition: avformat.h:1408
ff_rtp_send_vp9
void ff_rtp_send_vp9(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_vp9.c:26
len
int len
Definition: vorbis_enc_data.h:426
ff_rtp_send_vc2hq
void ff_rtp_send_vc2hq(AVFormatContext *s1, const uint8_t *buf, int size, int interlaced)
Definition: rtpenc_vc2hq.c:106
ff_rtp_muxer
const FFOutputFormat ff_rtp_muxer
Definition: rtpenc.c:700
rtpenc.h
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:161
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:487
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:756
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1431
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:744
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
av_malloc
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:98
avformat.h
ff_rtp_send_h264_hevc
void ff_rtp_send_h264_hevc(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc_h264_hevc.c:181
ff_rtp_send_amr
void ff_rtp_send_amr(AVFormatContext *s1, const uint8_t *buff, int size)
Packetize AMR frames into RTP packets according to RFC 3267, in octet-aligned mode.
Definition: rtpenc_amr.c:30
AV_CODEC_ID_H263P
@ AV_CODEC_ID_H263P
Definition: codec_id.h:71
random_seed.h
AV_CODEC_ID_ADPCM_G726LE
@ AV_CODEC_ID_ADPCM_G726LE
Definition: codec_id.h:412
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
ff_rtp_send_h263
void ff_rtp_send_h263(AVFormatContext *s1, const uint8_t *buf1, int size)
Packetize H.263 frames into RTP packets according to RFC 4629.
Definition: rtpenc_h263.c:43
RTCP_SR
@ RTCP_SR
Definition: rtp.h:99
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
AVPacket::stream_index
int stream_index
Definition: packet.h:590
rtp_write_packet
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: rtpenc.c:548
AVFormatContext::packet_size
unsigned int packet_size
Definition: avformat.h:1407
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:110
mem.h
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:343
AVFormatContext::start_time_realtime
int64_t start_time_realtime
Start time of the stream in real world time, in microseconds since the Unix epoch (00:00 1st January ...
Definition: avformat.h:1508
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:565
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV_CODEC_ID_ILBC
@ AV_CODEC_ID_ILBC
Definition: codec_id.h:519
AV_CODEC_ID_PCM_U16LE
@ AV_CODEC_ID_PCM_U16LE
Definition: codec_id.h:340
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:446
AV_CODEC_ID_VP8
@ AV_CODEC_ID_VP8
Definition: codec_id.h:192
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
TS_PACKET_SIZE
#define TS_PACKET_SIZE
Definition: mpegts.h:29
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:465
ff_rtp_send_xiph
void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size)
Packetize Xiph frames into RTP according to RFC 5215 (Vorbis) and the Theora RFC draft.
Definition: rtpenc_xiph.c:33
pkt
static AVPacket * pkt
Definition: demux_decode.c:55
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
rtp_send_mpegaudio
static void rtp_send_mpegaudio(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:415
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:54
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1291
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:351
mb_info
Definition: cinepakenc.c:87
ff_rtp_get_payload_type
int ff_rtp_get_payload_type(const AVFormatContext *fmt, const AVCodecParameters *par, int idx)
Return the payload type for a given stream used in the given format context.
Definition: rtp.c:93
mux.h