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 Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 "libavutil/mathematics.h"
26 #include "libavutil/random_seed.h"
27 #include "libavutil/opt.h"
28 
29 #include "rtpenc.h"
30 
31 //#define DEBUG
32 
33 static const AVOption options[] = {
35  { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM },
36  { NULL },
37 };
38 
39 static const AVClass rtp_muxer_class = {
40  .class_name = "RTP muxer",
41  .item_name = av_default_item_name,
42  .option = options,
43  .version = LIBAVUTIL_VERSION_INT,
44 };
45 
46 #define RTCP_SR_SIZE 28
47 
48 static int is_supported(enum CodecID id)
49 {
50  switch(id) {
51  case CODEC_ID_H263:
52  case CODEC_ID_H263P:
53  case CODEC_ID_H264:
56  case CODEC_ID_MPEG4:
57  case CODEC_ID_AAC:
58  case CODEC_ID_MP2:
59  case CODEC_ID_MP3:
60  case CODEC_ID_PCM_ALAW:
61  case CODEC_ID_PCM_MULAW:
62  case CODEC_ID_PCM_S8:
63  case CODEC_ID_PCM_S16BE:
64  case CODEC_ID_PCM_S16LE:
65  case CODEC_ID_PCM_U16BE:
66  case CODEC_ID_PCM_U16LE:
67  case CODEC_ID_PCM_U8:
68  case CODEC_ID_MPEG2TS:
69  case CODEC_ID_AMR_NB:
70  case CODEC_ID_AMR_WB:
71  case CODEC_ID_VORBIS:
72  case CODEC_ID_THEORA:
73  case CODEC_ID_VP8:
76  return 1;
77  default:
78  return 0;
79  }
80 }
81 
83 {
84  RTPMuxContext *s = s1->priv_data;
85  int max_packet_size, n;
86  AVStream *st;
87 
88  if (s1->nb_streams != 1)
89  return -1;
90  st = s1->streams[0];
91  if (!is_supported(st->codec->codec_id)) {
92  av_log(s1, AV_LOG_ERROR, "Unsupported codec %x\n", st->codec->codec_id);
93 
94  return -1;
95  }
96 
97  if (s->payload_type < 0)
100  s->timestamp = s->base_timestamp;
101  s->cur_timestamp = 0;
102  s->ssrc = av_get_random_seed();
103  s->first_packet = 1;
105  if (s1->start_time_realtime)
106  /* Round the NTP time to whole milliseconds. */
107  s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 +
109 
110  max_packet_size = s1->pb->max_packet_size;
111  if (max_packet_size <= 12)
112  return AVERROR(EIO);
113  s->buf = av_malloc(max_packet_size);
114  if (s->buf == NULL) {
115  return AVERROR(ENOMEM);
116  }
117  s->max_payload_size = max_packet_size - 12;
118 
119  s->max_frames_per_packet = 0;
120  if (s1->max_delay) {
121  if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
122  if (st->codec->frame_size == 0) {
123  av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
124  } else {
126  }
127  }
128  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
129  /* FIXME: We should round down here... */
130  s->max_frames_per_packet = av_rescale_q(s1->max_delay, (AVRational){1, 1000000}, st->codec->time_base);
131  }
132  }
133 
134  avpriv_set_pts_info(st, 32, 1, 90000);
135  switch(st->codec->codec_id) {
136  case CODEC_ID_MP2:
137  case CODEC_ID_MP3:
138  s->buf_ptr = s->buf + 4;
139  break;
140  case CODEC_ID_MPEG1VIDEO:
141  case CODEC_ID_MPEG2VIDEO:
142  break;
143  case CODEC_ID_MPEG2TS:
145  if (n < 1)
146  n = 1;
148  s->buf_ptr = s->buf;
149  break;
150  case CODEC_ID_H264:
151  /* check for H.264 MP4 syntax */
152  if (st->codec->extradata_size > 4 && st->codec->extradata[0] == 1) {
153  s->nal_length_size = (st->codec->extradata[4] & 0x03) + 1;
154  }
155  break;
156  case CODEC_ID_VORBIS:
157  case CODEC_ID_THEORA:
159  s->max_frames_per_packet = av_clip(s->max_frames_per_packet, 1, 15);
160  s->max_payload_size -= 6; // ident+frag+tdt/vdt+pkt_num+pkt_length
161  s->num_frames = 0;
162  goto defaultcase;
163  case CODEC_ID_VP8:
164  av_log(s1, AV_LOG_ERROR, "RTP VP8 payload implementation is "
165  "incompatible with the latest spec drafts.\n");
166  break;
167  case CODEC_ID_ADPCM_G722:
168  /* Due to a historical error, the clock rate for G722 in RTP is
169  * 8000, even if the sample rate is 16000. See RFC 3551. */
170  avpriv_set_pts_info(st, 32, 1, 8000);
171  break;
172  case CODEC_ID_AMR_NB:
173  case CODEC_ID_AMR_WB:
174  if (!s->max_frames_per_packet)
175  s->max_frames_per_packet = 12;
176  if (st->codec->codec_id == CODEC_ID_AMR_NB)
177  n = 31;
178  else
179  n = 61;
180  /* max_header_toc_size + the largest AMR payload must fit */
181  if (1 + s->max_frames_per_packet + n > s->max_payload_size) {
182  av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n");
183  return -1;
184  }
185  if (st->codec->channels != 1) {
186  av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
187  return -1;
188  }
189  case CODEC_ID_AAC:
190  s->num_frames = 0;
191  default:
192 defaultcase:
193  if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
194  avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
195  }
196  s->buf_ptr = s->buf;
197  break;
198  }
199 
200  return 0;
201 }
202 
203 /* send an rtcp sender report packet */
204 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
205 {
206  RTPMuxContext *s = s1->priv_data;
207  uint32_t rtp_ts;
208 
209  av_dlog(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
210 
211  s->last_rtcp_ntp_time = ntp_time;
212  rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
213  s1->streams[0]->time_base) + s->base_timestamp;
214  avio_w8(s1->pb, (RTP_VERSION << 6));
215  avio_w8(s1->pb, RTCP_SR);
216  avio_wb16(s1->pb, 6); /* length in words - 1 */
217  avio_wb32(s1->pb, s->ssrc);
218  avio_wb32(s1->pb, ntp_time / 1000000);
219  avio_wb32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
220  avio_wb32(s1->pb, rtp_ts);
221  avio_wb32(s1->pb, s->packet_count);
222  avio_wb32(s1->pb, s->octet_count);
223  avio_flush(s1->pb);
224 }
225 
226 /* send an rtp packet. sequence number is incremented, but the caller
227  must update the timestamp itself */
228 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
229 {
230  RTPMuxContext *s = s1->priv_data;
231 
232  av_dlog(s1, "rtp_send_data size=%d\n", len);
233 
234  /* build the RTP header */
235  avio_w8(s1->pb, (RTP_VERSION << 6));
236  avio_w8(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
237  avio_wb16(s1->pb, s->seq);
238  avio_wb32(s1->pb, s->timestamp);
239  avio_wb32(s1->pb, s->ssrc);
240 
241  avio_write(s1->pb, buf1, len);
242  avio_flush(s1->pb);
243 
244  s->seq++;
245  s->octet_count += len;
246  s->packet_count++;
247 }
248 
249 /* send an integer number of samples and compute time stamp and fill
250  the rtp send buffer before sending. */
252  const uint8_t *buf1, int size, int sample_size_bits)
253 {
254  RTPMuxContext *s = s1->priv_data;
255  int len, max_packet_size, n;
256  /* Calculate the number of bytes to get samples aligned on a byte border */
257  int aligned_samples_size = sample_size_bits/av_gcd(sample_size_bits, 8);
258 
259  max_packet_size = (s->max_payload_size / aligned_samples_size) * aligned_samples_size;
260  /* Not needed, but who knows. Don't check if samples aren't an even number of bytes. */
261  if ((sample_size_bits % 8) == 0 && ((8 * size) % sample_size_bits) != 0)
262  av_abort();
263  n = 0;
264  while (size > 0) {
265  s->buf_ptr = s->buf;
266  len = FFMIN(max_packet_size, size);
267 
268  /* copy data */
269  memcpy(s->buf_ptr, buf1, len);
270  s->buf_ptr += len;
271  buf1 += len;
272  size -= len;
273  s->timestamp = s->cur_timestamp + n * 8 / sample_size_bits;
274  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
275  n += (s->buf_ptr - s->buf);
276  }
277 }
278 
280  const uint8_t *buf1, int size)
281 {
282  RTPMuxContext *s = s1->priv_data;
283  int len, count, max_packet_size;
284 
285  max_packet_size = s->max_payload_size;
286 
287  /* test if we must flush because not enough space */
288  len = (s->buf_ptr - s->buf);
289  if ((len + size) > max_packet_size) {
290  if (len > 4) {
291  ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
292  s->buf_ptr = s->buf + 4;
293  }
294  }
295  if (s->buf_ptr == s->buf + 4) {
296  s->timestamp = s->cur_timestamp;
297  }
298 
299  /* add the packet */
300  if (size > max_packet_size) {
301  /* big packet: fragment */
302  count = 0;
303  while (size > 0) {
304  len = max_packet_size - 4;
305  if (len > size)
306  len = size;
307  /* build fragmented packet */
308  s->buf[0] = 0;
309  s->buf[1] = 0;
310  s->buf[2] = count >> 8;
311  s->buf[3] = count;
312  memcpy(s->buf + 4, buf1, len);
313  ff_rtp_send_data(s1, s->buf, len + 4, 0);
314  size -= len;
315  buf1 += len;
316  count += len;
317  }
318  } else {
319  if (s->buf_ptr == s->buf + 4) {
320  /* no fragmentation possible */
321  s->buf[0] = 0;
322  s->buf[1] = 0;
323  s->buf[2] = 0;
324  s->buf[3] = 0;
325  }
326  memcpy(s->buf_ptr, buf1, size);
327  s->buf_ptr += size;
328  }
329 }
330 
332  const uint8_t *buf1, int size)
333 {
334  RTPMuxContext *s = s1->priv_data;
335  int len, max_packet_size;
336 
337  max_packet_size = s->max_payload_size;
338 
339  while (size > 0) {
340  len = max_packet_size;
341  if (len > size)
342  len = size;
343 
344  s->timestamp = s->cur_timestamp;
345  ff_rtp_send_data(s1, buf1, len, (len == size));
346 
347  buf1 += len;
348  size -= len;
349  }
350 }
351 
352 /* NOTE: size is assumed to be an integer multiple of TS_PACKET_SIZE */
354  const uint8_t *buf1, int size)
355 {
356  RTPMuxContext *s = s1->priv_data;
357  int len, out_len;
358 
359  while (size >= TS_PACKET_SIZE) {
360  len = s->max_payload_size - (s->buf_ptr - s->buf);
361  if (len > size)
362  len = size;
363  memcpy(s->buf_ptr, buf1, len);
364  buf1 += len;
365  size -= len;
366  s->buf_ptr += len;
367 
368  out_len = s->buf_ptr - s->buf;
369  if (out_len >= s->max_payload_size) {
370  ff_rtp_send_data(s1, s->buf, out_len, 0);
371  s->buf_ptr = s->buf;
372  }
373  }
374 }
375 
377 {
378  RTPMuxContext *s = s1->priv_data;
379  AVStream *st = s1->streams[0];
380  int rtcp_bytes;
381  int size= pkt->size;
382 
383  av_dlog(s1, "%d: write len=%d\n", pkt->stream_index, size);
384 
385  rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
387  if (s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
388  (ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) {
389  rtcp_send_sr(s1, ff_ntp_time());
391  s->first_packet = 0;
392  }
393  s->cur_timestamp = s->base_timestamp + pkt->pts;
394 
395  switch(st->codec->codec_id) {
396  case CODEC_ID_PCM_MULAW:
397  case CODEC_ID_PCM_ALAW:
398  case CODEC_ID_PCM_U8:
399  case CODEC_ID_PCM_S8:
400  rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
401  break;
402  case CODEC_ID_PCM_U16BE:
403  case CODEC_ID_PCM_U16LE:
404  case CODEC_ID_PCM_S16BE:
405  case CODEC_ID_PCM_S16LE:
406  rtp_send_samples(s1, pkt->data, size, 16 * st->codec->channels);
407  break;
408  case CODEC_ID_ADPCM_G722:
409  /* The actual sample size is half a byte per sample, but since the
410  * stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
411  * the correct parameter for send_samples_bits is 8 bits per stream
412  * clock. */
413  rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
414  break;
415  case CODEC_ID_ADPCM_G726:
416  rtp_send_samples(s1, pkt->data, size,
418  break;
419  case CODEC_ID_MP2:
420  case CODEC_ID_MP3:
421  rtp_send_mpegaudio(s1, pkt->data, size);
422  break;
423  case CODEC_ID_MPEG1VIDEO:
424  case CODEC_ID_MPEG2VIDEO:
425  ff_rtp_send_mpegvideo(s1, pkt->data, size);
426  break;
427  case CODEC_ID_AAC:
428  if (s->flags & FF_RTP_FLAG_MP4A_LATM)
429  ff_rtp_send_latm(s1, pkt->data, size);
430  else
431  ff_rtp_send_aac(s1, pkt->data, size);
432  break;
433  case CODEC_ID_AMR_NB:
434  case CODEC_ID_AMR_WB:
435  ff_rtp_send_amr(s1, pkt->data, size);
436  break;
437  case CODEC_ID_MPEG2TS:
438  rtp_send_mpegts_raw(s1, pkt->data, size);
439  break;
440  case CODEC_ID_H264:
441  ff_rtp_send_h264(s1, pkt->data, size);
442  break;
443  case CODEC_ID_H263:
444  case CODEC_ID_H263P:
445  ff_rtp_send_h263(s1, pkt->data, size);
446  break;
447  case CODEC_ID_VORBIS:
448  case CODEC_ID_THEORA:
449  ff_rtp_send_xiph(s1, pkt->data, size);
450  break;
451  case CODEC_ID_VP8:
452  ff_rtp_send_vp8(s1, pkt->data, size);
453  break;
454  default:
455  /* better than nothing : send the codec raw data */
456  rtp_send_raw(s1, pkt->data, size);
457  break;
458  }
459  return 0;
460 }
461 
463 {
464  RTPMuxContext *s = s1->priv_data;
465 
466  av_freep(&s->buf);
467 
468  return 0;
469 }
470 
472  .name = "rtp",
473  .long_name = NULL_IF_CONFIG_SMALL("RTP output format"),
474  .priv_data_size = sizeof(RTPMuxContext),
475  .audio_codec = CODEC_ID_PCM_MULAW,
476  .video_codec = CODEC_ID_MPEG4,
480  .priv_class = &rtp_muxer_class,
481 };
static int write_header(AVFormatContext *s)
Definition: assenc.c:28
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:1103
int size
AVOption.
Definition: opt.h:244
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:76
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the pts for a given stream.
Definition: utils.c:3828
int payload_type
Definition: rtpenc.h:31
#define NTP_OFFSET_US
Definition: internal.h:83
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: rtpenc.c:376
#define RTP_VERSION
Definition: rtp.h:72
int64_t last_rtcp_ntp_time
Definition: rtpenc.h:41
int size
Definition: avcodec.h:909
AVOptions.
#define RTCP_TX_RATIO_NUM
Definition: rtp.h:76
unsigned int last_octet_count
Definition: rtpenc.h:47
static const AVOption options[]
Definition: rtpenc.c:33
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
int max_payload_size
Definition: rtpenc.h:37
#define RTCP_TX_RATIO_DEN
Definition: rtp.h:77
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:274
int nal_length_size
Number of bytes used for H.264 NAL length, if the MP4 syntax is used (1, 2 or 4)
Definition: rtpenc.h:59
uint16_t seq
Definition: rtpenc.h:33
#define FF_RTP_FLAG_MP4A_LATM
Definition: rtpenc.h:66
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1398
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:147
Format I/O context.
Definition: avformat.h:863
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:38
static const AVClass rtp_muxer_class
Definition: rtpenc.c:39
int max_frames_per_packet
Definition: rtpenc.h:53
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1387
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
AVStream ** streams
Definition: avformat.h:908
unsigned int octet_count
Definition: rtpenc.h:46
#define TS_PACKET_SIZE
Definition: mpegts.h:29
static int rtp_write_header(AVFormatContext *s1)
Definition: rtpenc.c:82
uint8_t * data
Definition: avcodec.h:908
static int flags
Definition: log.c:34
uint8_t * buf
Definition: rtpenc.h:50
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1974
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:190
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:67
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:88
uint64_t ff_ntp_time(void)
Get the current time since NTP epoch in microseconds.
Definition: utils.c:3538
#define av_abort()
Definition: internal.h:109
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:132
int max_packet_size
Definition: avio.h:103
uint32_t ssrc
Definition: rtpenc.h:32
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_aac.c:25
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
static int is_supported(enum CodecID id)
Definition: rtpenc.c:48
void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_latm.c:25
void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size)
Definition: rtpenc_vp8.c:26
int64_t av_gcd(int64_t a, int64_t b)
Return the greatest common divisor of a and b.
Definition: mathematics.c:71
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:140
static void rtp_send_mpegts_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:353
AVCodecContext * codec
codec context
Definition: avformat.h:623
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:907
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:30
int void avio_flush(AVIOContext *s)
Definition: aviobuf.c:205
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:277
#define FFMIN(a, b)
Definition: common.h:55
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
Definition: rtpenc.c:228
const char * name
Definition: avformat.h:390
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc_mpv.c:29
static void rtp_send_mpegaudio(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:279
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
Definition: log.h:158
LIBAVUTIL_VERSION_INT
Definition: eval.c:50
Stream structure.
Definition: avformat.h:620
static void rtp_send_samples(AVFormatContext *s1, const uint8_t *buf1, int size, int sample_size_bits)
Definition: rtpenc.c:251
int frame_size
Samples per packet, initialized when calling 'init'.
Definition: avcodec.h:1470
int64_t first_rtcp_ntp_time
Definition: rtpenc.h:42
uint32_t cur_timestamp
Definition: rtpenc.h:36
NULL
Definition: eval.c:50
AVOutputFormat ff_rtp_muxer
Definition: rtpenc.c:471
enum AVMediaType codec_type
Definition: avcodec.h:1574
int sample_rate
samples per second
Definition: avcodec.h:1456
AVIOContext * pb
Definition: avformat.h:896
av_default_item_name
Definition: dnxhdenc.c:43
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
Definition: rtpenc.h:68
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:169
int first_packet
Definition: rtpenc.h:48
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:111
int extradata_size
Definition: avcodec.h:1388
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:64
Describe the class of an AVClass context structure.
Definition: log.h:33
rational number numerator/denominator
Definition: rational.h:43
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
Definition: avcodec.h:418
int flags
Definition: rtpenc.h:61
static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
Definition: rtpenc.c:204
#define s1
Definition: regdef.h:38
int num_frames
Definition: rtpenc.h:38
uint32_t base_timestamp
Definition: rtpenc.h:35
Round toward -infinity.
Definition: mathematics.h:69
uint8_t * buf_ptr
Definition: rtpenc.h:51
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:533
struct RTPMuxContext RTPMuxContext
Definition: rtpenc.h:64
void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc_h264.c:78
Main libavformat public API header.
static void rtp_send_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
Definition: rtpenc.c:331
#define RTCP_SR_SIZE
Definition: rtpenc.c:46
Definition: rtp.h:87
CodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:83
unsigned int packet_count
Definition: rtpenc.h:45
uint32_t timestamp
Definition: rtpenc.h:34
int len
int channels
number of audio channels
Definition: avcodec.h:1457
void * priv_data
Format private data.
Definition: avformat.h:883
static int rtp_write_trailer(AVFormatContext *s1)
Definition: rtpenc.c:462
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:324
int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
Return the payload type for a given codec used in the given format context.
Definition: rtp.c:93
uint32_t av_get_random_seed(void)
Get random data.
Definition: random_seed.c:73
int stream_index
Definition: avcodec.h:910
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:652
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:901
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:336
enum CodecID codec_id
Definition: avcodec.h:1575