History

Merge remote-tracking branch 'qatar/master'

* qatar/master: avconv: add presets rtsp: Expose the flag options via private AVOptions for sdp and rtp, too rtsp: Make the rtsp flags avoptions set via a define rtpenc: Set a default video codec avoptions: Fix av_opt_flag_is_set rtp: Fix ff_rtp_get_payload_type doc: Update the documentation on setting options for RTSP rtsp: Remove the separate filter_source variable rtsp: Accept options via private avoptions instead of URL options rtsp: Simplify AVOption definitions rtsp: Merge the AVOption lists lavfi: port libmpcodecs delogo filter lavfi: port boxblur filter from libmpcodecs lavfi: add negate filter lavfi: add LUT (LookUp Table) generic filters AVOptions: don't segfault on NULL parameter in av_set_options_string() avio: Check for invalid buffer length. mpegenc/mpegtsenc: add muxrate private options. lavf: deprecate AVFormatContext.file_size mov: add support for TV metadata atoms tves, tvsn and stik Conflicts: Changelog doc/filters.texi doc/protocols.texi libavfilter/Makefile libavfilter/allfilters.c libavfilter/avfilter.h libavfilter/formats.c libavfilter/internal.h libavfilter/vf_boxblur.c libavfilter/vf_delogo.c libavfilter/vf_lut.c libavformat/mpegtsenc.c libavformat/utils.c libavformat/version.h libavutil/opt.c

Michael Niedermayer committed 15 years ago

Commit fae714a2 parents 9be937d 3ec344627 files · +398 −71Browse files

Unified · Split

27 files
  1. avconv.c +76 −1
  2. doc/avconv.texi +17 −0
  3. doc/filters.texi +1 −1
  4. doc/protocols.texi +15 −8
  5. ffmpeg.c +76 −1
  6. libavfilter/avfilter.h +1 −1
  7. libavfilter/vf_boxblur.c +2 −2
  8. libavfilter/vf_delogo.c +4 −4
  9. libavfilter/vf_lut.c +9 −3
  10. libavformat/aiffdec.c +0 −3
  11. libavformat/avformat.h +9 −2
  12. libavformat/aviobuf.c +5 −2
  13. libavformat/cafdec.c +0 −2
  14. libavformat/mov.c +33 −0
  15. libavformat/mpegenc.c +32 −1
  16. libavformat/mpegtsenc.c +5 −1
  17. libavformat/options.c +2 −0
  18. libavformat/qcp.c +1 −2
  19. libavformat/rtp.c +2 −1
  20. libavformat/rtpenc.c +1 −1
  21. libavformat/rtsp.c +70 −5
  22. libavformat/rtsp.h +16 −5
  23. libavformat/rtspdec.c +1 −7
  24. libavformat/rtspenc.c +1 −8
  25. libavformat/utils.c +6 −8
  26. libavformat/version.h +10 −1
  27. libavutil/opt.c +3 −1
