[vlc-commits] demux: adaptive: add stream buffering state event
Francois Cartegnie
git at videolan.org
Wed Sep 21 18:52:33 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 16 10:43:09 2016 +0200| [c958babfdfb33148177e3989f97529eca959bfea] | committer: Francois Cartegnie
demux: adaptive: add stream buffering state event
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c958babfdfb33148177e3989f97529eca959bfea
---
modules/demux/adaptive/SegmentTracker.cpp | 12 ++++++++++++
modules/demux/adaptive/SegmentTracker.hpp | 12 +++++++++++-
modules/demux/adaptive/Streams.cpp | 6 ++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index e75ed32..2f03b8b 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -53,6 +53,13 @@ SegmentTrackerEvent::SegmentTrackerEvent(const StreamFormat *fmt)
u.format.f = fmt;
}
+SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, bool enabled)
+{
+ type = BUFFERING_STATE;
+ u.buffering.enabled = enabled;
+ u.buffering.id = &id;
+}
+
SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSet *adaptSet)
{
first = true;
@@ -302,6 +309,11 @@ mtime_t SegmentTracker::getMinAheadTime() const
return 0;
}
+void SegmentTracker::notifyBufferingState(bool enabled) const
+{
+ notify(SegmentTrackerEvent(adaptationSet->getID(), enabled));
+}
+
void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
{
listeners.push_back(listener);
diff --git a/modules/demux/adaptive/SegmentTracker.hpp b/modules/demux/adaptive/SegmentTracker.hpp
index e85d006..bdc0955 100644
--- a/modules/demux/adaptive/SegmentTracker.hpp
+++ b/modules/demux/adaptive/SegmentTracker.hpp
@@ -20,13 +20,15 @@
#ifndef SEGMENTTRACKER_HPP
#define SEGMENTTRACKER_HPP
-#include <StreamFormat.hpp>
+#include "StreamFormat.hpp"
#include <vlc_common.h>
#include <list>
namespace adaptive
{
+ class ID;
+
namespace http
{
class AbstractConnectionManager;
@@ -54,11 +56,13 @@ namespace adaptive
SegmentTrackerEvent(SegmentChunk *);
SegmentTrackerEvent(BaseRepresentation *, BaseRepresentation *);
SegmentTrackerEvent(const StreamFormat *);
+ SegmentTrackerEvent(const ID &, bool);
enum
{
DISCONTINUITY,
SWITCHING,
FORMATCHANGE,
+ BUFFERING_STATE,
} type;
union
{
@@ -75,6 +79,11 @@ namespace adaptive
{
const StreamFormat *f;
} format;
+ struct
+ {
+ const ID *id;
+ bool enabled;
+ } buffering;
} u;
};
@@ -98,6 +107,7 @@ namespace adaptive
void setPositionByNumber(uint64_t, bool);
mtime_t getPlaybackTime() const; /* Current segment start time if selected */
mtime_t getMinAheadTime() const;
+ void notifyBufferingState(bool) const;
void registerListener(SegmentTrackerListenerInterface *);
void updateSelected();
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index be2da33..dcb325b 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -23,6 +23,7 @@
#endif
#include "Streams.hpp"
+#include "logic/AbstractAdaptationLogic.h"
#include "http/HTTPConnection.hpp"
#include "http/HTTPConnectionManager.h"
#include "playlist/BaseRepresentation.h"
@@ -77,6 +78,7 @@ bool AbstractStream::init(const StreamFormat &format_, SegmentTracker *tracker,
format = format_;
segmentTracker = tracker;
segmentTracker->registerListener(this);
+ segmentTracker->notifyBufferingState(true);
connManager = conn;
return true;
}
@@ -97,6 +99,8 @@ bool AbstractStream::init(const StreamFormat &format_, SegmentTracker *tracker,
AbstractStream::~AbstractStream()
{
delete currentChunk;
+ if(segmentTracker)
+ segmentTracker->notifyBufferingState(false);
delete segmentTracker;
delete demuxer;
@@ -234,6 +238,8 @@ bool AbstractStream::restartDemux()
void AbstractStream::setDisabled(bool b)
{
+ if(disabled != b)
+ segmentTracker->notifyBufferingState(!b);
disabled = b;
}
More information about the vlc-commits
mailing list