These member will be used for get more correct information of the MPD

Signed-off-by: Steven Liu <l...@chinaffmpeg.org>
---
 libavformat/dashdec.c | 134 +++++++++++++++++++++++++++++++++---------
 1 file changed, 107 insertions(+), 27 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 5bbe5d3985..27d44c2633 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -122,19 +122,17 @@ struct representation {
 typedef struct DASHContext {
     const AVClass *class;
     char *base_url;
-    char *adaptionset_contenttype_val;
-    char *adaptionset_par_val;
-    char *adaptionset_lang_val;
-    char *adaptionset_minbw_val;
-    char *adaptionset_maxbw_val;
-    char *adaptionset_minwidth_val;
-    char *adaptionset_maxwidth_val;
-    char *adaptionset_minheight_val;
-    char *adaptionset_maxheight_val;
-    char *adaptionset_minframerate_val;
-    char *adaptionset_maxframerate_val;
-    char *adaptionset_segmentalignment_val;
-    char *adaptionset_bitstreamswitching_val;
+    char *adaptionset_lang;
+    int64_t adaptionset_minbw;
+    int64_t adaptionset_maxbw;
+    int64_t adaptionset_minwidth;
+    int64_t adaptionset_maxwidth;
+    int64_t adaptionset_minheight;
+    int64_t adaptionset_maxheight;
+    AVRational adaptionset_minframerate;
+    AVRational adaptionset_maxframerate;
+    int adaptionset_segmentalignment;
+    int adaptionset_bitstreamswitching;
 
     int n_videos;
     struct representation **videos;
@@ -1116,6 +1114,90 @@ end:
     return ret;
 }
 
+static int parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr 
adaptionset_node)
+{
+    int ret = 0;
+    DASHContext *c = s->priv_data;
+    char *adaptionset_minbw_val = NULL;
+    char *adaptionset_maxbw_val = NULL;
+    char *adaptionset_minwidth_val = NULL;
+    char *adaptionset_maxwidth_val = NULL;
+    char *adaptionset_minheight_val = NULL;
+    char *adaptionset_maxheight_val = NULL;
+    char *adaptionset_minframerate_val = NULL;
+    char *adaptionset_maxframerate_val = NULL;
+    char *adaptionset_segmentalignment_val = NULL;
+    char *adaptionset_bitstreamswitching_val = NULL;
+
+    if (!adaptionset_node) {
+        av_log(s, AV_LOG_WARNING, "Cannot get AdaptionSet\n");
+        return AVERROR(EINVAL);
+    }
+
+    c->adaptionset_lang = xmlGetProp(adaptionset_node, "lang");
+
+    adaptionset_minbw_val = xmlGetProp(adaptionset_node, "minBandwidth");
+    if (adaptionset_minbw_val) {
+        c->adaptionset_minbw = (int64_t) strtoll(adaptionset_minbw_val, NULL, 
10);
+        xmlFree(adaptionset_minbw_val);
+    }
+    adaptionset_maxbw_val = xmlGetProp(adaptionset_node, "maxBandwidth");
+    if (adaptionset_maxbw_val) {
+        c->adaptionset_maxbw = (int64_t) strtoll(adaptionset_maxbw_val, NULL, 
10);
+        xmlFree(adaptionset_maxbw_val);
+    }
+    adaptionset_minwidth_val = xmlGetProp(adaptionset_node, "minWidth");
+    if (adaptionset_minwidth_val) {
+        c->adaptionset_minwidth = (int64_t) strtoll(adaptionset_minwidth_val, 
NULL, 10);
+        xmlFree(adaptionset_minwidth_val);
+    }
+    adaptionset_maxwidth_val = xmlGetProp(adaptionset_node, "maxWidth");
+    if (adaptionset_maxwidth_val) {
+        c->adaptionset_maxwidth = (int64_t) strtoll(adaptionset_maxwidth_val, 
NULL, 10);
+        xmlFree(adaptionset_maxwidth_val);
+    }
+    adaptionset_minheight_val = xmlGetProp(adaptionset_node, "minHeight");
+    if (adaptionset_minheight_val) {
+        c->adaptionset_minheight = (int64_t) strtoll(adaptionset_maxwidth_val, 
NULL, 10);
+        xmlFree(adaptionset_minheight_val);
+    }
+    adaptionset_maxheight_val = xmlGetProp(adaptionset_node, "maxHeight");
+    if (adaptionset_maxheight_val) {
+        c->adaptionset_maxheight = (int64_t) 
strtoll(adaptionset_maxheight_val, NULL, 10);
+        xmlFree(adaptionset_maxheight_val);
+    }
+    adaptionset_minframerate_val = xmlGetProp(adaptionset_node, 
"minFrameRate");
+    if (adaptionset_minframerate_val) {
+        ret = av_parse_video_rate(&c->adaptionset_minframerate, 
adaptionset_minframerate_val);
+        xmlFree(adaptionset_minframerate_val);
+        if (ret < 0)
+            av_log(s, AV_LOG_VERBOSE, "Ignoring invalid min frame rate 
'%s'\n", adaptionset_minframerate_val);
+    }
+    adaptionset_maxframerate_val = xmlGetProp(adaptionset_node, 
"maxFrameRate");
+    if (adaptionset_maxframerate_val) {
+        ret = av_parse_video_rate(&c->adaptionset_maxframerate, 
adaptionset_maxframerate_val);
+        xmlFree(adaptionset_maxframerate_val);
+        if (ret < 0)
+            av_log(s, AV_LOG_VERBOSE, "Ignoring invalid max frame rate 
'%s'\n", adaptionset_maxframerate_val);
+    }
+    adaptionset_segmentalignment_val = xmlGetProp(adaptionset_node, 
"segmentAlignment");
+    if (adaptionset_segmentalignment_val) {
+        c->adaptionset_segmentalignment = 0;
+        if (!av_strcasecmp(adaptionset_segmentalignment_val, "true"))
+            c->adaptionset_segmentalignment = 1;
+        xmlFree(adaptionset_segmentalignment_val);
+    }
+    adaptionset_bitstreamswitching_val = xmlGetProp(adaptionset_node, 
"bitstreamSwitching");
+    if (adaptionset_bitstreamswitching_val) {
+        c->adaptionset_bitstreamswitching = 0;
+        if (!av_strcasecmp(adaptionset_bitstreamswitching_val, "true"))
+            c->adaptionset_bitstreamswitching = 1;
+        xmlFree(adaptionset_bitstreamswitching_val);
+    }
+
+    return ret;
+}
+
 static int parse_manifest_adaptationset(AVFormatContext *s, const char *url,
                                         xmlNodePtr adaptionset_node,
                                         xmlNodePtr mpd_baseurl_node,
@@ -1124,26 +1206,16 @@ static int parse_manifest_adaptationset(AVFormatContext 
*s, const char *url,
                                         xmlNodePtr period_segmentlist_node)
 {
     int ret = 0;
-    DASHContext *c = s->priv_data;
     xmlNodePtr fragment_template_node = NULL;
     xmlNodePtr content_component_node = NULL;
     xmlNodePtr adaptionset_baseurl_node = NULL;
     xmlNodePtr adaptionset_segmentlist_node = NULL;
     xmlNodePtr adaptionset_supplementalproperty_node = NULL;
     xmlNodePtr node = NULL;
-    c->adaptionset_contenttype_val = xmlGetProp(adaptionset_node, 
"contentType");
-    c->adaptionset_par_val = xmlGetProp(adaptionset_node, "par");
-    c->adaptionset_lang_val = xmlGetProp(adaptionset_node, "lang");
-    c->adaptionset_minbw_val = xmlGetProp(adaptionset_node, "minBandwidth");
-    c->adaptionset_maxbw_val = xmlGetProp(adaptionset_node, "maxBandwidth");
-    c->adaptionset_minwidth_val = xmlGetProp(adaptionset_node, "minWidth");
-    c->adaptionset_maxwidth_val = xmlGetProp(adaptionset_node, "maxWidth");
-    c->adaptionset_minheight_val = xmlGetProp(adaptionset_node, "minHeight");
-    c->adaptionset_maxheight_val = xmlGetProp(adaptionset_node, "maxHeight");
-    c->adaptionset_minframerate_val = xmlGetProp(adaptionset_node, 
"minFrameRate");
-    c->adaptionset_maxframerate_val = xmlGetProp(adaptionset_node, 
"maxFrameRate");
-    c->adaptionset_segmentalignment_val = xmlGetProp(adaptionset_node, 
"segmentAlignment");
-    c->adaptionset_bitstreamswitching_val = xmlGetProp(adaptionset_node, 
"bitstreamSwitching");
+
+    ret = parse_manifest_adaptationset_attr(s, adaptionset_node);
+    if (ret < 0)
+        return ret;
 
     node = xmlFirstElementChild(adaptionset_node);
     while (node) {
@@ -2148,6 +2220,10 @@ static int dash_read_header(AVFormatContext *s)
                 av_dict_set_int(&rep->assoc_stream->metadata, 
"variant_bitrate", rep->bandwidth, 0);
             if (rep->id[0])
                 av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
+            if (c->adaptionset_lang) {
+                av_dict_set(&rep->assoc_stream->metadata, "lang", 
c->adaptionset_lang, 0);
+                xmlFree(c->adaptionset_lang);
+            }
         }
         for (i = 0; i < c->n_subtitles; i++) {
             rep = c->subtitles[i];
@@ -2155,6 +2231,10 @@ static int dash_read_header(AVFormatContext *s)
             rep->assoc_stream = s->streams[rep->stream_index];
             if (rep->id[0])
                 av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
+            if (c->adaptionset_lang) {
+                av_dict_set(&rep->assoc_stream->metadata, "lang", 
c->adaptionset_lang, 0);
+                xmlFree(c->adaptionset_lang);
+            }
         }
     }
 
-- 
2.25.0



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to