* 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
Unified · Split
| @@ -347,6 +347,8 @@ typedef struct OptionsContext { · 346 unmodified lines | |||
| 347 | int nb_inter_matrices; | 347 | int nb_inter_matrices; |
| 348 | SpecifierOpt *top_field_first; | 348 | SpecifierOpt *top_field_first; |
| 349 | int nb_top_field_first; | 349 | int nb_top_field_first; |
| 350 | SpecifierOpt *presets; | ||
| 351 | int nb_presets; | ||
| 350 | #if CONFIG_AVFILTER | 352 | #if CONFIG_AVFILTER |
| 351 | SpecifierOpt *filters; | 353 | SpecifierOpt *filters; |
| 352 | int nb_filters; | 354 | int nb_filters; |
| @@ -3087,15 +3089,62 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, · 2734 unmodified lines | |||
| 3087 | } | 3089 | } |
| 3088 | } | 3090 | } |
| 3089 | 3091 | ||
| 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 | |||
| 3090 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) | 3137 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) |
| 3091 | { | 3138 | { |
| 3092 | OutputStream *ost; | 3139 | OutputStream *ost; |
| 3093 | AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0); | 3140 | 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; |
| 3095 | int64_t max_frames = INT64_MAX; | 3142 | int64_t max_frames = INT64_MAX; |
| 3096 | char *bsf = NULL, *next, *codec_tag = NULL; | 3143 | char *bsf = NULL, *next, *codec_tag = NULL; |
| 3097 | AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; | 3144 | AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; |
| 3098 | double qscale = -1; | 3145 | double qscale = -1; |
| 3146 | char *buf = NULL, *arg = NULL, *preset = NULL; | ||
| 3147 | AVIOContext *s = NULL; | ||
| 3099 | 3148 | ||
| 3100 | if (!st) { | 3149 | if (!st) { |
| 3101 | av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); | 3150 | 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 | |||
| 3117 | avcodec_get_context_defaults3(st->codec, ost->enc); | 3166 | avcodec_get_context_defaults3(st->codec, ost->enc); |
| 3118 | st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy | 3167 | st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy |
| 3119 | 3168 | ||
| 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 | |||
| 3120 | MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); | 3194 | MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); |
| 3121 | ost->max_frames = max_frames; | 3195 | ost->max_frames = max_frames; |
| 3122 | 3196 | ||
| @@ -4027,6 +4101,7 @@ static const OptionDef options[] = { · 904 unmodified lines | |||
| 4027 | { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, | 4101 | { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, |
| 4028 | { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, | 4102 | { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, |
| 4029 | { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, | 4103 | { "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" }, | ||
| 4030 | { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, | 4105 | { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, |
| 4031 | { "map_metadata", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", | 4106 | { "map_metadata", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", |
| 4032 | "outfile[,metadata]:infile[,metadata]" }, | 4107 | "outfile[,metadata]:infile[,metadata]" }, |
| @@ -186,6 +186,8 @@ codec-dependent. · 185 unmodified lines | |||
| 186 | @var{filter_graph} is a description of the filter graph to apply to | 186 | @var{filter_graph} is a description of the filter graph to apply to |
| 187 | the stream. Use @code{-filters} to show all the available filters | 187 | the stream. Use @code{-filters} to show all the available filters |
| 188 | (including also sources and sinks). | 188 | (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). | ||
| 189 | 191 | ||
| 190 | @item -stats (@emph{global}) | 192 | @item -stats (@emph{global}) |
| 191 | Print encoding progress/statistics. On by default. | 193 | Print encoding progress/statistics. On by default. |
| @@ -770,6 +772,21 @@ quality). · 578 unmodified lines | |||
| 770 | @chapter Examples | 772 | @chapter Examples |
| 771 | @c man begin EXAMPLES | 773 | @c man begin EXAMPLES |
| 772 | 774 | ||
| 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 | |||
| 773 | @section Video and Audio grabbing | 790 | @section Video and Audio grabbing |
| 774 | 791 | ||
| 775 | If you specify the input format and device then avconv can grab video | 792 | If you specify the input format and device then avconv can grab video |
| @@ -432,7 +432,7 @@ horizontal and vertical chroma subsample values. For example for the · 431 unmodified lines | |||
| 432 | pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. | 432 | pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. |
| 433 | @end table | 433 | @end table |
| 434 | 434 | ||
| 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 |
| 436 | the value of the expression @code{min(w,h)/2} for the luma and alpha planes, | 436 | the value of the expression @code{min(w,h)/2} for the luma and alpha planes, |
| 437 | and of @code{min(cw,ch)/2} for the chroma planes. | 437 | and of @code{min(cw,ch)/2} for the chroma planes. |
| 438 | 438 | ||
| @@ -246,12 +246,15 @@ supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's · 245 unmodified lines | |||
| 246 | 246 | ||
| 247 | The required syntax for a RTSP url is: | 247 | The required syntax for a RTSP url is: |
| 248 | @example | 248 | @example |
| 249 | rtsp://@var{hostname}[:@var{port}]/@var{path}[?@var{options}] | 249 | rtsp://@var{hostname}[:@var{port}]/@var{path} |
| 250 | @end example | 250 | @end example |
| 251 | 251 | ||
| 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}), | ||
| 253 | are supported: | 254 | are supported: |
| 254 | 255 | ||
| 256 | Flags for @code{rtsp_transport}: | ||
| 257 | |||
| 255 | @table @option | 258 | @table @option |
| 256 | 259 | ||
| 257 | @item udp | 260 | @item udp |
| @@ -261,21 +264,25 @@ Use UDP as lower transport protocol. · 3 unmodified lines | |||
| 261 | Use TCP (interleaving within the RTSP control channel) as lower | 264 | Use TCP (interleaving within the RTSP control channel) as lower |
| 262 | transport protocol. | 265 | transport protocol. |
| 263 | 266 | ||
| 264 | @item multicast | 267 | @item udp_multicast |
| 265 | Use UDP multicast as lower transport protocol. | 268 | Use UDP multicast as lower transport protocol. |
| 266 | 269 | ||
| 267 | @item http | 270 | @item http |
| 268 | Use HTTP tunneling as lower transport protocol, which is useful for | 271 | Use HTTP tunneling as lower transport protocol, which is useful for |
| 269 | passing proxies. | 272 | passing proxies. |
| 270 | |||
| 271 | @item filter_src | ||
| 272 | Accept packets only from negotiated peer address and port. | ||
| 273 | @end table | 273 | @end table |
| 274 | 274 | ||
| 275 | Multiple lower transport protocols may be specified, in that case they are | 275 | Multiple lower transport protocols may be specified, in that case they are |
| 276 | tried one at a time (if the setup of one fails, the next one is tried). | 276 | tried one at a time (if the setup of one fails, the next one is tried). |
| 277 | For the muxer, only the @code{tcp} and @code{udp} options are supported. | 277 | For the muxer, only the @code{tcp} and @code{udp} options are supported. |
| 278 | 278 | ||
| 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 | |||
| 279 | When receiving data over UDP, the demuxer tries to reorder received packets | 286 | When receiving data over UDP, the demuxer tries to reorder received packets |
| 280 | (since they may arrive out of order, or packets may get lost totally). In | 287 | (since they may arrive out of order, or packets may get lost totally). In |
| 281 | order for this to be enabled, a maximum delay must be specified in the | 288 | order for this to be enabled, a maximum delay must be specified in the |
| @@ -291,13 +298,13 @@ Example command lines: · 9 unmodified lines | |||
| 291 | To watch a stream over UDP, with a max reordering delay of 0.5 seconds: | 298 | To watch a stream over UDP, with a max reordering delay of 0.5 seconds: |
| 292 | 299 | ||
| 293 | @example | 300 | @example |
| 294 | ffplay -max_delay 500000 rtsp://server/video.mp4?udp | 301 | ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4 |
| 295 | @end example | 302 | @end example |
| 296 | 303 | ||
| 297 | To watch a stream tunneled over HTTP: | 304 | To watch a stream tunneled over HTTP: |
| 298 | 305 | ||
| 299 | @example | 306 | @example |
| 300 | ffplay rtsp://server/video.mp4?http | 307 | ffplay -rtsp_transport http rtsp://server/video.mp4 |
| 301 | @end example | 308 | @end example |
| 302 | 309 | ||
| 303 | To send a stream in realtime to a RTSP server, for others to watch: | 310 | To send a stream in realtime to a RTSP server, for others to watch: |
| @@ -355,6 +355,8 @@ typedef struct OptionsContext { · 354 unmodified lines | |||
| 355 | int nb_inter_matrices; | 355 | int nb_inter_matrices; |
| 356 | SpecifierOpt *top_field_first; | 356 | SpecifierOpt *top_field_first; |
| 357 | int nb_top_field_first; | 357 | int nb_top_field_first; |
| 358 | SpecifierOpt *presets; | ||
| 359 | int nb_presets; | ||
| 358 | #if CONFIG_AVFILTER | 360 | #if CONFIG_AVFILTER |
| 359 | SpecifierOpt *filters; | 361 | SpecifierOpt *filters; |
| 360 | int nb_filters; | 362 | int nb_filters; |
| @@ -3202,15 +3204,62 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost) · 2841 unmodified lines | |||
| 3202 | } | 3204 | } |
| 3203 | } | 3205 | } |
| 3204 | 3206 | ||
| 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 | |||
| 3205 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) | 3252 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) |
| 3206 | { | 3253 | { |
| 3207 | OutputStream *ost; | 3254 | OutputStream *ost; |
| 3208 | AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0); | 3255 | 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; |
| 3210 | int64_t max_frames = INT64_MAX; | 3257 | int64_t max_frames = INT64_MAX; |
| 3211 | char *bsf = NULL, *next, *codec_tag = NULL; | 3258 | char *bsf = NULL, *next, *codec_tag = NULL; |
| 3212 | AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; | 3259 | AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; |
| 3213 | double qscale = -1; | 3260 | double qscale = -1; |
| 3261 | char *buf = NULL, *arg = NULL, *preset = NULL; | ||
| 3262 | AVIOContext *s = NULL; | ||
| 3214 | 3263 | ||
| 3215 | if (!st) { | 3264 | if (!st) { |
| 3216 | av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); | 3265 | 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 | |||
| 3232 | avcodec_get_context_defaults3(st->codec, ost->enc); | 3281 | avcodec_get_context_defaults3(st->codec, ost->enc); |
| 3233 | st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy | 3282 | st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy |
| 3234 | 3283 | ||
| 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 | |||
| 3235 | MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); | 3309 | MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); |
| 3236 | ost->max_frames = max_frames; | 3310 | ost->max_frames = max_frames; |
| 3237 | 3311 | ||
| @@ -4209,6 +4283,7 @@ static const OptionDef options[] = { · 971 unmodified lines | |||
| 4209 | { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, | 4283 | { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, |
| 4210 | { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, | 4284 | { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, |
| 4211 | { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, | 4285 | { "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" }, | ||
| 4212 | { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, | 4287 | { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, |
| 4213 | { "map_meta_data", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile", | 4288 | { "map_meta_data", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile", |
| 4214 | "outfile[,metadata]:infile[,metadata]" }, | 4289 | "outfile[,metadata]:infile[,metadata]" }, |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | #define LIBAVFILTER_VERSION_MAJOR 2 | 31 | #define LIBAVFILTER_VERSION_MAJOR 2 |
| 32 | #define LIBAVFILTER_VERSION_MINOR 43 | 32 | #define LIBAVFILTER_VERSION_MINOR 43 |
| 33 | #define LIBAVFILTER_VERSION_MICRO 6 | 33 | #define LIBAVFILTER_VERSION_MICRO 7 |
| 34 | 34 | ||
| 35 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ | 35 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| 36 | LIBAVFILTER_VERSION_MINOR, \ | 36 | LIBAVFILTER_VERSION_MINOR, \ |
| @@ -81,7 +81,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 80 unmodified lines | |||
| 81 | 81 | ||
| 82 | if (!args) { | 82 | if (!args) { |
| 83 | av_log(ctx, AV_LOG_ERROR, | 83 | 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"); |
| 85 | return AVERROR(EINVAL); | 85 | return AVERROR(EINVAL); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -342,4 +342,4 @@ AVFilter avfilter_vf_boxblur = { · 254 unmodified lines | |||
| 342 | .outputs = (AVFilterPad[]) {{ .name = "default", | 342 | .outputs = (AVFilterPad[]) {{ .name = "default", |
| 343 | .type = AVMEDIA_TYPE_VIDEO, }, | 343 | .type = AVMEDIA_TYPE_VIDEO, }, |
| 344 | { .name = NULL}}, | 344 | { .name = NULL}}, |
| 345 | }; | 345 | }; |
| @@ -154,9 +154,9 @@ static const char *delogo_get_name(void *ctx) · 153 unmodified lines | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | static const AVClass delogo_class = { | 156 | static const AVClass delogo_class = { |
| 157 | "DelogoContext", | 157 | .class_name = "DelogoContext", |
| 158 | delogo_get_name, | 158 | .item_name = delogo_get_name, |
| 159 | delogo_options | 159 | .option = delogo_options, |
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | static int query_formats(AVFilterContext *ctx) | 162 | static int query_formats(AVFilterContext *ctx) |
| @@ -285,4 +285,4 @@ AVFilter avfilter_vf_delogo = { · 122 unmodified lines | |||
| 285 | .outputs = (AVFilterPad[]) {{ .name = "default", | 285 | .outputs = (AVFilterPad[]) {{ .name = "default", |
| 286 | .type = AVMEDIA_TYPE_VIDEO, }, | 286 | .type = AVMEDIA_TYPE_VIDEO, }, |
| 287 | { .name = NULL}}, | 287 | { .name = NULL}}, |
| 288 | }; | 288 | }; |
| @@ -350,21 +350,27 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) · 349 unmodified lines | |||
| 350 | { .name = NULL}}, \ | 350 | { .name = NULL}}, \ |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | #if CONFIG_LUT_FILTER | ||
| 353 | DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init); | 354 | DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init); |
| 355 | #endif | ||
| 356 | #if CONFIG_LUTYUV_FILTER | ||
| 354 | DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init); | 357 | DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init); |
| 358 | #endif | ||
| 359 | #if CONFIG_LUTRGB_FILTER | ||
| 355 | DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init); | 360 | DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init); |
| 361 | #endif | ||
| 356 | 362 | ||
| 357 | #if CONFIG_NEGATE_FILTER | 363 | #if CONFIG_NEGATE_FILTER |
| 358 | 364 | ||
| 359 | static int negate_init(AVFilterContext *ctx, const char *args, void *opaque) | 365 | static int negate_init(AVFilterContext *ctx, const char *args, void *opaque) |
| 360 | { | 366 | { |
| 361 | LutContext *lut = ctx->priv; | 367 | LutContext *lut = ctx->priv; |
| 362 | char lut_params[1024]; | 368 | char lut_params[64]; |
| 363 | 369 | ||
| 364 | if (args) | 370 | if (args) |
| 365 | sscanf(args, "%d", &lut->negate_alpha); | 371 | sscanf(args, "%d", &lut->negate_alpha); |
| 366 | 372 | ||
| 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); |
| 368 | 374 | ||
| 369 | snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s", | 375 | snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s", |
| 370 | lut->negate_alpha ? "negval" : "val"); | 376 | lut->negate_alpha ? "negval" : "val"); |
| @@ -374,4 +380,4 @@ static int negate_init(AVFilterContext *ctx, const char *args, void *opaque) · 3 unmodified lines | |||
| 374 | 380 | ||
| 375 | DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init); | 381 | DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init); |
| 376 | 382 | ||
| 377 | #endif | 383 | #endif |
| @@ -275,9 +275,6 @@ static int aiff_read_header(AVFormatContext *s, · 274 unmodified lines | |||
| 275 | 275 | ||
| 276 | got_sound: | 276 | got_sound: |
| 277 | /* Now positioned, get the sound data start and end */ | 277 | /* 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 | |||
| 281 | av_set_pts_info(st, 64, 1, st->codec->sample_rate); | 278 | av_set_pts_info(st, 64, 1, st->codec->sample_rate); |
| 282 | st->start_time = 0; | 279 | st->start_time = 0; |
| 283 | st->duration = st->codec->frame_size ? | 280 | st->duration = st->codec->frame_size ? |
| @@ -745,10 +745,12 @@ typedef struct AVFormatContext { · 744 unmodified lines | |||
| 745 | */ | 745 | */ |
| 746 | int64_t duration; | 746 | int64_t duration; |
| 747 | 747 | ||
| 748 | #if FF_API_FILESIZE | ||
| 748 | /** | 749 | /** |
| 749 | * decoding: total file size, 0 if unknown | 750 | * decoding: total file size, 0 if unknown |
| 750 | */ | 751 | */ |
| 751 | int64_t file_size; | 752 | attribute_deprecated int64_t file_size; |
| 753 | #endif | ||
| 752 | 754 | ||
| 753 | /** | 755 | /** |
| 754 | * Decoding: total stream bitrate in bit/s, 0 if not | 756 | * Decoding: total stream bitrate in bit/s, 0 if not |
| @@ -763,7 +765,12 @@ typedef struct AVFormatContext { · 8 unmodified lines | |||
| 763 | /* av_seek_frame() support */ | 765 | /* av_seek_frame() support */ |
| 764 | int64_t data_offset; /**< offset of the first packet */ | 766 | int64_t data_offset; /**< offset of the first packet */ |
| 765 | 767 | ||
| 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 | ||
| 767 | unsigned int packet_size; | 774 | unsigned int packet_size; |
| 768 | int preload; | 775 | int preload; |
| 769 | int max_delay; | 776 | int max_delay; |
| @@ -778,13 +778,14 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) · 777 unmodified lines | |||
| 778 | { | 778 | { |
| 779 | int i; | 779 | int i; |
| 780 | 780 | ||
| 781 | if (buflen <= 0) | ||
| 782 | return AVERROR(EINVAL); | ||
| 781 | // reserve 1 byte for terminating 0 | 783 | // reserve 1 byte for terminating 0 |
| 782 | buflen = FFMIN(buflen - 1, maxlen); | 784 | buflen = FFMIN(buflen - 1, maxlen); |
| 783 | for (i = 0; i < buflen; i++) | 785 | for (i = 0; i < buflen; i++) |
| 784 | if (!(buf[i] = avio_r8(s))) | 786 | if (!(buf[i] = avio_r8(s))) |
| 785 | return i + 1; | 787 | return i + 1; |
| 786 | if (buflen) | 788 | buf[i] = 0; |
| 787 | buf[i] = 0; | ||
| 788 | for (; i < maxlen; i++) | 789 | for (; i < maxlen; i++) |
| 789 | if (!avio_r8(s)) | 790 | if (!avio_r8(s)) |
| 790 | return i + 1; | 791 | return i + 1; |
| @@ -796,6 +797,8 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) · 5 unmodified lines | |||
| 796 | {\ | 797 | {\ |
| 797 | char* q = buf;\ | 798 | char* q = buf;\ |
| 798 | int ret = 0;\ | 799 | int ret = 0;\ |
| 800 | if (buflen <= 0) \ | ||
| 801 | return AVERROR(EINVAL); \ | ||
| 799 | while (ret + 1 < maxlen) {\ | 802 | while (ret + 1 < maxlen) {\ |
| 800 | uint8_t tmp;\ | 803 | uint8_t tmp;\ |
| 801 | uint32_t ch;\ | 804 | uint32_t ch;\ |
| @@ -292,8 +292,6 @@ static int read_header(AVFormatContext *s, · 291 unmodified lines | |||
| 292 | "block size or frame size are variable.\n"); | 292 | "block size or frame size are variable.\n"); |
| 293 | return AVERROR_INVALIDDATA; | 293 | return AVERROR_INVALIDDATA; |
| 294 | } | 294 | } |
| 295 | s->file_size = avio_size(pb); | ||
| 296 | s->file_size = FFMAX(0, s->file_size); | ||
| 297 | 295 | ||
| 298 | av_set_pts_info(st, 64, 1, st->codec->sample_rate); | 296 | av_set_pts_info(st, 64, 1, st->codec->sample_rate); |
| 299 | st->start_time = 0; | 297 | st->start_time = 0; |
| @@ -99,6 +99,33 @@ static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, · 98 unmodified lines | |||
| 99 | return 0; | 99 | return 0; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 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 | |||
| 102 | static const uint32_t mac_to_unicode[128] = { | 129 | static const uint32_t mac_to_unicode[128] = { |
| 103 | 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1, | 130 | 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1, |
| 104 | 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8, | 131 | 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 | |||
| 174 | parse = mov_metadata_track_or_disc_number; break; | 201 | parse = mov_metadata_track_or_disc_number; break; |
| 175 | case MKTAG( 'd','i','s','k'): key = "disc"; | 202 | case MKTAG( 'd','i','s','k'): key = "disc"; |
| 176 | parse = mov_metadata_track_or_disc_number; break; | 203 | 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; | ||
| 177 | } | 210 | } |
| 178 | 211 | ||
| 179 | if (c->itunes_metadata && atom.size > 8) { | 212 | if (c->itunes_metadata && atom.size > 8) { |
| @@ -20,7 +20,9 @@ · 19 unmodified lines | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "libavutil/fifo.h" | 22 | #include "libavutil/fifo.h" |
| 23 | #include "libavutil/log.h" | ||
| 23 | #include "libavutil/mathematics.h" | 24 | #include "libavutil/mathematics.h" |
| 25 | #include "libavutil/opt.h" | ||
| 24 | #include "libavcodec/put_bits.h" | 26 | #include "libavcodec/put_bits.h" |
| 25 | #include "avformat.h" | 27 | #include "avformat.h" |
| 26 | #include "mpeg.h" | 28 | #include "mpeg.h" |
| @@ -56,6 +58,7 @@ typedef struct { · 29 unmodified lines | |||
| 56 | } StreamInfo; | 58 | } StreamInfo; |
| 57 | 59 | ||
| 58 | typedef struct { | 60 | typedef struct { |
| 61 | const AVClass *class; | ||
| 59 | int packet_size; /* required packet size */ | 62 | int packet_size; /* required packet size */ |
| 60 | int packet_number; | 63 | int packet_number; |
| 61 | int pack_header_freq; /* frequency (in packets^-1) at which we send pack headers */ | 64 | 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 | |||
| 416 | video_bitrate += codec_rate; | 419 | video_bitrate += codec_rate; |
| 417 | } | 420 | } |
| 418 | 421 | ||
| 422 | #if FF_API_MUXRATE | ||
| 419 | if(ctx->mux_rate){ | 423 | if(ctx->mux_rate){ |
| 420 | s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50); | 424 | s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50); |
| 421 | } else { | 425 | } else |
| 426 | #endif | ||
| 427 | if (!s->mux_rate) { | ||
| 422 | /* we increase slightly the bitrate to take into account the | 428 | /* we increase slightly the bitrate to take into account the |
| 423 | headers. XXX: compute it exactly */ | 429 | headers. XXX: compute it exactly */ |
| 424 | bitrate += bitrate*5/100; | 430 | bitrate += bitrate*5/100; |
| @@ -1227,7 +1233,23 @@ static int mpeg_mux_end(AVFormatContext *ctx) · 802 unmodified lines | |||
| 1227 | return 0; | 1233 | return 0; |
| 1228 | } | 1234 | } |
| 1229 | 1235 | ||
| 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 | |||
| 1230 | #if CONFIG_MPEG1SYSTEM_MUXER | 1251 | #if CONFIG_MPEG1SYSTEM_MUXER |
| 1252 | MPEGENC_CLASS(mpeg) | ||
| 1231 | AVOutputFormat ff_mpeg1system_muxer = { | 1253 | AVOutputFormat ff_mpeg1system_muxer = { |
| 1232 | .name = "mpeg", | 1254 | .name = "mpeg", |
| 1233 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format"), | 1255 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format"), |
| @@ -1239,9 +1261,11 @@ AVOutputFormat ff_mpeg1system_muxer = { · 5 unmodified lines | |||
| 1239 | .write_header = mpeg_mux_init, | 1261 | .write_header = mpeg_mux_init, |
| 1240 | .write_packet = mpeg_mux_write_packet, | 1262 | .write_packet = mpeg_mux_write_packet, |
| 1241 | .write_trailer = mpeg_mux_end, | 1263 | .write_trailer = mpeg_mux_end, |
| 1264 | .priv_class = &mpeg_class, | ||
| 1242 | }; | 1265 | }; |
| 1243 | #endif | 1266 | #endif |
| 1244 | #if CONFIG_MPEG1VCD_MUXER | 1267 | #if CONFIG_MPEG1VCD_MUXER |
| 1268 | MPEGENC_CLASS(vcd) | ||
| 1245 | AVOutputFormat ff_mpeg1vcd_muxer = { | 1269 | AVOutputFormat ff_mpeg1vcd_muxer = { |
| 1246 | .name = "vcd", | 1270 | .name = "vcd", |
| 1247 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"), | 1271 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"), |
| @@ -1252,9 +1276,11 @@ AVOutputFormat ff_mpeg1vcd_muxer = { · 4 unmodified lines | |||
| 1252 | .write_header = mpeg_mux_init, | 1276 | .write_header = mpeg_mux_init, |
| 1253 | .write_packet = mpeg_mux_write_packet, | 1277 | .write_packet = mpeg_mux_write_packet, |
| 1254 | .write_trailer = mpeg_mux_end, | 1278 | .write_trailer = mpeg_mux_end, |
| 1279 | .priv_class = &vcd_class, | ||
| 1255 | }; | 1280 | }; |
| 1256 | #endif | 1281 | #endif |
| 1257 | #if CONFIG_MPEG2VOB_MUXER | 1282 | #if CONFIG_MPEG2VOB_MUXER |
| 1283 | MPEGENC_CLASS(vob) | ||
| 1258 | AVOutputFormat ff_mpeg2vob_muxer = { | 1284 | AVOutputFormat ff_mpeg2vob_muxer = { |
| 1259 | .name = "vob", | 1285 | .name = "vob", |
| 1260 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), | 1286 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), |
| @@ -1266,11 +1292,13 @@ AVOutputFormat ff_mpeg2vob_muxer = { · 5 unmodified lines | |||
| 1266 | .write_header = mpeg_mux_init, | 1292 | .write_header = mpeg_mux_init, |
| 1267 | .write_packet = mpeg_mux_write_packet, | 1293 | .write_packet = mpeg_mux_write_packet, |
| 1268 | .write_trailer = mpeg_mux_end, | 1294 | .write_trailer = mpeg_mux_end, |
| 1295 | .priv_class = &vob_class, | ||
| 1269 | }; | 1296 | }; |
| 1270 | #endif | 1297 | #endif |
| 1271 | 1298 | ||
| 1272 | /* Same as mpeg2vob_mux except that the pack size is 2324 */ | 1299 | /* Same as mpeg2vob_mux except that the pack size is 2324 */ |
| 1273 | #if CONFIG_MPEG2SVCD_MUXER | 1300 | #if CONFIG_MPEG2SVCD_MUXER |
| 1301 | MPEGENC_CLASS(svcd) | ||
| 1274 | AVOutputFormat ff_mpeg2svcd_muxer = { | 1302 | AVOutputFormat ff_mpeg2svcd_muxer = { |
| 1275 | .name = "svcd", | 1303 | .name = "svcd", |
| 1276 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), | 1304 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), |
| @@ -1282,11 +1310,13 @@ AVOutputFormat ff_mpeg2svcd_muxer = { · 5 unmodified lines | |||
| 1282 | .write_header = mpeg_mux_init, | 1310 | .write_header = mpeg_mux_init, |
| 1283 | .write_packet = mpeg_mux_write_packet, | 1311 | .write_packet = mpeg_mux_write_packet, |
| 1284 | .write_trailer = mpeg_mux_end, | 1312 | .write_trailer = mpeg_mux_end, |
| 1313 | .priv_class = &svcd_class, | ||
| 1285 | }; | 1314 | }; |
| 1286 | #endif | 1315 | #endif |
| 1287 | 1316 | ||
| 1288 | /* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */ | 1317 | /* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */ |
| 1289 | #if CONFIG_MPEG2DVD_MUXER | 1318 | #if CONFIG_MPEG2DVD_MUXER |
| 1319 | MPEGENC_CLASS(dvd) | ||
| 1290 | AVOutputFormat ff_mpeg2dvd_muxer = { | 1320 | AVOutputFormat ff_mpeg2dvd_muxer = { |
| 1291 | .name = "dvd", | 1321 | .name = "dvd", |
| 1292 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"), | 1322 | .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"), |
| @@ -1298,5 +1328,6 @@ AVOutputFormat ff_mpeg2dvd_muxer = { · 5 unmodified lines | |||
| 1298 | .write_header = mpeg_mux_init, | 1328 | .write_header = mpeg_mux_init, |
| 1299 | .write_packet = mpeg_mux_write_packet, | 1329 | .write_packet = mpeg_mux_write_packet, |
| 1300 | .write_trailer = mpeg_mux_end, | 1330 | .write_trailer = mpeg_mux_end, |
| 1331 | .priv_class = &dvd_class, | ||
| 1301 | }; | 1332 | }; |
| 1302 | #endif | 1333 | #endif |
| @@ -92,6 +92,7 @@ static const AVOption options[] = { · 91 unmodified lines | |||
| 92 | {"mpegts_m2ts_mode", "Enable m2ts mode.", | 92 | {"mpegts_m2ts_mode", "Enable m2ts mode.", |
| 93 | offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 }, | 93 | offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 }, |
| 94 | -1,1, AV_OPT_FLAG_ENCODING_PARAM}, | 94 | -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}, | ||
| 95 | { NULL }, | 96 | { NULL }, |
| 96 | }; | 97 | }; |
| 97 | 98 | ||
| @@ -562,7 +563,10 @@ static int mpegts_write_header(AVFormatContext *s) · 464 unmodified lines | |||
| 562 | service->pcr_pid = ts_st->pid; | 563 | service->pcr_pid = ts_st->pid; |
| 563 | } | 564 | } |
| 564 | 565 | ||
| 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 | ||
| 566 | 570 | ||
| 567 | if (ts->mux_rate > 1) { | 571 | if (ts->mux_rate > 1) { |
| 568 | service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) / | 572 | service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) / |
| @@ -74,7 +74,9 @@ static const AVClass *format_child_class_next(const AVClass *prev) · 73 unmodified lines | |||
| 74 | 74 | ||
| 75 | static const AVOption options[]={ | 75 | static const AVOption options[]={ |
| 76 | {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, | 76 | {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, |
| 77 | #if FF_API_MUXRATE | ||
| 77 | {"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, | 78 | {"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, |
| 79 | #endif | ||
| 78 | {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, | 80 | {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, |
| 79 | {"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, | 81 | {"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, |
| 80 | {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, | 82 | {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, |
| @@ -92,8 +92,7 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap) · 91 unmodified lines | |||
| 92 | return AVERROR(ENOMEM); | 92 | return AVERROR(ENOMEM); |
| 93 | 93 | ||
| 94 | avio_rb32(pb); // "RIFF" | 94 | avio_rb32(pb); // "RIFF" |
| 95 | s->file_size = avio_rl32(pb) + 8; | 95 | avio_skip(pb, 4 + 8 + 4 + 1 + 1); // filesize + "QLCMfmt " + chunk-size + major-version + minor-version |
| 96 | avio_skip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version | ||
| 97 | 96 | ||
| 98 | st->codec->codec_type = AVMEDIA_TYPE_AUDIO; | 97 | st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
| 99 | st->codec->channels = 1; | 98 | st->codec->channels = 1; |
| @@ -98,7 +98,8 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec) · 97 unmodified lines | |||
| 98 | /* Was the payload type already specified for the RTP muxer? */ | 98 | /* Was the payload type already specified for the RTP muxer? */ |
| 99 | if (ofmt && ofmt->priv_class) { | 99 | if (ofmt && ofmt->priv_class) { |
| 100 | int64_t payload_type; | 100 | 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) | ||
| 102 | return (int)payload_type; | 103 | return (int)payload_type; |
| 103 | } | 104 | } |
| 104 | 105 | ||
| @@ -465,7 +465,7 @@ AVOutputFormat ff_rtp_muxer = { · 464 unmodified lines | |||
| 465 | .long_name = NULL_IF_CONFIG_SMALL("RTP output format"), | 465 | .long_name = NULL_IF_CONFIG_SMALL("RTP output format"), |
| 466 | .priv_data_size = sizeof(RTPMuxContext), | 466 | .priv_data_size = sizeof(RTPMuxContext), |
| 467 | .audio_codec = CODEC_ID_PCM_MULAW, | 467 | .audio_codec = CODEC_ID_PCM_MULAW, |
| 468 | .video_codec = CODEC_ID_NONE, | 468 | .video_codec = CODEC_ID_MPEG4, |
| 469 | .write_header = rtp_write_header, | 469 | .write_header = rtp_write_header, |
| 470 | .write_packet = rtp_write_packet, | 470 | .write_packet = rtp_write_packet, |
| 471 | .write_trailer = rtp_write_trailer, | 471 | .write_trailer = rtp_write_trailer, |
| @@ -45,6 +45,7 @@ · 44 unmodified lines | |||
| 45 | #include "rtpdec_formats.h" | 45 | #include "rtpdec_formats.h" |
| 46 | #include "rtpenc_chain.h" | 46 | #include "rtpenc_chain.h" |
| 47 | #include "url.h" | 47 | #include "url.h" |
| 48 | #include "rtpenc.h" | ||
| 48 | 49 | ||
| 49 | //#define DEBUG | 50 | //#define DEBUG |
| 50 | 51 | ||
| @@ -56,6 +57,36 @@ · 5 unmodified lines | |||
| 56 | #define SDP_MAX_SIZE 16384 | 57 | #define SDP_MAX_SIZE 16384 |
| 57 | #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH | 58 | #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH |
| 58 | 59 | ||
| 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 | |||
| 59 | static void get_word_until_chars(char *buf, int buf_size, | 90 | static void get_word_until_chars(char *buf, int buf_size, |
| 60 | const char *sep, const char **pp) | 91 | const char *sep, const char **pp) |
| 61 | { | 92 | { |
| @@ -1218,7 +1249,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, · 1156 unmodified lines | |||
| 1218 | case RTSP_LOWER_TRANSPORT_UDP: { | 1249 | case RTSP_LOWER_TRANSPORT_UDP: { |
| 1219 | char url[1024], options[30] = ""; | 1250 | char url[1024], options[30] = ""; |
| 1220 | 1251 | ||
| 1221 | if (rt->filter_source) | 1252 | if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC) |
| 1222 | av_strlcpy(options, "?connect=1", sizeof(options)); | 1253 | av_strlcpy(options, "?connect=1", sizeof(options)); |
| 1223 | /* Use source address if specified */ | 1254 | /* Use source address if specified */ |
| 1224 | if (reply->transports[0].source[0]) { | 1255 | if (reply->transports[0].source[0]) { |
| @@ -1308,8 +1339,17 @@ int ff_rtsp_connect(AVFormatContext *s) · 83 unmodified lines | |||
| 1308 | 1339 | ||
| 1309 | if (!ff_network_init()) | 1340 | if (!ff_network_init()) |
| 1310 | return AVERROR(EIO); | 1341 | return AVERROR(EIO); |
| 1311 | redirect: | 1342 | |
| 1312 | rt->control_transport = RTSP_MODE_PLAIN; | 1343 | 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; | ||
| 1313 | /* extract hostname and port */ | 1353 | /* extract hostname and port */ |
| 1314 | av_url_split(NULL, 0, auth, sizeof(auth), | 1354 | av_url_split(NULL, 0, auth, sizeof(auth), |
| 1315 | host, sizeof(host), &port, path, sizeof(path), s->filename); | 1355 | host, sizeof(host), &port, path, sizeof(path), s->filename); |
| @@ -1319,6 +1359,7 @@ redirect: · 3 unmodified lines | |||
| 1319 | if (port < 0) | 1359 | if (port < 0) |
| 1320 | port = RTSP_DEFAULT_PORT; | 1360 | port = RTSP_DEFAULT_PORT; |
| 1321 | 1361 | ||
| 1362 | #if FF_API_RTSP_URL_OPTIONS | ||
| 1322 | /* search for options */ | 1363 | /* search for options */ |
| 1323 | option_list = strrchr(path, '?'); | 1364 | option_list = strrchr(path, '?'); |
| 1324 | if (option_list) { | 1365 | if (option_list) { |
| @@ -1326,6 +1367,7 @@ redirect: · 1 unmodified line | |||
| 1326 | * the options back into the same string. */ | 1367 | * the options back into the same string. */ |
| 1327 | filename = option_list; | 1368 | filename = option_list; |
| 1328 | while (option_list) { | 1369 | while (option_list) { |
| 1370 | int handled = 1; | ||
| 1329 | /* move the option pointer */ | 1371 | /* move the option pointer */ |
| 1330 | option = ++option_list; | 1372 | option = ++option_list; |
| 1331 | option_list = strchr(option_list, '&'); | 1373 | option_list = strchr(option_list, '&'); |
| @@ -1343,7 +1385,7 @@ redirect: · 11 unmodified lines | |||
| 1343 | lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); | 1385 | lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); |
| 1344 | rt->control_transport = RTSP_MODE_TUNNEL; | 1386 | rt->control_transport = RTSP_MODE_TUNNEL; |
| 1345 | } else if (!strcmp(option, "filter_src")) { | 1387 | } else if (!strcmp(option, "filter_src")) { |
| 1346 | rt->filter_source = 1; | 1388 | rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC; |
| 1347 | } else { | 1389 | } else { |
| 1348 | /* Write options back into the buffer, using memmove instead | 1390 | /* Write options back into the buffer, using memmove instead |
| 1349 | * of strcpy since the strings may overlap. */ | 1391 | * of strcpy since the strings may overlap. */ |
| @@ -1351,10 +1393,16 @@ redirect: · 1 unmodified line | |||
| 1351 | memmove(++filename, option, len); | 1393 | memmove(++filename, option, len); |
| 1352 | filename += len; | 1394 | filename += len; |
| 1353 | if (option_list) *filename = '&'; | 1395 | if (option_list) *filename = '&'; |
| 1396 | handled = 0; | ||
| 1354 | } | 1397 | } |
| 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"); | ||
| 1355 | } | 1402 | } |
| 1356 | *filename = 0; | 1403 | *filename = 0; |
| 1357 | } | 1404 | } |
| 1405 | #endif | ||
| 1358 | 1406 | ||
| 1359 | if (!lower_transport_mask) | 1407 | if (!lower_transport_mask) |
| 1360 | lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1; | 1408 | 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 | |||
| 1797 | namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); | 1845 | namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); |
| 1798 | ff_url_join(url, sizeof(url), "rtp", NULL, | 1846 | ff_url_join(url, sizeof(url), "rtp", NULL, |
| 1799 | namebuf, rtsp_st->sdp_port, | 1847 | namebuf, rtsp_st->sdp_port, |
| 1800 | "?localport=%d&ttl=%d", rtsp_st->sdp_port, | 1848 | "?localport=%d&ttl=%d&connect=%d", rtsp_st->sdp_port, |
| 1801 | rtsp_st->sdp_ttl); | 1849 | rtsp_st->sdp_ttl, |
| 1850 | rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0); | ||
| 1802 | if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) { | 1851 | if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) { |
| 1803 | err = AVERROR_INVALIDDATA; | 1852 | err = AVERROR_INVALIDDATA; |
| 1804 | goto fail; | 1853 | goto fail; |
| @@ -1820,6 +1869,13 @@ static int sdp_read_close(AVFormatContext *s) · 15 unmodified lines | |||
| 1820 | return 0; | 1869 | return 0; |
| 1821 | } | 1870 | } |
| 1822 | 1871 | ||
| 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 | |||
| 1823 | AVInputFormat ff_sdp_demuxer = { | 1879 | AVInputFormat ff_sdp_demuxer = { |
| 1824 | .name = "sdp", | 1880 | .name = "sdp", |
| 1825 | .long_name = NULL_IF_CONFIG_SMALL("SDP"), | 1881 | .long_name = NULL_IF_CONFIG_SMALL("SDP"), |
| @@ -1828,6 +1884,7 @@ AVInputFormat ff_sdp_demuxer = { · 2 unmodified lines | |||
| 1828 | .read_header = sdp_read_header, | 1884 | .read_header = sdp_read_header, |
| 1829 | .read_packet = ff_rtsp_fetch_packet, | 1885 | .read_packet = ff_rtsp_fetch_packet, |
| 1830 | .read_close = sdp_read_close, | 1886 | .read_close = sdp_read_close, |
| 1887 | .priv_class = &sdp_demuxer_class | ||
| 1831 | }; | 1888 | }; |
| 1832 | #endif /* CONFIG_SDP_DEMUXER */ | 1889 | #endif /* CONFIG_SDP_DEMUXER */ |
| 1833 | 1890 | ||
| @@ -1924,6 +1981,13 @@ fail: · 90 unmodified lines | |||
| 1924 | return ret; | 1981 | return ret; |
| 1925 | } | 1982 | } |
| 1926 | 1983 | ||
| 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 | |||
| 1927 | AVInputFormat ff_rtp_demuxer = { | 1991 | AVInputFormat ff_rtp_demuxer = { |
| 1928 | .name = "rtp", | 1992 | .name = "rtp", |
| 1929 | .long_name = NULL_IF_CONFIG_SMALL("RTP input format"), | 1993 | .long_name = NULL_IF_CONFIG_SMALL("RTP input format"), |
| @@ -1933,6 +1997,7 @@ AVInputFormat ff_rtp_demuxer = { · 3 unmodified lines | |||
| 1933 | .read_packet = ff_rtsp_fetch_packet, | 1997 | .read_packet = ff_rtsp_fetch_packet, |
| 1934 | .read_close = sdp_read_close, | 1998 | .read_close = sdp_read_close, |
| 1935 | .flags = AVFMT_NOFILE, | 1999 | .flags = AVFMT_NOFILE, |
| 2000 | .priv_class = &rtp_demuxer_class | ||
| 1936 | }; | 2001 | }; |
| 1937 | #endif /* CONFIG_RTP_DEMUXER */ | 2002 | #endif /* CONFIG_RTP_DEMUXER */ |
| 1938 | 2003 | ||
| @@ -29,6 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "httpauth.h" | 29 | #include "httpauth.h" |
| 30 | 30 | ||
| 31 | #include "libavutil/log.h" | 31 | #include "libavutil/log.h" |
| 32 | #include "libavutil/opt.h" | ||
| 32 | 33 | ||
| 33 | /** | 34 | /** |
| 34 | * Network layer over which RTP/etc packet data will be transported. | 35 | * Network layer over which RTP/etc packet data will be transported. |
| @@ -37,7 +38,10 @@ enum RTSPLowerTransport { · 2 unmodified lines | |||
| 37 | RTSP_LOWER_TRANSPORT_UDP = 0, /**< UDP/unicast */ | 38 | RTSP_LOWER_TRANSPORT_UDP = 0, /**< UDP/unicast */ |
| 38 | RTSP_LOWER_TRANSPORT_TCP = 1, /**< TCP; interleaved in RTSP */ | 39 | RTSP_LOWER_TRANSPORT_TCP = 1, /**< TCP; interleaved in RTSP */ |
| 39 | RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2, /**< UDP/multicast */ | 40 | 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 */ | ||
| 41 | }; | 45 | }; |
| 42 | 46 | ||
| 43 | /** | 47 | /** |
| @@ -313,10 +317,6 @@ typedef struct RTSPState { · 269 unmodified lines | |||
| 313 | /** Reusable buffer for receiving packets */ | 317 | /** Reusable buffer for receiving packets */ |
| 314 | uint8_t* recvbuf; | 318 | uint8_t* recvbuf; |
| 315 | 319 | ||
| 316 | /** Filter incoming UDP packets - receive packets only from the right | ||
| 317 | * source address and port. */ | ||
| 318 | int filter_source; | ||
| 319 | |||
| 320 | /** | 320 | /** |
| 321 | * A mask with all requested transport methods | 321 | * A mask with all requested transport methods |
| 322 | */ | 322 | */ |
| @@ -349,8 +349,17 @@ typedef struct RTSPState { · 26 unmodified lines | |||
| 349 | 349 | ||
| 350 | /** Whether the server accepts the x-Dynamic-Rate header */ | 350 | /** Whether the server accepts the x-Dynamic-Rate header */ |
| 351 | int accept_dynamic_rate; | 351 | int accept_dynamic_rate; |
| 352 | |||
| 353 | /** | ||
| 354 | * Various option flags for the RTSP muxer/demuxer. | ||
| 355 | */ | ||
| 356 | int rtsp_flags; | ||
| 352 | } RTSPState; | 357 | } RTSPState; |
| 353 | 358 | ||
| 359 | #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - | ||
| 360 | receive packets only from the right | ||
| 361 | source address and port. */ | ||
| 362 | |||
| 354 | /** | 363 | /** |
| 355 | * Describes a single stream, as identified by a single m= line block in the | 364 | * Describes a single stream, as identified by a single m= line block in the |
| 356 | * SDP content. In the case of RDT, one RTSPStream can represent multiple | 365 | * 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 | |||
| 537 | */ | 546 | */ |
| 538 | void ff_rtsp_undo_setup(AVFormatContext *s); | 547 | void ff_rtsp_undo_setup(AVFormatContext *s); |
| 539 | 548 | ||
| 549 | extern const AVOption ff_rtsp_options[]; | ||
| 550 | |||
| 540 | #endif /* AVFORMAT_RTSP_H */ | 551 | #endif /* AVFORMAT_RTSP_H */ |
| @@ -22,7 +22,6 @@ · 21 unmodified lines | |||
| 22 | #include "libavutil/avstring.h" | 22 | #include "libavutil/avstring.h" |
| 23 | #include "libavutil/intreadwrite.h" | 23 | #include "libavutil/intreadwrite.h" |
| 24 | #include "libavutil/mathematics.h" | 24 | #include "libavutil/mathematics.h" |
| 25 | #include "libavutil/opt.h" | ||
| 26 | #include "avformat.h" | 25 | #include "avformat.h" |
| 27 | 26 | ||
| 28 | #include "internal.h" | 27 | #include "internal.h" |
| @@ -388,15 +387,10 @@ static int rtsp_read_close(AVFormatContext *s) · 359 unmodified lines | |||
| 388 | return 0; | 387 | return 0; |
| 389 | } | 388 | } |
| 390 | 389 | ||
| 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 | |||
| 396 | const AVClass rtsp_demuxer_class = { | 390 | const AVClass rtsp_demuxer_class = { |
| 397 | .class_name = "RTSP demuxer", | 391 | .class_name = "RTSP demuxer", |
| 398 | .item_name = av_default_item_name, | 392 | .item_name = av_default_item_name, |
| 399 | .option = options, | 393 | .option = ff_rtsp_options, |
| 400 | .version = LIBAVUTIL_VERSION_INT, | 394 | .version = LIBAVUTIL_VERSION_INT, |
| 401 | }; | 395 | }; |
| 402 | 396 | ||
| @@ -33,20 +33,13 @@ · 32 unmodified lines | |||
| 33 | #include "libavutil/intreadwrite.h" | 33 | #include "libavutil/intreadwrite.h" |
| 34 | #include "libavutil/avstring.h" | 34 | #include "libavutil/avstring.h" |
| 35 | #include "url.h" | 35 | #include "url.h" |
| 36 | #include "libavutil/opt.h" | ||
| 37 | #include "rtpenc.h" | ||
| 38 | 36 | ||
| 39 | #define SDP_MAX_SIZE 16384 | 37 | #define SDP_MAX_SIZE 16384 |
| 40 | 38 | ||
| 41 | static const AVOption options[] = { | ||
| 42 | FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags), | ||
| 43 | { NULL }, | ||
| 44 | }; | ||
| 45 | |||
| 46 | static const AVClass rtsp_muxer_class = { | 39 | static const AVClass rtsp_muxer_class = { |
| 47 | .class_name = "RTSP muxer", | 40 | .class_name = "RTSP muxer", |
| 48 | .item_name = av_default_item_name, | 41 | .item_name = av_default_item_name, |
| 49 | .option = options, | 42 | .option = ff_rtsp_options, |
| 50 | .version = LIBAVUTIL_VERSION_INT, | 43 | .version = LIBAVUTIL_VERSION_INT, |
| 51 | }; | 44 | }; |
| 52 | 45 | ||
| @@ -1902,7 +1902,7 @@ static int has_duration(AVFormatContext *ic) · 1901 unmodified lines | |||
| 1902 | static void update_stream_timings(AVFormatContext *ic) | 1902 | static void update_stream_timings(AVFormatContext *ic) |
| 1903 | { | 1903 | { |
| 1904 | int64_t start_time, start_time1, start_time_text, end_time, end_time1; | 1904 | int64_t start_time, start_time1, start_time_text, end_time, end_time1; |
| 1905 | int64_t duration, duration1; | 1905 | int64_t duration, duration1, filesize; |
| 1906 | int i; | 1906 | int i; |
| 1907 | AVStream *st; | 1907 | AVStream *st; |
| 1908 | 1908 | ||
| @@ -1945,9 +1945,9 @@ static void update_stream_timings(AVFormatContext *ic) · 36 unmodified lines | |||
| 1945 | if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) { | 1945 | if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) { |
| 1946 | ic->duration = duration; | 1946 | ic->duration = duration; |
| 1947 | } | 1947 | } |
| 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) { |
| 1949 | /* compute the bitrate */ | 1949 | /* 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 / |
| 1951 | (double)ic->duration; | 1951 | (double)ic->duration; |
| 1952 | } | 1952 | } |
| 1953 | } | 1953 | } |
| @@ -1988,9 +1988,8 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic) · 34 unmodified lines | |||
| 1988 | 1988 | ||
| 1989 | /* if duration is already set, we believe it */ | 1989 | /* if duration is already set, we believe it */ |
| 1990 | if (ic->duration == AV_NOPTS_VALUE && | 1990 | if (ic->duration == AV_NOPTS_VALUE && |
| 1991 | ic->bit_rate != 0 && | 1991 | ic->bit_rate != 0) { |
| 1992 | ic->file_size != 0) { | 1992 | filesize = ic->pb ? avio_size(ic->pb) : 0; |
| 1993 | filesize = ic->file_size; | ||
| 1994 | if (filesize > 0) { | 1993 | if (filesize > 0) { |
| 1995 | for(i = 0; i < ic->nb_streams; i++) { | 1994 | for(i = 0; i < ic->nb_streams; i++) { |
| 1996 | st = ic->streams[i]; | 1995 | st = ic->streams[i]; |
| @@ -2034,7 +2033,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) · 37 unmodified lines | |||
| 2034 | 2033 | ||
| 2035 | /* estimate the end time (duration) */ | 2034 | /* estimate the end time (duration) */ |
| 2036 | /* XXX: may need to support wrapping */ | 2035 | /* XXX: may need to support wrapping */ |
| 2037 | filesize = ic->file_size; | 2036 | filesize = ic->pb ? avio_size(ic->pb) : 0; |
| 2038 | end_time = AV_NOPTS_VALUE; | 2037 | end_time = AV_NOPTS_VALUE; |
| 2039 | do{ | 2038 | do{ |
| 2040 | offset = filesize - (DURATION_MAX_READ_SIZE<<retry); | 2039 | offset = filesize - (DURATION_MAX_READ_SIZE<<retry); |
| @@ -2098,7 +2097,6 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) · 57 unmodified lines | |||
| 2098 | if (file_size < 0) | 2097 | if (file_size < 0) |
| 2099 | file_size = 0; | 2098 | file_size = 0; |
| 2100 | } | 2099 | } |
| 2101 | ic->file_size = file_size; | ||
| 2102 | 2100 | ||
| 2103 | if ((!strcmp(ic->iformat->name, "mpeg") || | 2101 | if ((!strcmp(ic->iformat->name, "mpeg") || |
| 2104 | !strcmp(ic->iformat->name, "mpegts")) && | 2102 | !strcmp(ic->iformat->name, "mpegts")) && |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | |||
| 25 | 25 | ||
| 26 | #define LIBAVFORMAT_VERSION_MAJOR 53 | 26 | #define LIBAVFORMAT_VERSION_MAJOR 53 |
| 27 | #define LIBAVFORMAT_VERSION_MINOR 16 | 27 | #define LIBAVFORMAT_VERSION_MINOR 16 |
| 28 | #define LIBAVFORMAT_VERSION_MICRO 0 | 28 | #define LIBAVFORMAT_VERSION_MICRO 1 |
| 29 | 29 | ||
| 30 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | 30 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 31 | LIBAVFORMAT_VERSION_MINOR, \ | 31 | LIBAVFORMAT_VERSION_MINOR, \ |
| @@ -89,5 +89,14 @@ · 57 unmodified lines | |||
| 89 | #ifndef FF_API_TIMESTAMP | 89 | #ifndef FF_API_TIMESTAMP |
| 90 | #define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) | 90 | #define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) |
| 91 | #endif | 91 | #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 | ||
| 92 | 101 | ||
| 93 | #endif /* AVFORMAT_VERSION_H */ | 102 | #endif /* AVFORMAT_VERSION_H */ |
| @@ -503,7 +503,8 @@ int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_ · 502 unmodified lines | |||
| 503 | int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) | 503 | int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) |
| 504 | { | 504 | { |
| 505 | const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0); | 505 | 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); | ||
| 507 | int64_t res; | 508 | int64_t res; |
| 508 | 509 | ||
| 509 | if (!field || !flag || flag->type != AV_OPT_TYPE_CONST || | 510 | 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 | |||
| 700 | 701 | ||
| 701 | if (!opts) | 702 | if (!opts) |
| 702 | return 0; | 703 | return 0; |
| 704 | |||
| 703 | while (*opts) { | 705 | while (*opts) { |
| 704 | if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0) | 706 | if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0) |
| 705 | return ret; | 707 | return ret; |