[vlc-commits] demux: adaptive: enable start without probing all alternatives
Francois Cartegnie
git at videolan.org
Mon May 20 16:58:08 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Apr 29 17:26:12 2019 +0200| [6ae1fd2d0e37b02bc132857ee3f82eab3a8147f7] | committer: Francois Cartegnie
demux: adaptive: enable start without probing all alternatives
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ae1fd2d0e37b02bc132857ee3f82eab3a8147f7
---
modules/demux/adaptive/PlaylistManager.cpp | 13 ++++++++---
modules/demux/adaptive/SegmentTracker.cpp | 29 +++++++++++++++++++++++
modules/demux/adaptive/SegmentTracker.hpp | 3 +++
modules/demux/adaptive/Streams.cpp | 37 ++++++++++++++++++++++++++----
modules/demux/adaptive/Streams.hpp | 1 +
5 files changed, 76 insertions(+), 7 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 5b94eeb88e..fbf342e728 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -238,9 +238,16 @@ AbstractStream::buffering_status PlaylistManager::bufferize(vlc_tick_t i_nzdeadl
if(!st->isValid())
continue;
- if (st->isDisabled() &&
- (!st->isSelected() || !reactivateStream(st)))
- continue;
+ if(st->esCount())
+ {
+ if (st->isDisabled() &&
+ (!st->isSelected() || !reactivateStream(st)))
+ continue;
+ }
+ else
+ {
+ /* initial */
+ }
AbstractStream::buffering_status i_ret = st->bufferize(i_nzdeadline, i_min_buffering, i_extra_buffering);
if(i_return != AbstractStream::buffering_ongoing) /* Buffering streams need to keep going */
diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 8b2ab7c79e..d9d06296d8 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -117,6 +117,26 @@ StreamFormat SegmentTracker::getCurrentFormat() const
return StreamFormat();
}
+std::list<std::string> SegmentTracker::getCurrentCodecs() const
+{
+ BaseRepresentation *rep = curRepresentation;
+ if(!rep)
+ rep = logic->getNextRepresentation(adaptationSet, NULL);
+ if(rep)
+ return rep->getCodecs();
+ return std::list<std::string>();
+}
+
+const std::string & SegmentTracker::getStreamDescription() const
+{
+ return adaptationSet->description.Get();
+}
+
+const std::string & SegmentTracker::getStreamLanguage() const
+{
+ return adaptationSet->getLang();
+}
+
const Role & SegmentTracker::getStreamRole() const
{
return adaptationSet->getRole();
@@ -292,6 +312,15 @@ bool SegmentTracker::setPositionByTime(vlc_tick_t time, bool restarted, bool try
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
+ /* Stream might not have been loaded at all (HLS) or expired */
+ if(rep && rep->needsUpdate() &&
+ !rep->runLocalUpdates(resources, time, curNumber, false))
+ {
+ msg_Err(rep->getAdaptationSet()->getPlaylist()->getVLCObject(),
+ "Failed to update Representation %s", rep->getID().str().c_str());
+ return false;
+ }
+
if(rep &&
rep->getSegmentNumberByTime(time, &segnumber))
{
diff --git a/modules/demux/adaptive/SegmentTracker.hpp b/modules/demux/adaptive/SegmentTracker.hpp
index 925b265e28..a7a837ce12 100644
--- a/modules/demux/adaptive/SegmentTracker.hpp
+++ b/modules/demux/adaptive/SegmentTracker.hpp
@@ -119,6 +119,9 @@ namespace adaptive
~SegmentTracker();
StreamFormat getCurrentFormat() const;
+ std::list<std::string> getCurrentCodecs() const;
+ const std::string & getStreamDescription() const;
+ const std::string & getStreamLanguage() const;
const Role & getStreamRole() const;
bool segmentsListReady() const;
void reset();
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index bcc1f6aa96..1fc3e1ed4c 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -31,6 +31,7 @@
#include "playlist/SegmentChunk.hpp"
#include "plumbing/SourceStream.hpp"
#include "plumbing/CommandsQueue.hpp"
+#include "tools/FormatNamespace.hpp"
#include "tools/Debug.hpp"
#include <vlc_demux.h>
@@ -90,6 +91,7 @@ bool AbstractStream::init(const StreamFormat &format_, SegmentTracker *tracker,
segmentTracker->notifyBufferingState(true);
connManager = conn;
setTimeOffset(segmentTracker->getPlaybackTime());
+ declaredCodecs();
return true;
}
delete commandsqueue;
@@ -193,7 +195,7 @@ bool AbstractStream::seekAble() const
"discontinuity %d, commandsqueue draining %d, commandsqueue eof %d",
static_cast<void *>(demuxer), restarting, discontinuity, draining, eof);
- if(!demuxer || restarting || discontinuity || (!eof && draining))
+ if(!valid || restarting || discontinuity || (!eof && draining))
{
msg_Warn(p_realdemux, "not seekable");
return false;
@@ -242,6 +244,7 @@ bool AbstractStream::restartDemux()
bool b_ret = true;
if(!demuxer)
{
+ fakeesout->recycleAll();
b_ret = startDemux();
}
else if(demuxer->needsRestartOnSeek())
@@ -514,13 +517,14 @@ bool AbstractStream::setPosition(vlc_tick_t time, bool tryonly)
if(!seekAble())
return false;
- bool ret = segmentTracker->setPositionByTime(time, demuxer->needsRestartOnSeek(), tryonly);
+ bool b_needs_restart = demuxer ? demuxer->needsRestartOnSeek() : true;
+ bool ret = segmentTracker->setPositionByTime(time, b_needs_restart, tryonly);
if(!tryonly && ret)
{
// clear eof flag before restartDemux() to prevent readNextBlock() fail
eof = false;
notfound_sequence = 0;
- if(demuxer->needsRestartOnSeek())
+ if(b_needs_restart)
{
if(currentChunk)
delete currentChunk;
@@ -577,7 +581,7 @@ void AbstractStream::setTimeOffset(vlc_tick_t i_offset)
{
fakeEsOut()->setExpectedTimestampOffset(0);
}
- else if(demuxer)
+ else
{
fakeEsOut()->setExpectedTimestampOffset(i_offset);
}
@@ -662,6 +666,31 @@ void AbstractStream::trackerEvent(const SegmentTrackerEvent &event)
}
}
+void AbstractStream::declaredCodecs()
+{
+ const std::string & streamDesc = segmentTracker->getStreamDescription();
+ const std::string & streamLang = segmentTracker->getStreamLanguage();
+ std::list<std::string> codecs = segmentTracker->getCurrentCodecs();
+ for(std::list<std::string>::const_iterator it = codecs.begin();
+ it != codecs.end(); ++it)
+ {
+ FormatNamespace fnsp(*it);
+
+ es_format_t fmt;
+ es_format_Init(&fmt, fnsp.getFmt()->i_cat, fnsp.getFmt()->i_codec);
+ es_format_Copy(&fmt, fnsp.getFmt());
+
+ if(!streamLang.empty())
+ fmt.psz_language = strdup(streamLang.c_str());
+ if(!streamDesc.empty())
+ fmt.psz_description = strdup(streamDesc.c_str());
+
+ fakeEsOut()->declareEs( &fmt );
+
+ es_format_Clean(&fmt);
+ }
+}
+
FakeESOut::LockedFakeEsOut AbstractStream::fakeEsOut()
{
return fakeesout->WithLock();
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index 7c78d700e2..22989c9729 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -135,6 +135,7 @@ namespace adaptive
vlc_mutex_t lock; /* lock for everything accessed by dequeuing */
private:
+ void declaredCodecs();
buffering_status doBufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t);
buffering_status last_buffer_status;
bool valid;
More information about the vlc-commits
mailing list