[vlc-commits] demux: smooth: don't create empty segments list just for init

Francois Cartegnie git at videolan.org
Fri May 24 23:43:18 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 24 17:11:05 2019 +0200| [aa63b8cdea58b6d68c0717dbe1a9e51afdc7393d] | committer: Francois Cartegnie

demux: smooth: don't create empty segments list just for init

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

 .../demux/adaptive/playlist/SegmentInformation.hpp |  2 +-
 modules/demux/smooth/playlist/Parser.cpp           | 89 +++++++++++-----------
 modules/demux/smooth/playlist/Representation.cpp   | 10 +++
 modules/demux/smooth/playlist/Representation.hpp   |  4 +-
 4 files changed, 57 insertions(+), 48 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp
index 2dbedbf6f8..7970ce0e83 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -93,7 +93,7 @@ namespace adaptive
 
             protected:
                 std::size_t getAllSegments(std::vector<ISegment *> &) const;
-                std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&) const;
+                virtual std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&) const;
                 std::vector<SegmentInformation *> childs;
                 SegmentInformation * getChildByID( const ID & );
                 SegmentInformation *parent;
diff --git a/modules/demux/smooth/playlist/Parser.cpp b/modules/demux/smooth/playlist/Parser.cpp
index 85c8d76cfc..ffbe9a63e5 100644
--- a/modules/demux/smooth/playlist/Parser.cpp
+++ b/modules/demux/smooth/playlist/Parser.cpp
@@ -149,67 +149,64 @@ static void ParseQualityLevel(BaseAdaptationSet *adaptSet, Node *qualNode, const
     if(rep)
     {
         rep->setID(ID(id));
-        SegmentList *segmentList = new (std::nothrow) SegmentList(rep);
-        if(segmentList)
-        {
-            if(qualNode->hasAttribute("Bitrate"))
-                rep->setBandwidth(Integer<uint64_t>(qualNode->getAttributeValue("Bitrate")));
 
-            if(qualNode->hasAttribute("MaxWidth"))
-                rep->setWidth(Integer<uint64_t>(qualNode->getAttributeValue("MaxWidth")));
-            else if(qualNode->hasAttribute("Width"))
-                rep->setWidth(Integer<uint64_t>(qualNode->getAttributeValue("Width")));
+        if(qualNode->hasAttribute("Bitrate"))
+            rep->setBandwidth(Integer<uint64_t>(qualNode->getAttributeValue("Bitrate")));
 
-            if(qualNode->hasAttribute("MaxHeight"))
-                rep->setHeight(Integer<uint64_t>(qualNode->getAttributeValue("MaxHeight")));
-            else if(qualNode->hasAttribute("Height"))
-                rep->setHeight(Integer<uint64_t>(qualNode->getAttributeValue("Height")));
+        if(qualNode->hasAttribute("MaxWidth"))
+            rep->setWidth(Integer<uint64_t>(qualNode->getAttributeValue("MaxWidth")));
+        else if(qualNode->hasAttribute("Width"))
+            rep->setWidth(Integer<uint64_t>(qualNode->getAttributeValue("Width")));
 
-            if(qualNode->hasAttribute("FourCC"))
-                rep->addCodecs(qualNode->getAttributeValue("FourCC"));
+        if(qualNode->hasAttribute("MaxHeight"))
+            rep->setHeight(Integer<uint64_t>(qualNode->getAttributeValue("MaxHeight")));
+        else if(qualNode->hasAttribute("Height"))
+            rep->setHeight(Integer<uint64_t>(qualNode->getAttributeValue("Height")));
 
-            ForgedInitSegment *initSegment = new (std::nothrow)
-                    ForgedInitSegment(segmentList, type,
-                                      adaptSet->inheritTimescale(),
-                                      adaptSet->getPlaylist()->duration.Get());
-            if(initSegment)
-            {
-                initSegment->setTrackID(trackid);
+        if(qualNode->hasAttribute("FourCC"))
+            rep->addCodecs(qualNode->getAttributeValue("FourCC"));
+
+        ForgedInitSegment *initSegment = new (std::nothrow)
+                ForgedInitSegment(rep, type,
+                                  adaptSet->inheritTimescale(),
+                                  adaptSet->getPlaylist()->duration.Get());
+        if(initSegment)
+        {
+            initSegment->setTrackID(trackid);
+
+            if(!adaptSet->getLang().empty())
+                initSegment->setLanguage(adaptSet->getLang());
 
-                if(!adaptSet->getLang().empty())
-                    initSegment->setLanguage(adaptSet->getLang());
+            if(rep->getWidth() > 0 && rep->getHeight() > 0)
+                initSegment->setVideoSize(rep->getWidth(), rep->getHeight());
 
-                if(rep->getWidth() > 0 && rep->getHeight() > 0)
-                    initSegment->setVideoSize(rep->getWidth(), rep->getHeight());
+            if(qualNode->hasAttribute("FourCC"))
+                initSegment->setFourCC(qualNode->getAttributeValue("FourCC"));
 
-                if(qualNode->hasAttribute("FourCC"))
-                    initSegment->setFourCC(qualNode->getAttributeValue("FourCC"));
+            if(qualNode->hasAttribute("PacketSize"))
+                initSegment->setPacketSize(Integer<uint16_t>(qualNode->getAttributeValue("PacketSize")));
 
-                if(qualNode->hasAttribute("PacketSize"))
-                    initSegment->setPacketSize(Integer<uint16_t>(qualNode->getAttributeValue("PacketSize")));
+            if(qualNode->hasAttribute("Channels"))
+                initSegment->setChannels(Integer<uint16_t>(qualNode->getAttributeValue("Channels")));
 
-                if(qualNode->hasAttribute("Channels"))
-                    initSegment->setChannels(Integer<uint16_t>(qualNode->getAttributeValue("Channels")));
+            if(qualNode->hasAttribute("SamplingRate"))
+                initSegment->setSamplingRate(Integer<uint32_t>(qualNode->getAttributeValue("SamplingRate")));
 
-                if(qualNode->hasAttribute("SamplingRate"))
-                    initSegment->setSamplingRate(Integer<uint32_t>(qualNode->getAttributeValue("SamplingRate")));
+            if(qualNode->hasAttribute("BitsPerSample"))
+                initSegment->setBitsPerSample(Integer<uint32_t>(qualNode->getAttributeValue("BitsPerSample")));
 
-                if(qualNode->hasAttribute("BitsPerSample"))
-                    initSegment->setBitsPerSample(Integer<uint32_t>(qualNode->getAttributeValue("BitsPerSample")));
+            if(qualNode->hasAttribute("CodecPrivateData"))
+                initSegment->setCodecPrivateData(qualNode->getAttributeValue("CodecPrivateData"));
 
-                if(qualNode->hasAttribute("CodecPrivateData"))
-                    initSegment->setCodecPrivateData(qualNode->getAttributeValue("CodecPrivateData"));
+            if(qualNode->hasAttribute("AudioTag"))
+                initSegment->setAudioTag(Integer<uint16_t>(qualNode->getAttributeValue("AudioTag")));
 
-                if(qualNode->hasAttribute("AudioTag"))
-                    initSegment->setAudioTag(Integer<uint16_t>(qualNode->getAttributeValue("AudioTag")));
+            if(qualNode->hasAttribute("WaveFormatEx"))
+                initSegment->setWaveFormatEx(qualNode->getAttributeValue("WaveFormatEx"));
 
-                if(qualNode->hasAttribute("WaveFormatEx"))
-                    initSegment->setWaveFormatEx(qualNode->getAttributeValue("WaveFormatEx"));
+            initSegment->setSourceUrl("forged://");
 
-                initSegment->setSourceUrl("forged://");
-                segmentList->initialisationSegment.Set(initSegment);
-            }
-            rep->appendSegmentList(segmentList);
+            rep->initialisationSegment.Set(initSegment);
 
             adaptSet->addRepresentation(rep);
         }
diff --git a/modules/demux/smooth/playlist/Representation.cpp b/modules/demux/smooth/playlist/Representation.cpp
index cbae08ed56..9021de5c5c 100644
--- a/modules/demux/smooth/playlist/Representation.cpp
+++ b/modules/demux/smooth/playlist/Representation.cpp
@@ -43,6 +43,16 @@ StreamFormat Representation::getStreamFormat() const
     return StreamFormat(StreamFormat::MP4);
 }
 
+std::size_t Representation::getSegments(SegmentInfoType type, std::vector<ISegment *> &retSegments) const
+{
+    if(type == INFOTYPE_INIT && initialisationSegment.Get())
+    {
+        retSegments.push_back(initialisationSegment.Get());
+        return retSegments.size();
+    }
+    return BaseRepresentation::getSegments(type, retSegments);
+}
+
 std::string Representation::contextualize(size_t number, const std::string &component,
                                           const BaseSegmentTemplate *basetempl) const
 {
diff --git a/modules/demux/smooth/playlist/Representation.hpp b/modules/demux/smooth/playlist/Representation.hpp
index ada12f4d42..fb4087aecb 100644
--- a/modules/demux/smooth/playlist/Representation.hpp
+++ b/modules/demux/smooth/playlist/Representation.hpp
@@ -38,12 +38,14 @@ namespace smooth
         using namespace adaptive;
         using namespace adaptive::playlist;
 
-        class Representation : public BaseRepresentation
+        class Representation : public BaseRepresentation,
+                               public Initializable<Segment>
         {
             public:
                 Representation(BaseAdaptationSet *);
                 virtual ~Representation ();
 
+                virtual std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&) const; /* reimpl */
                 virtual StreamFormat getStreamFormat() const; /* reimpl */
 
                 /* for segment templates */



More information about the vlc-commits mailing list