[vlc-commits] [Git][videolan/vlc][master] demux: adaptive: add source id sequence as ES reuse signal
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Jul 22 13:30:28 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
47b89d98 by Francois Cartegnie at 2023-07-22T13:16:15+00:00
demux: adaptive: add source id sequence as ES reuse signal
- - - - -
9 changed files:
- modules/demux/adaptive/ID.cpp
- modules/demux/adaptive/ID.hpp
- modules/demux/adaptive/Streams.cpp
- modules/demux/adaptive/Streams.hpp
- modules/demux/adaptive/plumbing/FakeESOut.cpp
- modules/demux/adaptive/plumbing/FakeESOut.hpp
- modules/demux/adaptive/plumbing/FakeESOutID.cpp
- modules/demux/adaptive/plumbing/FakeESOutID.hpp
- modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
Changes:
=====================================
modules/demux/adaptive/ID.cpp
=====================================
@@ -59,6 +59,33 @@ std::string ID::str() const
return id;
}
+unsigned SrcID::next = 0;
+
+SrcID::SrcID(unsigned n)
+{
+ id = n;
+}
+
+bool SrcID::operator==(const SrcID &other) const
+{
+ return this->id == other.id;
+}
+
+bool SrcID::operator!=(const SrcID &other) const
+{
+ return ! this->operator==(other);
+}
+
+const SrcID SrcID::make()
+{
+ return SrcID(++SrcID::next);
+}
+
+const SrcID SrcID::dummy()
+{
+ return SrcID(0);
+}
+
const ID & Unique::getID() const
{
return id;
=====================================
modules/demux/adaptive/ID.hpp
=====================================
@@ -39,6 +39,19 @@ namespace adaptive
std::string id;
};
+ class SrcID
+ {
+ public:
+ bool operator==(const SrcID &) const;
+ bool operator!=(const SrcID &) const;
+ static const SrcID make();
+ static const SrcID dummy();
+ private:
+ SrcID(unsigned);
+ unsigned id;
+ static unsigned next;
+ };
+
class Unique
{
public:
=====================================
modules/demux/adaptive/Streams.cpp
=====================================
@@ -648,6 +648,7 @@ block_t * AbstractStream::readNextBlock()
/* clear up discontinuity on demux start (discontinuity on start segment bug) */
discontinuity = false;
needrestart = false;
+ fakeesout->setSrcID(nextSrcID);
}
else if(discontinuity || needrestart)
{
@@ -798,6 +799,7 @@ void AbstractStream::trackerEvent(const TrackerEvent &ev)
static_cast<const DiscontinuityEvent &>(ev);
discontinuity = true;
currentSequence = event.discontinuitySequenceNumber;
+ nextSrcID = SrcID::make();
}
break;
@@ -844,6 +846,7 @@ void AbstractStream::trackerEvent(const TrackerEvent &ev)
event.next ? event.next->getStreamFormat().str().c_str() : ""));
if(event.next)
{
+ nextSrcID = SrcID::make();
currentrep.width = event.next->getWidth() > 0 ? event.next->getWidth() : 0;
currentrep.height = event.next->getHeight() > 0 ? event.next->getHeight() : 0;
}
=====================================
modules/demux/adaptive/Streams.hpp
=====================================
@@ -161,6 +161,8 @@ namespace adaptive
vlc_tick_t currentDuration;
uint64_t currentSequence;
+ SrcID nextSrcID = SrcID::dummy();
+
private:
void declaredCodecs();
BufferingStatus doBufferize(Times, vlc_tick_t, vlc_tick_t,
=====================================
modules/demux/adaptive/plumbing/FakeESOut.cpp
=====================================
@@ -243,7 +243,7 @@ FakeESOutID * FakeESOut::createNewID( const es_format_t *p_fmt )
if( extrainfo )
extrainfo->fillExtraFMTInfo( &fmtcopy );
- FakeESOutID *es_id = new (std::nothrow) FakeESOutID( this, &fmtcopy );
+ FakeESOutID *es_id = new (std::nothrow) FakeESOutID( this, &fmtcopy, srcID );
es_format_Clean( &fmtcopy );
@@ -377,6 +377,11 @@ void FakeESOut::setSynchronizationReference(const SynchronizationReference &r)
synchronizationReference = r;
}
+void FakeESOut::setSrcID( const SrcID &s )
+{
+ srcID = s;
+}
+
void FakeESOut::schedulePCRReset()
{
AbstractCommand *command = commandsfactory->creatEsOutControlResetPCRCommand();
=====================================
modules/demux/adaptive/plumbing/FakeESOut.hpp
=====================================
@@ -23,6 +23,7 @@
#include <vlc_common.h>
#include <list>
#include "../Time.hpp"
+#include "../ID.hpp"
#include <vlc_threads.h>
namespace adaptive
@@ -113,6 +114,7 @@ namespace adaptive
void setSegmentProgressTimes(const SegmentTimes &);
bool hasSynchronizationReference() const;
void setSynchronizationReference(const SynchronizationReference &);
+ void setSrcID( const SrcID & );
void schedulePCRReset();
void scheduleAllForDeletion(); /* Queue Del commands for non Del issued ones */
void recycleAll(); /* Cancels all commands and send fakees for recycling */
@@ -145,6 +147,7 @@ namespace adaptive
std::list<FakeESOutID *> declared;
SegmentTimes startTimes;
SynchronizationReference synchronizationReference;
+ SrcID srcID = SrcID::dummy();
};
}
=====================================
modules/demux/adaptive/plumbing/FakeESOutID.cpp
=====================================
@@ -33,6 +33,17 @@ FakeESOutID::FakeESOutID( FakeESOut *fakeesout, const es_format_t *p_fmt )
, pending_delete( false )
{
es_format_Copy( &fmt, p_fmt );
+ srcid = SrcID::make();
+}
+
+FakeESOutID::FakeESOutID( FakeESOut *fakeesout, const es_format_t *p_fmt,
+ const SrcID &srcid_ )
+ : fakeesout( fakeesout )
+ , p_real_es_id( nullptr )
+ , pending_delete( false )
+{
+ es_format_Copy( &fmt, p_fmt );
+ srcid = srcid_;
}
FakeESOutID::~FakeESOutID()
@@ -82,6 +93,9 @@ const es_format_t *FakeESOutID::getFmt() const
bool FakeESOutID::isCompatible( const FakeESOutID *p_other ) const
{
+ if( p_other->srcid != srcid )
+ return false;
+
if( p_other->fmt.i_cat != fmt.i_cat ||
fmt.i_codec != p_other->fmt.i_codec ||
fmt.i_original_fourcc != p_other->fmt.i_original_fourcc )
@@ -113,7 +127,7 @@ bool FakeESOutID::isCompatible( const FakeESOutID *p_other ) const
if(fmt.i_cat == AUDIO_ES)
{
/* Reject audio streams with different or unknown rates */
- if(fmt.audio.i_rate != p_other->fmt.audio.i_rate || !fmt.audio.i_rate)
+ if(fmt.audio.i_rate != p_other->fmt.audio.i_rate)
return false;
if(fmt.i_extra &&
(fmt.i_extra != p_other->fmt.i_extra ||
=====================================
modules/demux/adaptive/plumbing/FakeESOutID.hpp
=====================================
@@ -20,6 +20,8 @@
#ifndef FAKEESOUTID_HPP
#define FAKEESOUTID_HPP
+#include "../ID.hpp"
+
#include <vlc_common.h>
#include <vlc_es.h>
@@ -49,6 +51,7 @@ namespace adaptive
{
public:
FakeESOutID( FakeESOut *, const es_format_t * );
+ FakeESOutID( FakeESOut *, const es_format_t *, const SrcID & );
virtual ~FakeESOutID();
void setRealESID( es_out_id_t * );
virtual es_out_id_t * realESID() const override;
@@ -67,6 +70,7 @@ namespace adaptive
es_out_id_t *p_real_es_id;
es_format_t fmt;
bool pending_delete;
+ SrcID srcid = SrcID::dummy();
};
}
=====================================
modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
=====================================
@@ -240,13 +240,21 @@ static int check3(es_out_t *out, DummyEsOut *dummy, FakeESOut *fakees)
es_format_Clean(&fmt);
es_format_Init(&fmt, VIDEO_ES, VLC_CODEC_H264);
FakeESOutID fakeid3(fakees, &fmt);
- Expect(fakeid0.isCompatible(&fakeid0) == false); // aac without rate
+ fmt.i_codec = VLC_CODEC_MPGV;
+ FakeESOutID fakeid4(fakees, &fmt);
+ fakees->setSrcID(SrcID::make()); // change source sequence id
+ FakeESOutID fakeid0b(fakees, fakeid0.getFmt());
+ FakeESOutID fakeid4b(fakees, fakeid4.getFmt());
+ Expect(fakeid0.isCompatible(&fakeid0) == true); // aac without rate, same source
Expect(fakeid0.isCompatible(&fakeid1) == false); // aac rate/unknown mix
Expect(fakeid1.isCompatible(&fakeid1) == true); // aac with same rate
Expect(fakeid0.isCompatible(&fakeid3) == false); // different codecs
Expect(fakeid1.isCompatible(&fakeid2) == false); // different original fourcc
Expect(fakeid2.isCompatible(&fakeid2) == true); // same original fourcc
Expect(fakeid3.isCompatible(&fakeid3) == false); // same video with extra codecs
+ Expect(fakeid0.isCompatible(&fakeid0b) == false); // aac without rate, different source
+ Expect(fakeid4.isCompatible(&fakeid4) == true); // same codec, same sequence
+ Expect(fakeid4.isCompatible(&fakeid4b) == false); // same codec, different sequence
es_format_Clean(&fmt);
} catch (...) {
return 1;
@@ -327,24 +335,15 @@ static int check3(es_out_t *out, DummyEsOut *dummy, FakeESOut *fakees)
Expect(e->b_selected == true);
/* on restart / new segment, incompatible codec parameters, ES MUST NOT be reused */
+ fakees->setSrcID(SrcID::make());
fakees->recycleAll();
Expect(dummy->eslist.size() == 2);
es_format_Clean(&fmt);
es_format_Init(&fmt, VIDEO_ES, VLC_CODEC_H264);
id = es_out_Add(out, &fmt);
- /* check ID signaling so we don't blame FakeEsOut */
- {
- FakeESOutID fakeid(fakees, &fmt);
- Expect(fakeid.isCompatible(&fakeid) == false);
- }
es_format_Clean(&fmt);
es_format_Init(&fmt, AUDIO_ES, VLC_CODEC_MP4A);
id = es_out_Add(out, &fmt);
- /* check ID signaling so we don't blame FakeEsOut */
- {
- FakeESOutID fakeid(fakees, &fmt);
- Expect(fakeid.isCompatible(&fakeid) == false);
- }
fakees->commandsQueue()->Commit();
fakees->commandsQueue()->Process(drainTimes);
Expect(dummy->eslist.size() == 4);
@@ -354,6 +353,18 @@ static int check3(es_out_t *out, DummyEsOut *dummy, FakeESOut *fakees)
if( e->fmt.i_cat == VIDEO_ES )
Expect(e->b_selected == true);
+ /* on restart / new segment, with compatible codec parameters, ES MUST be reused */
+ fakees->recycleAll();
+ Expect(dummy->eslist.size() == 2);
+ es_format_Clean(&fmt);
+ es_format_Init(&fmt, AUDIO_ES, VLC_CODEC_MP4A);
+ id = es_out_Add(out, &fmt);
+ fakees->commandsQueue()->Commit();
+ fakees->commandsQueue()->Process(drainTimes);
+ Expect(dummy->eslist.size() == 2); // mp4a reused
+ fakees->gc(); // should drop video
+ Expect(dummy->eslist.size() == 1);
+ Expect(dummy->eslist.front()->fmt.i_codec == fmt.i_codec);
} catch (...) {
return 1;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/47b89d9892d9d43daf65deed7c8fd9353e175c7d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/47b89d9892d9d43daf65deed7c8fd9353e175c7d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list