Go to the documentation of this file.
47 #define RTCP_SR_SIZE 28
101 if (
s1->nb_streams != 1) {
112 if (
s->payload_type < 0) {
117 s->payload_type = st->
id;
120 st->
id =
s->payload_type;
124 s->timestamp =
s->base_timestamp;
125 s->cur_timestamp = 0;
132 s->first_rtcp_ntp_time = (
s1->start_time_realtime / 1000) * 1000 +
145 if (
s1->packet_size) {
146 if (
s1->pb->max_packet_size)
148 s1->pb->max_packet_size);
150 s1->packet_size =
s1->pb->max_packet_size;
151 if (
s1->packet_size <= 12) {
159 s->max_payload_size =
s1->packet_size - 12;
170 s->buf_ptr =
s->buf + 4;
185 "Packetizing VC-2 is experimental and does not use all values "
186 "of the specification "
187 "(even though most receivers may handle it just fine). "
188 "Please set -strict experimental in order to enable it.\n");
196 "Packetizing H.261 is experimental and produces incorrect "
197 "packetization for cases where GOBs don't fit into packets "
198 "(even though most receivers may handle it just fine). "
199 "Please set -f_strict experimental in order to enable it.\n");
222 "Packetizing VP9 is experimental and its specification is "
223 "still in draft state. "
224 "Please set -strict experimental in order to enable it.\n");
231 s->max_frames_per_packet = 15;
257 s->max_frames_per_packet = 50;
263 if (1 +
s->max_frames_per_packet + n >
s->max_payload_size) {
273 s->max_frames_per_packet = 50;
294 s->last_rtcp_ntp_time = ntp_time;
296 s1->streams[0]->time_base) +
s->base_timestamp;
302 avio_wb32(
s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
342 avio_w8(
s1->pb, (
s->payload_type & 0x7f) | ((m & 0x01) << 7));
350 s->seq = (
s->seq + 1) & 0xffff;
351 s->octet_count +=
len;
358 const uint8_t *buf1,
int size,
int sample_size_bits)
361 int len, max_packet_size, n;
363 int aligned_samples_size = sample_size_bits/
av_gcd(sample_size_bits, 8);
365 max_packet_size = (
s->max_payload_size / aligned_samples_size) * aligned_samples_size;
367 if ((sample_size_bits % 8) == 0 && ((8 *
size) % sample_size_bits) != 0)
375 memcpy(
s->buf_ptr, buf1,
len);
379 s->timestamp =
s->cur_timestamp + n * 8 / sample_size_bits;
381 n += (
s->buf_ptr -
s->buf);
387 const uint8_t *buf1,
int size)
390 int len, count, max_packet_size;
392 max_packet_size =
s->max_payload_size;
395 len = (
s->buf_ptr -
s->buf);
396 if ((
len +
size) > max_packet_size) {
399 s->buf_ptr =
s->buf + 4;
402 if (
s->buf_ptr ==
s->buf + 4) {
403 s->timestamp =
s->cur_timestamp;
407 if (
size > max_packet_size) {
411 len = max_packet_size - 4;
417 s->buf[2] = count >> 8;
419 memcpy(
s->buf + 4, buf1,
len);
426 if (
s->buf_ptr ==
s->buf + 4) {
433 memcpy(
s->buf_ptr, buf1,
size);
439 const uint8_t *buf1,
int size)
442 int len, max_packet_size;
444 max_packet_size =
s->max_payload_size;
447 len = max_packet_size;
451 s->timestamp =
s->cur_timestamp;
461 const uint8_t *buf1,
int size)
466 s->timestamp =
s->cur_timestamp;
468 len =
s->max_payload_size - (
s->buf_ptr -
s->buf);
471 memcpy(
s->buf_ptr, buf1,
len);
476 out_len =
s->buf_ptr -
s->buf;
477 if (out_len >=
s->max_payload_size) {
493 if (
s->num_frames > 0 &&
500 if (!
s->num_frames) {
502 s->timestamp =
s->cur_timestamp;
509 s->cur_timestamp += frame_duration;
511 if (
s->num_frames ==
s->max_frames_per_packet) {
534 s->last_octet_count =
s->octet_count;
537 s->cur_timestamp =
s->base_timestamp +
pkt->
pts;
629 if (
size >
s->max_payload_size) {
631 "Packet size %d too large for max RTP payload size %d\n",
632 size,
s->max_payload_size);
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
static int rtp_write_header(AVFormatContext *s1)
#define FF_RTP_FLAG_MP4A_LATM
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
enum AVMediaType codec_type
General type of the encoded data.
void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buff, int size)
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.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf1, int size, const uint8_t *mb_info, int mb_info_size)
void ff_rtp_send_h261(AVFormatContext *s1, const uint8_t *buf1, int size)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
#define FF_RTP_FLAG_RFC2190
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
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...
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size)
if it could not because there are no more frames
static int rtp_write_trailer(AVFormatContext *s1)
void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define FF_RTP_FLAG_SKIP_RTCP
static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
static int is_supported(enum AVCodecID id)
static const AVOption options[]
const AVOutputFormat ff_rtp_muxer
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define RTCP_TX_RATIO_NUM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
#define RTCP_TX_RATIO_DEN
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static void rtp_send_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
static int write_trailer(AVFormatContext *s1)
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_CODEC_ID_MPEG2TS
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
void avio_w8(AVIOContext *s, int b)
static const AVClass rtp_muxer_class
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
int extradata_size
Size of the extradata content in bytes.
static int rtp_send_samples(AVFormatContext *s1, const uint8_t *buf1, int size, int sample_size_bits)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_NOPTS_VALUE
Undefined timestamp value.
@ 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...
static void rtp_send_mpegts_raw(AVFormatContext *s1, const uint8_t *buf1, int size)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time, int bye)
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size)
int block_align
Audio only.
#define FF_RTP_FLAG_SEND_BYE
void ff_rtp_send_vp9(AVFormatContext *s1, const uint8_t *buff, int size)
void ff_rtp_send_vc2hq(AVFormatContext *s1, const uint8_t *buf, int size, int interlaced)
enum AVFieldOrder field_order
Video only.
int id
Format-specific stream ID.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void ff_rtp_send_h264_hevc(AVFormatContext *s1, const uint8_t *buf1, int size)
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.
@ AV_CODEC_ID_ADPCM_G726LE
void ff_rtp_send_h263(AVFormatContext *s1, const uint8_t *buf1, int size)
Packetize H.263 frames into RTP packets according to RFC 4629.
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
void avio_wb16(AVIOContext *s, unsigned int val)
#define flags(name, subs,...)
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.
static void write_header(FFV1Context *f)
static void rtp_send_mpegaudio(AVFormatContext *s1, const uint8_t *buf1, int size)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
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.