[vlc-commits] [Git][videolan/vlc][master] demux: adaptive: provide way to signal end of commands group
Jean-Baptiste Kempf
gitlab at videolan.org
Wed May 19 07:47:05 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
077d5489 by Francois Cartegnie at 2021-05-19T05:47:53+00:00
demux: adaptive: provide way to signal end of commands group
Having to deal with es_Add or Del sequences forces the command
queue to expect another type of input on the esout before
recycling es, creating delay in multiple cases.
- - - - -
6 changed files:
- modules/demux/adaptive/Streams.cpp
- modules/demux/adaptive/plumbing/CommandsQueue.cpp
- modules/demux/adaptive/plumbing/CommandsQueue.hpp
- modules/demux/adaptive/plumbing/FakeESOut.cpp
- modules/demux/adaptive/plumbing/FakeESOut.hpp
- modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
Changes:
=====================================
modules/demux/adaptive/Streams.cpp
=====================================
@@ -408,6 +408,7 @@ AbstractStream::BufferingStatus AbstractStream::doBufferize(vlc_tick_t nz_deadli
/* need to read, demuxer still buffering, ... */
vlc_mutex_unlock(&lock);
Demuxer::Status demuxStatus = demuxer->demux(nz_deadline);
+ fakeEsOut()->scheduleNecessaryMilestone();
vlc_mutex_lock(&lock);
if(demuxStatus != Demuxer::Status::Success)
{
=====================================
modules/demux/adaptive/plumbing/CommandsQueue.cpp
=====================================
@@ -38,7 +38,8 @@ enum
ES_OUT_PRIVATE_COMMAND_DEL,
ES_OUT_PRIVATE_COMMAND_DESTROY,
ES_OUT_PRIVATE_COMMAND_SEND,
- ES_OUT_PRIVATE_COMMAND_DISCONTINUITY
+ ES_OUT_PRIVATE_COMMAND_DISCONTINUITY,
+ ES_OUT_PRIVATE_COMMAND_MILESTONE,
};
AbstractCommand::AbstractCommand( int type_ )
@@ -179,6 +180,17 @@ void EsOutMetaCommand::Execute()
out->sendMeta( group, p_meta );
}
+EsOutMilestoneCommand::EsOutMilestoneCommand( AbstractFakeEsOut *out )
+ : AbstractCommand( ES_OUT_PRIVATE_COMMAND_MILESTONE )
+{
+ this->out = out;
+}
+
+void EsOutMilestoneCommand::Execute()
+{
+ out->milestoneReached();
+}
+
/*
* Commands Default Factory
*/
@@ -225,6 +237,11 @@ EsOutMetaCommand * CommandsFactory::createEsOutMetaCommand( AbstractFakeEsOut *o
return nullptr;
}
+EsOutMilestoneCommand * CommandsFactory::createEsOutMilestoneCommand( AbstractFakeEsOut *out ) const
+{
+ return new (std::nothrow) EsOutMilestoneCommand( out );
+}
+
/*
* Commands Queue management
*/
=====================================
modules/demux/adaptive/plumbing/CommandsQueue.hpp
=====================================
@@ -137,6 +137,17 @@ namespace adaptive
vlc_meta_t *p_meta;
};
+ class EsOutMilestoneCommand : public AbstractCommand
+ {
+ friend class CommandsFactory;
+ public:
+ virtual void Execute() override;
+
+ protected:
+ EsOutMilestoneCommand( AbstractFakeEsOut * );
+ AbstractFakeEsOut *out;
+ };
+
/* Factory so we can alter behaviour and filter on execution */
class CommandsFactory
{
@@ -149,6 +160,7 @@ namespace adaptive
virtual EsOutControlResetPCRCommand * creatEsOutControlResetPCRCommand() const;
virtual EsOutDestroyCommand * createEsOutDestroyCommand() const;
virtual EsOutMetaCommand * createEsOutMetaCommand( AbstractFakeEsOut *, int, const vlc_meta_t * ) const;
+ virtual EsOutMilestoneCommand * createEsOutMilestoneCommand( AbstractFakeEsOut * ) const;
};
using Queueentry = std::pair<uint64_t, AbstractCommand *>;
=====================================
modules/demux/adaptive/plumbing/FakeESOut.cpp
=====================================
@@ -426,6 +426,22 @@ void FakeESOut::recycle( AbstractFakeESOutID *id_ )
recycle_candidates.push_back( id );
}
+void FakeESOut::milestoneReached()
+{
+ gc();
+}
+
+void FakeESOut::scheduleNecessaryMilestone()
+{
+ if( b_in_commands_group )
+ {
+ AbstractCommand *command = commandsfactory->createEsOutMilestoneCommand( this );
+ if( likely(command) )
+ commandsqueue->Schedule( command );
+ b_in_commands_group = false;
+ }
+}
+
vlc_tick_t FakeESOut::fixTimestamp(vlc_tick_t ts)
{
if(ts != VLC_TICK_INVALID)
@@ -506,6 +522,7 @@ es_out_id_t * FakeESOut::esOutAdd(const es_format_t *p_fmt)
{
fakeesidlist.push_back(es_id);
commandsqueue->Schedule( command );
+ b_in_commands_group = true;
return reinterpret_cast<es_out_id_t *>(es_id);
}
else
@@ -520,6 +537,8 @@ int FakeESOut::esOutSend(es_out_id_t *p_es, block_t *p_block)
{
vlc_mutex_locker locker(&lock);
+ scheduleNecessaryMilestone();
+
FakeESOutID *es_id = reinterpret_cast<FakeESOutID *>( p_es );
assert(!es_id->scheduledForDeletion());
@@ -546,12 +565,15 @@ void FakeESOut::esOutDel(es_out_id_t *p_es)
es_id->setScheduledForDeletion();
commandsqueue->Schedule( command );
}
+ b_in_commands_group = true;
}
int FakeESOut::esOutControl(int i_query, va_list args)
{
vlc_mutex_locker locker(&lock);
+ scheduleNecessaryMilestone();
+
switch( i_query )
{
case ES_OUT_SET_PCR:
@@ -608,6 +630,8 @@ void FakeESOut::esOutDestroy()
{
vlc_mutex_locker locker(&lock);
+ scheduleNecessaryMilestone();
+
AbstractCommand *command = commandsfactory->createEsOutDestroyCommand();
if( likely(command) )
commandsqueue->Schedule( command );
=====================================
modules/demux/adaptive/plumbing/FakeESOut.hpp
=====================================
@@ -44,6 +44,7 @@ namespace adaptive
AbstractFakeEsOut();
virtual ~AbstractFakeEsOut();
operator es_out_t*();
+ virtual void milestoneReached() = 0;
/* Used by FakeES ID */
virtual void recycle( AbstractFakeESOutID * ) = 0;
virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) = 0;
@@ -92,6 +93,8 @@ namespace adaptive
vlc_tick_t fixTimestamp(vlc_tick_t);
void declareEs( const es_format_t * );
+ virtual void milestoneReached() override;
+
/* Used by FakeES ID */
virtual void recycle( AbstractFakeESOutID *id ) override;
virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) override;
@@ -100,6 +103,7 @@ namespace adaptive
virtual void sendMeta( int, const vlc_meta_t * ) override;
/**/
+ void scheduleNecessaryMilestone();
void schedulePCRReset();
void scheduleAllForDeletion(); /* Queue Del commands for non Del issued ones */
void recycleAll(); /* Cancels all commands and send fakees for recycling */
@@ -127,6 +131,7 @@ namespace adaptive
vlc_tick_t timestamp_first;
vlc_tick_t timestamps_offset;
int priority;
+ bool b_in_commands_group;
std::list<FakeESOutID *> fakeesidlist;
std::list<FakeESOutID *> recycle_candidates;
std::list<FakeESOutID *> declared;
=====================================
modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
=====================================
@@ -42,6 +42,7 @@ class TestEsOut : public AbstractFakeEsOut
public:
TestEsOut() {}
virtual ~TestEsOut() { cleanup(); }
+ virtual void milestoneReached() override {}
virtual void recycle(AbstractFakeESOutID *) override {}
virtual void createOrRecycleRealEsID(AbstractFakeESOutID *) override {}
virtual void setPriority(int) override {}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/077d5489adfe1288f33e564a420892f9686d40b5
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/077d5489adfe1288f33e564a420892f9686d40b5
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list