[vlc-commits] demux: adaptive: add type to retrieved chunks
Francois Cartegnie
git at videolan.org
Tue Mar 2 23:44:59 UTC 2021
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Feb 27 17:26:37 2021 +0100| [1ef4b4f824b744437a7b397c5289f56742e08114] | committer: Francois Cartegnie
demux: adaptive: add type to retrieved chunks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1ef4b4f824b744437a7b397c5289f56742e08114
---
modules/demux/adaptive/encryption/Keyring.cpp | 3 ++-
modules/demux/adaptive/http/Chunk.cpp | 12 +++++++-----
modules/demux/adaptive/http/Chunk.h | 16 +++++++++++++---
modules/demux/adaptive/playlist/Segment.cpp | 3 ++-
modules/demux/adaptive/tools/Retrieve.cpp | 5 +++--
modules/demux/adaptive/tools/Retrieve.hpp | 6 +++++-
modules/demux/dash/DASHManager.cpp | 2 +-
modules/demux/hls/playlist/Parser.cpp | 2 +-
modules/demux/smooth/SmoothManager.cpp | 2 +-
9 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/modules/demux/adaptive/encryption/Keyring.cpp b/modules/demux/adaptive/encryption/Keyring.cpp
index 95613b1a12..d16c3bdb9a 100644
--- a/modules/demux/adaptive/encryption/Keyring.cpp
+++ b/modules/demux/adaptive/encryption/Keyring.cpp
@@ -24,6 +24,7 @@
#include "Keyring.hpp"
#include "../tools/Retrieve.hpp"
+#include "../http/Chunk.h"
#include <vlc_block.h>
@@ -51,7 +52,7 @@ KeyringKey Keyring::getKey(SharedResources *resources, const std::string &uri)
{
/* Pretty bad inside the lock */
msg_Dbg(obj, "Retrieving AES key %s", uri.c_str());
- block_t *p_block = Retrieve::HTTP(resources, uri);
+ block_t *p_block = Retrieve::HTTP(resources, http::ChunkType::Key, uri);
if(p_block)
{
if(p_block->i_buffer == 16)
diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index cfbadabc98..447072e5fb 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -139,7 +139,7 @@ block_t * AbstractChunk::read(size_t size)
}
HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManager *manager,
- const adaptive::ID &id, bool access) :
+ const adaptive::ID &id, ChunkType t, bool access) :
AbstractChunkSource(),
connection (nullptr),
connManager (manager),
@@ -148,6 +148,7 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManag
prepared = false;
eof = false;
sourceid = id;
+ type = t;
setUseAccess(access);
if(!init(url))
eof = true;
@@ -292,8 +293,9 @@ block_t * HTTPChunkSource::readBlock()
}
HTTPChunkBufferedSource::HTTPChunkBufferedSource(const std::string& url, AbstractConnectionManager *manager,
- const adaptive::ID &sourceid, bool access) :
- HTTPChunkSource(url, manager, sourceid, access),
+ const adaptive::ID &sourceid,
+ ChunkType type, bool access) :
+ HTTPChunkSource(url, manager, sourceid, type, access),
p_head (nullptr),
pp_tail (&p_head),
buffered (0)
@@ -503,8 +505,8 @@ block_t * HTTPChunkBufferedSource::read(size_t readsize)
}
HTTPChunk::HTTPChunk(const std::string &url, AbstractConnectionManager *manager,
- const adaptive::ID &id, bool access):
- AbstractChunk(new HTTPChunkSource(url, manager, id, access))
+ const adaptive::ID &id, ChunkType type, bool access):
+ AbstractChunk(new HTTPChunkSource(url, manager, id, type, access))
{
}
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index f88abfa984..bcfa8dc468 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -43,6 +43,15 @@ namespace adaptive
class AbstractConnectionManager;
class AbstractChunk;
+ enum class ChunkType
+ {
+ Segment,
+ Init,
+ Index,
+ Playlist,
+ Key,
+ };
+
class AbstractChunkSource
{
public:
@@ -91,7 +100,7 @@ namespace adaptive
{
public:
HTTPChunkSource(const std::string &url, AbstractConnectionManager *,
- const ID &, bool = false);
+ const ID &, ChunkType, bool = false);
virtual ~HTTPChunkSource();
virtual block_t * readBlock () override;
@@ -110,6 +119,7 @@ namespace adaptive
bool prepared;
bool eof;
ID sourceid;
+ ChunkType type;
private:
bool init(const std::string &);
@@ -122,7 +132,7 @@ namespace adaptive
public:
HTTPChunkBufferedSource(const std::string &url, AbstractConnectionManager *,
- const ID &, bool = false);
+ const ID &, ChunkType, bool = false);
virtual ~HTTPChunkBufferedSource();
virtual block_t * readBlock () override;
virtual block_t * read (size_t) override;
@@ -150,7 +160,7 @@ namespace adaptive
{
public:
HTTPChunk(const std::string &url, AbstractConnectionManager *,
- const ID &, bool = false);
+ const ID &, ChunkType, bool = false);
virtual ~HTTPChunk();
protected:
diff --git a/modules/demux/adaptive/playlist/Segment.cpp b/modules/demux/adaptive/playlist/Segment.cpp
index fcd57da8c6..e0ec87199f 100644
--- a/modules/demux/adaptive/playlist/Segment.cpp
+++ b/modules/demux/adaptive/playlist/Segment.cpp
@@ -79,7 +79,8 @@ SegmentChunk* ISegment::toChunk(SharedResources *res, AbstractConnectionManager
{
const std::string url = getUrlSegment().toString(index, rep);
HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager,
- rep->getAdaptationSet()->getID());
+ rep->getAdaptationSet()->getID(),
+ ChunkType::Segment);
if( source )
{
if(startByte != endByte)
diff --git a/modules/demux/adaptive/tools/Retrieve.cpp b/modules/demux/adaptive/tools/Retrieve.cpp
index 2fa886de69..6bbdab5b24 100644
--- a/modules/demux/adaptive/tools/Retrieve.cpp
+++ b/modules/demux/adaptive/tools/Retrieve.cpp
@@ -32,12 +32,13 @@
using namespace adaptive;
using namespace adaptive::http;
-block_t * Retrieve::HTTP(SharedResources *resources, const std::string &uri)
+block_t * Retrieve::HTTP(SharedResources *resources, ChunkType type,
+ const std::string &uri)
{
HTTPChunk *datachunk;
try
{
- datachunk = new HTTPChunk(uri, resources->getConnManager(), ID(), true);
+ datachunk = new HTTPChunk(uri, resources->getConnManager(), ID(), type, true);
} catch (...) {
return nullptr;
}
diff --git a/modules/demux/adaptive/tools/Retrieve.hpp b/modules/demux/adaptive/tools/Retrieve.hpp
index 7b19430052..ce748457c9 100644
--- a/modules/demux/adaptive/tools/Retrieve.hpp
+++ b/modules/demux/adaptive/tools/Retrieve.hpp
@@ -26,11 +26,15 @@
namespace adaptive
{
class SharedResources;
+ namespace http
+ {
+ enum class ChunkType;
+ };
class Retrieve
{
public:
- static block_t * HTTP(SharedResources *, const std::string &uri);
+ static block_t * HTTP(SharedResources *, http::ChunkType, const std::string &uri);
};
}
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index 7b2d3adb81..3e93237fe9 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -94,7 +94,7 @@ bool DASHManager::updatePlaylist()
{
std::string url(p_demux->psz_url);
- block_t *p_block = Retrieve::HTTP(resources, url);
+ block_t *p_block = Retrieve::HTTP(resources, ChunkType::Playlist, url);
if(!p_block)
return false;
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 8001b4e9fe..a43ec7f8ab 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -154,7 +154,7 @@ void M3U8Parser::createAndFillRepresentation(vlc_object_t *p_obj, BaseAdaptation
bool M3U8Parser::appendSegmentsFromPlaylistURI(vlc_object_t *p_obj, HLSRepresentation *rep)
{
- block_t *p_block = Retrieve::HTTP(resources, rep->getPlaylistUrl().toString());
+ block_t *p_block = Retrieve::HTTP(resources, ChunkType::Playlist, rep->getPlaylistUrl().toString());
if(p_block)
{
stream_t *substream = vlc_stream_MemoryNew(p_obj, p_block->p_buffer, p_block->i_buffer, true);
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index 3a12fdf142..d4347d703f 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -57,7 +57,7 @@ Manifest * SmoothManager::fetchManifest()
{
std::string playlisturl(p_demux->psz_url);
- block_t *p_block = Retrieve::HTTP(resources, playlisturl);
+ block_t *p_block = Retrieve::HTTP(resources, ChunkType::Playlist, playlisturl);
if(!p_block)
return nullptr;
More information about the vlc-commits
mailing list