[vlc-commits] demux: adaptive: merge toChunk/getChunk

Francois Cartegnie git at videolan.org
Fri Jun 10 17:16:13 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun  1 11:37:48 2016 +0200| [5e2ee2536a1cc6b3a53858b032fa891863d33418] | committer: Francois Cartegnie

demux: adaptive: merge toChunk/getChunk

AbstractChunk no longer segment chunk

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

 modules/demux/adaptive/playlist/Segment.cpp        |   39 +++++++++-----------
 modules/demux/adaptive/playlist/Segment.h          |    2 -
 .../demux/smooth/playlist/ForgedInitSegment.cpp    |   12 ++++--
 .../demux/smooth/playlist/ForgedInitSegment.hpp    |    4 +-
 4 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/modules/demux/adaptive/playlist/Segment.cpp b/modules/demux/adaptive/playlist/Segment.cpp
index d9e77f4..03f5efa 100644
--- a/modules/demux/adaptive/playlist/Segment.cpp
+++ b/modules/demux/adaptive/playlist/Segment.cpp
@@ -61,35 +61,32 @@ ISegment::~ISegment()
     assert(chunksuse.Get() == 0);
 }
 
-SegmentChunk * ISegment::getChunk(const std::string &url, BaseRepresentation *rep, HTTPConnectionManager *connManager)
-{
-    HTTPChunkBufferedSource *source = new HTTPChunkBufferedSource(url, connManager);
-    if(startByte != endByte)
-        source->setBytesRange(BytesRange(startByte, endByte));
-    connManager->downloader->schedule(source);
-    return new (std::nothrow) SegmentChunk(this, source, rep);
-}
-
 void ISegment::onChunkDownload(block_t **, SegmentChunk *, BaseRepresentation *)
 {
 
 }
 
-SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *ctxrep, HTTPConnectionManager *connManager)
+SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *rep, HTTPConnectionManager *connManager)
 {
-    SegmentChunk *chunk;
-    try
+    const std::string url = getUrlSegment().toString(index, rep);
+    HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager);
+    if( source )
     {
-        chunk = getChunk(getUrlSegment().toString(index, ctxrep), ctxrep, connManager);
-        if (!chunk)
-            return NULL;
+        if(startByte != endByte)
+            source->setBytesRange(BytesRange(startByte, endByte));
+
+        SegmentChunk *chunk = new (std::nothrow) SegmentChunk(this, source, rep);
+        if( chunk )
+        {
+            connManager->downloader->schedule(source);
+            return chunk;
+        }
+        else
+        {
+            delete source;
+        }
     }
-    catch (int)
-    {
-        return NULL;
-    };
-
-    return chunk;
+    return NULL;
 }
 
 bool ISegment::isTemplate() const
diff --git a/modules/demux/adaptive/playlist/Segment.h b/modules/demux/adaptive/playlist/Segment.h
index 7d0b0da..db24acd 100644
--- a/modules/demux/adaptive/playlist/Segment.h
+++ b/modules/demux/adaptive/playlist/Segment.h
@@ -88,8 +88,6 @@ namespace adaptive
                 uint64_t                sequence;
                 static const int        SEQUENCE_INVALID;
                 static const int        SEQUENCE_FIRST;
-
-                virtual SegmentChunk * getChunk(const std::string &, BaseRepresentation *, HTTPConnectionManager *);
         };
 
         class Segment : public ISegment
diff --git a/modules/demux/smooth/playlist/ForgedInitSegment.cpp b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
index 0f12ede..2ddc273 100644
--- a/modules/demux/smooth/playlist/ForgedInitSegment.cpp
+++ b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
@@ -299,14 +299,20 @@ block_t * ForgedInitSegment::buildMoovBox()
     return moov;
 }
 
-SegmentChunk * ForgedInitSegment::getChunk(const std::string &, BaseRepresentation *rep, HTTPConnectionManager *)
+SegmentChunk* ForgedInitSegment::toChunk(size_t, BaseRepresentation *rep, HTTPConnectionManager *)
 {
     block_t *moov = buildMoovBox();
     if(moov)
     {
         MemoryChunkSource *source = new (std::nothrow) MemoryChunkSource(moov);
-        return new (std::nothrow) SegmentChunk(this, source, rep);
+        if( source )
+        {
+            SegmentChunk *chunk = new (std::nothrow) SegmentChunk(this, source, rep);
+            if( chunk )
+                return chunk;
+            else
+                delete source;
+        }
     }
-
     return NULL;
 }
diff --git a/modules/demux/smooth/playlist/ForgedInitSegment.hpp b/modules/demux/smooth/playlist/ForgedInitSegment.hpp
index 4590ed1..a685e91 100644
--- a/modules/demux/smooth/playlist/ForgedInitSegment.hpp
+++ b/modules/demux/smooth/playlist/ForgedInitSegment.hpp
@@ -39,6 +39,7 @@ namespace smooth
                 ForgedInitSegment(ICanonicalUrl *parent, const std::string &,
                                   uint64_t, uint64_t);
                 virtual ~ForgedInitSegment();
+                virtual SegmentChunk* toChunk(size_t, BaseRepresentation *, HTTPConnectionManager *); /* reimpl */
                 void setWaveFormatEx(const std::string &);
                 void setCodecPrivateData(const std::string &);
                 void setChannels(uint16_t);
@@ -51,9 +52,6 @@ namespace smooth
                 void setTrackID(unsigned);
                 void setLanguage(const std::string &);
 
-            protected:
-                virtual SegmentChunk * getChunk(const std::string &, BaseRepresentation *, HTTPConnectionManager *); /* reimpl */
-
             private:
                 void fromWaveFormatEx(const uint8_t *p_data, size_t i_data);
                 void fromVideoInfoHeader(const uint8_t *p_data, size_t i_data);



More information about the vlc-commits mailing list