[vlc-commits] demux: adaptative: parse hls resolution

Francois Cartegnie git at videolan.org
Thu Aug 6 17:30:19 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Aug  2 01:46:35 2015 +0200| [fe955928ba92a5f5181dd4a2f9231b5b028024b9] | committer: Francois Cartegnie

demux: adaptative: parse hls resolution

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

 modules/demux/hls/playlist/Parser.cpp |   11 +++++++++++
 modules/demux/hls/playlist/Tags.cpp   |   19 +++++++++++++++++++
 modules/demux/hls/playlist/Tags.hpp   |    1 +
 3 files changed, 31 insertions(+)

diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 8c16b86..fe6caf0 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -120,6 +120,7 @@ void Parser::parseRepresentation(BaseAdaptationSet *adaptSet, const AttributesTa
     const Attribute *uriAttr = tag->getAttributeByName("URI");
     const Attribute *bwAttr = tag->getAttributeByName("BANDWIDTH");
     const Attribute *codecsAttr = tag->getAttributeByName("CODECS");
+    const Attribute *resAttr = tag->getAttributeByName("RESOLUTION");
 
     Representation *rep = new (std::nothrow) Representation(adaptSet);
     if(rep)
@@ -147,6 +148,16 @@ void Parser::parseRepresentation(BaseAdaptationSet *adaptSet, const AttributesTa
         if(codecsAttr && codecsAttr->quotedString().find(',') != std::string::npos)
             rep->setMimeType("video/mp2t");
 
+        if(resAttr)
+        {
+            std::pair<int, int> res = resAttr->getResolution();
+            if(res.first * res.second)
+            {
+                rep->setWidth(res.first);
+                rep->setHeight(res.second);
+            }
+        }
+
         parseSegments(rep, tagslist);
 
         adaptSet->addRepresentation(rep);
diff --git a/modules/demux/hls/playlist/Tags.cpp b/modules/demux/hls/playlist/Tags.cpp
index 30dca03..eb06500 100644
--- a/modules/demux/hls/playlist/Tags.cpp
+++ b/modules/demux/hls/playlist/Tags.cpp
@@ -89,6 +89,25 @@ std::pair<std::size_t,std::size_t> Attribute::getByteRange() const
     return ret;
 }
 
+std::pair<int, int> Attribute::getResolution() const
+{
+    int w = 0, h = 0;
+
+    std::istringstream is(value);
+    if(!is.eof())
+    {
+        is >> w;
+        if(!is.eof())
+        {
+            char c = is.get();
+            if(c == 'x' && !is.eof())
+                is >> h;
+        }
+    }
+
+    return std::make_pair(w, h);
+}
+
 std::string Attribute::quotedString() const
 {
     if(value.length() < 2)
diff --git a/modules/demux/hls/playlist/Tags.hpp b/modules/demux/hls/playlist/Tags.hpp
index 229f0db..c7cacaa 100644
--- a/modules/demux/hls/playlist/Tags.hpp
+++ b/modules/demux/hls/playlist/Tags.hpp
@@ -47,6 +47,7 @@ namespace hls
                 double floatingPoint() const;
                 std::vector<uint8_t> hexSequence() const;
                 std::pair<std::size_t,std::size_t> getByteRange() const;
+                std::pair<int, int> getResolution() const;
 
                 std::string name;
                 std::string value;



More information about the vlc-commits mailing list