From 79157f400bec7fdb6385befa63fdafc727378143 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Apr 2011 00:29:30 +0200 Subject: error: remove AVERROR_NUMEXPECTED AVERROR_NUMEXPECTED is used only in the image muxer and demuxer, and has a too much specific meaning, which is better explained through a log message. Thus it can be replaced by AVERROR(EINVAL). This breaks API. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavformat') diff --git a/libavformat/utils.c b/libavformat/utils.c index 19498b96a4..88e9a49e87 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -581,7 +581,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, /* check filename in case an image number is expected */ if (fmt->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { - err = AVERROR_NUMEXPECTED; + err = AVERROR(EINVAL); goto fail; } } -- cgit v1.2.3 From fe8e039460064ad765c37736dadd123478c5ff1f Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 20 Apr 2011 10:10:10 +0300 Subject: applehttp: Expose the stream bitrate via metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps callers to intelligently switch between bitrate variants. Signed-off-by: Martin Storsjö --- doc/demuxers.texi | 2 ++ libavformat/applehttp.c | 3 +++ libavformat/avformat.h | 1 + libavformat/version.h | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'libavformat') diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 4168fc10c6..98f9fdeff8 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -72,5 +72,7 @@ This demuxer presents all AVStreams from all variant streams. The id field is set to the bitrate variant index number. By setting the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), the caller can decide which variant streams to actually receive. +The total bitrate of the variant that the stream belongs to is +available in a metadata key named "variant_bitrate". @c man end INPUT DEVICES diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index df4494a785..90b86a8733 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -367,6 +367,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) for (i = 0; i < c->n_variants; i++) { struct variant *v = c->variants[i]; AVInputFormat *in_fmt = NULL; + char bitrate_str[20]; if (v->n_segments == 0) continue; @@ -393,6 +394,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ret < 0) goto fail; v->stream_offset = stream_offset; + snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth); /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { AVStream *st = av_new_stream(s, i); @@ -401,6 +403,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; } avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); + av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, 0); } stream_offset += v->ctx->nb_streams; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2567aabd5a..732756222e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -104,6 +104,7 @@ struct AVFormatContext; * service_provider -- name of the service provider in broadcasting. * title -- name of the work. * track -- number of this work in the set, can be in form current/total. + * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of */ #define AV_METADATA_MATCH_CASE 1 diff --git a/libavformat/version.h b/libavformat/version.h index 01730183b2..04c5d73f50 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -25,7 +25,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MINOR 0 -#define LIBAVFORMAT_VERSION_MICRO 0 +#define LIBAVFORMAT_VERSION_MICRO 1 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ -- cgit v1.2.3