Commit 6ba79d21 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: add fixed rate adaptation policy

parent b397e42f
......@@ -39,9 +39,10 @@ IAdaptationLogic* AdaptationLogicFactory::create ( IAdaptationLogic::LogicType l
switch(logic)
{
case IAdaptationLogic::AlwaysBest: return new AlwaysBestAdaptationLogic (mpd);
case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpd);
case IAdaptationLogic::AlwaysLowest: return new AlwaysLowestAdaptationLogic (mpd);
case IAdaptationLogic::FixedRate: return new FixedRateAdaptationLogic (mpd);
case IAdaptationLogic::Default:
case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpd);
default:
return NULL;
}
......
......@@ -44,7 +44,8 @@ namespace dash
Default,
AlwaysBest,
AlwaysLowest,
RateBased
RateBased,
FixedRate
};
virtual dash::http::Chunk* getNextChunk (Streams::Type) = 0;
......
......@@ -76,3 +76,25 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
if(bpsSamplecount % 5 == 0)
currentBps = bpsAvg;
}
FixedRateAdaptationLogic::FixedRateAdaptationLogic(mpd::MPD *mpd) :
AbstractAdaptationLogic(mpd)
{
currentBps = var_InheritInteger( mpd->getVLCObject(), "dash-prefbw" ) * 8192;
}
Representation *FixedRateAdaptationLogic::getCurrentRepresentation(Streams::Type type) const
{
if(currentPeriod == NULL)
return NULL;
RepresentationSelector selector;
Representation *rep = selector.select(currentPeriod, type, currentBps);
if ( rep == NULL )
{
rep = selector.select(currentPeriod, type);
if ( rep == NULL )
return NULL;
}
return rep;
}
......@@ -48,6 +48,17 @@ namespace dash
size_t bpsSamplecount;
size_t currentBps;
};
class FixedRateAdaptationLogic : public AbstractAdaptationLogic
{
public:
FixedRateAdaptationLogic(mpd::MPD *mpd);
dash::mpd::Representation *getCurrentRepresentation(Streams::Type) const;
private:
size_t currentBps;
};
}
}
......
......@@ -55,6 +55,9 @@ static void Close (vlc_object_t *);
#define DASH_HEIGHT_TEXT N_("Preferred Height")
#define DASH_HEIGHT_LONGTEXT N_("Preferred Height")
#define DASH_BW_TEXT N_("Fixed Bandwidth in KiB/s")
#define DASH_BW_LONGTEXT N_("Preferred bandwidth for non adaptative streams")
vlc_module_begin ()
set_shortname( N_("DASH"))
set_description( N_("Dynamic Adaptive Streaming over HTTP") )
......@@ -63,6 +66,7 @@ vlc_module_begin ()
set_subcategory( SUBCAT_INPUT_DEMUX )
add_integer( "dash-prefwidth", 480, DASH_WIDTH_TEXT, DASH_WIDTH_LONGTEXT, true )
add_integer( "dash-prefheight", 360, DASH_HEIGHT_TEXT, DASH_HEIGHT_LONGTEXT, true )
add_integer( "dash-prefbw", 250, DASH_BW_TEXT, DASH_BW_LONGTEXT, false )
set_callbacks( Open, Close )
vlc_module_end ()
......@@ -105,7 +109,7 @@ static int Open(vlc_object_t *p_obj)
p_sys->p_mpd = mpd;
dash::DASHManager*p_dashManager = new dash::DASHManager(p_sys->p_mpd,
dash::logic::IAdaptationLogic::AlwaysLowest,
dash::logic::IAdaptationLogic::Default,
p_demux->s);
dash::mpd::Period *period = mpd->getFirstPeriod();
......
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