Commit 5f1dec1a authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: add bandwith debugging

parent 39589fb6
...@@ -411,7 +411,8 @@ AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::L ...@@ -411,7 +411,8 @@ AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::L
{ {
int width = var_InheritInteger(p_demux, "adaptative-width"); int width = var_InheritInteger(p_demux, "adaptative-width");
int height = var_InheritInteger(p_demux, "adaptative-height"); int height = var_InheritInteger(p_demux, "adaptative-height");
RateBasedAdaptationLogic *logic = new (std::nothrow) RateBasedAdaptationLogic(width, height); RateBasedAdaptationLogic *logic =
new (std::nothrow) RateBasedAdaptationLogic(VLC_OBJECT(p_demux), width, height);
conn->setDownloadRateObserver(logic); conn->setDownloadRateObserver(logic);
return logic; return logic;
} }
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
#include "../playlist/BaseRepresentation.h" #include "../playlist/BaseRepresentation.h"
#include "../playlist/BasePeriod.h" #include "../playlist/BasePeriod.h"
#include "../http/Chunk.h" #include "../http/Chunk.h"
#include "../tools/Debug.hpp"
using namespace adaptative::logic; using namespace adaptative::logic;
RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) : RateBasedAdaptationLogic::RateBasedAdaptationLogic (vlc_object_t *p_obj_, int w, int h) :
AbstractAdaptationLogic (), AbstractAdaptationLogic (),
bpsAvg(0), bpsRemainder(0), bpsSamplecount(0), bpsAvg(0), bpsRemainder(0), bpsSamplecount(0),
currentBps(0) currentBps(0)
...@@ -42,6 +43,7 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) : ...@@ -42,6 +43,7 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
width = w; width = w;
height = h; height = h;
usedBps = 0; usedBps = 0;
p_obj = p_obj_;
} }
BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *currep) const BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *currep) const
...@@ -86,6 +88,9 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time) ...@@ -86,6 +88,9 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
} }
currentBps = bpsAvg * 3/4; currentBps = bpsAvg * 3/4;
BwDebug(msg_Info(p_obj, "Current bandwidth %zu KiB/s using %u%%",
(bpsAvg / 8192), (bpsAvg) ? (unsigned)(usedBps * 100.0 / bpsAvg) : 0 ));
} }
void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event) void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
...@@ -96,6 +101,9 @@ void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event) ...@@ -96,6 +101,9 @@ void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
usedBps -= event.u.switching.prev->getBandwidth(); usedBps -= event.u.switching.prev->getBandwidth();
if(event.u.switching.next) if(event.u.switching.next)
usedBps += event.u.switching.next->getBandwidth(); usedBps += event.u.switching.next->getBandwidth();
BwDebug(msg_Info(p_obj, "New bandwidth usage %zu KiB/s %u%%",
(usedBps / 8192), (bpsAvg) ? (unsigned)(usedBps * 100.0 / bpsAvg) : 0 ));
} }
} }
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "AbstractAdaptationLogic.h" #include "AbstractAdaptationLogic.h"
#define MINBUFFER 30
namespace adaptative namespace adaptative
{ {
namespace logic namespace logic
...@@ -37,7 +35,7 @@ namespace adaptative ...@@ -37,7 +35,7 @@ namespace adaptative
class RateBasedAdaptationLogic : public AbstractAdaptationLogic class RateBasedAdaptationLogic : public AbstractAdaptationLogic
{ {
public: public:
RateBasedAdaptationLogic (int, int); RateBasedAdaptationLogic (vlc_object_t *, int, int);
BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const; BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const;
virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */ virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */
...@@ -51,6 +49,7 @@ namespace adaptative ...@@ -51,6 +49,7 @@ namespace adaptative
size_t bpsSamplecount; size_t bpsSamplecount;
size_t currentBps; size_t currentBps;
size_t usedBps; size_t usedBps;
vlc_object_t * p_obj;
}; };
class FixedRateAdaptationLogic : public AbstractAdaptationLogic class FixedRateAdaptationLogic : public AbstractAdaptationLogic
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define DEBUG_HPP #define DEBUG_HPP
//#define ADAPTATIVE_ADVANCED_DEBUG 0 //#define ADAPTATIVE_ADVANCED_DEBUG 0
//#define ADAPTATIVE_BW_DEBUG 0
#ifdef ADAPTATIVE_ADVANCED_DEBUG #ifdef ADAPTATIVE_ADVANCED_DEBUG
#define AdvDebug(code) code #define AdvDebug(code) code
...@@ -28,5 +29,11 @@ ...@@ -28,5 +29,11 @@
#define AdvDebug(code) #define AdvDebug(code)
#endif #endif
#ifdef ADAPTATIVE_BW_DEBUG
#define BwDebug(code) code
#else
#define BwDebug(code)
#endif
#endif // DEBUG_HPP #endif // DEBUG_HPP
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment