[vlc-commits] demux: hls: add basic support for init segments

Francois Cartegnie git at videolan.org
Thu Jul 14 19:26:06 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 11 10:57:52 2016 +0200| [3a7ecdede117bf803b0421f2b9410fcfb8a48c00] | committer: Francois Cartegnie

demux: hls: add basic support for init segments

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

 modules/demux/hls/playlist/HLSSegment.cpp |   12 ------------
 modules/demux/hls/playlist/HLSSegment.hpp |    1 -
 modules/demux/hls/playlist/Parser.cpp     |   23 +++++++++++++++++++++++
 modules/demux/hls/playlist/Tags.cpp       |    5 +++++
 modules/demux/hls/playlist/Tags.hpp       |    1 +
 5 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/modules/demux/hls/playlist/HLSSegment.cpp b/modules/demux/hls/playlist/HLSSegment.cpp
index bbd28f8..dd86a0c 100644
--- a/modules/demux/hls/playlist/HLSSegment.cpp
+++ b/modules/demux/hls/playlist/HLSSegment.cpp
@@ -137,18 +137,6 @@ void HLSSegment::setEncryption(SegmentEncryption &enc)
     encryption = enc;
 }
 
-void HLSSegment::debug(vlc_object_t *obj, int indent) const
-{
-    std::stringstream ss;
-    ss.imbue(std::locale("C"));
-    ss << std::string(indent, ' ') << debugName <<
-    " #" << (getSequenceNumber() - Segment::SEQUENCE_FIRST) <<
-    " url=" << getUrlSegment().toString();
-    if(startByte!=endByte)
-        ss << " @" << startByte << ".." << endByte;
-    msg_Dbg(obj, "%s", ss.str().c_str());
-}
-
 int HLSSegment::compare(ISegment *segment) const
 {
     HLSSegment *hlssegment = dynamic_cast<HLSSegment *>(segment);
diff --git a/modules/demux/hls/playlist/HLSSegment.hpp b/modules/demux/hls/playlist/HLSSegment.hpp
index f4c18d7..0957d9d 100644
--- a/modules/demux/hls/playlist/HLSSegment.hpp
+++ b/modules/demux/hls/playlist/HLSSegment.hpp
@@ -55,7 +55,6 @@ namespace hls
                 virtual ~HLSSegment();
                 void setEncryption(SegmentEncryption &);
                 mtime_t getUTCTime() const;
-                void debug(vlc_object_t *, int) const; /* reimpl */
                 virtual int compare(ISegment *) const; /* reimpl */
 
             protected:
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index bc7d1f1..fd044bc 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -332,6 +332,29 @@ void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const s
             }
             break;
 
+            case AttributesTag::EXTXMAP:
+            {
+                const AttributesTag *keytag = static_cast<const AttributesTag *>(tag);
+                const Attribute *uriAttr;
+                if(keytag && (uriAttr = keytag->getAttributeByName("URI")) &&
+                   !segmentList->initialisationSegment.Get()) /* FIXME: handle discontinuities */
+                {
+                    InitSegment *initSegment = new (std::nothrow) InitSegment(rep);
+                    if(initSegment)
+                    {
+                        initSegment->setSourceUrl(uriAttr->quotedString());
+                        const Attribute *byterangeAttr = keytag->getAttributeByName("BYTERANGE");
+                        if(byterangeAttr)
+                        {
+                            const std::pair<std::size_t,std::size_t> range = byterangeAttr->unescapeQuotes().getByteRange();
+                            initSegment->setByteRange(range.first, range.first + range.second - 1);
+                        }
+                        segmentList->initialisationSegment.Set(initSegment);
+                    }
+                }
+            }
+            break;
+
             case Tag::EXTXDISCONTINUITY:
                 discontinuity  = true;
                 break;
diff --git a/modules/demux/hls/playlist/Tags.cpp b/modules/demux/hls/playlist/Tags.cpp
index 6ff0293..f0ef338 100644
--- a/modules/demux/hls/playlist/Tags.cpp
+++ b/modules/demux/hls/playlist/Tags.cpp
@@ -111,6 +111,11 @@ std::pair<int, int> Attribute::getResolution() const
     return std::make_pair(w, h);
 }
 
+Attribute Attribute::unescapeQuotes() const
+{
+    return Attribute(this->name, quotedString());
+}
+
 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 e919513..504c806 100644
--- a/modules/demux/hls/playlist/Tags.hpp
+++ b/modules/demux/hls/playlist/Tags.hpp
@@ -38,6 +38,7 @@ namespace hls
             public:
                 Attribute(const std::string &, const std::string &);
 
+                Attribute unescapeQuotes() const;
                 uint64_t decimal() const;
                 std::string quotedString() const;
                 double floatingPoint() const;



More information about the vlc-commits mailing list