本文整理汇总了C++中BaseRepresentation类的典型用法代码示例。如果您正苦于以下问题:C++ BaseRepresentation类的具体用法?C++ BaseRepresentation怎么用?C++ BaseRepresentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseRepresentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: segmentsListReady
bool SegmentTracker::segmentsListReady() const
{
BaseRepresentation *rep = curRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep && rep->getPlaylist()->isLive())
return rep->getMinAheadTime(curNumber) > 0;
return true;
}
示例2: getMinAheadTime
mtime_t SegmentTracker::getMinAheadTime() const
{
BaseRepresentation *rep = curRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep)
return rep->getMinAheadTime(curNumber);
return 0;
}
示例3: initialFormat
StreamFormat SegmentTracker::initialFormat() const
{
BaseRepresentation *rep = curRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep)
return rep->getStreamFormat();
return StreamFormat();
}
示例4: getNextChunk
Chunk * SegmentTracker::getNextChunk(StreamType type, bool switch_allowed)
{
BaseRepresentation *rep;
ISegment *segment;
if(!currentPeriod)
return NULL;
if( !switch_allowed ||
(prevRepresentation && prevRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) )
rep = prevRepresentation;
else
rep = logic->getCurrentRepresentation(type, currentPeriod);
if ( rep == NULL )
return NULL;
if(rep != prevRepresentation)
{
prevRepresentation = rep;
initializing = true;
}
if(initializing)
{
initializing = false;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INIT);
if(segment)
return segment->toChunk(count, rep);
}
if(!indexed)
{
indexed = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX);
if(segment)
return segment->toChunk(count, rep);
}
segment = rep->getSegment(BaseRepresentation::INFOTYPE_MEDIA, count);
if(!segment)
{
currentPeriod = playlist->getNextPeriod(currentPeriod);
resetCounter();
return getNextChunk(type, switch_allowed);
}
Chunk *chunk = segment->toChunk(count, rep);
if(chunk)
count++;
return chunk;
}
示例5: getCurrentFormat
StreamFormat SegmentTracker::getCurrentFormat() const
{
BaseRepresentation *rep = curRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep)
{
/* Ensure ephemere content is updated/loaded */
if(rep->needsUpdate())
(void) rep->runLocalUpdates(0, curNumber, false);
return rep->getStreamFormat();
}
return StreamFormat();
}
示例6: setPositionByTime
bool SegmentTracker::setPositionByTime(mtime_t time, bool restarted, bool tryonly)
{
uint64_t segnumber;
BaseRepresentation *rep = prevRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep &&
rep->getSegmentNumberByTime(time, &segnumber))
{
if(!tryonly)
setPositionByNumber(segnumber, restarted);
return true;
}
return false;
}
示例7: select
BaseRepresentation * RepresentationSelector::select(BaseAdaptationSet *adaptSet, uint64_t bitrate) const
{
if (adaptSet == NULL)
return NULL;
BaseRepresentation *best = NULL;
std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
BaseRepresentation *candidate = select(reps, (best)?best->getBandwidth():0, bitrate);
if (candidate)
{
if (candidate->getBandwidth() > bitrate) /* none matched, returned lowest */
return candidate;
best = candidate;
}
return best;
}
示例8:
BaseRepresentation *
NearOptimalAdaptationLogic::getNextQualityIndex( BaseAdaptationSet *adaptSet, RepresentationSelector &selector,
float gammaP, mtime_t VD, mtime_t Q )
{
BaseRepresentation *ret = NULL;
BaseRepresentation *prev = NULL;
float argmax;
for(BaseRepresentation *rep = selector.lowest(adaptSet);
rep && rep != prev; rep = selector.higher(adaptSet, rep))
{
float arg = ( VD * (getUtility(rep) + gammaP) - Q ) / rep->getBandwidth();
if(ret == NULL || argmax <= arg)
{
ret = rep;
argmax = arg;
}
prev = rep;
}
return ret;
}
示例9: selector
BaseRepresentation *NearOptimalAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *prevRep)
{
RepresentationSelector selector(maxwidth, maxheight);
const float umin = getUtility(selector.lowest(adaptSet));
const float umax = getUtility(selector.highest(adaptSet));
vlc_mutex_lock(&lock);
std::map<ID, NearOptimalContext>::iterator it = streams.find(adaptSet->getID());
if(it == streams.end())
{
vlc_mutex_unlock(&lock);
return selector.lowest(adaptSet);
}
NearOptimalContext ctxcopy = (*it).second;
const unsigned bps = getAvailableBw(currentBps, prevRep);
vlc_mutex_unlock(&lock);
const float gammaP = 1.0 + (umax - umin) / ((float)ctxcopy.buffering_target / ctxcopy.buffering_min - 1.0);
const float Vd = ((float)ctxcopy.buffering_min / CLOCK_FREQ - 1.0) / (umin + gammaP);
BaseRepresentation *m;
if(prevRep == NULL) /* Starting */
{
m = selector.select(adaptSet, bps);
}
else
{
/* noted m* */
m = getNextQualityIndex(adaptSet, selector, gammaP - umin /* umin == Sm, utility = std::log(S/Sm) */,
Vd, (float)ctxcopy.buffering_level / CLOCK_FREQ);
if(m->getBandwidth() < prevRep->getBandwidth()) /* m*[n] < m*[n-1] */
{
BaseRepresentation *mp = selector.select(adaptSet, bps); /* m' */
if(mp->getBandwidth() <= m->getBandwidth())
{
mp = m;
}
else if(mp->getBandwidth() > prevRep->getBandwidth())
{
mp = prevRep;
}
else
{
mp = selector.lower(adaptSet, mp);
}
m = mp;
}
}
BwDebug( msg_Info(p_obj, "buffering level %.2f% rep %ld kBps %zu kBps",
(float) 100 * ctxcopy.buffering_level / ctxcopy.buffering_target, m->getBandwidth()/8000, bps / 8000); );
示例10: select
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, adaptative::StreamType type, uint64_t bitrate) const
{
if (period == NULL)
return NULL;
std::vector<BaseAdaptationSet *> adaptSets = period->getAdaptationSets(type);
BaseRepresentation *best = NULL;
std::vector<BaseAdaptationSet *>::const_iterator adaptIt;
for(adaptIt=adaptSets.begin(); adaptIt!=adaptSets.end(); ++adaptIt)
{
std::vector<BaseRepresentation *> reps = (*adaptIt)->getRepresentations();
BaseRepresentation *candidate = select(reps, (best)?best->getBandwidth():0, bitrate);
if (candidate)
{
if (candidate->getBandwidth() > bitrate) /* none matched, returned lowest */
return candidate;
best = candidate;
}
}
return best;
}
示例11: getPlaybackTime
mtime_t SegmentTracker::getPlaybackTime() const
{
mtime_t time, duration;
BaseRepresentation *rep = curRepresentation;
if(!rep)
rep = logic->getNextRepresentation(adaptationSet, NULL);
if(rep &&
rep->getPlaybackTimeDurationBySegmentNumber(next, &time, &duration))
{
/* LVP added, TFE */
// apparently not used
//msg_Info(NULL, "TFE SegmentTracker getPlaybackTime, %" PRId64 ", %" PRId64 ", %" PRId64,
// mdate(), time, duration);
//std::cerr << "TFE SegmentTracker::getPlaybackTime time and duration, "
// << mdate() << ", " << time << ", " << duration << std::endl;
return time;
}
return 0;
}
示例12: notify
SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed, HTTPConnectionManager *connManager)
{
BaseRepresentation *rep = NULL;
ISegment *segment;
if(!adaptationSet)
return NULL;
/* Ensure we don't keep chaining init/index without data */
if( initializing )
{
if( prevRepresentation )
switch_allowed = false;
else
switch_allowed = true;
}
if( !switch_allowed ||
(prevRepresentation && prevRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) )
rep = prevRepresentation;
else
rep = logic->getNextRepresentation(adaptationSet, prevRepresentation);
if ( rep == NULL )
return NULL;
if(rep != prevRepresentation)
{
notify(SegmentTrackerEvent(prevRepresentation, rep));
prevRepresentation = rep;
init_sent = false;
index_sent = false;
initializing = true;
}
/* Ensure ephemere content is updated/loaded */
if(rep->needsUpdate())
updateSelected();
if(!init_sent)
{
init_sent = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INIT);
if(segment)
return segment->toChunk(count, rep, connManager);
}
if(!index_sent)
{
index_sent = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX);
if(segment)
return segment->toChunk(count, rep, connManager);
}
bool b_gap = false;
segment = rep->getNextSegment(BaseRepresentation::INFOTYPE_MEDIA, count, &count, &b_gap);
if(!segment)
{
reset();
return NULL;
}
/* stop initializing after 1st chunk */
initializing = false;
SegmentChunk *chunk = segment->toChunk(count, rep, connManager);
if(chunk)
count++;
/* We need to check segment/chunk format changes, as we can't rely on representation's (HLS)*/
if(format != chunk->getStreamFormat())
{
format = chunk->getStreamFormat();
notify(SegmentTrackerEvent(&format));
}
/* Handle both implicit and explicit discontinuities */
if( (b_gap && count) || (chunk && chunk->discontinuity) )
{
notify(SegmentTrackerEvent(chunk));
}
return chunk;
}
示例13: selector
BaseRepresentation *PredictiveAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *prevRep)
{
RepresentationSelector selector(maxwidth, maxheight);
BaseRepresentation *rep;
vlc_mutex_lock(&lock);
std::map<ID, PredictiveStats>::iterator it = streams.find(adaptSet->getID());
if(it == streams.end())
{
rep = selector.highest(adaptSet);
}
else
{
PredictiveStats &stats = (*it).second;
double f_buffering_level = (double)stats.buffering_level / stats.buffering_target;
double f_min_buffering_level = f_buffering_level;
unsigned i_max_bitrate = 0;
if(streams.size() > 1)
{
std::map<ID, PredictiveStats>::const_iterator it2 = streams.begin();
for(; it2 != streams.end(); ++it2)
{
if(it2 == it)
continue;
const PredictiveStats &other = (*it2).second;
f_min_buffering_level = std::min((double)other.buffering_level / other.buffering_target,
f_min_buffering_level);
i_max_bitrate = std::max(i_max_bitrate, other.last_download_rate);
}
}
if(stats.starting())
{
rep = selector.highest(adaptSet);
}
else
{
const unsigned i_available_bw = getAvailableBw(i_max_bitrate, prevRep);
if(!prevRep)
{
rep = selector.select(adaptSet, i_available_bw);
}
else if(f_buffering_level > 0.8)
{
rep = selector.select(adaptSet, std::max((uint64_t) i_available_bw,
(uint64_t) prevRep->getBandwidth()));
}
else if(f_buffering_level > 0.5)
{
rep = prevRep;
}
else
{
if(f_buffering_level > 2 * stats.last_duration)
{
rep = selector.lower(adaptSet, prevRep);
}
else
{
rep = selector.select(adaptSet, i_available_bw * f_buffering_level);
}
}
}
BwDebug( for(it=streams.begin(); it != streams.end(); ++it)
{
const PredictiveStats &s = (*it).second;
msg_Info(p_obj, "Stream %s buffering level %.2f%",
(*it).first.str().c_str(), (double) s.buffering_level / s.buffering_target);
} );
BwDebug( if( rep != prevRep )
msg_Info(p_obj, "Stream %s new bandwidth usage %zu KiB/s",
adaptSet->getID().str().c_str(), rep->getBandwidth() / 8000); );
示例14: notify
SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed, HTTPConnectionManager *connManager)
{
BaseRepresentation *rep = NULL, *prevRep = NULL;
ISegment *segment;
if(!adaptationSet)
return NULL;
/* Ensure we don't keep chaining init/index without data */
if( initializing )
{
if( curRepresentation )
switch_allowed = false;
else
switch_allowed = true;
}
if( !switch_allowed ||
(curRepresentation && curRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) )
rep = curRepresentation;
else
rep = logic->getNextRepresentation(adaptationSet, curRepresentation);
if ( rep == NULL )
return NULL;
if(rep != curRepresentation)
{
notify(SegmentTrackerEvent(curRepresentation, rep));
prevRep = curRepresentation;
curRepresentation = rep;
init_sent = false;
index_sent = false;
initializing = true;
}
bool b_updated = false;
/* Ensure ephemere content is updated/loaded */
if(rep->needsUpdate())
b_updated = rep->runLocalUpdates(getPlaybackTime(), curNumber, false);
if(prevRep && !rep->consistentSegmentNumber())
{
/* Convert our segment number */
next = rep->translateSegmentNumber(next, prevRep);
}
else if(first && rep->getPlaylist()->isLive())
{
next = rep->getLiveStartSegmentNumber(next);
first = false;
}
if(b_updated)
{
if(!rep->consistentSegmentNumber())
curRepresentation->pruneBySegmentNumber(curNumber);
curRepresentation->scheduleNextUpdate(next);
}
if(!init_sent)
{
init_sent = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INIT);
if(segment)
return segment->toChunk(next, rep, connManager);
}
if(!index_sent)
{
index_sent = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX);
if(segment)
return segment->toChunk(next, rep, connManager);
}
bool b_gap = false;
segment = rep->getNextSegment(BaseRepresentation::INFOTYPE_MEDIA, next, &next, &b_gap);
if(!segment)
{
reset();
return NULL;
}
if(initializing)
{
b_gap = false;
/* stop initializing after 1st chunk */
initializing = false;
}
SegmentChunk *chunk = segment->toChunk(next, rep, connManager);
/* We need to check segment/chunk format changes, as we can't rely on representation's (HLS)*/
if(chunk && format != chunk->getStreamFormat())
{
format = chunk->getStreamFormat();
notify(SegmentTrackerEvent(&format));
}
//.........这里部分代码省略.........
示例15: notify
SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
AbstractConnectionManager *connManager)
{
/* LVP added, TFE DEBUG */
//msg_Info(NULL, "TFE DEBUG SegmentTracker getNextChunk, %" PRId64, mdate());
//std::cerr << "TFE DEBUG SegmentTracker getNextChunk, " << mdate() << std::endl;
BaseRepresentation *rep = NULL, *prevRep = NULL;
ISegment *segment;
if(!adaptationSet) {
/* LVP added, TFE DEBUG */
//msg_Info(NULL, "TFE DEBUG SegmentTracker getNextChunk no adaptation set, %" PRId64, mdate());
//std::cerr << "TFE DEBUG SegmentTracker getNextChunk no adaptation set, " << mdate() << std::endl;
return NULL;
}
/* Ensure we don't keep chaining init/index without data */
if( initializing )
{
if( curRepresentation )
switch_allowed = false;
else
switch_allowed = true;
}
if( !switch_allowed ||
(curRepresentation && curRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) )
rep = curRepresentation;
else
rep = logic->getNextRepresentation(adaptationSet, curRepresentation);
if ( rep == NULL ) {
/* LVP added, TFE DEBUG */
//msg_Info(NULL, "TFE DEBUG SegmentTracker no rep 1, %" PRId64, mdate());
//std::cerr << "TFE DEBUG SegmentTracker no rep 1, " << mdate() << std::endl;
return NULL;
}
if(rep != curRepresentation)
{
notify(SegmentTrackerEvent(curRepresentation, rep));
prevRep = curRepresentation;
curRepresentation = rep;
init_sent = false;
index_sent = false;
initializing = true;
}
bool b_updated = false;
/* Ensure ephemere content is updated/loaded */
if(rep->needsUpdate())
b_updated = rep->runLocalUpdates(getPlaybackTime(), curNumber, false);
if(prevRep && !rep->consistentSegmentNumber())
{
/* Convert our segment number */
next = rep->translateSegmentNumber(next, prevRep);
}
else if(first && rep->getPlaylist()->isLive())
{
next = rep->getLiveStartSegmentNumber(next);
first = false;
}
if(b_updated)
{
if(!rep->consistentSegmentNumber())
curRepresentation->pruneBySegmentNumber(curNumber);
curRepresentation->scheduleNextUpdate(next);
}
if(rep->getStreamFormat() != format)
{
/* Initial format ? */
if(format == StreamFormat(StreamFormat::UNSUPPORTED))
{
format = rep->getStreamFormat();
}
else
{
format = rep->getStreamFormat();
notify(SegmentTrackerEvent(&format)); /* Notify new demux format */
return NULL; /* Force current demux to end */
}
}
if(format == StreamFormat(StreamFormat::UNSUPPORTED))
{
return NULL; /* Can't return chunk because no demux will be created */
}
if(!init_sent)
{
//.........这里部分代码省略.........