本文整理汇总了C++中MediaByteRange::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaByteRange::Clear方法的具体用法?C++ MediaByteRange::Clear怎么用?C++ MediaByteRange::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaByteRange
的用法示例。
在下文中一共展示了MediaByteRange::Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mon
nsresult
DASHRepDecoder::GetByteRangeForSeek(int64_t const aOffset,
MediaByteRange& aByteRange)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
// Only check data ranges if they're available and if this decoder is active,
// i.e. inactive rep decoders should only load metadata.
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
for (uint32_t i = 0; i < mByteRanges.Length(); i++) {
NS_ENSURE_FALSE(mByteRanges[i].IsNull(), NS_ERROR_NOT_INITIALIZED);
// Check if |aOffset| lies within the current data range.
if (mByteRanges[i].mStart <= aOffset && aOffset <= mByteRanges[i].mEnd) {
if (mMainDecoder->IsDecoderAllowedToDownloadSubsegment(this, i)) {
mCurrentByteRange = aByteRange = mByteRanges[i];
mSubsegmentIdx = i;
// XXX Hack: should be setting subsegment outside this function, but
// need to review seeking for multiple switches anyhow.
mMainDecoder->SetSubsegmentIndex(this, i);
LOG("Getting DATA range [%d] for seek offset [%lld]: "
"bytes [%lld] to [%lld]",
i, aOffset, aByteRange.mStart, aByteRange.mEnd);
return NS_OK;
}
break;
}
}
// Don't allow metadata downloads once they're loaded and byte ranges have
// been populated.
bool canDownloadMetadata = mByteRanges.IsEmpty();
if (canDownloadMetadata) {
// Check metadata ranges; init range.
if (mInitByteRange.mStart <= aOffset && aOffset <= mInitByteRange.mEnd) {
mCurrentByteRange = aByteRange = mInitByteRange;
mSubsegmentIdx = 0;
LOG("Getting INIT range for seek offset [%lld]: bytes [%lld] to "
"[%lld]", aOffset, aByteRange.mStart, aByteRange.mEnd);
return NS_OK;
}
// ... index range.
if (mIndexByteRange.mStart <= aOffset && aOffset <= mIndexByteRange.mEnd) {
mCurrentByteRange = aByteRange = mIndexByteRange;
mSubsegmentIdx = 0;
LOG("Getting INDEXES range for seek offset [%lld]: bytes [%lld] to "
"[%lld]", aOffset, aByteRange.mStart, aByteRange.mEnd);
return NS_OK;
}
} else {
LOG1("Metadata should be read; inhibiting further metadata downloads.");
}
// If no byte range is found by this stage, clear the parameter and return.
aByteRange.Clear();
if (mByteRanges.IsEmpty() || !canDownloadMetadata) {
// Assume mByteRanges will be populated after metadata is read.
LOG("Data ranges not populated [%s]; metadata download restricted [%s]: "
"offset[%lld].",
(mByteRanges.IsEmpty() ? "yes" : "no"),
(canDownloadMetadata ? "no" : "yes"), aOffset);
return NS_ERROR_NOT_AVAILABLE;
} else {
// Cannot seek to an unknown offset.
// XXX Revisit this for dynamic MPD profiles if MPD is regularly updated.
LOG("Error! Offset [%lld] is in an unknown range!", aOffset);
return NS_ERROR_ILLEGAL_VALUE;
}
}