本文整理汇总了C++中MediaResource::ReadAt方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaResource::ReadAt方法的具体用法?C++ MediaResource::ReadAt怎么用?C++ MediaResource::ReadAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaResource
的用法示例。
在下文中一共展示了MediaResource::ReadAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/**
* If this stream is an MP3, we want to parse the headers to estimate the
* stream duration.
*/
nsresult GStreamerReader::ParseMP3Headers()
{
MediaResource *resource = mDecoder->GetResource();
const uint32_t MAX_READ_BYTES = 4096;
uint64_t offset = 0;
char bytes[MAX_READ_BYTES];
uint32_t bytesRead;
do {
nsresult rv = resource->ReadAt(offset, bytes, MAX_READ_BYTES, &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(bytesRead, NS_ERROR_FAILURE);
mMP3FrameParser.Parse(bytes, bytesRead, offset);
offset += bytesRead;
} while (!mMP3FrameParser.ParsedHeaders());
if (mMP3FrameParser.IsMP3()) {
mLastParserDuration = mMP3FrameParser.GetDuration();
mDataOffset = mMP3FrameParser.GetMP3Offset();
// Update GStreamer's stream length in case we found any ID3 headers to
// ignore.
gst_app_src_set_size(mSource, GetDataLength());
}
return NS_OK;
}
示例2: while
/**
* If this stream is an MP3, we want to parse the headers to estimate the
* stream duration.
*/
nsresult GStreamerReader::ParseMP3Headers()
{
MediaResource *resource = mDecoder->GetResource();
const uint32_t MAX_READ_BYTES = 4096;
uint64_t offset = 0;
char bytes[MAX_READ_BYTES];
uint32_t bytesRead;
do {
nsresult rv = resource->ReadAt(offset, bytes, MAX_READ_BYTES, &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(bytesRead, NS_ERROR_FAILURE);
mMP3FrameParser.Parse(bytes, bytesRead, offset);
offset += bytesRead;
} while (!mMP3FrameParser.ParsedHeaders());
if (mMP3FrameParser.IsMP3()) {
mLastParserDuration = mMP3FrameParser.GetDuration();
}
return NS_OK;
}