Go to the documentation of this file.
21 #include "config_components.h"
44 #define MAX_EXTRADATA_SIZE ((INT_MAX - 10) / 2)
46 struct sdp_session_level {
63 static void sdp_write_address(
char *buff,
int size,
const char *dest_addr,
64 const char *dest_type,
int ttl)
69 if (ttl > 0 && !strcmp(dest_type,
"IP4")) {
72 av_strlcatf(buff,
size,
"c=IN %s %s/%d\r\n", dest_type, dest_addr, ttl);
79 static void sdp_write_header(
char *buff,
int size,
struct sdp_session_level *
s)
82 "o=- %d %d IN %s %s\r\n"
85 s->id,
s->version,
s->src_type,
s->src_addr,
87 sdp_write_address(buff,
size,
s->dst_addr,
s->dst_type,
s->ttl);
90 s->start_time,
s->end_time);
94 static int resolve_destination(
char *dest_addr,
int size,
char *
type,
112 if (ai->ai_family == AF_INET6)
120 static int resolve_destination(
char *dest_addr,
int size,
char *
type,
127 static int sdp_get_address(
char *dest_addr,
int size,
int *ttl,
const char *url)
137 if (strcmp(proto,
"rtp") && strcmp(proto,
"srtp")) {
144 p = strchr(url,
'?');
149 *ttl = strtol(buff,
NULL, 10);
158 #define MAX_PSET_SIZE 1024
164 static const char pset_string[] =
"; sprop-parameter-sets=";
165 static const char profile_string[] =
"; profile-level-id=";
168 uint8_t *tmpbuf =
NULL;
169 const uint8_t *
sps =
NULL, *sps_end;
192 memcpy(psets, pset_string, strlen(pset_string));
193 p = psets + strlen(pset_string);
195 while (
r < extradata + extradata_size) {
200 nal_type = *
r & 0x1f;
202 if (nal_type != 7 && nal_type != 8) {
206 if (p != (psets + strlen(pset_string))) {
207 if (p - psets >= MAX_PSET_SIZE)
218 MAX_PSET_SIZE - (p - psets), r1 -
r);
228 if (
sps && sps_end -
sps >= 4 && p - psets <= MAX_PSET_SIZE - strlen(profile_string) - 7) {
229 memcpy(p, profile_string, strlen(profile_string));
245 uint8_t *tmpbuf =
NULL;
246 int ps_pos[3] = { 0 };
247 static const char *
const ps_names[3] = {
"vps",
"sps",
"pps" };
248 int num_arrays, num_nalus;
273 if (extradata_size < 23)
276 num_arrays = extradata[22];
278 for (
i = 0;
i < num_arrays;
i++) {
279 int num_nalus, nalu_type;
280 if (
pos + 3 > extradata_size)
282 nalu_type = extradata[
pos] & 0x3f;
287 else if (nalu_type == 33)
289 else if (nalu_type == 34)
293 for (j = 0; j < num_nalus; j++) {
295 if (
pos + 2 > extradata_size)
299 if (
pos +
len > extradata_size)
304 if (!ps_pos[0] || !ps_pos[1] || !ps_pos[2])
315 for (
i = 0;
i < 3;
i++) {
320 av_strlcatf(psets, MAX_PSET_SIZE,
"sprop-%s=", ps_names[
i]);
326 for (j = 0; j < num_nalus; j++) {
332 strpos = strlen(psets);
368 memcpy(
config,
"; config=", 9);
379 char *encoded_config;
380 const uint8_t *header_start[3];
381 int headers_len, header_len[3], config_len;
382 int first_header_size,
ret;
388 first_header_size = 42;
391 first_header_size = 30;
399 first_header_size, header_start,
406 headers_len = header_len[0] + header_len[2];
419 if (!encoded_config) {
429 config[7] = (headers_len >> 8) & 0xff;
430 config[8] = headers_len & 0xff;
432 config[10] = header_len[0];
434 memcpy(
config + 12, header_start[0], header_len[0]);
435 memcpy(
config + 12 + header_len[0], header_start[2], header_len[2]);
441 *
out = encoded_config;
446 "Not enough memory for configuration string\n");
456 int profile_level = 0x2B;
463 profile_level = 0x28;
466 profile_level = 0x29;
468 profile_level = 0x2A;
472 profile_level = 0x2B;
476 return profile_level;
486 uint8_t config_byte[6];
492 for (rate_index = 0; rate_index < 16; rate_index++)
495 if (rate_index == 16) {
500 config_byte[0] = 0x40;
502 config_byte[2] = 0x20 | rate_index;
504 config_byte[4] = 0x3f;
505 config_byte[5] = 0xc0;
518 static int sdp_write_media_attributes(
char *buff,
int size,
const AVStream *st,
540 "a=fmtp:%d packetization-mode=%d%s\r\n",
547 const char *pic_fmt =
NULL;
569 "a=framesize:%d %d-%d\r\n",
575 ret = extradata2psets_hevc(fmt, p, &
config);
591 "a=fmtp:%d profile-level-id=1%s\r\n",
598 ret = latm_context2config(fmt, p, &
config);
602 "a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n",
604 payload_type, latm_context2profilelevel(p),
config);
614 av_log(fmt,
AV_LOG_ERROR,
"AAC with no global headers is currently not supported.\n");
618 "a=fmtp:%d profile-level-id=1;"
619 "mode=AAC-hbr;sizelength=13;indexlength=3;"
620 "indexdeltalength=3%s\r\n",
651 "a=fmtp:%d octet-align=1\r\n",
657 "a=fmtp:%d octet-align=1\r\n",
663 ret = xiph_extradata2config(fmt, p, &
config);
672 "a=fmtp:%d configuration=%s\r\n",
694 ret = xiph_extradata2config(fmt, p, &
config);
703 "a=fmtp:%d delivery-method=inline; "
704 "width=%d; height=%d; sampling=%s; "
705 "configuration=%s\r\n",
706 payload_type, payload_type,
738 "a=fmtp:%d sampling=%s; "
739 "width=%d; height=%d; "
741 payload_type, payload_type,
786 "a=fmtp:%d mode=%d\r\n",
819 const char *dest_addr,
const char *dest_type,
832 default :
type =
"application";
break;
836 sdp_write_address(buff,
size, dest_addr, dest_type, ttl);
841 return sdp_write_media_attributes(buff,
size, st, payload_type, fmt);
847 struct sdp_session_level
s = { 0 };
848 int i, j, port, ttl, is_multicast,
index = 0;
849 char dst[32], dst_type[5];
851 memset(buf, 0,
size);
853 s.src_addr =
"127.0.0.1";
855 s.name = title ? title->
value :
"No Name";
860 port = sdp_get_address(
dst,
sizeof(
dst), &ttl, ac[0]->url ? ac[0]->url :
"");
861 is_multicast = resolve_destination(
dst,
sizeof(
dst), dst_type,
867 s.dst_type = dst_type;
869 if (!strcmp(dst_type,
"IP6")) {
875 sdp_write_header(buf,
size, &
s);
878 for (
i = 0;
i < n_files;
i++) {
880 port = sdp_get_address(
dst,
sizeof(
dst), &ttl, ac[
i]->url ? ac[
i]->url :
"");
881 is_multicast = resolve_destination(
dst,
sizeof(
dst), dst_type,
889 (port > 0) ? port + j * 2 : 0,
896 "a=control:streamid=%d\r\n",
i + j);
899 uint8_t *crypto_suite =
NULL, *crypto_params =
NULL;
904 if (crypto_suite && crypto_suite[0])
906 "a=crypto:1 %s inline:%s\r\n",
907 crypto_suite, crypto_params);
923 const char *dest_addr,
const char *dest_type,
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
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
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
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
Check whether a particular flag is set in a flags field.
enum AVMediaType codec_type
General type of the encoded data.
This struct describes the properties of an encoded stream.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
int nb_channels
Number of channels in this layout.
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
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 type
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static enum AVPixelFormat pix_fmt
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define PTRDIFF_SPECIFIER
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness, void *logctx)
Writes HEVC extradata (parameter sets and declarative SEI NAL units with nuh_layer_id == 0,...
int ff_is_multicast_address(struct sockaddr *addr)
#define AV_PIX_FMT_YUV422P10
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int64_t start_time
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
#define i(width, name, range_min, range_max)
int block_align
Audio only.
#define MAX_EXTRADATA_SIZE
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
enum AVFieldOrder field_order
Video only.
const struct AVOutputFormat * oformat
The output container format.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_CODEC_ID_ADPCM_G726LE
int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size)
int ff_sdp_write_media(char *buff, int size, const AVStream *st, int idx, const char *dest_addr, const char *dest_type, int port, int ttl, AVFormatContext *fmt)
Append the media-specific SDP fragment for the media stream c to the buffer buff.
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, int first_header_size, const uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
const int ff_mpeg4audio_sample_rates[16]
int bits_per_coded_sample
The number of bits per sample in the codedwords.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const uint8_t * ff_nal_find_startcode(const uint8_t *p, const uint8_t *end)
void * priv_data
Format private data.
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.
const AVClass * av_class
A class for private options.
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