[vlc-commits] demux: hls: use probed format only

Francois Cartegnie git at videolan.org
Fri May 17 20:34:55 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May 13 18:15:25 2019 +0200| [a047b31b978e4a3bd86b3c1a8f7dec9281d1a056] | committer: Francois Cartegnie

demux: hls: use probed format only

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

 modules/demux/adaptive/SegmentTracker.cpp |  6 +++---
 modules/demux/adaptive/Streams.cpp        |  2 +-
 modules/demux/hls/HLSStreams.cpp          |  4 ++--
 modules/demux/hls/playlist/Parser.cpp     | 32 -------------------------------
 modules/demux/hls/playlist/Parser.hpp     |  1 -
 5 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 9e835c1c15..be7554aee1 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -88,7 +88,7 @@ SegmentTracker::SegmentTracker(SharedResources *res,
     curRepresentation = NULL;
     setAdaptationLogic(logic_);
     adaptationSet = adaptSet;
-    format = StreamFormat::UNSUPPORTED;
+    format = StreamFormat::UNKNOWN;
 }
 
 SegmentTracker::~SegmentTracker()
@@ -134,7 +134,7 @@ void SegmentTracker::reset()
     init_sent = false;
     index_sent = false;
     initializing = true;
-    format = StreamFormat::UNSUPPORTED;
+    format = StreamFormat::UNKNOWN;
 }
 
 SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
@@ -201,7 +201,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
     if(rep->getStreamFormat() != format)
     {
         /* Initial format ? */
-        if(format == StreamFormat(StreamFormat::UNSUPPORTED))
+        if(format == StreamFormat(StreamFormat::UNKNOWN))
         {
             format = rep->getStreamFormat();
         }
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index e477ef4c35..dda8c101f6 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -42,7 +42,7 @@ using namespace adaptive::http;
 AbstractStream::AbstractStream(demux_t * demux_)
 {
     p_realdemux = demux_;
-    format = StreamFormat::UNSUPPORTED;
+    format = StreamFormat::UNKNOWN;
     currentChunk = NULL;
     eof = false;
     valid = true;
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 7d01f80b55..7bd90c885c 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -163,11 +163,11 @@ AbstractDemuxer *HLSStream::newDemux(demux_t *p_realdemux, const StreamFormat &f
     return ret;
 }
 
-AbstractStream * HLSStreamFactory::create(demux_t *realdemux, const StreamFormat &,
+AbstractStream * HLSStreamFactory::create(demux_t *realdemux, const StreamFormat &format,
                                SegmentTracker *tracker, AbstractConnectionManager *manager) const
 {
     HLSStream *stream = new (std::nothrow) HLSStream(realdemux);
-    if(stream && !stream->init(StreamFormat(StreamFormat::UNKNOWN), tracker, manager))
+    if(stream && !stream->init(format, tracker, manager))
     {
         delete stream;
         return NULL;
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index dd60b46275..9e990d9c3f 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -87,36 +87,6 @@ static void releaseTagsList(std::list<Tag *> &list)
     list.clear();
 }
 
-void M3U8Parser::setFormatFromExtension(Representation *rep, const std::string &filename)
-{
-    std::size_t pos = filename.find_last_of('.');
-    if(pos != std::string::npos)
-    {
-        std::string extension = Helper::getFileExtension(filename);
-        transform(extension.begin(), extension.end(), extension.begin(), (int (*)(int))std::tolower);
-        if(extension == "aac")
-        {
-            rep->streamFormat = StreamFormat(StreamFormat::PACKEDAAC);
-        }
-        else if(extension == "ts" || extension == "mp2t" || extension == "mpeg" || extension == "m2ts")
-        {
-            rep->streamFormat = StreamFormat(StreamFormat::MPEG2TS);
-        }
-        else if(extension == "mp4" || extension == "m4s" || extension == "mov" || extension == "m4v")
-        {
-            rep->streamFormat = StreamFormat(StreamFormat::MP4);
-        }
-        else if(extension == "vtt" || extension == "wvtt" || extension == "webvtt")
-        {
-            rep->streamFormat = StreamFormat(StreamFormat::WEBVTT);
-        }
-        else
-        {
-            rep->streamFormat = StreamFormat(StreamFormat::UNKNOWN);
-        }
-    }
-}
-
 Representation * M3U8Parser::createRepresentation(BaseAdaptationSet *adaptSet, const AttributesTag * tag)
 {
     const Attribute *uriAttr = tag->getAttributeByName("URI");
@@ -293,8 +263,6 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
                     break;
 
                 segment->setSourceUrl(uritag->getValue().value);
-                if((unsigned)rep->getStreamFormat() == StreamFormat::UNKNOWN)
-                    setFormatFromExtension(rep, uritag->getValue().value);
 
                 /* Need to use EXTXTARGETDURATION as default as some can't properly set segment one */
                 double duration = rep->targetDuration;
diff --git a/modules/demux/hls/playlist/Parser.hpp b/modules/demux/hls/playlist/Parser.hpp
index 8582184969..5b98704a0c 100644
--- a/modules/demux/hls/playlist/Parser.hpp
+++ b/modules/demux/hls/playlist/Parser.hpp
@@ -65,7 +65,6 @@ namespace hls
                 void createAndFillRepresentation(vlc_object_t *, BaseAdaptationSet *,
                                                  const AttributesTag *, const std::list<Tag *>&);
                 void parseSegments(vlc_object_t *, Representation *, const std::list<Tag *>&);
-                void setFormatFromExtension(Representation *rep, const std::string &);
                 std::list<Tag *> parseEntries(stream_t *);
                 adaptive::SharedResources *resources;
         };



More information about the vlc-commits mailing list