[vlc-commits] demux: adaptive: change tracker Events
Francois Cartegnie
git at videolan.org
Fri Jan 22 15:12:26 UTC 2021
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jan 20 19:23:00 2021 +0100| [79ca05e2e228fa7c62a101bedcf3292284713740] | committer: Francois Cartegnie
demux: adaptive: change tracker Events
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=79ca05e2e228fa7c62a101bedcf3292284713740
---
modules/demux/adaptive/SegmentTracker.cpp | 85 +++++++++------
modules/demux/adaptive/SegmentTracker.hpp | 119 +++++++++++++--------
modules/demux/adaptive/Streams.cpp | 38 ++++---
modules/demux/adaptive/Streams.hpp | 2 +-
.../demux/adaptive/logic/AbstractAdaptationLogic.h | 2 +-
.../adaptive/logic/NearOptimalAdaptationLogic.cpp | 36 ++++---
.../adaptive/logic/NearOptimalAdaptationLogic.hpp | 2 +-
.../adaptive/logic/PredictiveAdaptationLogic.cpp | 44 ++++----
.../adaptive/logic/PredictiveAdaptationLogic.hpp | 2 +-
.../adaptive/logic/RateBasedAdaptationLogic.cpp | 14 +--
.../adaptive/logic/RateBasedAdaptationLogic.h | 2 +-
11 files changed, 210 insertions(+), 136 deletions(-)
diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 0cc7035175..7368be83ed 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -38,46 +38,63 @@ using namespace adaptive;
using namespace adaptive::logic;
using namespace adaptive::playlist;
-SegmentTrackerEvent::SegmentTrackerEvent(SegmentChunk *s)
+TrackerEvent::TrackerEvent(Type t)
{
- type = Type::Discontinuity;
- u.discontinuity.sc = s;
+ type = t;
}
-SegmentTrackerEvent::SegmentTrackerEvent(BaseRepresentation *prev, BaseRepresentation *next)
+TrackerEvent::~TrackerEvent()
{
- type = Type::RepresentationSwitch;
- u.switching.prev = prev;
- u.switching.next = next;
+
+}
+
+TrackerEvent::Type TrackerEvent::getType() const
+{
+ return type;
+}
+
+DiscontinuityEvent::DiscontinuityEvent()
+ : TrackerEvent(Type::Discontinuity)
+{
+
+}
+
+RepresentationSwitchEvent::RepresentationSwitchEvent(BaseRepresentation *prev,
+ BaseRepresentation *next)
+ : TrackerEvent(Type::RepresentationSwitch)
+{
+ this->prev = prev;
+ this->next = next;
}
-SegmentTrackerEvent::SegmentTrackerEvent(const StreamFormat *fmt)
+FormatChangedEvent::FormatChangedEvent(const StreamFormat *f)
+ : TrackerEvent(Type::FormatChange)
{
- type = Type::FormatChange;
- u.format.f = fmt;
+ this->format = f;
}
-SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, bool enabled)
+SegmentChangedEvent::SegmentChangedEvent(const ID &id, vlc_tick_t duration)
+ : TrackerEvent(Type::SegmentChange)
{
- type = Type::BufferingStateUpdate;
- u.buffering.enabled = enabled;
- u.buffering.id = &id;
+ this->id = &id;
+ this->duration = duration;
}
-SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, vlc_tick_t min, vlc_tick_t current, vlc_tick_t target)
+BufferingStateUpdatedEvent::BufferingStateUpdatedEvent(const ID &id, bool enabled)
+ : TrackerEvent(Type::BufferingStateUpdate)
{
- type = Type::BufferingLevelChange;
- u.buffering_level.minimum = min;
- u.buffering_level.current = current;
- u.buffering_level.target = target;
- u.buffering.id = &id;
+ this->id = &id;
+ this->enabled = enabled;
}
-SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, vlc_tick_t duration)
+BufferingLevelChangedEvent::BufferingLevelChangedEvent(const ID &id, vlc_tick_t minimum,
+ vlc_tick_t current, vlc_tick_t target)
+ : TrackerEvent(Type::BufferingLevelChange)
{
- type = Type::SegmentChange;
- u.segment.duration = duration;
- u.segment.id = &id;
+ this->id = &id;
+ this->minimum = minimum;
+ this->current = current;
+ this->target = target;
}
SegmentTracker::SegmentTracker(SharedResources *res,
@@ -198,7 +215,7 @@ const Role & SegmentTracker::getStreamRole() const
void SegmentTracker::reset()
{
- notify(SegmentTrackerEvent(current.rep, nullptr));
+ notify(RepresentationSwitchEvent(current.rep, nullptr));
current = Position();
next = Position();
initializing = true;
@@ -257,7 +274,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
if(b_switched)
{
- notify(SegmentTrackerEvent(current.rep, next.rep));
+ notify(RepresentationSwitchEvent(current.rep, next.rep));
initializing = true;
assert(!next.index_sent);
assert(!next.init_sent);
@@ -276,7 +293,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
else
{
format = current.rep->getStreamFormat();
- notify(SegmentTrackerEvent(&format)); /* Notify new demux format */
+ notify(FormatChangedEvent(&format)); /* Notify new demux format */
return nullptr; /* Force current demux to end */
}
}
@@ -284,7 +301,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
{
/* Handle the corner case when only the demuxer can know the format and
* demuxer starts after the format change (Probe != buffering) */
- notify(SegmentTrackerEvent(&format)); /* Notify new demux format */
+ notify(FormatChangedEvent(&format)); /* Notify new demux format */
return nullptr; /* Force current demux to end */
}
@@ -334,7 +351,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
if(chunk)
{
const Timescale timescale = next.rep->inheritTimescale();
- notify(SegmentTrackerEvent(next.rep->getAdaptationSet()->getID(),
+ notify(SegmentChangedEvent(next.rep->getAdaptationSet()->getID(),
timescale.ToTime(segment->duration.Get())));
}
@@ -342,13 +359,13 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
if(chunk && format != chunk->getStreamFormat())
{
format = chunk->getStreamFormat();
- notify(SegmentTrackerEvent(&format));
+ notify(FormatChangedEvent(&format));
}
/* Handle both implicit and explicit discontinuities */
if( (b_gap && next.number) || (chunk && chunk->discontinuity) )
{
- notify(SegmentTrackerEvent(chunk));
+ notify(DiscontinuityEvent());
}
if(chunk)
@@ -465,12 +482,12 @@ vlc_tick_t SegmentTracker::getMinAheadTime() const
void SegmentTracker::notifyBufferingState(bool enabled) const
{
- notify(SegmentTrackerEvent(adaptationSet->getID(), enabled));
+ notify(BufferingStateUpdatedEvent(adaptationSet->getID(), enabled));
}
void SegmentTracker::notifyBufferingLevel(vlc_tick_t min, vlc_tick_t current, vlc_tick_t target) const
{
- notify(SegmentTrackerEvent(adaptationSet->getID(), min, current, target));
+ notify(BufferingLevelChangedEvent(adaptationSet->getID(), min, current, target));
}
void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
@@ -494,7 +511,7 @@ void SegmentTracker::updateSelected()
}
}
-void SegmentTracker::notify(const SegmentTrackerEvent &event) const
+void SegmentTracker::notify(const TrackerEvent &event) const
{
std::list<SegmentTrackerListenerInterface *>::const_iterator it;
for(it=listeners.begin();it != listeners.end(); ++it)
diff --git a/modules/demux/adaptive/SegmentTracker.hpp b/modules/demux/adaptive/SegmentTracker.hpp
index cd303ec072..e3711b9bea 100644
--- a/modules/demux/adaptive/SegmentTracker.hpp
+++ b/modules/demux/adaptive/SegmentTracker.hpp
@@ -53,15 +53,9 @@ namespace adaptive
using namespace logic;
using namespace http;
- class SegmentTrackerEvent
+ class TrackerEvent
{
public:
- SegmentTrackerEvent(SegmentChunk *);
- SegmentTrackerEvent(BaseRepresentation *, BaseRepresentation *);
- SegmentTrackerEvent(const StreamFormat *);
- SegmentTrackerEvent(const ID &, bool);
- SegmentTrackerEvent(const ID &, vlc_tick_t, vlc_tick_t, vlc_tick_t);
- SegmentTrackerEvent(const ID &, vlc_tick_t);
enum class Type
{
Discontinuity,
@@ -70,46 +64,85 @@ namespace adaptive
SegmentChange,
BufferingStateUpdate,
BufferingLevelChange,
- } type;
- union
- {
- struct
- {
- SegmentChunk *sc;
- } discontinuity;
- struct
- {
- BaseRepresentation *prev;
- BaseRepresentation *next;
- } switching;
- struct
- {
- const StreamFormat *f;
- } format;
- struct
- {
- const ID *id;
- bool enabled;
- } buffering;
- struct
- {
- const ID *id;
- vlc_tick_t minimum;
- vlc_tick_t current;
- vlc_tick_t target;
- } buffering_level;
- struct
- {
- const ID *id;
- vlc_tick_t duration;
- } segment;
- } u;
+ };
+ TrackerEvent() = delete;
+ virtual ~TrackerEvent() = 0;
+ Type getType() const;
+
+ protected:
+ TrackerEvent(Type t);
+
+ private:
+ Type type;
+ };
+
+ class DiscontinuityEvent : public TrackerEvent
+ {
+ public:
+ DiscontinuityEvent();
+ virtual ~DiscontinuityEvent() = default;
+ };
+
+ class RepresentationSwitchEvent : public TrackerEvent
+ {
+ public:
+ RepresentationSwitchEvent() = delete;
+ RepresentationSwitchEvent(BaseRepresentation *, BaseRepresentation *);
+ virtual ~RepresentationSwitchEvent() = default;
+
+ BaseRepresentation *prev;
+ BaseRepresentation *next;
+ };
+
+ class FormatChangedEvent : public TrackerEvent
+ {
+ public:
+ FormatChangedEvent() = delete;
+ FormatChangedEvent(const StreamFormat *);
+ virtual ~FormatChangedEvent() = default;
+
+ const StreamFormat *format;
+ };
+
+ class SegmentChangedEvent : public TrackerEvent
+ {
+ public:
+ SegmentChangedEvent() = delete;
+ SegmentChangedEvent(const ID &, vlc_tick_t);
+ virtual ~SegmentChangedEvent() = default;
+
+ const ID *id;
+ vlc_tick_t duration;
+ };
+
+ class BufferingStateUpdatedEvent : public TrackerEvent
+ {
+ public:
+ BufferingStateUpdatedEvent() = delete;
+ BufferingStateUpdatedEvent(const ID &, bool);
+ virtual ~BufferingStateUpdatedEvent() = default;
+
+ const ID *id;
+ bool enabled;
+ };
+
+ class BufferingLevelChangedEvent : public TrackerEvent
+ {
+ public:
+ BufferingLevelChangedEvent() = delete;
+ BufferingLevelChangedEvent(const ID &, vlc_tick_t, vlc_tick_t, vlc_tick_t);
+ virtual ~BufferingLevelChangedEvent() = default;
+
+ const ID *id;
+ vlc_tick_t minimum;
+ vlc_tick_t current;
+ vlc_tick_t target;
};
class SegmentTrackerListenerInterface
{
public:
- virtual void trackerEvent(const SegmentTrackerEvent &) = 0;
+ virtual void trackerEvent(const TrackerEvent &) = 0;
virtual ~SegmentTrackerListenerInterface() = default;
};
@@ -158,7 +191,7 @@ namespace adaptive
private:
void setAdaptationLogic(AbstractAdaptationLogic *);
- void notify(const SegmentTrackerEvent &) const;
+ void notify(const TrackerEvent &) const;
bool first;
bool initializing;
Position current;
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index b8434e8603..04cfc39f87 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -639,45 +639,53 @@ AbstractDemuxer *AbstractStream::newDemux(vlc_object_t *p_obj, const StreamForma
return ret;
}
-void AbstractStream::trackerEvent(const SegmentTrackerEvent &event)
+void AbstractStream::trackerEvent(const TrackerEvent &ev)
{
- switch(event.type)
+ switch(ev.getType())
{
- case SegmentTrackerEvent::Type::Discontinuity:
+ case TrackerEvent::Type::Discontinuity:
discontinuity = true;
break;
- case SegmentTrackerEvent::Type::FormatChange:
+ case TrackerEvent::Type::FormatChange:
+ {
+ const FormatChangedEvent &event =
+ static_cast<const FormatChangedEvent &>(ev);
/* Check if our current demux is still valid */
- if(*event.u.format.f != format || format == StreamFormat(StreamFormat::UNKNOWN))
+ if(*event.format != format || format == StreamFormat(StreamFormat::UNKNOWN))
{
/* Format has changed between segments, we need to drain and change demux */
msg_Info(p_realdemux, "Changing stream format %s -> %s",
- format.str().c_str(), event.u.format.f->str().c_str());
- format = *event.u.format.f;
+ format.str().c_str(), event.format->str().c_str());
+ format = *event.format;
/* This is an implict discontinuity */
discontinuity = true;
}
+ }
break;
- case SegmentTrackerEvent::Type::RepresentationSwitch:
+ case TrackerEvent::Type::RepresentationSwitch:
+ {
+ const RepresentationSwitchEvent &event =
+ static_cast<const RepresentationSwitchEvent &>(ev);
if(demuxer && !inrestart)
{
if(!demuxer->bitstreamSwitchCompatible() ||
- (event.u.switching.next &&
- !event.u.switching.next->getAdaptationSet()->isBitSwitchable()))
+ (event.next &&
+ !event.next->getAdaptationSet()->isBitSwitchable()))
needrestart = true;
}
AdvDebug(msg_Dbg(p_realdemux, "Stream %s switching %s %s to %s %s",
description.c_str(),
- event.u.switching.prev ? event.u.switching.prev->getID().str().c_str() : "",
- event.u.switching.prev ? event.u.switching.prev->getStreamFormat().str().c_str() : "",
- event.u.switching.next ? event.u.switching.next->getID().str().c_str() : "",
- event.u.switching.next ? event.u.switching.next->getStreamFormat().str().c_str() : ""));
+ event.prev ? event.prev->getID().str().c_str() : "",
+ event.prev ? event.prev->getStreamFormat().str().c_str() : "",
+ event.next ? event.next->getID().str().c_str() : "",
+ event.next ? event.next->getStreamFormat().str().c_str() : ""));
+ }
break;
- case SegmentTrackerEvent::Type::SegmentChange:
+ case TrackerEvent::Type::SegmentChange:
if(demuxer && demuxer->needsRestartOnEachSegment() && !inrestart)
{
needrestart = true;
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index b255642bb7..54ea4e5b72 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -98,7 +98,7 @@ namespace adaptive
/**/
virtual void fillExtraFMTInfo( es_format_t * ) const override;
- virtual void trackerEvent(const SegmentTrackerEvent &) override;
+ virtual void trackerEvent(const TrackerEvent &) override;
protected:
bool seekAble() const;
diff --git a/modules/demux/adaptive/logic/AbstractAdaptationLogic.h b/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
index 7542114ce9..33becd4aca 100644
--- a/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
+++ b/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
@@ -49,7 +49,7 @@ namespace adaptive
virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) = 0;
virtual void updateDownloadRate (const ID &, size_t, vlc_tick_t);
- virtual void trackerEvent (const SegmentTrackerEvent &) {}
+ virtual void trackerEvent (const TrackerEvent &) override {}
void setMaxDeviceResolution (int, int);
enum class LogicType
diff --git a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
index b171bfbe1f..d5e42b2d48 100644
--- a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
@@ -194,27 +194,31 @@ void NearOptimalAdaptationLogic::updateDownloadRate(const ID &id, size_t dlsize,
vlc_mutex_unlock(&lock);
}
-void NearOptimalAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
+void NearOptimalAdaptationLogic::trackerEvent(const TrackerEvent &ev)
{
- switch(event.type)
+ switch(ev.getType())
{
- case SegmentTrackerEvent::Type::RepresentationSwitch:
+ case TrackerEvent::Type::RepresentationSwitch:
{
+ const RepresentationSwitchEvent &event =
+ static_cast<const RepresentationSwitchEvent &>(ev);
vlc_mutex_lock(&lock);
- if(event.u.switching.prev)
- usedBps -= event.u.switching.prev->getBandwidth();
- if(event.u.switching.next)
- usedBps += event.u.switching.next->getBandwidth();
+ if(event.prev)
+ usedBps -= event.prev->getBandwidth();
+ if(event.next)
+ usedBps += event.next->getBandwidth();
BwDebug(msg_Info(p_obj, "New total bandwidth usage %zu kBps", (usedBps / 8000)));
vlc_mutex_unlock(&lock);
}
break;
- case SegmentTrackerEvent::Type::BufferingStateUpdate:
+ case TrackerEvent::Type::BufferingStateUpdate:
{
- const ID &id = *event.u.buffering.id;
+ const BufferingStateUpdatedEvent &event =
+ static_cast<const BufferingStateUpdatedEvent &>(ev);
+ const ID &id = *event.id;
vlc_mutex_lock(&lock);
- if(event.u.buffering.enabled)
+ if(event.enabled)
{
if(streams.find(id) == streams.end())
{
@@ -230,17 +234,19 @@ void NearOptimalAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
}
vlc_mutex_unlock(&lock);
BwDebug(msg_Info(p_obj, "Stream %s is now known %sactive", id.str().c_str(),
- (event.u.buffering.enabled) ? "" : "in"));
+ (event.enabled) ? "" : "in"));
}
break;
- case SegmentTrackerEvent::Type::BufferingLevelChange:
+ case TrackerEvent::Type::BufferingLevelChange:
{
- const ID &id = *event.u.buffering.id;
+ const BufferingLevelChangedEvent &event =
+ static_cast<const BufferingLevelChangedEvent &>(ev);
+ const ID &id = *event.id;
vlc_mutex_lock(&lock);
NearOptimalContext &ctx = streams[id];
- ctx.buffering_level = event.u.buffering_level.current;
- ctx.buffering_target = event.u.buffering_level.target;
+ ctx.buffering_level = event.current;
+ ctx.buffering_target = event.target;
vlc_mutex_unlock(&lock);
}
break;
diff --git a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
index 022b42badf..ee2cd9815f 100644
--- a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
+++ b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
@@ -53,7 +53,7 @@ namespace adaptive
virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *,
BaseRepresentation *) override;
virtual void updateDownloadRate (const ID &, size_t, vlc_tick_t) override;
- virtual void trackerEvent (const SegmentTrackerEvent &) override;
+ virtual void trackerEvent (const TrackerEvent &) override;
private:
BaseRepresentation * getNextQualityIndex( BaseAdaptationSet *, RepresentationSelector &,
diff --git a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
index 2e05cfb2d1..24221c62e5 100644
--- a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
@@ -175,28 +175,32 @@ unsigned PredictiveAdaptationLogic::getAvailableBw(unsigned i_bw, const BaseRepr
return i_remain > i_bw ? i_remain : i_bw;
}
-void PredictiveAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
+void PredictiveAdaptationLogic::trackerEvent(const TrackerEvent &ev)
{
- switch(event.type)
+ switch(ev.getType())
{
- case SegmentTrackerEvent::Type::RepresentationSwitch:
+ case TrackerEvent::Type::RepresentationSwitch:
{
+ const RepresentationSwitchEvent &event =
+ static_cast<const RepresentationSwitchEvent &>(ev);
vlc_mutex_lock(&lock);
- if(event.u.switching.prev)
- usedBps -= event.u.switching.prev->getBandwidth();
- if(event.u.switching.next)
- usedBps += event.u.switching.next->getBandwidth();
+ if(event.prev)
+ usedBps -= event.prev->getBandwidth();
+ if(event.next)
+ usedBps += event.next->getBandwidth();
BwDebug(msg_Info(p_obj, "New total bandwidth usage %zu KiB/s", (usedBps / 8000)));
vlc_mutex_unlock(&lock);
}
break;
- case SegmentTrackerEvent::Type::BufferingStateUpdate:
+ case TrackerEvent::Type::BufferingStateUpdate:
{
- const ID &id = *event.u.buffering.id;
+ const BufferingStateUpdatedEvent &event =
+ static_cast<const BufferingStateUpdatedEvent &>(ev);
+ const ID &id = *event.id;
vlc_mutex_lock(&lock);
- if(event.u.buffering.enabled)
+ if(event.enabled)
{
if(streams.find(id) == streams.end())
{
@@ -212,27 +216,31 @@ void PredictiveAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
}
vlc_mutex_unlock(&lock);
BwDebug(msg_Info(p_obj, "Stream %s is now known %sactive", id.str().c_str(),
- (event.u.buffering.enabled) ? "" : "in"));
+ (event.enabled) ? "" : "in"));
}
break;
- case SegmentTrackerEvent::Type::BufferingLevelChange:
+ case TrackerEvent::Type::BufferingLevelChange:
{
- const ID &id = *event.u.buffering.id;
+ const BufferingLevelChangedEvent &event =
+ static_cast<const BufferingLevelChangedEvent &>(ev);
+ const ID &id = *event.id;
vlc_mutex_lock(&lock);
PredictiveStats &stats = streams[id];
- stats.buffering_level = event.u.buffering_level.current;
- stats.buffering_target = event.u.buffering_level.target;
+ stats.buffering_level = event.current;
+ stats.buffering_target = event.target;
vlc_mutex_unlock(&lock);
}
break;
- case SegmentTrackerEvent::Type::SegmentChange:
+ case TrackerEvent::Type::SegmentChange:
{
- const ID &id = *event.u.segment.id;
+ const SegmentChangedEvent &event =
+ static_cast<const SegmentChangedEvent &>(ev);
+ const ID &id = *event.id;
vlc_mutex_lock(&lock);
PredictiveStats &stats = streams[id];
- stats.last_duration = event.u.segment.duration;
+ stats.last_duration = event.duration;
vlc_mutex_unlock(&lock);
}
break;
diff --git a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
index c69e47fa16..cf60162889 100644
--- a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
+++ b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
@@ -54,7 +54,7 @@ namespace adaptive
virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *,
BaseRepresentation *) override;
virtual void updateDownloadRate (const ID &, size_t, vlc_tick_t) override;
- virtual void trackerEvent (const SegmentTrackerEvent &) override;
+ virtual void trackerEvent (const TrackerEvent &) override;
private:
unsigned getAvailableBw(unsigned, const BaseRepresentation *) const;
diff --git a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
index caf9c55a17..f657bdf8a7 100644
--- a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
@@ -105,15 +105,17 @@ void RateBasedAdaptationLogic::updateDownloadRate(const ID &, size_t size, vlc_t
vlc_mutex_unlock(&lock);
}
-void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
+void RateBasedAdaptationLogic::trackerEvent(const TrackerEvent &ev)
{
- if(event.type == SegmentTrackerEvent::Type::RepresentationSwitch)
+ if(ev.getType() == TrackerEvent::Type::RepresentationSwitch)
{
+ const RepresentationSwitchEvent &event =
+ static_cast<const RepresentationSwitchEvent &>(ev);
vlc_mutex_lock(&lock);
- if(event.u.switching.prev)
- usedBps -= event.u.switching.prev->getBandwidth();
- if(event.u.switching.next)
- usedBps += event.u.switching.next->getBandwidth();
+ if(event.prev)
+ usedBps -= event.prev->getBandwidth();
+ if(event.next)
+ usedBps += event.next->getBandwidth();
BwDebug(msg_Info(p_obj, "New bandwidth usage %zu KiB/s %u%%",
(usedBps / 8000), (bpsAvg) ? (unsigned)(usedBps * 100.0 / bpsAvg) : 0 ));
diff --git a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
index 33b9a2b680..9b94996e54 100644
--- a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
+++ b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
@@ -42,7 +42,7 @@ namespace adaptive
BaseRepresentation *getNextRepresentation(BaseAdaptationSet *,
BaseRepresentation *) override;
virtual void updateDownloadRate(const ID &, size_t, vlc_tick_t) override;
- virtual void trackerEvent(const SegmentTrackerEvent &) override;
+ virtual void trackerEvent(const TrackerEvent &) override;
private:
size_t bpsAvg;
More information about the vlc-commits
mailing list