[vlc-commits] dash: Try to fetch mimeType attribute from the parent element.

Hugo Beauzée-Luyssen git at videolan.org
Tue Jan 24 23:21:55 CET 2012


vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Dec 28 17:30:13 2011 +0100| [41f7cecbe29a0c91480fd2ea8859d927b43f66ec] | committer: Jean-Baptiste Kempf

dash: Try to fetch mimeType attribute from the parent element.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 9caf4cee157920d0f27fda86d9fe411a625a3173)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_filter/dash/mpd/BasicCMParser.cpp |   15 ++++++++++-----
 modules/stream_filter/dash/mpd/BasicCMParser.h   |    4 +++-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index dde4c9d..c1db5ad 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -150,7 +150,7 @@ void    BasicCMParser::setGroups            (Node *root, Period *period)
     for(size_t i = 0; i < groups.size(); i++)
     {
         Group *group = new Group(groups.at(i)->getAttributes());
-        if ( this->parseCommonAttributesElements( groups.at( i ), group ) == false )
+        if ( this->parseCommonAttributesElements( groups.at( i ), group, NULL ) == false )
         {
             delete group;
             continue ;
@@ -169,7 +169,7 @@ void    BasicCMParser::setRepresentations   (Node *root, Group *group)
         const std::map<std::string, std::string>    attributes = representations.at(i)->getAttributes();
 
         Representation *rep = new Representation( attributes );
-        if ( this->parseCommonAttributesElements( representations.at( i ), rep ) == false )
+        if ( this->parseCommonAttributesElements( representations.at( i ), rep, group ) == false )
         {
             delete rep;
             continue ;
@@ -351,7 +351,7 @@ void BasicCMParser::parseContentDescriptor(Node *node, const std::string &name,
     }
 }
 
-bool    BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttributesElements *common) const
+bool    BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttributesElements *common, CommonAttributesElements *parent ) const
 {
     const std::map<std::string, std::string>                &attr = node->getAttributes();
     std::map<std::string, std::string>::const_iterator      it;
@@ -359,8 +359,13 @@ bool    BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttribut
     it = attr.find( "mimeType" );
     if ( it == attr.end() )
     {
-        std::cerr << "Missing mandatory attribute: @mimeType" << std::endl;
-        return false;
+        if ( parent && parent->getMimeType().empty() == false )
+            common->setMimeType( parent->getMimeType() );
+        else
+        {
+            std::cerr << "Missing mandatory attribute: @mimeType" << std::endl;
+            return false;
+        }
     }
     common->setMimeType( it->second );
     //Everything else is optionnal.
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index 9033e13..fbf808d 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -67,7 +67,9 @@ namespace dash
                 void    parseContentDescriptor( xml::Node *node, const std::string &name,
                                                 void (CommonAttributesElements::*addPtr)(ContentDescription*),
                                                 CommonAttributesElements *self ) const;
-                bool    parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
+                bool    parseCommonAttributesElements( dash::xml::Node *node,
+                                                       CommonAttributesElements *common,
+                                                       CommonAttributesElements *parent ) const;
                 bool    parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
                 ProgramInformation*     parseProgramInformation();
         };



More information about the vlc-commits mailing list