本文整理汇总了C++中MediaResource::GetNextCachedData方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaResource::GetNextCachedData方法的具体用法?C++ MediaResource::GetNextCachedData怎么用?C++ MediaResource::GetNextCachedData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaResource
的用法示例。
在下文中一共展示了MediaResource::GetNextCachedData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBuffered
nsresult MediaOmxReader::GetBuffered(mozilla::dom::TimeRanges* aBuffered, int64_t aStartTime)
{
if (!mOmxDecoder.get())
return NS_OK;
MediaResource* stream = mOmxDecoder->GetResource();
int64_t durationUs = 0;
mOmxDecoder->GetDuration(&durationUs);
// Nothing to cache if the media takes 0us to play.
if (!durationUs)
return NS_OK;
// Special case completely cached files. This also handles local files.
if (stream->IsDataCachedToEndOfResource(0)) {
aBuffered->Add(0, durationUs);
return NS_OK;
}
int64_t totalBytes = stream->GetLength();
// If we can't determine the total size, pretend that we have nothing
// buffered. This will put us in a state of eternally-low-on-undecoded-data
// which is not get, but about the best we can do.
if (totalBytes == -1)
return NS_OK;
int64_t startOffset = stream->GetNextCachedData(0);
while (startOffset >= 0) {
int64_t endOffset = stream->GetCachedDataEnd(startOffset);
// Bytes [startOffset..endOffset] are cached.
NS_ASSERTION(startOffset >= 0, "Integer underflow in GetBuffered");
NS_ASSERTION(endOffset >= 0, "Integer underflow in GetBuffered");
uint64_t startUs = BytesToTime(startOffset, totalBytes, durationUs);
uint64_t endUs = BytesToTime(endOffset, totalBytes, durationUs);
if (startUs != endUs) {
aBuffered->Add((double)startUs / USECS_PER_S, (double)endUs / USECS_PER_S);
}
startOffset = stream->GetNextCachedData(endOffset);
}
return NS_OK;
}