[vlc-commits] demux: adaptive: make commandsqueue to use only abstract objects
Francois Cartegnie
git at videolan.org
Tue Jan 19 16:50:36 UTC 2021
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan 15 10:09:25 2021 +0100| [817cb824b9534017484fdae3f19048ec94b90b4d] | committer: Francois Cartegnie
demux: adaptive: make commandsqueue to use only abstract objects
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=817cb824b9534017484fdae3f19048ec94b90b4d
---
modules/demux/adaptive/Streams.cpp | 4 +-
modules/demux/adaptive/plumbing/CommandsQueue.cpp | 51 +++++++++++------------
modules/demux/adaptive/plumbing/CommandsQueue.hpp | 43 +++++++++----------
modules/demux/adaptive/plumbing/FakeESOut.cpp | 28 +++++++++++--
modules/demux/adaptive/plumbing/FakeESOut.hpp | 15 +++++--
modules/demux/adaptive/plumbing/FakeESOutID.cpp | 4 +-
modules/demux/adaptive/plumbing/FakeESOutID.hpp | 21 +++++++---
modules/demux/hls/HLSStreams.cpp | 2 +-
8 files changed, 103 insertions(+), 65 deletions(-)
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 28818f878d..b8434e8603 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -434,7 +434,7 @@ AbstractStream::Status AbstractStream::dequeue(vlc_tick_t nz_deadline, vlc_tick_
msg_Dbg(p_realdemux, "Stream %s pcr %" PRId64 " dts %" PRId64 " deadline %" PRId64 " [DRAINING]",
description.c_str(), pcrvalue, dtsvalue, nz_deadline));
- *pi_pcr = fakeEsOut()->commandsQueue()->Process(p_realdemux->out, VLC_TICK_0 + nz_deadline);
+ *pi_pcr = fakeEsOut()->commandsQueue()->Process(VLC_TICK_0 + nz_deadline);
if(!fakeEsOut()->commandsQueue()->isEmpty())
return Status::Demuxed;
@@ -460,7 +460,7 @@ AbstractStream::Status AbstractStream::dequeue(vlc_tick_t nz_deadline, vlc_tick_
if(nz_deadline + VLC_TICK_0 <= bufferingLevel) /* demuxed */
{
- *pi_pcr = fakeEsOut()->commandsQueue()->Process( p_realdemux->out, VLC_TICK_0 + nz_deadline );
+ *pi_pcr = fakeEsOut()->commandsQueue()->Process( VLC_TICK_0 + nz_deadline );
return Status::Demuxed;
}
diff --git a/modules/demux/adaptive/plumbing/CommandsQueue.cpp b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
index 34a54e0fc7..0b8dbe1488 100644
--- a/modules/demux/adaptive/plumbing/CommandsQueue.cpp
+++ b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
@@ -61,13 +61,13 @@ int AbstractCommand::getType() const
return type;
}
-AbstractFakeEsCommand::AbstractFakeEsCommand( int type, FakeESOutID *p_es ) :
+AbstractFakeEsCommand::AbstractFakeEsCommand( int type, AbstractFakeESOutID *p_es ) :
AbstractCommand( type )
{
p_fakeid = p_es;
}
-EsOutSendCommand::EsOutSendCommand( FakeESOutID *p_es, block_t *p_block_ ) :
+EsOutSendCommand::EsOutSendCommand( AbstractFakeESOutID *p_es, block_t *p_block_ ) :
AbstractFakeEsCommand( ES_OUT_PRIVATE_COMMAND_SEND, p_es )
{
p_block = p_block_;
@@ -79,14 +79,10 @@ EsOutSendCommand::~EsOutSendCommand()
block_Release( p_block );
}
-void EsOutSendCommand::Execute( es_out_t *out )
+void EsOutSendCommand::Execute()
{
- /* Be sure to notify Data before Sending, because UI would still not pick new ES */
- p_fakeid->notifyData();
- if( p_fakeid->realESID() &&
- es_out_Send( out, p_fakeid->realESID(), p_block ) == VLC_SUCCESS )
- p_block = nullptr;
- p_fakeid->notifyData();
+ p_fakeid->sendData( p_block );
+ p_block = nullptr;
}
vlc_tick_t EsOutSendCommand::getTime() const
@@ -102,17 +98,17 @@ const void * EsOutSendCommand::esIdentifier() const
return static_cast<const void *>(p_fakeid);
}
-EsOutDelCommand::EsOutDelCommand( FakeESOutID *p_es ) :
+EsOutDelCommand::EsOutDelCommand( AbstractFakeESOutID *p_es ) :
AbstractFakeEsCommand( ES_OUT_PRIVATE_COMMAND_DEL, p_es )
{
}
-void EsOutDelCommand::Execute( es_out_t * )
+void EsOutDelCommand::Execute( )
{
p_fakeid->release();
}
-EsOutAddCommand::EsOutAddCommand( FakeESOutID *p_es ) :
+EsOutAddCommand::EsOutAddCommand( AbstractFakeESOutID *p_es ) :
AbstractFakeEsCommand( ES_OUT_PRIVATE_COMMAND_ADD, p_es )
{
}
@@ -121,7 +117,7 @@ EsOutAddCommand::~EsOutAddCommand()
{
}
-void EsOutAddCommand::Execute( es_out_t * )
+void EsOutAddCommand::Execute( )
{
/* Create the real ES on the adaptive demux */
p_fakeid->create();
@@ -135,7 +131,7 @@ EsOutControlPCRCommand::EsOutControlPCRCommand( int group_, vlc_tick_t pcr_ ) :
type = ES_OUT_SET_GROUP_PCR;
}
-void EsOutControlPCRCommand::Execute( es_out_t * )
+void EsOutControlPCRCommand::Execute( )
{
// do nothing here
}
@@ -150,7 +146,7 @@ EsOutDestroyCommand::EsOutDestroyCommand() :
{
}
-void EsOutDestroyCommand::Execute( es_out_t * )
+void EsOutDestroyCommand::Execute( )
{
}
@@ -159,14 +155,16 @@ EsOutControlResetPCRCommand::EsOutControlResetPCRCommand() :
{
}
-void EsOutControlResetPCRCommand::Execute( es_out_t * )
+void EsOutControlResetPCRCommand::Execute( )
{
}
-EsOutMetaCommand::EsOutMetaCommand( int i_group, vlc_meta_t *p_meta ) :
+EsOutMetaCommand::EsOutMetaCommand( AbstractFakeEsOut *out,
+ int i_group, vlc_meta_t *p_meta ) :
AbstractCommand( ES_OUT_SET_GROUP_META )
{
group = i_group;
+ this->out = out;
this->p_meta = p_meta;
}
@@ -176,26 +174,26 @@ EsOutMetaCommand::~EsOutMetaCommand()
vlc_meta_Delete( p_meta );
}
-void EsOutMetaCommand::Execute( es_out_t *out )
+void EsOutMetaCommand::Execute()
{
- es_out_Control( out, ES_OUT_SET_GROUP_META, group, p_meta );
+ out->sendMeta( group, p_meta );
}
/*
* Commands Default Factory
*/
-EsOutSendCommand * CommandsFactory::createEsOutSendCommand( FakeESOutID *id, block_t *p_block ) const
+EsOutSendCommand * CommandsFactory::createEsOutSendCommand( AbstractFakeESOutID *id, block_t *p_block ) const
{
return new (std::nothrow) EsOutSendCommand( id, p_block );
}
-EsOutDelCommand * CommandsFactory::createEsOutDelCommand( FakeESOutID *id ) const
+EsOutDelCommand * CommandsFactory::createEsOutDelCommand( AbstractFakeESOutID *id ) const
{
return new (std::nothrow) EsOutDelCommand( id );
}
-EsOutAddCommand * CommandsFactory::createEsOutAddCommand( FakeESOutID *id ) const
+EsOutAddCommand * CommandsFactory::createEsOutAddCommand( AbstractFakeESOutID *id ) const
{
return new (std::nothrow) EsOutAddCommand( id );
}
@@ -215,13 +213,14 @@ EsOutControlResetPCRCommand * CommandsFactory::creatEsOutControlResetPCRCommand(
return new (std::nothrow) EsOutControlResetPCRCommand();
}
-EsOutMetaCommand * CommandsFactory::createEsOutMetaCommand( int group, const vlc_meta_t *p_meta ) const
+EsOutMetaCommand * CommandsFactory::createEsOutMetaCommand( AbstractFakeEsOut *out, int group,
+ const vlc_meta_t *p_meta ) const
{
vlc_meta_t *p_dup = vlc_meta_New();
if( p_dup )
{
vlc_meta_Merge( p_dup, p_meta );
- return new (std::nothrow) EsOutMetaCommand( group, p_dup );
+ return new (std::nothrow) EsOutMetaCommand( out, group, p_dup );
}
return nullptr;
}
@@ -303,7 +302,7 @@ const CommandsFactory * CommandsQueue::factory() const
return commandsFactory;
}
-vlc_tick_t CommandsQueue::Process( es_out_t *out, vlc_tick_t barrier )
+vlc_tick_t CommandsQueue::Process( vlc_tick_t barrier )
{
vlc_tick_t lastdts = barrier;
std::set<const void *> disabled_esids;
@@ -387,7 +386,7 @@ vlc_tick_t CommandsQueue::Process( es_out_t *out, vlc_tick_t barrier )
lastdts = dts;
}
- command->Execute( out );
+ command->Execute();
delete command;
}
pcr = lastdts; /* Warn! no PCR update/lock release until execution */
diff --git a/modules/demux/adaptive/plumbing/CommandsQueue.hpp b/modules/demux/adaptive/plumbing/CommandsQueue.hpp
index fe12de5c55..96c8a46167 100644
--- a/modules/demux/adaptive/plumbing/CommandsQueue.hpp
+++ b/modules/demux/adaptive/plumbing/CommandsQueue.hpp
@@ -28,15 +28,15 @@
namespace adaptive
{
- class FakeESOut;
- class FakeESOutID;
+ class AbstractFakeEsOut;
+ class AbstractFakeESOutID;
class AbstractCommand
{
friend class CommandsFactory;
public:
virtual ~AbstractCommand();
- virtual void Execute( es_out_t * ) = 0;
+ virtual void Execute( ) = 0;
virtual vlc_tick_t getTime() const;
int getType() const;
@@ -48,8 +48,8 @@ namespace adaptive
class AbstractFakeEsCommand : public AbstractCommand
{
protected:
- AbstractFakeEsCommand( int, FakeESOutID * );
- FakeESOutID *p_fakeid;
+ AbstractFakeEsCommand( int, AbstractFakeESOutID * );
+ AbstractFakeESOutID *p_fakeid;
};
class EsOutSendCommand : public AbstractFakeEsCommand
@@ -57,12 +57,12 @@ namespace adaptive
friend class CommandsFactory;
public:
virtual ~EsOutSendCommand();
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute( ) override;
virtual vlc_tick_t getTime() const override;
const void * esIdentifier() const;
protected:
- EsOutSendCommand( FakeESOutID *, block_t * );
+ EsOutSendCommand( AbstractFakeESOutID *, block_t * );
block_t *p_block;
};
@@ -70,10 +70,10 @@ namespace adaptive
{
friend class CommandsFactory;
public:
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
protected:
- EsOutDelCommand( FakeESOutID * );
+ EsOutDelCommand( AbstractFakeESOutID * );
};
class EsOutAddCommand : public AbstractFakeEsCommand
@@ -81,17 +81,17 @@ namespace adaptive
friend class CommandsFactory;
public:
virtual ~EsOutAddCommand();
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
protected:
- EsOutAddCommand( FakeESOutID * );
+ EsOutAddCommand( AbstractFakeESOutID * );
};
class EsOutControlPCRCommand : public AbstractCommand
{
friend class CommandsFactory;
public:
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
virtual vlc_tick_t getTime() const override;
protected:
@@ -104,7 +104,7 @@ namespace adaptive
{
friend class CommandsFactory;
public:
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
protected:
EsOutDestroyCommand();
@@ -114,7 +114,7 @@ namespace adaptive
{
friend class CommandsFactory;
public:
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
protected:
EsOutControlResetPCRCommand();
@@ -124,11 +124,12 @@ namespace adaptive
{
friend class CommandsFactory;
public:
- virtual void Execute( es_out_t *out ) override;
+ virtual void Execute() override;
protected:
- EsOutMetaCommand( int, vlc_meta_t * );
+ EsOutMetaCommand( AbstractFakeEsOut *, int, vlc_meta_t * );
virtual ~EsOutMetaCommand();
+ AbstractFakeEsOut *out;
int group;
vlc_meta_t *p_meta;
};
@@ -138,13 +139,13 @@ namespace adaptive
{
public:
virtual ~CommandsFactory() {}
- virtual EsOutSendCommand * createEsOutSendCommand( FakeESOutID *, block_t * ) const;
- virtual EsOutDelCommand * createEsOutDelCommand( FakeESOutID * ) const;
- virtual EsOutAddCommand * createEsOutAddCommand( FakeESOutID * ) const;
+ virtual EsOutSendCommand * createEsOutSendCommand( AbstractFakeESOutID *, block_t * ) const;
+ virtual EsOutDelCommand * createEsOutDelCommand( AbstractFakeESOutID * ) const;
+ virtual EsOutAddCommand * createEsOutAddCommand( AbstractFakeESOutID * ) const;
virtual EsOutControlPCRCommand * createEsOutControlPCRCommand( int, vlc_tick_t ) const;
virtual EsOutControlResetPCRCommand * creatEsOutControlResetPCRCommand() const;
virtual EsOutDestroyCommand * createEsOutDestroyCommand() const;
- virtual EsOutMetaCommand * createEsOutMetaCommand( int, const vlc_meta_t * ) const;
+ virtual EsOutMetaCommand * createEsOutMetaCommand( AbstractFakeEsOut *, int, const vlc_meta_t * ) const;
};
using Queueentry = std::pair<uint64_t, AbstractCommand *>;
@@ -157,7 +158,7 @@ namespace adaptive
~CommandsQueue();
const CommandsFactory * factory() const;
void Schedule( AbstractCommand * );
- vlc_tick_t Process( es_out_t *out, vlc_tick_t );
+ vlc_tick_t Process( vlc_tick_t );
void Abort( bool b_reset );
void Commit();
bool isEmpty() const;
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index 8cd12823d9..841f81dc18 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -238,8 +238,9 @@ FakeESOutID * FakeESOut::createNewID( const es_format_t *p_fmt )
return es_id;
}
-void FakeESOut::createOrRecycleRealEsID( FakeESOutID *es_id )
+void FakeESOut::createOrRecycleRealEsID( AbstractFakeESOutID *es_id_ )
{
+ FakeESOutID *es_id = static_cast<FakeESOutID *>(es_id_);
std::list<FakeESOutID *>::iterator it;
es_out_id_t *realid = nullptr;
@@ -288,11 +289,29 @@ void FakeESOut::createOrRecycleRealEsID( FakeESOutID *es_id )
es_id->setRealESID( realid );
}
-void FakeESOut::setPriority(int p)
+void FakeESOut::setPriority( int p )
{
priority = p;
}
+void FakeESOut::sendData( AbstractFakeESOutID *id_, block_t *p_block )
+{
+ FakeESOutID *id = static_cast<FakeESOutID *>(id_);
+ /* Be sure to notify Data before Sending, because UI would still not pick new ES */
+ gc();
+ if( !id->realESID() ||
+ es_out_Send( real_es_out, id->realESID(), p_block ) != VLC_SUCCESS )
+ {
+ block_Release( p_block );
+ }
+ gc();
+}
+
+void FakeESOut::sendMeta( int group, const vlc_meta_t *p_meta )
+{
+ es_out_Control( real_es_out, ES_OUT_SET_GROUP_META, group, p_meta );
+}
+
size_t FakeESOut::esCount() const
{
if(!declared.empty())
@@ -392,8 +411,9 @@ bool FakeESOut::restarting() const
return b;
}
-void FakeESOut::recycle( FakeESOutID *id )
+void FakeESOut::recycle( AbstractFakeESOutID *id_ )
{
+ FakeESOutID *id = static_cast<FakeESOutID *>(id_);
fakeesidlist.remove( id );
recycle_candidates.push_back( id );
}
@@ -549,7 +569,7 @@ int FakeESOut::esOutControl(int i_query, va_list args)
{
static_cast<void>(va_arg( args, int )); /* ignore group */
const vlc_meta_t *p_meta = va_arg( args, const vlc_meta_t * );
- AbstractCommand *command = commandsqueue->factory()->createEsOutMetaCommand( -1, p_meta );
+ AbstractCommand *command = commandsqueue->factory()->createEsOutMetaCommand( this,-1, p_meta );
if( likely(command) )
{
commandsqueue->Schedule( command );
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.hpp b/modules/demux/adaptive/plumbing/FakeESOut.hpp
index 5c15843e8e..d31d2c0fae 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.hpp
@@ -33,6 +33,7 @@ namespace adaptive
};
class CommandsQueue;
+ class AbstractFakeESOutID;
class FakeESOutID;
class AbstractFakeEsOut
@@ -42,6 +43,12 @@ namespace adaptive
AbstractFakeEsOut();
virtual ~AbstractFakeEsOut();
operator es_out_t*();
+ /* Used by FakeES ID */
+ virtual void recycle( AbstractFakeESOutID * ) = 0;
+ virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) = 0;
+ virtual void setPriority(int) = 0;
+ virtual void sendData( AbstractFakeESOutID *, block_t * ) = 0;
+ virtual void sendMeta( int, const vlc_meta_t * ) = 0;
private:
void *esoutpriv;
@@ -84,9 +91,11 @@ namespace adaptive
void declareEs( const es_format_t * );
/* Used by FakeES ID */
- void recycle( FakeESOutID *id );
- void createOrRecycleRealEsID( FakeESOutID * );
- void setPriority(int);
+ virtual void recycle( AbstractFakeESOutID *id ) override;
+ virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) override;
+ virtual void setPriority(int) override;
+ virtual void sendData( AbstractFakeESOutID *, block_t * ) override;
+ virtual void sendMeta( int, const vlc_meta_t * ) override;
/**/
void schedulePCRReset();
diff --git a/modules/demux/adaptive/plumbing/FakeESOutID.cpp b/modules/demux/adaptive/plumbing/FakeESOutID.cpp
index f9eedf9a22..72b36301d6 100644
--- a/modules/demux/adaptive/plumbing/FakeESOutID.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOutID.cpp
@@ -45,9 +45,9 @@ void FakeESOutID::setRealESID( es_out_id_t *real_es_id )
p_real_es_id = real_es_id;
}
-void FakeESOutID::notifyData()
+void FakeESOutID::sendData( block_t *p_block )
{
- fakeesout->gc();
+ fakeesout->sendData( this, p_block );
}
void FakeESOutID::create()
diff --git a/modules/demux/adaptive/plumbing/FakeESOutID.hpp b/modules/demux/adaptive/plumbing/FakeESOutID.hpp
index fe780b6d3d..78944463f7 100644
--- a/modules/demux/adaptive/plumbing/FakeESOutID.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOutID.hpp
@@ -27,17 +27,26 @@ namespace adaptive
{
class FakeESOut;
- class FakeESOutID
+ class AbstractFakeESOutID
+ {
+ public:
+ virtual es_out_id_t * realESID() = 0;
+ virtual void create() = 0;
+ virtual void release() = 0;
+ virtual void sendData(block_t *) = 0;
+ };
+
+ class FakeESOutID : public AbstractFakeESOutID
{
public:
FakeESOutID( FakeESOut *, const es_format_t * );
- ~FakeESOutID();
+ virtual ~FakeESOutID();
void setRealESID( es_out_id_t * );
- es_out_id_t * realESID();
+ virtual es_out_id_t * realESID() override;
const es_format_t *getFmt() const;
- void create();
- void release();
- void notifyData();
+ virtual void create() override;
+ virtual void release() override;
+ virtual void sendData(block_t *) override;
bool isCompatible( const FakeESOutID * ) const;
/* Ensure we won't issue delete command twice */
void setScheduledForDeletion();
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index cc75417868..2604b5acf2 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -117,7 +117,7 @@ block_t * HLSStream::checkBlock(block_t *p_block, bool b_first)
if( b_meta_updated )
{
b_meta_updated = false;
- AbstractCommand *command = fakeEsOut()->commandsQueue()->factory()->createEsOutMetaCommand( -1, p_meta );
+ AbstractCommand *command = fakeEsOut()->commandsQueue()->factory()->createEsOutMetaCommand( fakeesout, -1, p_meta );
if( command )
fakeEsOut()->commandsQueue()->Schedule( command );
}
More information about the vlc-commits
mailing list