本文整理汇总了C++中TimeRanges::add方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeRanges::add方法的具体用法?C++ TimeRanges::add怎么用?C++ TimeRanges::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeRanges
的用法示例。
在下文中一共展示了TimeRanges::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
TimeRanges* TimeRanges::create(const blink::WebTimeRanges& webRanges) {
TimeRanges* ranges = TimeRanges::create();
unsigned size = webRanges.size();
for (unsigned i = 0; i < size; ++i)
ranges->add(webRanges[i].start, webRanges[i].end);
return ranges;
}
示例2: copy
TimeRanges* TimeRanges::copy() const {
TimeRanges* newSession = TimeRanges::create();
unsigned size = m_ranges.size();
for (unsigned i = 0; i < size; i++)
newSession->add(m_ranges[i].m_start, m_ranges[i].m_end);
return newSession;
}
示例3: unionWith
void TimeRanges::unionWith(const TimeRanges* other) {
DCHECK(other);
TimeRanges* unioned = copy();
for (size_t index = 0; index < other->m_ranges.size(); ++index) {
const Range& range = other->m_ranges[index];
unioned->add(range.m_start, range.m_end);
}
m_ranges.swap(unioned->m_ranges);
}
示例4: buffered
TimeRanges* MediaSource::buffered() const {
// Implements MediaSource algorithm for HTMLMediaElement.buffered.
// https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#htmlmediaelement-extensions
HeapVector<Member<TimeRanges>> ranges(m_activeSourceBuffers->length());
for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
ranges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXCEPTION);
// 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges
// object and abort these steps.
if (ranges.isEmpty())
return TimeRanges::create();
// 2. Let active ranges be the ranges returned by buffered for each
// SourceBuffer object in activeSourceBuffers.
// 3. Let highest end time be the largest range end time in the active ranges.
double highestEndTime = -1;
for (size_t i = 0; i < ranges.size(); ++i) {
unsigned length = ranges[i]->length();
if (length)
highestEndTime = std::max(
highestEndTime, ranges[i]->end(length - 1, ASSERT_NO_EXCEPTION));
}
// Return an empty range if all ranges are empty.
if (highestEndTime < 0)
return TimeRanges::create();
// 4. Let intersection ranges equal a TimeRange object containing a single
// range from 0 to highest end time.
TimeRanges* intersectionRanges = TimeRanges::create(0, highestEndTime);
// 5. For each SourceBuffer object in activeSourceBuffers run the following
// steps:
bool ended = readyState() == endedKeyword();
for (size_t i = 0; i < ranges.size(); ++i) {
// 5.1 Let source ranges equal the ranges returned by the buffered attribute
// on the current SourceBuffer.
TimeRanges* sourceRanges = ranges[i].get();
// 5.2 If readyState is "ended", then set the end time on the last range in
// source ranges to highest end time.
if (ended && sourceRanges->length())
sourceRanges->add(
sourceRanges->start(sourceRanges->length() - 1, ASSERT_NO_EXCEPTION),
highestEndTime);
// 5.3 Let new intersection ranges equal the the intersection between the
// intersection ranges and the source ranges.
// 5.4 Replace the ranges in intersection ranges with the new intersection
// ranges.
intersectionRanges->intersectWith(sourceRanges);
}
return intersectionRanges;
}
示例5: invert
void TimeRanges::invert() {
TimeRanges* inverted = TimeRanges::create();
double posInf = std::numeric_limits<double>::infinity();
double negInf = -std::numeric_limits<double>::infinity();
if (!m_ranges.size()) {
inverted->add(negInf, posInf);
} else {
double start = m_ranges.first().m_start;
if (start != negInf)
inverted->add(negInf, start);
for (size_t index = 0; index + 1 < m_ranges.size(); ++index)
inverted->add(m_ranges[index].m_end, m_ranges[index + 1].m_start);
double end = m_ranges.last().m_end;
if (end != posInf)
inverted->add(end, posInf);
}
m_ranges.swap(inverted->m_ranges);
}