[vlc-commits] demux: dash: parse language

Francois Cartegnie git at videolan.org
Sat Jul 25 22:30:46 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Jul 25 19:36:14 2015 +0200| [07fb2c8825f227564de30492e23c18645802198d] | committer: Francois Cartegnie

demux: dash: parse language

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

 modules/demux/adaptative/PlaylistManager.cpp |   15 +++++++++++++++
 modules/demux/dash/mpd/IsoffMainParser.cpp   |   10 ++++++++++
 2 files changed, 25 insertions(+)

diff --git a/modules/demux/adaptative/PlaylistManager.cpp b/modules/demux/adaptative/PlaylistManager.cpp
index fae117b..32c251d 100644
--- a/modules/demux/adaptative/PlaylistManager.cpp
+++ b/modules/demux/adaptative/PlaylistManager.cpp
@@ -28,6 +28,7 @@
 #include "playlist/AbstractPlaylist.hpp"
 #include "playlist/BasePeriod.h"
 #include "playlist/BaseAdaptationSet.h"
+#include "playlist/BaseRepresentation.h"
 #include "http/HTTPConnectionManager.h"
 #include "logic/AlwaysBestAdaptationLogic.h"
 #include "logic/RateBasedAdaptationLogic.h"
@@ -102,6 +103,20 @@ bool PlaylistManager::setupPeriod()
                     delete logic;
                     throw VLC_ENOMEM;
                 }
+
+                std::list<std::string> languages;
+                if(!set->getLang().empty())
+                {
+                    languages = set->getLang();
+                }
+                else if(!set->getRepresentations().empty())
+                {
+                    languages = set->getRepresentations().front()->getLang();
+                }
+
+                if(!languages.empty())
+                    st->setLanguage(languages.front());
+
                 st->create(logic, tracker, streamOutputFactory);
                 streams.push_back(st);
             } catch (int) {
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index c4e665e..cf81742 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -225,6 +225,16 @@ void    IsoffMainParser::setAdaptationSets  (Node *periodNode, Period *period)
         if((*it)->hasAttribute("mimeType"))
             adaptationSet->setMimeType((*it)->getAttributeValue("mimeType"));
 
+        if((*it)->hasAttribute("lang"))
+        {
+            std::string lang = (*it)->getAttributeValue("lang");
+            std::size_t pos = lang.find_first_of('-');
+            if(pos != std::string::npos && pos > 0)
+                adaptationSet->addLang(lang.substr(0, pos));
+            else if (lang.size() < 4)
+                adaptationSet->addLang(lang);
+        }
+
         Node *baseUrl = DOMHelper::getFirstChildElementByName((*it), "BaseURL");
         if(baseUrl)
             adaptationSet->baseUrl.Set(new Url(baseUrl->getText()));



More information about the vlc-commits mailing list