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
{
int width = var_InheritInteger(p_demux, "adaptative-width");
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);
return logic;
}
......
......@@ -31,10 +31,11 @@
#include "../playlist/BaseRepresentation.h"
#include "../playlist/BasePeriod.h"
#include "../http/Chunk.h"
#include "../tools/Debug.hpp"
using namespace adaptative::logic;
RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
RateBasedAdaptationLogic::RateBasedAdaptationLogic (vlc_object_t *p_obj_, int w, int h) :
AbstractAdaptationLogic (),
bpsAvg(0), bpsRemainder(0), bpsSamplecount(0),
currentBps(0)
......@@ -42,6 +43,7 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
width = w;
height = h;
usedBps = 0;
p_obj = p_obj_;
}
BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *currep) const
......@@ -86,6 +88,9 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
}
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)
......@@ -96,6 +101,9 @@ void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
usedBps -= event.u.switching.prev->getBandwidth();
if(event.u.switching.next)
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 @@
#include "AbstractAdaptationLogic.h"
#define MINBUFFER 30
namespace adaptative
{
namespace logic
......@@ -37,7 +35,7 @@ namespace adaptative
class RateBasedAdaptationLogic : public AbstractAdaptationLogic
{
public:
RateBasedAdaptationLogic (int, int);
RateBasedAdaptationLogic (vlc_object_t *, int, int);
BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const;
virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */
......@@ -51,6 +49,7 @@ namespace adaptative
size_t bpsSamplecount;
size_t currentBps;
size_t usedBps;
vlc_object_t * p_obj;
};
class FixedRateAdaptationLogic : public AbstractAdaptationLogic
......
......@@ -21,6 +21,7 @@
#define DEBUG_HPP
//#define ADAPTATIVE_ADVANCED_DEBUG 0
//#define ADAPTATIVE_BW_DEBUG 0
#ifdef ADAPTATIVE_ADVANCED_DEBUG
#define AdvDebug(code) code
......@@ -28,5 +29,11 @@
#define AdvDebug(code)
#endif
#ifdef ADAPTATIVE_BW_DEBUG
#define BwDebug(code) code
#else
#define BwDebug(code)
#endif
#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