[vlc-commits] demux: dash: refactor reading common attribute elements

Francois Cartegnie git at videolan.org
Thu Feb 25 10:03:37 UTC 2021


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 23 17:14:46 2021 +0100| [f65d50e1e8794f5db734ab202ece71ce527fb509] | committer: Francois Cartegnie

demux: dash: refactor reading common attribute elements

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f65d50e1e8794f5db734ab202ece71ce527fb509
---

 modules/demux/dash/mpd/IsoffMainParser.cpp | 27 +++++++++++++++++----------
 modules/demux/dash/mpd/IsoffMainParser.h   |  2 ++
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index bf9087e0cf..62257fa902 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -294,8 +294,8 @@ void    IsoffMainParser::parseAdaptationSets  (MPD *mpd, Node *periodNode, BaseP
         AdaptationSet *adaptationSet = new AdaptationSet(period);
         if(!adaptationSet)
             continue;
-        if((*it)->hasAttribute("mimeType"))
-            adaptationSet->setMimeType((*it)->getAttributeValue("mimeType"));
+
+        parseCommonAttributesElements(*it, adaptationSet);
 
         if((*it)->hasAttribute("lang"))
             adaptationSet->setLang((*it)->getAttributeValue("lang"));
@@ -353,6 +353,20 @@ void    IsoffMainParser::parseAdaptationSets  (MPD *mpd, Node *periodNode, BaseP
             delete adaptationSet;
     }
 }
+
+void IsoffMainParser::parseCommonAttributesElements(Node *node,
+                                                    CommonAttributesElements *commonAttrElements)
+{
+    if(node->hasAttribute("width"))
+        commonAttrElements->setWidth(atoi(node->getAttributeValue("width").c_str()));
+
+    if(node->hasAttribute("height"))
+        commonAttrElements->setHeight(atoi(node->getAttributeValue("height").c_str()));
+
+    if(node->hasAttribute("mimeType"))
+        commonAttrElements->setMimeType(node->getAttributeValue("mimeType"));
+}
+
 void    IsoffMainParser::parseRepresentations (MPD *mpd, Node *adaptationSetNode, AdaptationSet *adaptationSet)
 {
     std::vector<Node *> representations = DOMHelper::getElementByTagName(adaptationSetNode, "Representation", false);
@@ -373,18 +387,11 @@ void    IsoffMainParser::parseRepresentations (MPD *mpd, Node *adaptationSetNode
         if(repNode->hasAttribute("id"))
             currentRepresentation->setID(ID(repNode->getAttributeValue("id")));
 
-        if(repNode->hasAttribute("width"))
-            currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str()));
-
-        if(repNode->hasAttribute("height"))
-            currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str()));
+        parseCommonAttributesElements(repNode, currentRepresentation);
 
         if(repNode->hasAttribute("bandwidth"))
             currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str()));
 
-        if(repNode->hasAttribute("mimeType"))
-            currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType"));
-
         if(repNode->hasAttribute("codecs"))
             currentRepresentation->addCodecs(repNode->getAttributeValue("codecs"));
 
diff --git a/modules/demux/dash/mpd/IsoffMainParser.h b/modules/demux/dash/mpd/IsoffMainParser.h
index df40796604..51b4a67434 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.h
+++ b/modules/demux/dash/mpd/IsoffMainParser.h
@@ -43,6 +43,7 @@ namespace adaptive
         class SegmentInformation;
         class SegmentTemplate;
         class BasePeriod;
+        class CommonAttributesElements;
     }
     namespace xml
     {
@@ -88,6 +89,7 @@ namespace dash
                 void    parseMultipleSegmentBaseType(MPD *mpd, xml::Node *node,
                                              AbstractMultipleSegmentBaseType *base,
                                              SegmentInformation *parent);
+                void    parseCommonAttributesElements(xml::Node *, CommonAttributesElements *);
 
                 xml::Node       *root;
                 vlc_object_t    *p_object;



More information about the vlc-commits mailing list