avconv.c+76−1
@@ -347,6 +347,8 @@ typedef struct OptionsContext { · 346 unmodified lines
347347 int nb_inter_matrices;
348348 SpecifierOpt *top_field_first;
349349 int nb_top_field_first;
350+ SpecifierOpt *presets;
351+ int nb_presets;
350352 #if CONFIG_AVFILTER
351353 SpecifierOpt *filters;
352354 int nb_filters;
@@ -3087,15 +3089,62 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, · 2734 unmodified lines
30873089 }
30883090 }
30893091
3092+static uint8_t *get_line(AVIOContext *s)
3093+{
3094+ AVIOContext *line;
3095+ uint8_t *buf;
3096+ char c;
3097+
3098+ if (avio_open_dyn_buf(&line) < 0) {
3099+ av_log(NULL, AV_LOG_FATAL, "Could not alloc buffer for reading preset.\n");
3100+ exit_program(1);
3101+ }
3102+
3103+ while ((c = avio_r8(s)) && c != '\n')
3104+ avio_w8(line, c);
3105+ avio_w8(line, 0);
3106+ avio_close_dyn_buf(line, &buf);
3107+
3108+ return buf;
3109+}
3110+
3111+static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
3112+{
3113+ int i, ret = 1;
3114+ char filename[1000];
3115+ const char *base[3] = { getenv("AVCONV_DATADIR"),
3116+ getenv("HOME"),
3117+ AVCONV_DATADIR,
3118+ };
3119+
3120+ for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) {
3121+ if (!base[i])
3122+ continue;
3123+ if (codec_name) {
3124+ snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
3125+ i != 1 ? "" : "/.avconv", codec_name, preset_name);
3126+ ret = avio_open(s, filename, AVIO_FLAG_READ);
3127+ }
3128+ if (ret) {
3129+ snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
3130+ i != 1 ? "" : "/.avconv", preset_name);
3131+ ret = avio_open(s, filename, AVIO_FLAG_READ);
3132+ }
3133+ }
3134+ return ret;
3135+}
3136+
30903137 static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
30913138 {
30923139 OutputStream *ost;
30933140 AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0);
3094− int idx = oc->nb_streams - 1;
3141+ int idx = oc->nb_streams - 1, ret = 0;
30953142 int64_t max_frames = INT64_MAX;
30963143 char *bsf = NULL, *next, *codec_tag = NULL;
30973144 AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
30983145 double qscale = -1;
3146+ char *buf = NULL, *arg = NULL, *preset = NULL;
3147+ AVIOContext *s = NULL;
30993148
31003149 if (!st) {
31013150 av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
@@ -3117,6 +3166,31 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 15 unmodified lines
31173166 avcodec_get_context_defaults3(st->codec, ost->enc);
31183167 st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
31193168
3169+ MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
3170+ if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
3171+ do {
3172+ buf = get_line(s);
3173+ if (!buf[0] || buf[0] == '#') {
3174+ av_free(buf);
3175+ continue;
3176+ }
3177+ if (!(arg = strchr(buf, '='))) {
3178+ av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
3179+ exit_program(1);
3180+ }
3181+ *arg++ = 0;
3182+ av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
3183+ av_free(buf);
3184+ } while (!s->eof_reached);
3185+ avio_close(s);
3186+ }
3187+ if (ret) {
3188+ av_log(NULL, AV_LOG_FATAL,
3189+ "Preset %s specified for stream %d:%d, but could not be opened.\n",
3190+ preset, ost->file_index, ost->index);
3191+ exit_program(1);
3192+ }
3193+
31203194 MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
31213195 ost->max_frames = max_frames;
31223196
@@ -4027,6 +4101,7 @@ static const OptionDef options[] = { · 904 unmodified lines
40274101 { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
40284102 { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
40294103 { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
4104+ { "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" },
40304105 { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" },
40314106 { "map_metadata", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_metadata}, "set metadata information of outfile from infile",
40324107 "outfile[,metadata]:infile[,metadata]" },
doc/avconv.texi+17−0
@@ -186,6 +186,8 @@ codec-dependent. · 185 unmodified lines
186186 @var{filter_graph} is a description of the filter graph to apply to
187187 the stream. Use @code{-filters} to show all the available filters
188188 (including also sources and sinks).
189+@item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
190+Specify the preset for matching stream(s).
189191
190192 @item -stats (@emph{global})
191193 Print encoding progress/statistics. On by default.
@@ -770,6 +772,21 @@ quality). · 578 unmodified lines
770772 @chapter Examples
771773 @c man begin EXAMPLES
772774
775+@section Preset files
776+
777+A preset file contains a sequence of @var{option=value} pairs, one for
778+each line, specifying a sequence of options which can be specified also on
779+the command line. Lines starting with the hash ('#') character are ignored and
780+are used to provide comments. Empty lines are also ignored. Check the
781+@file{ffpresets} directory in the Libav source tree for examples.
782+
783+Preset files are specified with the @code{pre} option, this option takes a
784+preset name as input. Avconv searches for a file named @var{preset_name}.avpreset in
785+the directories @file{$AVCONV_DATADIR} (if set), and @file{$HOME/.avconv}, and in
786+the data directory defined at configuration time (usually @file{$PREFIX/share/avconv})
787+in that order. For example, if the argument is @code{libx264-max}, it will
788+search for the file @file{libx264-max.avpreset}.
789+
773790 @section Video and Audio grabbing
774791
775792 If you specify the input format and device then avconv can grab video
doc/filters.texi+1−1
@@ -432,7 +432,7 @@ horizontal and vertical chroma subsample values. For example for the · 431 unmodified lines
432432 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
433433 @end table
434434
435−The radius must be a non-negative number, and must be not greater than
435+The radius must be a non-negative number, and must not be greater than
436436 the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
437437 and of @code{min(cw,ch)/2} for the chroma planes.
438438
doc/protocols.texi+15−8
@@ -246,12 +246,15 @@ supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's · 245 unmodified lines
246246
247247 The required syntax for a RTSP url is:
248248 @example
249−rtsp://@var{hostname}[:@var{port}]/@var{path}[?@var{options}]
249+rtsp://@var{hostname}[:@var{port}]/@var{path}
250250 @end example
251251
252−@var{options} is a @code{&}-separated list. The following options
252+The following options (set on the @file{ffmpeg}/@file{ffplay} command
253+line, or set in code via @code{AVOption}s or in @code{avformat_open_input}),
253254 are supported:
254255
256+Flags for @code{rtsp_transport}:
257+
255258 @table @option
256259
257260 @item udp
@@ -261,21 +264,25 @@ Use UDP as lower transport protocol. · 3 unmodified lines
261264 Use TCP (interleaving within the RTSP control channel) as lower
262265 transport protocol.
263266
264−@item multicast
267+@item udp_multicast
265268 Use UDP multicast as lower transport protocol.
266269
267270 @item http
268271 Use HTTP tunneling as lower transport protocol, which is useful for
269272 passing proxies.
270−
271−@item filter_src
272−Accept packets only from negotiated peer address and port.
273273 @end table
274274
275275 Multiple lower transport protocols may be specified, in that case they are
276276 tried one at a time (if the setup of one fails, the next one is tried).
277277 For the muxer, only the @code{tcp} and @code{udp} options are supported.
278278
279+Flags for @code{rtsp_flags}:
280+
281+@table @option
282+@item filter_src
283+Accept packets only from negotiated peer address and port.
284+@end table
285+
279286 When receiving data over UDP, the demuxer tries to reorder received packets
280287 (since they may arrive out of order, or packets may get lost totally). In
281288 order for this to be enabled, a maximum delay must be specified in the
@@ -291,13 +298,13 @@ Example command lines: · 9 unmodified lines
291298 To watch a stream over UDP, with a max reordering delay of 0.5 seconds:
292299
293300 @example
294−ffplay -max_delay 500000 rtsp://server/video.mp4?udp
301+ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
295302 @end example
296303
297304 To watch a stream tunneled over HTTP:
298305
299306 @example
300−ffplay rtsp://server/video.mp4?http
307+ffplay -rtsp_transport http rtsp://server/video.mp4
301308 @end example
302309
303310 To send a stream in realtime to a RTSP server, for others to watch:
ffmpeg.c+76−1
@@ -355,6 +355,8 @@ typedef struct OptionsContext { · 354 unmodified lines
355355 int nb_inter_matrices;
356356 SpecifierOpt *top_field_first;
357357 int nb_top_field_first;
358+ SpecifierOpt *presets;
359+ int nb_presets;
358360 #if CONFIG_AVFILTER
359361 SpecifierOpt *filters;
360362 int nb_filters;
@@ -3202,15 +3204,62 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost) · 2841 unmodified lines
32023204 }
32033205 }
32043206
3207+static uint8_t *get_line(AVIOContext *s)
3208+{
3209+ AVIOContext *line;
3210+ uint8_t *buf;
3211+ char c;
3212+
3213+ if (avio_open_dyn_buf(&line) < 0) {
3214+ av_log(NULL, AV_LOG_FATAL, "Could not alloc buffer for reading preset.\n");
3215+ exit_program(1);
3216+ }
3217+
3218+ while ((c = avio_r8(s)) && c != '\n')
3219+ avio_w8(line, c);
3220+ avio_w8(line, 0);
3221+ avio_close_dyn_buf(line, &buf);
3222+
3223+ return buf;
3224+}
3225+
3226+static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
3227+{
3228+ int i, ret = 1;
3229+ char filename[1000];
3230+ const char *base[3] = { getenv("AVCONV_DATADIR"),
3231+ getenv("HOME"),
3232+ AVCONV_DATADIR,
3233+ };
3234+
3235+ for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) {
3236+ if (!base[i])
3237+ continue;
3238+ if (codec_name) {
3239+ snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
3240+ i != 1 ? "" : "/.avconv", codec_name, preset_name);
3241+ ret = avio_open(s, filename, AVIO_FLAG_READ);
3242+ }
3243+ if (ret) {
3244+ snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
3245+ i != 1 ? "" : "/.avconv", preset_name);
3246+ ret = avio_open(s, filename, AVIO_FLAG_READ);
3247+ }
3248+ }
3249+ return ret;
3250+}
3251+
32053252 static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
32063253 {
32073254 OutputStream *ost;
32083255 AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0);
3209− int idx = oc->nb_streams - 1;
3256+ int idx = oc->nb_streams - 1, ret = 0;
32103257 int64_t max_frames = INT64_MAX;
32113258 char *bsf = NULL, *next, *codec_tag = NULL;
32123259 AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
32133260 double qscale = -1;
3261+ char *buf = NULL, *arg = NULL, *preset = NULL;
3262+ AVIOContext *s = NULL;
32143263
32153264 if (!st) {
32163265 av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
@@ -3232,6 +3281,31 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 15 unmodified lines
32323281 avcodec_get_context_defaults3(st->codec, ost->enc);
32333282 st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
32343283
3284+ MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
3285+ if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
3286+ do {
3287+ buf = get_line(s);
3288+ if (!buf[0] || buf[0] == '#') {
3289+ av_free(buf);
3290+ continue;
3291+ }
3292+ if (!(arg = strchr(buf, '='))) {
3293+ av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
3294+ exit_program(1);
3295+ }
3296+ *arg++ = 0;
3297+ av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
3298+ av_free(buf);
3299+ } while (!s->eof_reached);
3300+ avio_close(s);
3301+ }
3302+ if (ret) {
3303+ av_log(NULL, AV_LOG_FATAL,
3304+ "Preset %s specified for stream %d:%d, but could not be opened.\n",
3305+ preset, ost->file_index, ost->index);
3306+ exit_program(1);
3307+ }
3308+
32353309 MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
32363310 ost->max_frames = max_frames;
32373311
@@ -4209,6 +4283,7 @@ static const OptionDef options[] = { · 971 unmodified lines
42094283 { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
42104284 { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
42114285 { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
4286+ { "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" },
42124287 { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" },
42134288 { "map_meta_data", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile",
42144289 "outfile[,metadata]:infile[,metadata]" },
libavfilter/avfilter.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030
3131 #define LIBAVFILTER_VERSION_MAJOR 2
3232 #define LIBAVFILTER_VERSION_MINOR 43
33−#define LIBAVFILTER_VERSION_MICRO 6
33+#define LIBAVFILTER_VERSION_MICRO 7
3434
3535 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
3636 LIBAVFILTER_VERSION_MINOR, \
libavfilter/vf_boxblur.c+2−2
@@ -81,7 +81,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 80 unmodified lines
8181
8282 if (!args) {
8383 av_log(ctx, AV_LOG_ERROR,
84− "Filter expects 2 or 4 arguments, none provided\n");
84+ "Filter expects 2 or 4 or 6 arguments, none provided\n");
8585 return AVERROR(EINVAL);
8686 }
8787
@@ -342,4 +342,4 @@ AVFilter avfilter_vf_boxblur = { · 254 unmodified lines
342342 .outputs = (AVFilterPad[]) {{ .name = "default",
343343 .type = AVMEDIA_TYPE_VIDEO, },
344344 { .name = NULL}},
345−};
345+};
libavfilter/vf_delogo.c+4−4
@@ -154,9 +154,9 @@ static const char *delogo_get_name(void *ctx) · 153 unmodified lines
154154 }
155155
156156 static const AVClass delogo_class = {
157− "DelogoContext",
158− delogo_get_name,
159− delogo_options
157+ .class_name = "DelogoContext",
158+ .item_name = delogo_get_name,
159+ .option = delogo_options,
160160 };
161161
162162 static int query_formats(AVFilterContext *ctx)
@@ -285,4 +285,4 @@ AVFilter avfilter_vf_delogo = { · 122 unmodified lines
285285 .outputs = (AVFilterPad[]) {{ .name = "default",
286286 .type = AVMEDIA_TYPE_VIDEO, },
287287 { .name = NULL}},
288−};
288+};
libavfilter/vf_lut.c+9−3
@@ -350,21 +350,27 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 349 unmodified lines
350350 { .name = NULL}}, \
351351 }
352352
353+#if CONFIG_LUT_FILTER
353354 DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init);
355+#endif
356+#if CONFIG_LUTYUV_FILTER
354357 DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init);
358+#endif
359+#if CONFIG_LUTRGB_FILTER
355360 DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init);
361+#endif
356362
357363 #if CONFIG_NEGATE_FILTER
358364
359365 static int negate_init(AVFilterContext *ctx, const char *args, void *opaque)
360366 {
361367 LutContext *lut = ctx->priv;
362− char lut_params[1024];
368+ char lut_params[64];
363369
364370 if (args)
365371 sscanf(args, "%d", &lut->negate_alpha);
366372
367− av_log(ctx, AV_LOG_INFO, "negate_alpha:%d\n", lut->negate_alpha);
373+ av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha);
368374
369375 snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s",
370376 lut->negate_alpha ? "negval" : "val");
@@ -374,4 +380,4 @@ static int negate_init(AVFilterContext *ctx, const char *args, void *opaque) · 3 unmodified lines
374380
375381 DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init);
376382
377−#endif
383+#endif
libavformat/aiffdec.c+0−3
@@ -275,9 +275,6 @@ static int aiff_read_header(AVFormatContext *s, · 274 unmodified lines
275275
276276 got_sound:
277277 /* Now positioned, get the sound data start and end */
278− if (st->nb_frames)
279− s->file_size = st->nb_frames * st->codec->block_align;
280−
281278 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
282279 st->start_time = 0;
283280 st->duration = st->codec->frame_size ?
libavformat/avformat.h+9−2
@@ -745,10 +745,12 @@ typedef struct AVFormatContext { · 744 unmodified lines
745745 */
746746 int64_t duration;
747747
748+#if FF_API_FILESIZE
748749 /**
749750 * decoding: total file size, 0 if unknown
750751 */
751− int64_t file_size;
752+ attribute_deprecated int64_t file_size;
753+#endif
752754
753755 /**
754756 * Decoding: total stream bitrate in bit/s, 0 if not
@@ -763,7 +765,12 @@ typedef struct AVFormatContext { · 8 unmodified lines
763765 /* av_seek_frame() support */
764766 int64_t data_offset; /**< offset of the first packet */
765767
766− int mux_rate;
768+#if FF_API_MUXRATE
769+ /**
770+ * use mpeg muxer private options instead
771+ */
772+ attribute_deprecated int mux_rate;
773+#endif
767774 unsigned int packet_size;
768775 int preload;
769776 int max_delay;
libavformat/aviobuf.c+5−2
@@ -778,13 +778,14 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) · 777 unmodified lines
778778 {
779779 int i;
780780
781+ if (buflen <= 0)
782+ return AVERROR(EINVAL);
781783 // reserve 1 byte for terminating 0
782784 buflen = FFMIN(buflen - 1, maxlen);
783785 for (i = 0; i < buflen; i++)
784786 if (!(buf[i] = avio_r8(s)))
785787 return i + 1;
786− if (buflen)
787− buf[i] = 0;
788+ buf[i] = 0;
788789 for (; i < maxlen; i++)
789790 if (!avio_r8(s))
790791 return i + 1;
@@ -796,6 +797,8 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) · 5 unmodified lines
796797 {\
797798 char* q = buf;\
798799 int ret = 0;\
800+ if (buflen <= 0) \
801+ return AVERROR(EINVAL); \
799802 while (ret + 1 < maxlen) {\
800803 uint8_t tmp;\
801804 uint32_t ch;\
libavformat/cafdec.c+0−2
@@ -292,8 +292,6 @@ static int read_header(AVFormatContext *s, · 291 unmodified lines
292292 "block size or frame size are variable.\n");
293293 return AVERROR_INVALIDDATA;
294294 }
295− s->file_size = avio_size(pb);
296− s->file_size = FFMAX(0, s->file_size);
297295
298296 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
299297 st->start_time = 0;
libavformat/mov.c+33−0
@@ -99,6 +99,33 @@ static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, · 98 unmodified lines
9999 return 0;
100100 }
101101
102+static int mov_metadata_int8(MOVContext *c, AVIOContext *pb,
103+ unsigned len, const char *key)
104+{
105+ char buf[16];
106+
107+ /* bypass padding bytes */
108+ avio_r8(pb);
109+ avio_r8(pb);
110+ avio_r8(pb);
111+
112+ snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
113+ av_dict_set(&c->fc->metadata, key, buf, 0);
114+
115+ return 0;
116+}
117+
118+static int mov_metadata_stik(MOVContext *c, AVIOContext *pb,
119+ unsigned len, const char *key)
120+{
121+ char buf[16];
122+
123+ snprintf(buf, sizeof(buf), "%hu", avio_r8(pb));
124+ av_dict_set(&c->fc->metadata, key, buf, 0);
125+
126+ return 0;
127+}
128+
102129 static const uint32_t mac_to_unicode[128] = {
103130 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
104131 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
@@ -174,6 +201,12 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 69 unmodified lines
174201 parse = mov_metadata_track_or_disc_number; break;
175202 case MKTAG( 'd','i','s','k'): key = "disc";
176203 parse = mov_metadata_track_or_disc_number; break;
204+ case MKTAG( 't','v','e','s'): key = "episode_sort";
205+ parse = mov_metadata_int8; break;
206+ case MKTAG( 't','v','s','n'): key = "season_number";
207+ parse = mov_metadata_int8; break;
208+ case MKTAG( 's','t','i','k'): key = "media_type";
209+ parse = mov_metadata_stik; break;
177210 }
178211
179212 if (c->itunes_metadata && atom.size > 8) {
libavformat/mpegenc.c+32−1
@@ -20,7 +20,9 @@ · 19 unmodified lines
2020 */
2121
2222 #include "libavutil/fifo.h"
23+#include "libavutil/log.h"
2324 #include "libavutil/mathematics.h"
25+#include "libavutil/opt.h"
2426 #include "libavcodec/put_bits.h"
2527 #include "avformat.h"
2628 #include "mpeg.h"
@@ -56,6 +58,7 @@ typedef struct { · 29 unmodified lines
5658 } StreamInfo;
5759
5860 typedef struct {
61+ const AVClass *class;
5962 int packet_size; /* required packet size */
6063 int packet_number;
6164 int pack_header_freq; /* frequency (in packets^-1) at which we send pack headers */
@@ -416,9 +419,12 @@ static int mpeg_mux_init(AVFormatContext *ctx) · 354 unmodified lines
416419 video_bitrate += codec_rate;
417420 }
418421
422+#if FF_API_MUXRATE
419423 if(ctx->mux_rate){
420424 s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50);
421− } else {
425+ } else
426+#endif
427+ if (!s->mux_rate) {
422428 /* we increase slightly the bitrate to take into account the
423429 headers. XXX: compute it exactly */
424430 bitrate += bitrate*5/100;
@@ -1227,7 +1233,23 @@ static int mpeg_mux_end(AVFormatContext *ctx) · 802 unmodified lines
12271233 return 0;
12281234 }
12291235
1236+#define OFFSET(x) offsetof(MpegMuxContext, x)
1237+#define E AV_OPT_FLAG_ENCODING_PARAM
1238+static const AVOption options[] = {
1239+ { "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, {0}, 0, INT_MAX, E },
1240+ { NULL },
1241+};
1242+
1243+#define MPEGENC_CLASS(flavor)\
1244+static const AVClass flavor ## _class = {\
1245+ .class_name = #flavor " muxer",\
1246+ .item_name = av_default_item_name,\
1247+ .version = LIBAVUTIL_VERSION_INT,\
1248+ .option = options,\
1249+};
1250+
12301251 #if CONFIG_MPEG1SYSTEM_MUXER
1252+MPEGENC_CLASS(mpeg)
12311253 AVOutputFormat ff_mpeg1system_muxer = {
12321254 .name = "mpeg",
12331255 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format"),
@@ -1239,9 +1261,11 @@ AVOutputFormat ff_mpeg1system_muxer = { · 5 unmodified lines
12391261 .write_header = mpeg_mux_init,
12401262 .write_packet = mpeg_mux_write_packet,
12411263 .write_trailer = mpeg_mux_end,
1264+ .priv_class = &mpeg_class,
12421265 };
12431266 #endif
12441267 #if CONFIG_MPEG1VCD_MUXER
1268+MPEGENC_CLASS(vcd)
12451269 AVOutputFormat ff_mpeg1vcd_muxer = {
12461270 .name = "vcd",
12471271 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"),
@@ -1252,9 +1276,11 @@ AVOutputFormat ff_mpeg1vcd_muxer = { · 4 unmodified lines
12521276 .write_header = mpeg_mux_init,
12531277 .write_packet = mpeg_mux_write_packet,
12541278 .write_trailer = mpeg_mux_end,
1279+ .priv_class = &vcd_class,
12551280 };
12561281 #endif
12571282 #if CONFIG_MPEG2VOB_MUXER
1283+MPEGENC_CLASS(vob)
12581284 AVOutputFormat ff_mpeg2vob_muxer = {
12591285 .name = "vob",
12601286 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
@@ -1266,11 +1292,13 @@ AVOutputFormat ff_mpeg2vob_muxer = { · 5 unmodified lines
12661292 .write_header = mpeg_mux_init,
12671293 .write_packet = mpeg_mux_write_packet,
12681294 .write_trailer = mpeg_mux_end,
1295+ .priv_class = &vob_class,
12691296 };
12701297 #endif
12711298
12721299 /* Same as mpeg2vob_mux except that the pack size is 2324 */
12731300 #if CONFIG_MPEG2SVCD_MUXER
1301+MPEGENC_CLASS(svcd)
12741302 AVOutputFormat ff_mpeg2svcd_muxer = {
12751303 .name = "svcd",
12761304 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
@@ -1282,11 +1310,13 @@ AVOutputFormat ff_mpeg2svcd_muxer = { · 5 unmodified lines
12821310 .write_header = mpeg_mux_init,
12831311 .write_packet = mpeg_mux_write_packet,
12841312 .write_trailer = mpeg_mux_end,
1313+ .priv_class = &svcd_class,
12851314 };
12861315 #endif
12871316
12881317 /* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */
12891318 #if CONFIG_MPEG2DVD_MUXER
1319+MPEGENC_CLASS(dvd)
12901320 AVOutputFormat ff_mpeg2dvd_muxer = {
12911321 .name = "dvd",
12921322 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"),
@@ -1298,5 +1328,6 @@ AVOutputFormat ff_mpeg2dvd_muxer = { · 5 unmodified lines
12981328 .write_header = mpeg_mux_init,
12991329 .write_packet = mpeg_mux_write_packet,
13001330 .write_trailer = mpeg_mux_end,
1331+ .priv_class = &dvd_class,
13011332 };
13021333 #endif
libavformat/mpegtsenc.c+5−1
@@ -92,6 +92,7 @@ static const AVOption options[] = { · 91 unmodified lines
9292 {"mpegts_m2ts_mode", "Enable m2ts mode.",
9393 offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 },
9494 -1,1, AV_OPT_FLAG_ENCODING_PARAM},
95+ { "muxrate", NULL, offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT, {1}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
9596 { NULL },
9697 };
9798
@@ -562,7 +563,10 @@ static int mpegts_write_header(AVFormatContext *s) · 464 unmodified lines
562563 service->pcr_pid = ts_st->pid;
563564 }
564565
565− ts->mux_rate = s->mux_rate ? s->mux_rate : 1;
566+#if FF_API_MUXRATE
567+ if (s->mux_rate)
568+ ts->mux_rate = s->mux_rate;
569+#endif
566570
567571 if (ts->mux_rate > 1) {
568572 service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) /
libavformat/options.c+2−0
@@ -74,7 +74,9 @@ static const AVClass *format_child_class_next(const AVClass *prev) · 73 unmodified lines
7474
7575 static const AVOption options[]={
7676 {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D},
77+#if FF_API_MUXRATE
7778 {"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
79+#endif
7880 {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
7981 {"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"},
8082 {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"},
libavformat/qcp.c+1−2
@@ -92,8 +92,7 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap) · 91 unmodified lines
9292 return AVERROR(ENOMEM);
9393
9494 avio_rb32(pb); // "RIFF"
95− s->file_size = avio_rl32(pb) + 8;
96− avio_skip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version
95+ avio_skip(pb, 4 + 8 + 4 + 1 + 1); // filesize + "QLCMfmt " + chunk-size + major-version + minor-version
9796
9897 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
9998 st->codec->channels = 1;
libavformat/rtp.c+2−1
@@ -98,7 +98,8 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec) · 97 unmodified lines
9898 /* Was the payload type already specified for the RTP muxer? */
9999 if (ofmt && ofmt->priv_class) {
100100 int64_t payload_type;
101− if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0)
101+ if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 &&
102+ payload_type >= 0)
102103 return (int)payload_type;
103104 }
104105
libavformat/rtpenc.c+1−1
@@ -465,7 +465,7 @@ AVOutputFormat ff_rtp_muxer = { · 464 unmodified lines
465465 .long_name = NULL_IF_CONFIG_SMALL("RTP output format"),
466466 .priv_data_size = sizeof(RTPMuxContext),
467467 .audio_codec = CODEC_ID_PCM_MULAW,
468− .video_codec = CODEC_ID_NONE,
468+ .video_codec = CODEC_ID_MPEG4,
469469 .write_header = rtp_write_header,
470470 .write_packet = rtp_write_packet,
471471 .write_trailer = rtp_write_trailer,
libavformat/rtsp.c+70−5
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 #include "rtpdec_formats.h"
4646 #include "rtpenc_chain.h"
4747 #include "url.h"
48+#include "rtpenc.h"
4849
4950 //#define DEBUG
5051
@@ -56,6 +57,36 @@ · 5 unmodified lines
5657 #define SDP_MAX_SIZE 16384
5758 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
5859
60+#define OFFSET(x) offsetof(RTSPState, x)
61+#define DEC AV_OPT_FLAG_DECODING_PARAM
62+#define ENC AV_OPT_FLAG_ENCODING_PARAM
63+
64+#define RTSP_FLAG_OPTS(name, longname) \
65+ { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
66+ { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }
67+
68+const AVOption ff_rtsp_options[] = {
69+ { "initial_pause", "Don't start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_INT, {0}, 0, 1, DEC },
70+ FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags),
71+ { "rtsp_transport", "RTSP transport protocols", OFFSET(lower_transport_mask), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC|ENC, "rtsp_transport" }, \
72+ { "udp", "UDP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP}, 0, 0, DEC|ENC, "rtsp_transport" }, \
73+ { "tcp", "TCP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_TCP}, 0, 0, DEC|ENC, "rtsp_transport" }, \
74+ { "udp_multicast", "UDP multicast", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP_MULTICAST}, 0, 0, DEC, "rtsp_transport" },
75+ { "http", "HTTP tunneling", 0, AV_OPT_TYPE_CONST, {(1 << RTSP_LOWER_TRANSPORT_HTTP)}, 0, 0, DEC, "rtsp_transport" },
76+ RTSP_FLAG_OPTS("rtsp_flags", "RTSP flags"),
77+ { NULL },
78+};
79+
80+static const AVOption sdp_options[] = {
81+ RTSP_FLAG_OPTS("sdp_flags", "SDP flags"),
82+ { NULL },
83+};
84+
85+static const AVOption rtp_options[] = {
86+ RTSP_FLAG_OPTS("rtp_flags", "RTP flags"),
87+ { NULL },
88+};
89+
5990 static void get_word_until_chars(char *buf, int buf_size,
6091 const char *sep, const char **pp)
6192 {
@@ -1218,7 +1249,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, · 1156 unmodified lines
12181249 case RTSP_LOWER_TRANSPORT_UDP: {
12191250 char url[1024], options[30] = "";
12201251
1221− if (rt->filter_source)
1252+ if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
12221253 av_strlcpy(options, "?connect=1", sizeof(options));
12231254 /* Use source address if specified */
12241255 if (reply->transports[0].source[0]) {
@@ -1308,8 +1339,17 @@ int ff_rtsp_connect(AVFormatContext *s) · 83 unmodified lines
13081339
13091340 if (!ff_network_init())
13101341 return AVERROR(EIO);
1311−redirect:
1342+
13121343 rt->control_transport = RTSP_MODE_PLAIN;
1344+ if (rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_HTTP)) {
1345+ rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP;
1346+ rt->control_transport = RTSP_MODE_TUNNEL;
1347+ }
1348+ /* Only pass through valid flags from here */
1349+ rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
1350+
1351+redirect:
1352+ lower_transport_mask = rt->lower_transport_mask;
13131353 /* extract hostname and port */
13141354 av_url_split(NULL, 0, auth, sizeof(auth),
13151355 host, sizeof(host), &port, path, sizeof(path), s->filename);
@@ -1319,6 +1359,7 @@ redirect: · 3 unmodified lines
13191359 if (port < 0)
13201360 port = RTSP_DEFAULT_PORT;
13211361
1362+#if FF_API_RTSP_URL_OPTIONS
13221363 /* search for options */
13231364 option_list = strrchr(path, '?');
13241365 if (option_list) {
@@ -1326,6 +1367,7 @@ redirect: · 1 unmodified line
13261367 * the options back into the same string. */
13271368 filename = option_list;
13281369 while (option_list) {
1370+ int handled = 1;
13291371 /* move the option pointer */
13301372 option = ++option_list;
13311373 option_list = strchr(option_list, '&');
@@ -1343,7 +1385,7 @@ redirect: · 11 unmodified lines
13431385 lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
13441386 rt->control_transport = RTSP_MODE_TUNNEL;
13451387 } else if (!strcmp(option, "filter_src")) {
1346− rt->filter_source = 1;
1388+ rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC;
13471389 } else {
13481390 /* Write options back into the buffer, using memmove instead
13491391 * of strcpy since the strings may overlap. */
@@ -1351,10 +1393,16 @@ redirect: · 1 unmodified line
13511393 memmove(++filename, option, len);
13521394 filename += len;
13531395 if (option_list) *filename = '&';
1396+ handled = 0;
13541397 }
1398+ if (handled)
1399+ av_log(s, AV_LOG_WARNING, "Options passed via URL are "
1400+ "deprecated, use -rtsp_transport "
1401+ "and -rtsp_flags instead.\n");
13551402 }
13561403 *filename = 0;
13571404 }
1405+#endif
13581406
13591407 if (!lower_transport_mask)
13601408 lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
@@ -1797,8 +1845,9 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap) · 436 unmodified lines
17971845 namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
17981846 ff_url_join(url, sizeof(url), "rtp", NULL,
17991847 namebuf, rtsp_st->sdp_port,
1800− "?localport=%d&ttl=%d", rtsp_st->sdp_port,
1801− rtsp_st->sdp_ttl);
1848+ "?localport=%d&ttl=%d&connect=%d", rtsp_st->sdp_port,
1849+ rtsp_st->sdp_ttl,
1850+ rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0);
18021851 if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) {
18031852 err = AVERROR_INVALIDDATA;
18041853 goto fail;
@@ -1820,6 +1869,13 @@ static int sdp_read_close(AVFormatContext *s) · 15 unmodified lines
18201869 return 0;
18211870 }
18221871
1872+static const AVClass sdp_demuxer_class = {
1873+ .class_name = "SDP demuxer",
1874+ .item_name = av_default_item_name,
1875+ .option = sdp_options,
1876+ .version = LIBAVUTIL_VERSION_INT,
1877+};
1878+
18231879 AVInputFormat ff_sdp_demuxer = {
18241880 .name = "sdp",
18251881 .long_name = NULL_IF_CONFIG_SMALL("SDP"),
@@ -1828,6 +1884,7 @@ AVInputFormat ff_sdp_demuxer = { · 2 unmodified lines
18281884 .read_header = sdp_read_header,
18291885 .read_packet = ff_rtsp_fetch_packet,
18301886 .read_close = sdp_read_close,
1887+ .priv_class = &sdp_demuxer_class
18311888 };
18321889 #endif /* CONFIG_SDP_DEMUXER */
18331890
@@ -1924,6 +1981,13 @@ fail: · 90 unmodified lines
19241981 return ret;
19251982 }
19261983
1984+static const AVClass rtp_demuxer_class = {
1985+ .class_name = "RTP demuxer",
1986+ .item_name = av_default_item_name,
1987+ .option = rtp_options,
1988+ .version = LIBAVUTIL_VERSION_INT,
1989+};
1990+
19271991 AVInputFormat ff_rtp_demuxer = {
19281992 .name = "rtp",
19291993 .long_name = NULL_IF_CONFIG_SMALL("RTP input format"),
@@ -1933,6 +1997,7 @@ AVInputFormat ff_rtp_demuxer = { · 3 unmodified lines
19331997 .read_packet = ff_rtsp_fetch_packet,
19341998 .read_close = sdp_read_close,
19351999 .flags = AVFMT_NOFILE,
2000+ .priv_class = &rtp_demuxer_class
19362001 };
19372002 #endif /* CONFIG_RTP_DEMUXER */
19382003
libavformat/rtsp.h+16−5
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "httpauth.h"
3030
3131 #include "libavutil/log.h"
32+#include "libavutil/opt.h"
3233
3334 /**
3435 * Network layer over which RTP/etc packet data will be transported.
@@ -37,7 +38,10 @@ enum RTSPLowerTransport { · 2 unmodified lines
3738 RTSP_LOWER_TRANSPORT_UDP = 0, /**< UDP/unicast */
3839 RTSP_LOWER_TRANSPORT_TCP = 1, /**< TCP; interleaved in RTSP */
3940 RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2, /**< UDP/multicast */
40− RTSP_LOWER_TRANSPORT_NB
41+ RTSP_LOWER_TRANSPORT_NB,
42+ RTSP_LOWER_TRANSPORT_HTTP = 8, /**< HTTP tunneled - not a proper
43+ transport mode as such,
44+ only for use via AVOptions */
4145 };
4246
4347 /**
@@ -313,10 +317,6 @@ typedef struct RTSPState { · 269 unmodified lines
313317 /** Reusable buffer for receiving packets */
314318 uint8_t* recvbuf;
315319
316− /** Filter incoming UDP packets - receive packets only from the right
317− * source address and port. */
318− int filter_source;
319−
320320 /**
321321 * A mask with all requested transport methods
322322 */
@@ -349,8 +349,17 @@ typedef struct RTSPState { · 26 unmodified lines
349349
350350 /** Whether the server accepts the x-Dynamic-Rate header */
351351 int accept_dynamic_rate;
352+
353+ /**
354+ * Various option flags for the RTSP muxer/demuxer.
355+ */
356+ int rtsp_flags;
352357 } RTSPState;
353358
359+#define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -
360+ receive packets only from the right
361+ source address and port. */
362+
354363 /**
355364 * Describes a single stream, as identified by a single m= line block in the
356365 * SDP content. In the case of RDT, one RTSPStream can represent multiple
@@ -537,4 +546,6 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, · 180 unmodified lines
537546 */
538547 void ff_rtsp_undo_setup(AVFormatContext *s);
539548
549+extern const AVOption ff_rtsp_options[];
550+
540551 #endif /* AVFORMAT_RTSP_H */
libavformat/rtspdec.c+1−7
@@ -22,7 +22,6 @@ · 21 unmodified lines
2222 #include "libavutil/avstring.h"
2323 #include "libavutil/intreadwrite.h"
2424 #include "libavutil/mathematics.h"
25−#include "libavutil/opt.h"
2625 #include "avformat.h"
2726
2827 #include "internal.h"
@@ -388,15 +387,10 @@ static int rtsp_read_close(AVFormatContext *s) · 359 unmodified lines
388387 return 0;
389388 }
390389
391−static const AVOption options[] = {
392− { "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 },
393− { NULL },
394−};
395−
396390 const AVClass rtsp_demuxer_class = {
397391 .class_name = "RTSP demuxer",
398392 .item_name = av_default_item_name,
399− .option = options,
393+ .option = ff_rtsp_options,
400394 .version = LIBAVUTIL_VERSION_INT,
401395 };
402396
libavformat/rtspenc.c+1−8
@@ -33,20 +33,13 @@ · 32 unmodified lines
3333 #include "libavutil/intreadwrite.h"
3434 #include "libavutil/avstring.h"
3535 #include "url.h"
36−#include "libavutil/opt.h"
37−#include "rtpenc.h"
3836
3937 #define SDP_MAX_SIZE 16384
4038
41−static const AVOption options[] = {
42− FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags),
43− { NULL },
44−};
45−
4639 static const AVClass rtsp_muxer_class = {
4740 .class_name = "RTSP muxer",
4841 .item_name = av_default_item_name,
49− .option = options,
42+ .option = ff_rtsp_options,
5043 .version = LIBAVUTIL_VERSION_INT,
5144 };
5245
libavformat/utils.c+6−8
@@ -1902,7 +1902,7 @@ static int has_duration(AVFormatContext *ic) · 1901 unmodified lines
19021902 static void update_stream_timings(AVFormatContext *ic)
19031903 {
19041904 int64_t start_time, start_time1, start_time_text, end_time, end_time1;
1905− int64_t duration, duration1;
1905+ int64_t duration, duration1, filesize;
19061906 int i;
19071907 AVStream *st;
19081908
@@ -1945,9 +1945,9 @@ static void update_stream_timings(AVFormatContext *ic) · 36 unmodified lines
19451945 if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) {
19461946 ic->duration = duration;
19471947 }
1948− if (ic->file_size > 0 && ic->duration != AV_NOPTS_VALUE) {
1948+ if (ic->pb && (filesize = avio_size(ic->pb)) > 0 && ic->duration != AV_NOPTS_VALUE) {
19491949 /* compute the bitrate */
1950− ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE /
1950+ ic->bit_rate = (double)filesize * 8.0 * AV_TIME_BASE /
19511951 (double)ic->duration;
19521952 }
19531953 }
@@ -1988,9 +1988,8 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic) · 34 unmodified lines
19881988
19891989 /* if duration is already set, we believe it */
19901990 if (ic->duration == AV_NOPTS_VALUE &&
1991− ic->bit_rate != 0 &&
1992− ic->file_size != 0) {
1993− filesize = ic->file_size;
1991+ ic->bit_rate != 0) {
1992+ filesize = ic->pb ? avio_size(ic->pb) : 0;
19941993 if (filesize > 0) {
19951994 for(i = 0; i < ic->nb_streams; i++) {
19961995 st = ic->streams[i];
@@ -2034,7 +2033,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) · 37 unmodified lines
20342033
20352034 /* estimate the end time (duration) */
20362035 /* XXX: may need to support wrapping */
2037− filesize = ic->file_size;
2036+ filesize = ic->pb ? avio_size(ic->pb) : 0;
20382037 end_time = AV_NOPTS_VALUE;
20392038 do{
20402039 offset = filesize - (DURATION_MAX_READ_SIZE<<retry);
@@ -2098,7 +2097,6 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) · 57 unmodified lines
20982097 if (file_size < 0)
20992098 file_size = 0;
21002099 }
2101− ic->file_size = file_size;
21022100
21032101 if ((!strcmp(ic->iformat->name, "mpeg") ||
21042102 !strcmp(ic->iformat->name, "mpegts")) &&
libavformat/version.h+10−1
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525
2626 #define LIBAVFORMAT_VERSION_MAJOR 53
2727 #define LIBAVFORMAT_VERSION_MINOR 16
28−#define LIBAVFORMAT_VERSION_MICRO 0
28+#define LIBAVFORMAT_VERSION_MICRO 1
2929
3030 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3131 LIBAVFORMAT_VERSION_MINOR, \
@@ -89,5 +89,14 @@ · 57 unmodified lines
8989 #ifndef FF_API_TIMESTAMP
9090 #define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54)
9191 #endif
92+#ifndef FF_API_FILESIZE
93+#define FF_API_FILESIZE (LIBAVFORMAT_VERSION_MAJOR < 54)
94+#endif
95+#ifndef FF_API_MUXRATE
96+#define FF_API_MUXRATE (LIBAVFORMAT_VERSION_MAJOR < 54)
97+#endif
98+#ifndef FF_API_RTSP_URL_OPTIONS
99+#define FF_API_RTSP_URL_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 54)
100+#endif
92101
93102 #endif /* AVFORMAT_VERSION_H */
libavutil/opt.c+3−1
@@ -503,7 +503,8 @@ int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_ · 502 unmodified lines
503503 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
504504 {
505505 const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
506− const AVOption *flag = av_opt_find(obj, flag_name, NULL, 0, 0);
506+ const AVOption *flag = av_opt_find(obj, flag_name,
507+ field ? field->unit : NULL, 0, 0);
507508 int64_t res;
508509
509510 if (!field || !flag || flag->type != AV_OPT_TYPE_CONST ||
@@ -700,6 +701,7 @@ int av_set_options_string(void *ctx, const char *opts, · 190 unmodified lines
700701
701702 if (!opts)
702703 return 0;
704+
703705 while (*opts) {
704706 if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)
705707 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t