[FFmpeg-devel,1/6] dashdec: Expose bandwidth and representation ID as metadata

Submitted by Steven Liu on Jan. 8, 2018, 2:48 a.m.

Details

Message ID 2AD9AC27-FE59-471E-AB16-0FAB9928B572@chinaffmpeg.org
State Accepted
Commit 66e551eafb8d202f37ba5a2bbe03741966a9e241
Headers show

Commit Message

Steven Liu Jan. 8, 2018, 2:48 a.m.
> On 8 Jan 2018, at 02:46, Stefan _ <sfan5@live.de> wrote:
> 
> <0001-dashdec-Expose-bandwidth-and-representation-ID-as-me.patch>

>From ba640900c260f8b5b1919c4274b2c2e3e57e2546 Mon Sep 17 00:00:00 2001
From: sfan5 <sfan5@live.de>
Date: Thu, 4 Jan 2018 23:45:26 +0100
Subject: [PATCH 1/6] dashdec: Expose bandwidth and representation ID as
 metadata

---
 libavformat/dashdec.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 0e3afd2a3..1a18ab021 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -84,6 +84,8 @@  struct representation {
     int stream_index;
 
     enum AVMediaType type;
+    char id[20];
+    int bandwidth;
 
     int n_fragments;
     struct fragment **fragments; /* VOD list of fragment for profile */
@@ -801,6 +803,8 @@  static int parse_manifest_representation(AVFormatContext *s, const char *url,
         if (rep) {
             if (rep->fragment_duration > 0 && !rep->fragment_timescale)
                 rep->fragment_timescale = 1;
+            rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
+            strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id));
             if (type == AVMEDIA_TYPE_VIDEO) {
                 rep->rep_idx = video_rep_idx;
                 c->cur_video = rep;
@@ -1650,10 +1654,20 @@  static int dash_read_header(AVFormatContext *s)
         }
 
         if (c->cur_video) {
-            av_program_add_stream_index(s, 0, c->cur_video->stream_index);
+            int stream_index = c->cur_video->stream_index;
+            av_program_add_stream_index(s, 0, stream_index);
+            if (c->cur_video->bandwidth > 0)
+                av_dict_set_int(&s->streams[stream_index]->metadata, "variant_bitrate", c->cur_video->bandwidth, 0);
+            if (c->cur_video->id[0])
+                av_dict_set(&s->streams[stream_index]->metadata, "id", c->cur_video->id, 0);
         }
         if (c->cur_audio) {
-            av_program_add_stream_index(s, 0, c->cur_audio->stream_index);
+            int stream_index = c->cur_audio->stream_index;
+            av_program_add_stream_index(s, 0, stream_index);
+            if (c->cur_audio->bandwidth > 0)
+                av_dict_set_int(&s->streams[stream_index]->metadata, "variant_bitrate", c->cur_audio->bandwidth, 0);
+            if (c->cur_audio->id[0])
+                av_dict_set(&s->streams[stream_index]->metadata, "id", c->cur_audio->id, 0);
         }
     }