[vlc-commits] demux: adaptive: fix smooth template overloading

Francois Cartegnie git at videolan.org
Wed Jan 6 20:27:02 UTC 2021


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan  5 22:20:38 2021 +0100| [0e1610fa42fd9cb9843e1347c7e994bdcdaee144] | committer: Francois Cartegnie

demux: adaptive: fix smooth template overloading

regression by refactoring changes in b15abfbf556c53b23a6bd86d3fd4ac4a4accec7d

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

 modules/demux/adaptive/playlist/SegmentTemplate.cpp | 16 +++++++++++-----
 modules/demux/adaptive/playlist/SegmentTemplate.h   |  5 +++--
 modules/demux/dash/mpd/IsoffMainParser.cpp          |  2 +-
 modules/demux/smooth/playlist/Parser.cpp            |  2 +-
 modules/demux/smooth/playlist/SmoothSegment.cpp     |  9 +++++----
 modules/demux/smooth/playlist/SmoothSegment.hpp     |  8 ++++----
 6 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentTemplate.cpp b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
index 64907ff248..2bef4b3d40 100644
--- a/modules/demux/adaptive/playlist/SegmentTemplate.cpp
+++ b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
@@ -31,13 +31,12 @@
 
 using namespace adaptive::playlist;
 
-SegmentTemplateSegment::SegmentTemplateSegment( SegmentTemplate *templ_,
-                                                ICanonicalUrl *parent ) :
+SegmentTemplateSegment::SegmentTemplateSegment( ICanonicalUrl *parent ) :
     Segment( parent )
 {
     debugName = "SegmentTemplateSegment";
     templated = true;
-    templ = templ_;
+    templ = nullptr;
 }
 
 SegmentTemplateSegment::~SegmentTemplateSegment()
@@ -50,12 +49,19 @@ void SegmentTemplateSegment::setSourceUrl(const std::string &url)
     sourceUrl = Url(Url::Component(url, templ));
 }
 
-SegmentTemplate::SegmentTemplate( SegmentInformation *parent ) :
+void SegmentTemplateSegment::setParentTemplate( SegmentTemplate *templ_ )
+{
+    templ = templ_;
+}
+
+SegmentTemplate::SegmentTemplate( SegmentTemplateSegment *seg, SegmentInformation *parent ) :
     AbstractMultipleSegmentBaseType( parent, AbstractAttr::Type::SegmentTemplate )
 {
     initialisationSegment.Set( nullptr );
     parentSegmentInformation = parent;
-    virtualsegment = new SegmentTemplateSegment( this, parent );
+    virtualsegment = seg;
+    virtualsegment->setParent( parentSegmentInformation );
+    virtualsegment->setParentTemplate( this );
 }
 
 SegmentTemplate::~SegmentTemplate()
