[vlc-commits] demux: adaptive: add getter for chunk type

Francois Cartegnie git at videolan.org
Wed Apr 7 18:29:01 UTC 2021


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Mar 18 11:26:53 2021 +0100| [da69089732b850ef27f0b3e55f45c76cad5e883b] | committer: Francois Cartegnie

demux: adaptive: add getter for chunk type

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

 modules/demux/adaptive/http/Chunk.cpp               | 11 ++++++++---
 modules/demux/adaptive/http/Chunk.h                 |  5 +++--
 modules/demux/smooth/playlist/ForgedInitSegment.cpp |  2 +-
 modules/demux/smooth/playlist/MemoryChunk.cpp       |  3 ++-
 modules/demux/smooth/playlist/MemoryChunk.hpp       |  2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index d5d9a8f337..2e02b1af11 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -38,8 +38,9 @@
 using namespace adaptive::http;
 using vlc::threads::mutex_locker;
 
-AbstractChunkSource::AbstractChunkSource()
+AbstractChunkSource::AbstractChunkSource(ChunkType t)
 {
+    type = t;
     contentLength = 0;
     requeststatus = RequestStatus::Success;
 }
@@ -71,6 +72,11 @@ RequestStatus AbstractChunkSource::getRequestStatus() const
     return requeststatus;
 }
 
+ChunkType AbstractChunkSource::getChunkType() const
+{
+    return type;
+}
+
 AbstractChunk::AbstractChunk(AbstractChunkSource *source_)
 {
     bytesRead = 0;
@@ -140,7 +146,7 @@ block_t * AbstractChunk::read(size_t size)
 
 HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManager *manager,
                                  const adaptive::ID &id, ChunkType t, bool access) :
-    AbstractChunkSource(),
+    AbstractChunkSource(t),
     connection   (nullptr),
     connManager  (manager),
     consumed     (0)
@@ -148,7 +154,6 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManag
     prepared = false;
     eof = false;
     sourceid = id;
-    type = t;
     setUseAccess(access);
     if(!init(url))
         eof = true;
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index 7cdf04f9cd..7ddb356ae5 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -68,14 +68,16 @@ namespace adaptive
         class AbstractChunkSource : public ChunkInterface
         {
             public:
-                AbstractChunkSource();
+                AbstractChunkSource(ChunkType);
                 virtual ~AbstractChunkSource();
                 void                setBytesRange   (const BytesRange &);
                 const BytesRange &  getBytesRange   () const;
+                ChunkType           getChunkType    () const;
                 virtual std::string getContentType  () const override;
                 virtual RequestStatus getRequestStatus() const override;
 
             protected:
+                ChunkType           type;
                 RequestStatus       requeststatus;
                 size_t              contentLength;
                 BytesRange          bytesRange;
@@ -130,7 +132,6 @@ namespace adaptive
                 bool                prepared;
                 bool                eof;
                 ID                  sourceid;
-                ChunkType           type;
                 vlc_tick_t          requestStartTime;
                 vlc_tick_t          responseTime;
                 vlc_tick_t          downloadEndTime;
diff --git a/modules/demux/smooth/playlist/ForgedInitSegment.cpp b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
index 4c62d632a7..029c91cf7b 100644
--- a/modules/demux/smooth/playlist/ForgedInitSegment.cpp
+++ b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
@@ -144,7 +144,7 @@ SegmentChunk* ForgedInitSegment::toChunk(SharedResources *, AbstractConnectionMa
     block_t *moov = buildMoovBox(lvl->getCodecParameters());
     if(moov)
     {
-        MemoryChunkSource *source = new (std::nothrow) MemoryChunkSource(moov);
+        MemoryChunkSource *source = new (std::nothrow) MemoryChunkSource(ChunkType::Init, moov);
         if( source )
         {
             SegmentChunk *chunk = new (std::nothrow) SegmentChunk(source, rep);
diff --git a/modules/demux/smooth/playlist/MemoryChunk.cpp b/modules/demux/smooth/playlist/MemoryChunk.cpp
index 51ce45c0fc..6c601b81ab 100644
--- a/modules/demux/smooth/playlist/MemoryChunk.cpp
+++ b/modules/demux/smooth/playlist/MemoryChunk.cpp
@@ -27,7 +27,8 @@
 
 using namespace smooth::http;
 
-MemoryChunkSource::MemoryChunkSource(block_t *block)
+MemoryChunkSource::MemoryChunkSource(ChunkType t, block_t *block)
+    : AbstractChunkSource(t)
 {
     data = block;
     i_read = 0;
diff --git a/modules/demux/smooth/playlist/MemoryChunk.hpp b/modules/demux/smooth/playlist/MemoryChunk.hpp
index b3a3ecb2f9..4616bf971f 100644
--- a/modules/demux/smooth/playlist/MemoryChunk.hpp
+++ b/modules/demux/smooth/playlist/MemoryChunk.hpp
@@ -31,7 +31,7 @@ namespace smooth
         class MemoryChunkSource : public AbstractChunkSource
         {
             public:
-                MemoryChunkSource(block_t *);
+                MemoryChunkSource(ChunkType, block_t *);
                 virtual ~MemoryChunkSource();
 
                 virtual block_t * readBlock() override;



More information about the vlc-commits mailing list