[vlc-commits] demux: adaptative: add streamoutput recycling
Francois Cartegnie
git at videolan.org
Wed Sep 23 21:15:09 CEST 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 23 13:02:00 2015 +0200| [0e9356ef434ac235c3d1a6cc3a85c94a75ab179e] | committer: Francois Cartegnie
demux: adaptative: add streamoutput recycling
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0e9356ef434ac235c3d1a6cc3a85c94a75ab179e
---
modules/demux/adaptative/plumbing/StreamOutput.cpp | 20 ++++++++++++++++----
modules/demux/adaptative/plumbing/StreamOutput.hpp | 6 ++++--
modules/demux/dash/DASHManager.cpp | 15 +++++++++++----
modules/demux/dash/DASHManager.h | 2 +-
modules/demux/hls/HLSStreams.cpp | 18 ++++++++++++------
modules/demux/hls/HLSStreams.hpp | 6 ++++--
6 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/modules/demux/adaptative/plumbing/StreamOutput.cpp b/modules/demux/adaptative/plumbing/StreamOutput.cpp
index 37bb944..c19425a 100644
--- a/modules/demux/adaptative/plumbing/StreamOutput.cpp
+++ b/modules/demux/adaptative/plumbing/StreamOutput.cpp
@@ -48,7 +48,8 @@ AbstractStreamOutput::~AbstractStreamOutput()
{
}
-BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, const std::string &name) :
+BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, const std::string &name,
+ AbstractStreamOutput *recycled) :
AbstractStreamOutput(demux, format)
{
this->name = name;
@@ -57,7 +58,18 @@ BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, c
CommandsFactory *factory = new CommandsFactory();
- fakeesout = new (std::nothrow) FakeESOut( realdemux->out, factory );
+ /* Try to recycle compatible output if any */
+ BaseStreamOutput *my_recycled = dynamic_cast<BaseStreamOutput *>(recycled);
+ if(my_recycled)
+ {
+ fakeesout = my_recycled->fakeesout;
+ my_recycled->fakeesout = NULL;
+ }
+ else
+ {
+ fakeesout = new (std::nothrow) FakeESOut( realdemux->out, factory );
+ }
+
if (!fakeesout)
{
delete factory;
@@ -75,7 +87,8 @@ BaseStreamOutput::~BaseStreamOutput()
if (demuxstream)
stream_Delete(demuxstream);
- delete fakeesout;
+ if(fakeesout)
+ delete fakeesout;
}
mtime_t BaseStreamOutput::getPCR() const
@@ -163,4 +176,3 @@ void BaseStreamOutput::fillExtraFMTInfo( es_format_t *p_fmt ) const
if(!p_fmt->psz_description && !description.empty())
p_fmt->psz_description = strdup(description.c_str());
}
-
diff --git a/modules/demux/adaptative/plumbing/StreamOutput.hpp b/modules/demux/adaptative/plumbing/StreamOutput.hpp
index 083a765..97d22ef 100644
--- a/modules/demux/adaptative/plumbing/StreamOutput.hpp
+++ b/modules/demux/adaptative/plumbing/StreamOutput.hpp
@@ -67,7 +67,8 @@ namespace adaptative
{
public:
virtual ~AbstractStreamOutputFactory() {}
- virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &) const = 0;
+ virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &,
+ AbstractStreamOutput * = NULL ) const = 0;
};
class BaseStreamOutput : public AbstractStreamOutput,
@@ -76,7 +77,8 @@ namespace adaptative
friend class BaseStreamOutputEsOutControlPCRCommand;
public:
- BaseStreamOutput(demux_t *, const StreamFormat &, const std::string &);
+ BaseStreamOutput(demux_t *, const StreamFormat &, const std::string &,
+ AbstractStreamOutput * = NULL);
virtual ~BaseStreamOutput();
virtual void pushBlock(block_t *, bool); /* reimpl */
virtual mtime_t getPCR() const; /* reimpl */
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index be942ba..dc18481 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -48,18 +48,25 @@ using namespace dash::mpd;
using namespace adaptative::logic;
-AbstractStreamOutput *DASHStreamOutputFactory::create(demux_t *demux, const StreamFormat &format) const
+AbstractStreamOutput *DASHStreamOutputFactory::create(demux_t *demux, const StreamFormat &format,
+ AbstractStreamOutput *recycled) const
{
+ AbstractStreamOutput *ret = NULL;
unsigned fmt = format;
switch(fmt)
{
case DASHStreamFormat::MP4:
- return new BaseStreamOutput(demux, format, "mp4");
+ ret = new BaseStreamOutput(demux, format, "mp4", recycled);
+ break;
case DASHStreamFormat::MPEG2TS:
- return new BaseStreamOutput(demux, format, "ts");
+ ret = new BaseStreamOutput(demux, format, "ts", recycled);
+ break;
}
- return NULL;
+
+ delete recycled;
+
+ return ret;
}
DASHManager::DASHManager(demux_t *demux_, MPD *mpd,
diff --git a/modules/demux/dash/DASHManager.h b/modules/demux/dash/DASHManager.h
index b86b627..e89998d 100644
--- a/modules/demux/dash/DASHManager.h
+++ b/modules/demux/dash/DASHManager.h
@@ -37,7 +37,7 @@ namespace dash
class DASHStreamOutputFactory : public AbstractStreamOutputFactory
{
public:
- virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &) const;
+ virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &, AbstractStreamOutput * = NULL) const;
};
class DASHManager : public PlaylistManager
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 999750d..cadcc06 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -23,28 +23,34 @@
using namespace hls;
-AbstractStreamOutput *HLSStreamOutputFactory::create(demux_t *demux, const StreamFormat &format) const
+AbstractStreamOutput *HLSStreamOutputFactory::create(demux_t *demux, const StreamFormat &format,
+ AbstractStreamOutput *recycled) const
{
+ AbstractStreamOutput *ret = NULL;
unsigned fmt = format;
switch(fmt)
{
case HLSStreamFormat::PACKEDAAC:
- return new HLSPackedStreamOutput(demux, format, "any");
+ ret = new HLSPackedStreamOutput(demux, format, "any", recycled);
break;
case HLSStreamFormat::UNKNOWN:
case HLSStreamFormat::MPEG2TS:
- return new BaseStreamOutput(demux, format, "ts");
+ ret = new BaseStreamOutput(demux, format, "ts", recycled);
case HLSStreamFormat::UNSUPPORTED:
default:
break;
}
- return NULL;
+
+ delete recycled;
+
+ return ret;
}
-HLSPackedStreamOutput::HLSPackedStreamOutput(demux_t *demux, const StreamFormat &format, const std::string &name) :
- BaseStreamOutput(demux, format, name)
+HLSPackedStreamOutput::HLSPackedStreamOutput(demux_t *demux, const StreamFormat &format, const std::string &name,
+ AbstractStreamOutput *recycled) :
+ BaseStreamOutput(demux, format, name, recycled)
{
b_timestamps_offset_set = false;
}
diff --git a/modules/demux/hls/HLSStreams.hpp b/modules/demux/hls/HLSStreams.hpp
index bdf3da1..1e0b8ba 100644
--- a/modules/demux/hls/HLSStreams.hpp
+++ b/modules/demux/hls/HLSStreams.hpp
@@ -33,13 +33,15 @@ namespace hls
class HLSStreamOutputFactory : public AbstractStreamOutputFactory
{
public:
- virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &) const;
+ virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &,
+ AbstractStreamOutput * = NULL) const;
};
class HLSPackedStreamOutput : public BaseStreamOutput
{
public:
- HLSPackedStreamOutput(demux_t *, const StreamFormat &, const std::string &);
+ HLSPackedStreamOutput(demux_t *, const StreamFormat &, const std::string &,
+ AbstractStreamOutput * = NULL);
virtual void pushBlock(block_t *, bool); /* reimpl */
virtual void setPosition(mtime_t); /* reimpl */
More information about the vlc-commits
mailing list