diff --git a/modules/demux/adaptive/playlist/SegmentTemplate.h b/modules/demux/adaptive/playlist/SegmentTemplate.h
index e55ead23b7..63f2a107fc 100644
--- a/modules/demux/adaptive/playlist/SegmentTemplate.h
+++ b/modules/demux/adaptive/playlist/SegmentTemplate.h
@@ -39,9 +39,10 @@ namespace adaptive
         class SegmentTemplateSegment : public Segment
         {
             public:
-                SegmentTemplateSegment( SegmentTemplate *, ICanonicalUrl * = nullptr );
+                SegmentTemplateSegment( ICanonicalUrl * = nullptr );
                 virtual ~SegmentTemplateSegment();
                 virtual void setSourceUrl( const std::string &url ); /* reimpl */
+                void setParentTemplate( SegmentTemplate * );
 
             protected:
                 const SegmentTemplate *templ;
@@ -50,7 +51,7 @@ namespace adaptive
         class SegmentTemplate : public AbstractMultipleSegmentBaseType
         {
             public:
-                SegmentTemplate( SegmentInformation * = nullptr );
+                SegmentTemplate( SegmentTemplateSegment *, SegmentInformation * = nullptr );
                 virtual ~SegmentTemplate();
                 void setSourceUrl( const std::string &url );
                 uint64_t getLiveTemplateNumber(vlc_tick_t, bool = true) const;
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index d191e3fad5..bf9087e0cf 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -237,7 +237,7 @@ size_t IsoffMainParser::parseSegmentTemplate(MPD *mpd, Node *templateNode, Segme
     if(templateNode->hasAttribute("media"))
         mediaurl = templateNode->getAttributeValue("media");
 
-    SegmentTemplate *mediaTemplate = new (std::nothrow) SegmentTemplate(info);
+    SegmentTemplate *mediaTemplate = new (std::nothrow) SegmentTemplate(new SegmentTemplateSegment(), info);
     if(!mediaTemplate)
         return total;
     mediaTemplate->setSourceUrl(mediaurl);
diff --git a/modules/demux/smooth/playlist/Parser.cpp b/modules/demux/smooth/playlist/Parser.cpp
index 23471e2743..387fe8a9bc 100644
--- a/modules/demux/smooth/playlist/Parser.cpp
+++ b/modules/demux/smooth/playlist/Parser.cpp
@@ -237,7 +237,7 @@ static void ParseStreamIndex(BasePeriod *period, Node *streamIndexNode, unsigned
         if(!url.empty())
         {
             /* SmoothSegment is a template holder */
-            SmoothSegmentTemplate *templ = new SmoothSegmentTemplate(adaptSet);
+            SegmentTemplate *templ = new SegmentTemplate(new SmoothSegmentTemplateSegment(), adaptSet);
             if(templ)
             {
                 templ->setSourceUrl(url);
diff --git a/modules/demux/smooth/playlist/SmoothSegment.cpp b/modules/demux/smooth/playlist/SmoothSegment.cpp
index 706db863e8..e04bdefc0a 100644
--- a/modules/demux/smooth/playlist/SmoothSegment.cpp
+++ b/modules/demux/smooth/playlist/SmoothSegment.cpp
@@ -64,19 +64,20 @@ void SmoothSegmentChunk::onDownload(block_t **pp_block)
     }
 }
 
-SmoothSegmentTemplate::SmoothSegmentTemplate(SegmentInformation *parent) :
-    SegmentTemplate( parent )
+SmoothSegmentTemplateSegment::SmoothSegmentTemplateSegment(ICanonicalUrl *parent)
+    : SegmentTemplateSegment(parent)
 {
 
 }
 
-SmoothSegmentTemplate::~SmoothSegmentTemplate()
+SmoothSegmentTemplateSegment::~SmoothSegmentTemplateSegment()
 {
 
 }
 
-SegmentChunk* SmoothSegmentTemplate::createChunk(AbstractChunkSource *source, BaseRepresentation *rep)
+SegmentChunk* SmoothSegmentTemplateSegment::createChunk(AbstractChunkSource *source, BaseRepresentation *rep)
 {
      /* act as factory */
     return new (std::nothrow) SmoothSegmentChunk(source, rep);
 }
+
diff --git a/modules/demux/smooth/playlist/SmoothSegment.hpp b/modules/demux/smooth/playlist/SmoothSegment.hpp
index a04f65b4a2..6eda4e7b5c 100644
--- a/modules/demux/smooth/playlist/SmoothSegment.hpp
+++ b/modules/demux/smooth/playlist/SmoothSegment.hpp
@@ -33,15 +33,15 @@ namespace smooth
         {
             public:
                 SmoothSegmentChunk(AbstractChunkSource *, BaseRepresentation *);
-                ~SmoothSegmentChunk();
+                virtual ~SmoothSegmentChunk();
                 virtual void onDownload(block_t **); /* reimpl */
         };
 
-        class SmoothSegmentTemplate : public SegmentTemplate
+        class SmoothSegmentTemplateSegment : public SegmentTemplateSegment
         {
             public:
-                SmoothSegmentTemplate(SegmentInformation * = nullptr);
-                ~SmoothSegmentTemplate();
+                SmoothSegmentTemplateSegment( ICanonicalUrl * = nullptr );
+                virtual ~SmoothSegmentTemplateSegment();
                 virtual SegmentChunk* createChunk(AbstractChunkSource *, BaseRepresentation *); /* reimpl */
         };
     }



More information about the vlc-commits mailing list