diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-10-13 04:55:40 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-13 06:00:03 +0200 |
commit | f884ef00de362a5460a9c58318d009bcae440cc8 (patch) | |
tree | 955b7a1dc3f2bf89fb9332d0e732aac9e52b0e29 /libavformat | |
parent | c1847c932b1576e8224c38e112a5fd29fa8a6098 (diff) | |
parent | 47a1d794dba02239f9eeb37e9dfd4dfdb634c3b7 (diff) | |
download | ffmpeg-f884ef00de362a5460a9c58318d009bcae440cc8.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (31 commits)
tiffenc: initialize forgotten avctx.
avplay: free the active audio packet at exit.
avplay: free rdft data used for spectrogram analysis.
log.h: make AVClass a named struct
fix ac3 encoder documentation
vc1: more prettyprinting cosmetics
vc1: prettyprint some tables
vc1: K&R formatting cosmetics
AVOptions: bump minor and add APIchanges entry.
cmdutils/avtools: simplify show_help() by using av_opt_child_class_next()
AVOptions: rename FF_OPT_TYPE_* => AV_OPT_TYPE_*
Remove all uses of deprecated AVOptions API.
AVOptions: add av_opt_next, deprecate av_next_option.
AVOptions: add functions for evaluating option strings.
AVOptions: split get_number().
AVOptions: add av_opt_get*, deprecate av_get*.
AVOptions: add av_opt_set*().
AVOptions: add new API for enumerating children.
rv34: move inverse transform functions to DSP context
flvenc: Write the right metadata entry count
...
Conflicts:
avconv.c
cmdutils.c
doc/APIchanges
ffplay.c
ffprobe.c
libavcodec/ac3dec.c
libavcodec/h264.c
libavcodec/libvpxenc.c
libavcodec/libx264.c
libavcodec/mpeg12enc.c
libavcodec/options.c
libavdevice/libdc1394.c
libavdevice/v4l2.c
libavfilter/vf_drawtext.c
libavformat/flvdec.c
libavformat/mpegtsenc.c
libavformat/options.c
libavutil/avutil.h
libavutil/opt.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/applehttp.c | 4 | ||||
-rw-r--r-- | libavformat/crypto.c | 4 | ||||
-rw-r--r-- | libavformat/flvdec.c | 28 | ||||
-rw-r--r-- | libavformat/flvenc.c | 13 | ||||
-rw-r--r-- | libavformat/gif.c | 2 | ||||
-rw-r--r-- | libavformat/http.c | 2 | ||||
-rw-r--r-- | libavformat/img2.c | 8 | ||||
-rw-r--r-- | libavformat/latmenc.c | 2 | ||||
-rw-r--r-- | libavformat/movenc.c | 4 | ||||
-rw-r--r-- | libavformat/mp3enc.c | 4 | ||||
-rw-r--r-- | libavformat/mpegts.c | 2 | ||||
-rw-r--r-- | libavformat/mpegtsenc.c | 12 | ||||
-rw-r--r-- | libavformat/mxfenc.c | 16 | ||||
-rw-r--r-- | libavformat/options.c | 101 | ||||
-rw-r--r-- | libavformat/pcmdec.c | 4 | ||||
-rw-r--r-- | libavformat/rawdec.c | 2 | ||||
-rw-r--r-- | libavformat/rawvideodec.c | 6 | ||||
-rw-r--r-- | libavformat/rtp.c | 6 | ||||
-rw-r--r-- | libavformat/rtpdec.c | 16 | ||||
-rw-r--r-- | libavformat/rtpdec.h | 24 | ||||
-rw-r--r-- | libavformat/rtpenc.c | 2 | ||||
-rw-r--r-- | libavformat/rtpenc.h | 4 | ||||
-rw-r--r-- | libavformat/rtpenc_chain.c | 13 | ||||
-rw-r--r-- | libavformat/rtpproto.c | 8 | ||||
-rw-r--r-- | libavformat/rtsp.c | 31 | ||||
-rw-r--r-- | libavformat/rtsp.h | 3 | ||||
-rw-r--r-- | libavformat/rtspdec.c | 2 | ||||
-rw-r--r-- | libavformat/spdifenc.c | 8 | ||||
-rw-r--r-- | libavformat/tty.c | 6 | ||||
-rw-r--r-- | libavformat/wav.c | 2 |
30 files changed, 194 insertions, 145 deletions
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index d4026daae2..eccef6a303 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -350,8 +350,8 @@ static int open_input(struct variant *var) snprintf(url, sizeof(url), "crypto:%s", seg->url); if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ)) < 0) return ret; - av_set_string3(var->input->priv_data, "key", key, 0, NULL); - av_set_string3(var->input->priv_data, "iv", iv, 0, NULL); + av_opt_set(var->input->priv_data, "key", key, 0); + av_opt_set(var->input->priv_data, "iv", iv, 0); if ((ret = ffurl_connect(var->input)) < 0) { ffurl_close(var->input); var->input = NULL; diff --git a/libavformat/crypto.c b/libavformat/crypto.c index 5e7ee1eba3..b9d3e0326f 100644 --- a/libavformat/crypto.c +++ b/libavformat/crypto.c @@ -46,8 +46,8 @@ typedef struct { #define OFFSET(x) offsetof(CryptoContext, x) static const AVOption options[] = { - {"key", "AES decryption key", OFFSET(key), FF_OPT_TYPE_BINARY }, - {"iv", "AES decryption initialization vector", OFFSET(iv), FF_OPT_TYPE_BINARY }, + {"key", "AES decryption key", OFFSET(key), AV_OPT_TYPE_BINARY }, + {"iv", "AES decryption initialization vector", OFFSET(iv), AV_OPT_TYPE_BINARY }, { NULL } }; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 828d25fda3..7efe156666 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -276,17 +276,35 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; + if (amf_type == AMF_DATA_TYPE_NUMBER) { + if (!strcmp(key, "duration")) + s->duration = num_val * AV_TIME_BASE; + else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) + vcodec->bit_rate = num_val * 1024.0; + else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) + acodec->bit_rate = num_val * 1024.0; + } + + if (!strcmp(key, "duration") || + !strcmp(key, "filesize") || + !strcmp(key, "width") || + !strcmp(key, "height") || + !strcmp(key, "videodatarate") || + !strcmp(key, "framerate") || + !strcmp(key, "videocodecid") || + !strcmp(key, "audiodatarate") || + !strcmp(key, "audiosamplerate") || + !strcmp(key, "audiosamplesize") || + !strcmp(key, "stereo") || + !strcmp(key, "audiocodecid")) + return 0; + if(amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if(amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); - if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; - else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) - vcodec->bit_rate = num_val * 1024.0; - else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) - acodec->bit_rate = num_val * 1024.0; } else if(amf_type == AMF_DATA_TYPE_OBJECT){ if(s->nb_streams==1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))){ s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index fe866f10c8..143c58ca50 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -180,9 +180,9 @@ static int flv_write_header(AVFormatContext *s) AVIOContext *pb = s->pb; FLVContext *flv = s->priv_data; AVCodecContext *audio_enc = NULL, *video_enc = NULL; - int i; + int i, metadata_count = 0; double framerate = 0.0; - int64_t metadata_size_pos, data_size; + int64_t metadata_size_pos, data_size, metadata_count_pos; AVDictionaryEntry *tag = NULL; for(i=0; i<s->nb_streams; i++){ @@ -240,7 +240,9 @@ static int flv_write_header(AVFormatContext *s) /* mixed array (hash) with size and string/type/data tuples */ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY); - avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size + metadata_count_pos = avio_tell(pb); + metadata_count = 5*!!video_enc + 5*!!audio_enc + 2; // +2 for duration and file size + avio_wb32(pb, metadata_count); put_amf_string(pb, "duration"); flv->duration_offset= avio_tell(pb); @@ -300,6 +302,7 @@ static int flv_write_header(AVFormatContext *s) put_amf_string(pb, tag->key); avio_w8(pb, AMF_DATA_TYPE_STRING); put_amf_string(pb, tag->value); + metadata_count++; } put_amf_string(pb, "filesize"); @@ -311,6 +314,10 @@ static int flv_write_header(AVFormatContext *s) /* write total size of tag */ data_size= avio_tell(pb) - metadata_size_pos - 10; + + avio_seek(pb, metadata_count_pos, SEEK_SET); + avio_wb32(pb, metadata_count); + avio_seek(pb, metadata_size_pos, SEEK_SET); avio_wb24(pb, data_size); avio_skip(pb, data_size + 10 - 3); diff --git a/libavformat/gif.c b/libavformat/gif.c index 280a663690..200bc70573 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -351,7 +351,7 @@ static int gif_write_trailer(AVFormatContext *s) #define OFFSET(x) offsetof(GIFContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "loop", "Number of times to loop the output.", OFFSET(loop), FF_OPT_TYPE_INT, {0}, 0, 65535, ENC }, + { "loop", "Number of times to loop the output.", OFFSET(loop), AV_OPT_TYPE_INT, {0}, 0, 65535, ENC }, { NULL }, }; diff --git a/libavformat/http.c b/libavformat/http.c index 751a2029cd..265aff27e0 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -54,7 +54,7 @@ typedef struct { #define OFFSET(x) offsetof(HTTPContext, x) static const AVOption options[] = { -{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), FF_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */ +{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */ {NULL} }; static const AVClass httpcontext_class = { diff --git a/libavformat/img2.c b/libavformat/img2.c index 5ac57e5c32..1e6fb966c6 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -462,10 +462,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) #define OFFSET(x) offsetof(VideoData, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, - { "loop", "", OFFSET(loop), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "loop", "", OFFSET(loop), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, { NULL }, }; diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c index c461ac39dc..9ff2f4f86f 100644 --- a/libavformat/latmenc.c +++ b/libavformat/latmenc.c @@ -38,7 +38,7 @@ typedef struct { static const AVOption options[] = { {"smc-interval", "StreamMuxConfig interval.", - offsetof(LATMContext, mod), FF_OPT_TYPE_INT, {.dbl = 0x0014}, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(LATMContext, mod), AV_OPT_TYPE_INT, {.dbl = 0x0014}, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, {NULL}, }; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7670f356fe..5fd54fcb77 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -42,8 +42,8 @@ #include <assert.h> static const AVOption options[] = { - { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, - { "rtphint", "Add RTP hint tracks", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "rtphint", "Add RTP hint tracks", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags), { NULL }, }; diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 38a2665b22..b212978dc9 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -191,9 +191,9 @@ AVOutputFormat ff_mp2_muxer = { static const AVOption options[] = { { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", - offsetof(MP3Context, id3v2_version), FF_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM}, { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.", - offsetof(MP3Context, write_id3v1), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 1facf3de69..5196fab1e4 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -126,7 +126,7 @@ struct MpegTSContext { }; static const AVOption options[] = { - {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), FF_OPT_TYPE_INT, + {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 1eb935c182..1173f69d78 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -80,17 +80,17 @@ typedef struct MpegTSWrite { static const AVOption options[] = { { "mpegts_transport_stream_id", "Set transport_stream_id field.", - offsetof(MpegTSWrite, transport_stream_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, transport_stream_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_original_network_id", "Set original_network_id field.", - offsetof(MpegTSWrite, original_network_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, original_network_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_service_id", "Set service_id field.", - offsetof(MpegTSWrite, service_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, service_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_pmt_start_pid", "Set the first pid of the PMT.", - offsetof(MpegTSWrite, pmt_start_pid), FF_OPT_TYPE_INT, {.dbl = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT, {.dbl = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_start_pid", "Set the first pid.", - offsetof(MpegTSWrite, start_pid), FF_OPT_TYPE_INT, {.dbl = 0x0100 }, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT, {.dbl = 0x0100 }, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM}, {"mpegts_m2ts_mode", "Enable m2ts mode.", - offsetof(MpegTSWrite, m2ts_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, + offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 }, -1,1, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 6ffd0c0ff7..ce71ed2e51 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1871,7 +1871,7 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int mxf_interleave_get_packet, mxf_compare_timestamps); } -static const AVClass class = { +static const AVClass mxf_class = { .class_name = "mxf", .item_name = av_default_item_name, .version = LIBAVUTIL_VERSION_INT, @@ -1881,6 +1881,16 @@ static const AVClass class = { }, }; +static const AVClass mxf_d10_class = { + .class_name = "mxf_d10", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, + .option = (const AVOption[]){ + {TIMECODE_OPT(MXFContext, AV_OPT_FLAG_ENCODING_PARAM)}, + {NULL} + }, +}; + AVOutputFormat ff_mxf_muxer = { .name = "mxf", .long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format"), @@ -1894,7 +1904,7 @@ AVOutputFormat ff_mxf_muxer = { .write_trailer = mxf_write_footer, .flags = AVFMT_NOTIMESTAMPS, .interleave_packet = mxf_interleave, - .priv_class = &class, + .priv_class = &mxf_class, }; AVOutputFormat ff_mxf_d10_muxer = { @@ -1909,5 +1919,5 @@ AVOutputFormat ff_mxf_d10_muxer = { .write_trailer = mxf_write_footer, .flags = AVFMT_NOTIMESTAMPS, .interleave_packet = mxf_interleave, - .priv_class = &class, + .priv_class = &mxf_d10_class, }; diff --git a/libavformat/options.c b/libavformat/options.c index 65f1a4e639..c099ea63a1 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -33,30 +33,36 @@ static const char* format_to_name(void* ptr) else return "NULL"; } -static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) +static void *format_child_next(void *obj, void *prev) +{ + AVFormatContext *s = obj; + if (!prev && s->priv_data && + ((s->iformat && s->iformat->priv_class) || + s->oformat && s->oformat->priv_class)) + return s->priv_data; + return NULL; +} + +static const AVClass *format_child_class_next(const AVClass *prev) { - AVFormatContext *s = obj; AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL; - if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) { - if ((s->iformat && !s->iformat->priv_class) || - (s->oformat && !s->oformat->priv_class)) - return NULL; - return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags); - } - - while ((ifmt = av_iformat_next(ifmt))) { - const AVOption *o; - - if (ifmt->priv_class && (o = av_opt_find(&ifmt->priv_class, name, unit, opt_flags, search_flags))) - return o; - } - while ((ofmt = av_oformat_next(ofmt))) { - const AVOption *o; - - if (ofmt->priv_class && (o = av_opt_find(&ofmt->priv_class, name, unit, opt_flags, search_flags))) - return o; - } + + while (prev && (ifmt = av_iformat_next(ifmt))) + if (ifmt->priv_class == prev) + break; + if ((prev && ifmt) || (!prev)) + while (ifmt = av_iformat_next(ifmt)) + if (ifmt->priv_class) + return ifmt->priv_class; + + while (prev && (ofmt = av_oformat_next(ofmt))) + if (ofmt->priv_class == prev) + break; + while (ofmt = av_oformat_next(ofmt)) + if (ofmt->priv_class) + return ofmt->priv_class; + return NULL; } @@ -67,33 +73,33 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i #define D AV_OPT_FLAG_DECODING_PARAM static const AVOption options[]={ -{"probesize", "set probing size", OFFSET(probesize), FF_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, -{"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, -{"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, -{"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, -{"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, -{"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"}, -{"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"}, -{"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"}, -{"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, +{"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, +{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, +{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, +{"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, +{"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"}, +{"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"}, +{"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"}, #if FF_API_FLAG_RTP_HINT -{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"}, +{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"}, #endif -{"discardcorrupt", "discard corrupted frames", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, -{"sortdts", "try to interleave outputted packets by dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"}, -{"keepside", "dont merge side data", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, -{"latm", "enable RTP MP4A-LATM payload", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, -{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, -{"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, -{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, -{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ -{"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, -{"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, -{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, -{"fer", "set error detection aggressivity", OFFSET(error_recognition), FF_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"careful", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"}, -{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, +{"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, +{"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"keepside", "dont merge side data", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, +{"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, +{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, +{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, +{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, +{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ +{"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, +{"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, +{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, +{"fer", "set error detection aggressivity", OFFSET(error_recognition), AV_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, +{"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, +{"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"}, +{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, {NULL}, }; @@ -106,7 +112,8 @@ static const AVClass av_format_context_class = { .item_name = format_to_name, .option = options, .version = LIBAVUTIL_VERSION_INT, - .opt_find = opt_find, + .child_next = format_child_next, + .child_class_next = format_child_class_next, }; static void avformat_get_context_defaults(AVFormatContext *s) diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index 3e6132b880..542ee17749 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -49,8 +49,8 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) } static const AVOption pcm_options[] = { - { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(RawAudioDemuxerContext, channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 4fc48ed586..c3be73cf77 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -171,7 +171,7 @@ fail: #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM const AVOption ff_rawvideo_options[] = { - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC}, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC}, { NULL }, }; diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c index f5329a7b9e..8bd0dc92f0 100644 --- a/libavformat/rawvideodec.c +++ b/libavformat/rawvideodec.c @@ -47,9 +47,9 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption rawvideo_options[] = { - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; diff --git a/libavformat/rtp.c b/libavformat/rtp.c index 127b540748..d85b1b79db 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -97,9 +97,9 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec) /* Was the payload type already specified for the RTP muxer? */ if (ofmt && ofmt->priv_class) { - int payload_type = av_get_int(fmt->priv_data, "payload_type", NULL); - if (payload_type >= 0) - return payload_type; + int64_t payload_type; + if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0) + return (int)payload_type; } /* static payload type */ diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 002222f0ee..9023dd6985 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -218,7 +218,7 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) return 1; } -int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) +int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) { AVIOContext *pb; uint8_t *buf; @@ -315,7 +315,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) return 0; } -void rtp_send_punch_packets(URLContext* rtp_handle) +void ff_rtp_send_punch_packets(URLContext* rtp_handle) { AVIOContext *pb; uint8_t *buf; @@ -359,7 +359,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) * MPEG2TS streams to indicate that they should be demuxed inside the * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned) */ -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) +RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) { RTPDemuxContext *s; @@ -407,8 +407,8 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r } void -rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, - RTPDynamicProtocolHandler *handler) +ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, + RTPDynamicProtocolHandler *handler) { s->dynamic_protocol_context = ctx; s->parse_packet = handler->parse_packet; @@ -722,8 +722,8 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, * @return 0 if a packet is returned, 1 if a packet is returned and more can follow * (use buf as NULL to read the next). -1 if no packet (error or no more packet). */ -int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, - uint8_t **bufptr, int len) +int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, + uint8_t **bufptr, int len) { int rv = rtp_parse_one_packet(s, pkt, bufptr, len); s->prev_ret = rv; @@ -732,7 +732,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, return rv ? rv : has_next_packet(s); } -void rtp_parse_close(RTPDemuxContext *s) +void ff_rtp_parse_close(RTPDemuxContext *s) { ff_rtp_reset_packet_queue(s); if (!strcmp(ff_rtp_enc_name(s->payload_type), "MP2T")) { diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h index 2801101fd3..dbb45f5709 100644 --- a/libavformat/rtpdec.h +++ b/libavformat/rtpdec.h @@ -38,18 +38,18 @@ typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler; #define RTP_NOTS_VALUE ((uint32_t)-1) typedef struct RTPDemuxContext RTPDemuxContext; -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size); -void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, - RTPDynamicProtocolHandler *handler); -int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, - uint8_t **buf, int len); -void rtp_parse_close(RTPDemuxContext *s); +RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size); +void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, + RTPDynamicProtocolHandler *handler); +int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, + uint8_t **buf, int len); +void ff_rtp_parse_close(RTPDemuxContext *s); int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s); void ff_rtp_reset_packet_queue(RTPDemuxContext *s); -int rtp_get_local_rtp_port(URLContext *h); -int rtp_get_local_rtcp_port(URLContext *h); +int ff_rtp_get_local_rtp_port(URLContext *h); +int ff_rtp_get_local_rtcp_port(URLContext *h); -int rtp_set_remote_url(URLContext *h, const char *uri); +int ff_rtp_set_remote_url(URLContext *h, const char *uri); /** * Send a dummy packet on both port pairs to set up the connection @@ -62,19 +62,19 @@ int rtp_set_remote_url(URLContext *h, const char *uri); * The same routine is used with RDT too, even if RDT doesn't use normal * RTP packets otherwise. */ -void rtp_send_punch_packets(URLContext* rtp_handle); +void ff_rtp_send_punch_packets(URLContext* rtp_handle); /** * some rtp servers assume client is dead if they don't hear from them... * so we send a Receiver Report to the provided ByteIO context * (we don't have access to the rtcp handle from here) */ -int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); +int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); /** * Get the file handle for the RTCP socket. */ -int rtp_get_rtcp_file_handle(URLContext *h); +int ff_rtp_get_rtcp_file_handle(URLContext *h); // these statistics are used for rtcp receiver reports... typedef struct { diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index a336c64b37..bf183e7d21 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -32,7 +32,7 @@ static const AVOption options[] = { FF_RTP_FLAG_OPTS(RTPMuxContext, flags), - { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, + { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h index cba0d02d91..901336322d 100644 --- a/libavformat/rtpenc.h +++ b/libavformat/rtpenc.h @@ -66,8 +66,8 @@ typedef struct RTPMuxContext RTPMuxContext; #define FF_RTP_FLAG_MP4A_LATM 1 #define FF_RTP_FLAG_OPTS(ctx, fieldname) \ - { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ - { "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, FF_OPT_TYPE_CONST, {.dbl = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ + { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ + { "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, AV_OPT_TYPE_CONST, {.dbl = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index ed96d72f62..df7b9957b0 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -31,6 +31,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, AVFormatContext *rtpctx; int ret; AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); + uint8_t *rtpflags; + AVDictionary *opts = NULL; if (!rtp_format) return NULL; @@ -51,12 +53,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio; rtpctx->flags |= s->flags & AVFMT_FLAG_MP4A_LATM; - av_set_parameters(rtpctx, NULL); - /* Copy the rtpflags values straight through */ - if (s->oformat->priv_class && - av_find_opt(s->priv_data, "rtpflags", NULL, 0, 0)) - av_set_int(rtpctx->priv_data, "rtpflags", - av_get_int(s->priv_data, "rtpflags", NULL)); + if (av_opt_get(s, "rtpflags", AV_OPT_SEARCH_CHILDREN, &rtpflags) >= 0) + av_dict_set(&opts, "rtpflags", rtpflags, AV_DICT_DONT_STRDUP_VAL); /* Set the synchronized start time. */ rtpctx->start_time_realtime = s->start_time_realtime; @@ -67,7 +65,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, ffio_fdopen(&rtpctx->pb, handle); } else ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); - ret = avformat_write_header(rtpctx, NULL); + ret = avformat_write_header(rtpctx, &opts); + av_dict_free(&opts); if (ret) { if (handle) { diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index d2ce53c670..4f4cde621c 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -60,7 +60,7 @@ typedef struct RTPContext { * @return zero if no error. */ -int rtp_set_remote_url(URLContext *h, const char *uri) +int ff_rtp_set_remote_url(URLContext *h, const char *uri) { RTPContext *s = h->priv_data; char hostname[256]; @@ -301,7 +301,7 @@ static int rtp_close(URLContext *h) * @return the local port number */ -int rtp_get_local_rtp_port(URLContext *h) +int ff_rtp_get_local_rtp_port(URLContext *h) { RTPContext *s = h->priv_data; return ff_udp_get_local_port(s->rtp_hd); @@ -313,7 +313,7 @@ int rtp_get_local_rtp_port(URLContext *h) * @return the local port number */ -int rtp_get_local_rtcp_port(URLContext *h) +int ff_rtp_get_local_rtcp_port(URLContext *h) { RTPContext *s = h->priv_data; return ff_udp_get_local_port(s->rtcp_hd); @@ -325,7 +325,7 @@ static int rtp_get_file_handle(URLContext *h) return s->rtp_fd; } -int rtp_get_rtcp_file_handle(URLContext *h) { +int ff_rtp_get_rtcp_file_handle(URLContext *h) { RTPContext *s = h->priv_data; return s->rtcp_fd; } diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 3b410a3043..64e29cc487 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -501,7 +501,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s) } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC) ff_rdt_parse_close(rtsp_st->transport_priv); else if (CONFIG_RTPDEC) - rtp_parse_close(rtsp_st->transport_priv); + ff_rtp_parse_close(rtsp_st->transport_priv); } rtsp_st->transport_priv = NULL; if (rtsp_st->rtp_handle) @@ -558,7 +558,7 @@ static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); else if (CONFIG_RTPDEC) - rtsp_st->transport_priv = rtp_parse_open(s, st, rtsp_st->rtp_handle, + rtsp_st->transport_priv = ff_rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) ? 0 : RTP_REORDER_QUEUE_DEFAULT_SIZE); @@ -567,9 +567,9 @@ static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) return AVERROR(ENOMEM); } else if (rt->transport != RTSP_TRANSPORT_RDT && CONFIG_RTPDEC) { if (rtsp_st->dynamic_handler) { - rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv, - rtsp_st->dynamic_protocol_context, - rtsp_st->dynamic_handler); + ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv, + rtsp_st->dynamic_protocol_context, + rtsp_st->dynamic_handler); } } @@ -808,6 +808,9 @@ void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf, if (strstr(p, "GET_PARAMETER") && method && !strcmp(method, "OPTIONS")) rt->get_parameter_supported = 1; + } else if (av_stristart(p, "x-Accept-Dynamic-Rate:", &p) && rt) { + p += strspn(p, SPACE_CHARS); + rt->accept_dynamic_rate = atoi(p); } } @@ -1121,7 +1124,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, goto fail; rtp_opened: - port = rtp_get_local_rtp_port(rtsp_st->rtp_handle); + port = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle); have_port: snprintf(transport, sizeof(transport) - 1, "%s/UDP;", trans_pref); @@ -1165,6 +1168,8 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, snprintf(cmd, sizeof(cmd), "Transport: %s\r\n", transport); + if (rt->accept_dynamic_rate) + av_strlcat(cmd, "x-Dynamic-Rate: 0\r\n", sizeof(cmd)); if (i == 0 && rt->server_type == RTSP_SERVER_REAL && CONFIG_RTPDEC) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, @@ -1225,7 +1230,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, reply->transports[0].server_port_min, "%s", options); } if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && - rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { + ff_rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1235,7 +1240,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, */ if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && s->iformat && CONFIG_RTPDEC) - rtp_send_punch_packets(rtsp_st->rtp_handle); + ff_rtp_send_punch_packets(rtsp_st->rtp_handle); break; } case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { @@ -1569,7 +1574,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, if (rtsp_st->rtp_handle) { p[max_p].fd = ffurl_get_file_handle(rtsp_st->rtp_handle); p[max_p++].events = POLLIN; - p[max_p].fd = rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); + p[max_p].fd = ff_rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); p[max_p++].events = POLLIN; } } @@ -1624,7 +1629,7 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) if (rt->transport == RTSP_TRANSPORT_RDT) { ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); } else - ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); + ret = ff_rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); if (ret == 0) { rt->cur_transport_priv = NULL; return 0; @@ -1672,13 +1677,13 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: len = udp_read_packet(s, &rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end); if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) - rtp_check_and_send_back_rr(rtsp_st->transport_priv, len); + ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, len); break; } if (len == AVERROR(EAGAIN) && first_queue_st && rt->transport == RTSP_TRANSPORT_RTP) { rtsp_st = first_queue_st; - ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, NULL, 0); + ret = ff_rtp_parse_packet(rtsp_st->transport_priv, pkt, NULL, 0); goto end; } if (len < 0) @@ -1688,7 +1693,7 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) if (rt->transport == RTSP_TRANSPORT_RDT) { ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); } else { - ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); + ret = ff_rtp_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); if (ret < 0) { /* Either bad packet, or a RTCP packet. Check if the * first_rtcp_ntp_time field was initialized. */ diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 3d0345d35c..7d0dac12e2 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -346,6 +346,9 @@ typedef struct RTSPState { * Option flags for the chained RTP muxer. */ int rtp_muxer_flags; + + /** Whether the server accepts the x-Dynamic-Rate header */ + int accept_dynamic_rate; } RTSPState; /** diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 2391055202..3235365842 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -389,7 +389,7 @@ static int rtsp_read_close(AVFormatContext *s) } static const AVOption options[] = { - { "initial_pause", "Don't start playing the stream immediately", offsetof(RTSPState, initial_pause), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { "initial_pause", "Don't start playing the stream immediately", offsetof(RTSPState, initial_pause), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index 84372f82da..8602c0fee1 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -86,10 +86,10 @@ typedef struct IEC61937Context { } IEC61937Context; static const AVOption options[] = { -{ "spdif_flags", "IEC 61937 encapsulation flags", offsetof(IEC61937Context, spdif_flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, -{ "be", "output in big-endian format (for use as s16be)", 0, FF_OPT_TYPE_CONST, {.dbl = SPDIF_FLAG_BIGENDIAN}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, -{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(IEC61937Context, dtshd_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM }, -{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(IEC61937Context, dtshd_fallback), FF_OPT_TYPE_INT, {.dbl = 60}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, +{ "spdif_flags", "IEC 61937 encapsulation flags", offsetof(IEC61937Context, spdif_flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, +{ "be", "output in big-endian format (for use as s16be)", 0, AV_OPT_TYPE_CONST, {.dbl = SPDIF_FLAG_BIGENDIAN}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, +{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(IEC61937Context, dtshd_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM }, +{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(IEC61937Context, dtshd_fallback), AV_OPT_TYPE_INT, {.dbl = 60}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; diff --git a/libavformat/tty.c b/libavformat/tty.c index 1e653e1e09..913ec457da 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -142,9 +142,9 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt) #define OFFSET(x) offsetof(TtyDemuxContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), AV_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; diff --git a/libavformat/wav.c b/libavformat/wav.c index d6b9b53b4f..bd8c847e85 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -201,7 +201,7 @@ static int wav_write_trailer(AVFormatContext *s) #define OFFSET(x) offsetof(WAVContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), FF_OPT_TYPE_INT, { 0 }, 0, 1, ENC }, + { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), AV_OPT_TYPE_INT, { 0 }, 0, 1, ENC }, { NULL }, }; |