]> git.sesse.net Git - ffmpeg/commitdiff
applehttp: Expose the stream bitrate via metadata
authorMartin Storsjö <martin@martin.st>
Wed, 20 Apr 2011 07:10:10 +0000 (10:10 +0300)
committerMartin Storsjö <martin@martin.st>
Thu, 21 Apr 2011 11:13:09 +0000 (14:13 +0300)
This helps callers to intelligently switch between bitrate
variants.

Signed-off-by: Martin Storsjö <martin@martin.st>
doc/demuxers.texi
libavformat/applehttp.c
libavformat/avformat.h
libavformat/version.h

index 4168fc10c637e181f0ba3d9090ea914f602b8614..98f9fdeff871d4156555ca9112cb260310457659 100644 (file)
@@ -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
index df4494a78581da847530d30113ffacb931ed8c15..90b86a8733d6d949a58b20c087c0154ee3683e34 100644 (file)
@@ -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;
     }
index 2567aabd5ac7f809841ac16d129a38a5676b58fc..732756222e7cd5df1835d91b84ae998cadcb3d3d 100644 (file)
@@ -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
index 01730183b211eb47968a7f3fa7d3e412016647a0..04c5d73f50220bd6714ca91e8e253a0b864e9c64 100644 (file)
@@ -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, \