зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1392178 - move MediaResource::CachedReadAt to MediaResourceIndex. r=gerald
MozReview-Commit-ID: LnAXXaRQ4C --HG-- extra : rebase_source : cc041eeb94807b4e235ca2b827d4db13f1410e09 extra : intermediate-source : fd1bff4bb32ae8cefd909d709d28a229e35fa110 extra : source : 677ede60ac88260d779502d25102c7a66bf0d65c
This commit is contained in:
Родитель
157c942bc4
Коммит
448e22c303
|
@ -175,17 +175,6 @@ public:
|
|||
// each read.
|
||||
virtual bool ShouldCacheReads() = 0;
|
||||
|
||||
already_AddRefed<MediaByteBuffer> CachedReadAt(int64_t aOffset, uint32_t aCount)
|
||||
{
|
||||
RefPtr<MediaByteBuffer> bytes = new MediaByteBuffer();
|
||||
bool ok = bytes->SetLength(aCount, fallible);
|
||||
NS_ENSURE_TRUE(ok, nullptr);
|
||||
char* curr = reinterpret_cast<char*>(bytes->Elements());
|
||||
nsresult rv = ReadFromCache(curr, aOffset, aCount);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return bytes.forget();
|
||||
}
|
||||
|
||||
// Report the current offset in bytes from the start of the stream.
|
||||
// This is used to approximate where we currently are in the playback of a
|
||||
// media.
|
||||
|
@ -777,6 +766,19 @@ public:
|
|||
bytes->SetLength(curr - start);
|
||||
return bytes.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<MediaByteBuffer> CachedMediaReadAt(int64_t aOffset,
|
||||
uint32_t aCount) const
|
||||
{
|
||||
RefPtr<MediaByteBuffer> bytes = new MediaByteBuffer();
|
||||
bool ok = bytes->SetLength(aCount, fallible);
|
||||
NS_ENSURE_TRUE(ok, nullptr);
|
||||
char* curr = reinterpret_cast<char*>(bytes->Elements());
|
||||
nsresult rv = mResource->ReadFromCache(curr, aOffset, aCount);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return bytes.forget();
|
||||
}
|
||||
|
||||
// Get the length of the stream in bytes. Returns -1 if not known.
|
||||
// This can change over time; after a seek operation, a misbehaving
|
||||
// server may give us a resource of a different length to what it had
|
||||
|
|
|
@ -446,10 +446,12 @@ void WebMBufferedState::UpdateIndex(const MediaByteRangeSet& aRanges, MediaResou
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaResourceIndex res(aResource);
|
||||
while (length > 0) {
|
||||
static const uint32_t BLOCK_SIZE = 1048576;
|
||||
uint32_t block = std::min(length, BLOCK_SIZE);
|
||||
RefPtr<MediaByteBuffer> bytes = aResource->CachedReadAt(offset, block);
|
||||
RefPtr<MediaByteBuffer> bytes = res.CachedMediaReadAt(offset, block);
|
||||
if (!bytes) {
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче