Bug 1174220 - Part 2: Use MediaByteBuffer instead of MediaLargeByteBuffer. r=jya

All MediaLargeByteBuffer calls already include the `mozilla::fallible`
parameter so we can safely replace MediaLargeByteBuffer with MediaByteBuffer.
This commit is contained in:
Birunthan Mohanathas 2015-06-14 21:37:13 -07:00
Родитель 61b1dc8e69
Коммит 2d96c72f58
18 изменённых файлов: 63 добавлений и 64 удалений

Просмотреть файл

@ -22,7 +22,6 @@ class Image;
class ImageContainer;
}
class MediaLargeByteBuffer;
class MediaByteBuffer;
// Container that holds media samples.
@ -369,7 +368,7 @@ private:
explicit MediaRawDataWriter(MediaRawData* aMediaRawData);
bool EnsureSize(size_t aSize);
MediaRawData* mTarget;
nsRefPtr<MediaLargeByteBuffer> mBuffer;
nsRefPtr<MediaByteBuffer> mBuffer;
};
class MediaRawData : public MediaData {
@ -403,7 +402,7 @@ private:
// read as required by some data decoders.
// Returns false if memory couldn't be allocated.
bool EnsureCapacity(size_t aSize);
nsRefPtr<MediaLargeByteBuffer> mBuffer;
nsRefPtr<MediaByteBuffer> mBuffer;
CryptoSample mCryptoInternal;
uint32_t mPadding;
MediaRawData(const MediaRawData&); // Not implemented

Просмотреть файл

@ -20,7 +20,7 @@ namespace mozilla {
MP4Demuxer::MP4Demuxer(MediaResource* aResource)
: mResource(aResource)
, mStream(new mp4_demuxer::ResourceStream(aResource))
, mInitData(new MediaLargeByteBuffer)
, mInitData(new MediaByteBuffer)
{
}

Просмотреть файл

@ -51,7 +51,7 @@ private:
friend class MP4TrackDemuxer;
nsRefPtr<MediaResource> mResource;
nsRefPtr<mp4_demuxer::ResourceStream> mStream;
nsRefPtr<MediaLargeByteBuffer> mInitData;
nsRefPtr<MediaByteBuffer> mInitData;
UniquePtr<mp4_demuxer::MP4Metadata> mMetadata;
nsTArray<nsRefPtr<MP4TrackDemuxer>> mDemuxers;
};

Просмотреть файл

@ -37,7 +37,7 @@ ContainerParser::ContainerParser(const nsACString& aType)
}
bool
ContainerParser::IsInitSegmentPresent(MediaLargeByteBuffer* aData)
ContainerParser::IsInitSegmentPresent(MediaByteBuffer* aData)
{
MSE_DEBUG(ContainerParser, "aLength=%u [%x%x%x%x]",
aData->Length(),
@ -49,7 +49,7 @@ return false;
}
bool
ContainerParser::IsMediaSegmentPresent(MediaLargeByteBuffer* aData)
ContainerParser::IsMediaSegmentPresent(MediaByteBuffer* aData)
{
MSE_DEBUG(ContainerParser, "aLength=%u [%x%x%x%x]",
aData->Length(),
@ -61,7 +61,7 @@ ContainerParser::IsMediaSegmentPresent(MediaLargeByteBuffer* aData)
}
bool
ContainerParser::ParseStartAndEndTimestamps(MediaLargeByteBuffer* aData,
ContainerParser::ParseStartAndEndTimestamps(MediaByteBuffer* aData,
int64_t& aStart, int64_t& aEnd)
{
return false;
@ -86,7 +86,7 @@ ContainerParser::HasCompleteInitData()
return mHasInitData && !!mInitData->Length();
}
MediaLargeByteBuffer*
MediaByteBuffer*
ContainerParser::InitData()
{
return mInitData;
@ -121,7 +121,7 @@ public:
static const unsigned NS_PER_USEC = 1000;
static const unsigned USEC_PER_SEC = 1000000;
bool IsInitSegmentPresent(MediaLargeByteBuffer* aData) override
bool IsInitSegmentPresent(MediaByteBuffer* aData) override
{
ContainerParser::IsInitSegmentPresent(aData);
// XXX: This is overly primitive, needs to collect data as it's appended
@ -144,7 +144,7 @@ public:
return false;
}
bool IsMediaSegmentPresent(MediaLargeByteBuffer* aData) override
bool IsMediaSegmentPresent(MediaByteBuffer* aData) override
{
ContainerParser::IsMediaSegmentPresent(aData);
// XXX: This is overly primitive, needs to collect data as it's appended
@ -165,7 +165,7 @@ public:
return false;
}
bool ParseStartAndEndTimestamps(MediaLargeByteBuffer* aData,
bool ParseStartAndEndTimestamps(MediaByteBuffer* aData,
int64_t& aStart, int64_t& aEnd) override
{
bool initSegment = IsInitSegmentPresent(aData);
@ -173,7 +173,7 @@ public:
mOffset = 0;
mParser = WebMBufferedParser(0);
mOverlappedMapping.Clear();
mInitData = new MediaLargeByteBuffer();
mInitData = new MediaByteBuffer();
mResource = new SourceBufferResource(NS_LITERAL_CSTRING("video/webm"));
}
@ -258,7 +258,7 @@ public:
, mMonitor("MP4ContainerParser Index Monitor")
{}
bool IsInitSegmentPresent(MediaLargeByteBuffer* aData) override
bool IsInitSegmentPresent(MediaByteBuffer* aData) override
{
ContainerParser::IsInitSegmentPresent(aData);
// Each MP4 atom has a chunk size and chunk type. The root chunk in an MP4
@ -278,7 +278,7 @@ public:
(*aData)[7] == 'p';
}
bool IsMediaSegmentPresent(MediaLargeByteBuffer* aData) override
bool IsMediaSegmentPresent(MediaByteBuffer* aData) override
{
ContainerParser::IsMediaSegmentPresent(aData);
if (aData->Length() < 8) {
@ -298,7 +298,7 @@ public:
(*aData)[7] == 'x');
}
bool ParseStartAndEndTimestamps(MediaLargeByteBuffer* aData,
bool ParseStartAndEndTimestamps(MediaByteBuffer* aData,
int64_t& aStart, int64_t& aEnd) override
{
MonitorAutoLock mon(mMonitor); // We're not actually racing against anything,
@ -312,7 +312,7 @@ public:
// manually. This allows the ContainerParser to be shared across different
// timestampOffsets.
mParser = new mp4_demuxer::MoofParser(mStream, 0, /* aIsAudio = */ false, &mMonitor);
mInitData = new MediaLargeByteBuffer();
mInitData = new MediaByteBuffer();
} else if (!mStream || !mParser) {
return false;
}

Просмотреть файл

@ -13,7 +13,7 @@
namespace mozilla {
class MediaLargeByteBuffer;
class MediaByteBuffer;
class SourceBufferResource;
class ContainerParser {
@ -24,17 +24,17 @@ public:
// Return true if aData starts with an initialization segment.
// The base implementation exists only for debug logging and is expected
// to be called first from the overriding implementation.
virtual bool IsInitSegmentPresent(MediaLargeByteBuffer* aData);
virtual bool IsInitSegmentPresent(MediaByteBuffer* aData);
// Return true if aData starts with a media segment.
// The base implementation exists only for debug logging and is expected
// to be called first from the overriding implementation.
virtual bool IsMediaSegmentPresent(MediaLargeByteBuffer* aData);
virtual bool IsMediaSegmentPresent(MediaByteBuffer* aData);
// Parse aData to extract the start and end frame times from the media
// segment. aData may not start on a parser sync boundary. Return true
// if aStart and aEnd have been updated.
virtual bool ParseStartAndEndTimestamps(MediaLargeByteBuffer* aData,
virtual bool ParseStartAndEndTimestamps(MediaByteBuffer* aData,
int64_t& aStart, int64_t& aEnd);
// Compare aLhs and rHs, considering any error that may exist in the
@ -44,7 +44,7 @@ public:
virtual int64_t GetRoundingError();
MediaLargeByteBuffer* InitData();
MediaByteBuffer* InitData();
bool HasInitData()
{
@ -65,7 +65,7 @@ public:
static ContainerParser* CreateForMIMEType(const nsACString& aType);
protected:
nsRefPtr<MediaLargeByteBuffer> mInitData;
nsRefPtr<MediaByteBuffer> mInitData;
nsRefPtr<SourceBufferResource> mResource;
bool mHasInitData;
MediaByteRange mCompleteInitSegmentRange;

Просмотреть файл

@ -20,7 +20,7 @@ extern PRLogModuleInfo* GetSourceBufferResourceLog();
namespace mozilla {
ResourceItem::ResourceItem(MediaLargeByteBuffer* aData)
ResourceItem::ResourceItem(MediaByteBuffer* aData)
: mData(aData)
{
}
@ -82,7 +82,7 @@ ResourceQueue::CopyData(uint64_t aOffset, uint32_t aCount, char* aDest)
}
void
ResourceQueue::AppendItem(MediaLargeByteBuffer* aData)
ResourceQueue::AppendItem(MediaByteBuffer* aData)
{
mLogicalLength += aData->Length();
Push(new ResourceItem(aData));
@ -111,7 +111,7 @@ uint32_t ResourceQueue::EvictBefore(uint64_t aOffset, ErrorResult& aRv)
uint32_t offset = aOffset - mOffset;
mOffset += offset;
evicted += offset;
nsRefPtr<MediaLargeByteBuffer> data = new MediaLargeByteBuffer;
nsRefPtr<MediaByteBuffer> data = new MediaByteBuffer;
if (!data->AppendElements(item->mData->Elements() + offset,
item->mData->Length() - offset,
fallible)) {

Просмотреть файл

@ -26,9 +26,9 @@ class ErrorResult;
// timepoint.
struct ResourceItem {
explicit ResourceItem(MediaLargeByteBuffer* aData);
explicit ResourceItem(MediaByteBuffer* aData);
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
nsRefPtr<MediaLargeByteBuffer> mData;
nsRefPtr<MediaByteBuffer> mData;
};
class ResourceQueue : private nsDeque {
@ -45,7 +45,7 @@ public:
// Copies aCount bytes from aOffset in the queue into aDest.
void CopyData(uint64_t aOffset, uint32_t aCount, char* aDest);
void AppendItem(MediaLargeByteBuffer* aData);
void AppendItem(MediaByteBuffer* aData);
// Tries to evict at least aSizeToEvict from the queue up until
// aOffset. Returns amount evicted.

Просмотреть файл

@ -433,7 +433,7 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
{
MSE_DEBUG("AppendData(aLength=%u)", aLength);
nsRefPtr<MediaLargeByteBuffer> data = PrepareAppend(aData, aLength, aRv);
nsRefPtr<MediaByteBuffer> data = PrepareAppend(aData, aLength, aRv);
if (!data) {
return;
}
@ -536,7 +536,7 @@ SourceBuffer::AppendError(bool aDecoderError)
}
}
already_AddRefed<MediaLargeByteBuffer>
already_AddRefed<MediaByteBuffer>
SourceBuffer::PrepareAppend(const uint8_t* aData, uint32_t aLength, ErrorResult& aRv)
{
typedef SourceBufferContentManager::EvictDataResult Result;
@ -584,7 +584,7 @@ SourceBuffer::PrepareAppend(const uint8_t* aData, uint32_t aLength, ErrorResult&
return nullptr;
}
nsRefPtr<MediaLargeByteBuffer> data = new MediaLargeByteBuffer();
nsRefPtr<MediaByteBuffer> data = new MediaByteBuffer();
if (!data->AppendElements(aData, aLength, fallible)) {
aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
return nullptr;

Просмотреть файл

@ -32,7 +32,7 @@ struct JSContext;
namespace mozilla {
class ErrorResult;
class MediaLargeByteBuffer;
class MediaByteBuffer;
template <typename T> class AsyncEventRunner;
class TrackBuffersManager;
@ -157,11 +157,11 @@ private:
// http://w3c.github.io/media-source/#sourcebuffer-append-error
void AppendError(bool aDecoderError);
// Implements the "Prepare Append Algorithm". Returns MediaLargeByteBuffer object
// Implements the "Prepare Append Algorithm". Returns MediaByteBuffer object
// on success or nullptr (with aRv set) on error.
already_AddRefed<MediaLargeByteBuffer> PrepareAppend(const uint8_t* aData,
uint32_t aLength,
ErrorResult& aRv);
already_AddRefed<MediaByteBuffer> PrepareAppend(const uint8_t* aData,
uint32_t aLength,
ErrorResult& aRv);
void AppendDataCompletedWithSuccess(bool aHasActiveTracks);
void AppendDataErrored(nsresult aError);

Просмотреть файл

@ -33,7 +33,7 @@ public:
// Add data to the end of the input buffer.
// Returns false if the append failed.
virtual bool
AppendData(MediaLargeByteBuffer* aData, TimeUnit aTimestampOffset) = 0;
AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) = 0;
// Run MSE Buffer Append Algorithm
// 3.5.5 Buffer Append Algorithm.

Просмотреть файл

@ -212,7 +212,7 @@ SourceBufferResource::EvictAll()
}
void
SourceBufferResource::AppendData(MediaLargeByteBuffer* aData)
SourceBufferResource::AppendData(MediaByteBuffer* aData)
{
SBR_DEBUG("AppendData(aData=%p, aLength=%u)",
aData->Elements(), aData->Length());

Просмотреть файл

@ -27,7 +27,7 @@ class nsIStreamListener;
namespace mozilla {
class MediaDecoder;
class MediaLargeByteBuffer;
class MediaByteBuffer;
namespace dom {
@ -103,7 +103,7 @@ public:
}
// Used by SourceBuffer.
void AppendData(MediaLargeByteBuffer* aData);
void AppendData(MediaByteBuffer* aData);
void Ended();
bool IsEnded()
{

Просмотреть файл

@ -139,7 +139,7 @@ TrackBuffer::ContinueShutdown()
}
bool
TrackBuffer::AppendData(MediaLargeByteBuffer* aData, TimeUnit aTimestampOffset)
TrackBuffer::AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset)
{
MOZ_ASSERT(NS_IsMainThread());
mInputBuffer = aData;
@ -162,7 +162,7 @@ TrackBuffer::BufferAppend()
nsRefPtr<AppendPromise> p = mInitializationPromise.Ensure(__func__);
bool hadInitData = mParser->HasInitData();
bool hadCompleteInitData = mParser->HasCompleteInitData();
nsRefPtr<MediaLargeByteBuffer> oldInit = mParser->InitData();
nsRefPtr<MediaByteBuffer> oldInit = mParser->InitData();
bool newInitData = mParser->IsInitSegmentPresent(mInputBuffer);
// TODO: Run more of the buffer append algorithm asynchronously.
@ -262,7 +262,7 @@ TrackBuffer::BufferAppend()
}
bool
TrackBuffer::AppendDataToCurrentResource(MediaLargeByteBuffer* aData, uint32_t aDuration)
TrackBuffer::AppendDataToCurrentResource(MediaByteBuffer* aData, uint32_t aDuration)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mCurrentDecoder) {
@ -724,7 +724,7 @@ TrackBuffer::OnMetadataRead(MetadataHolder* aMetadata,
// Adding an empty buffer will reopen the SourceBufferResource
if (!aWasEnded) {
nsRefPtr<MediaLargeByteBuffer> emptyBuffer = new MediaLargeByteBuffer;
nsRefPtr<MediaByteBuffer> emptyBuffer = new MediaByteBuffer;
aDecoder->GetResource()->AppendData(emptyBuffer);
}
// HACK END.

Просмотреть файл

@ -22,7 +22,7 @@ namespace mozilla {
class ContainerParser;
class MediaSourceDecoder;
class MediaLargeByteBuffer;
class MediaByteBuffer;
class TrackBuffer final : public SourceBufferContentManager {
public:
@ -30,7 +30,7 @@ public:
nsRefPtr<ShutdownPromise> Shutdown();
bool AppendData(MediaLargeByteBuffer* aData, TimeUnit aTimestampOffset) override;
bool AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) override;
// Append data to the current decoder. Also responsible for calling
// NotifyDataArrived on the decoder to keep buffered range computation up
@ -119,7 +119,7 @@ private:
// Helper for AppendData, ensures NotifyDataArrived is called whenever
// data is appended to the current decoder's SourceBufferResource.
bool AppendDataToCurrentResource(MediaLargeByteBuffer* aData,
bool AppendDataToCurrentResource(MediaByteBuffer* aData,
uint32_t aDuration /* microseconds */);
// Queue on the parent's decoder task queue a call to NotifyTimeRangesChanged.
void NotifyTimeRangesChanged();
@ -163,7 +163,7 @@ private:
SourceBufferDecoder* aDecoder);
nsAutoPtr<ContainerParser> mParser;
nsRefPtr<MediaLargeByteBuffer> mInputBuffer;
nsRefPtr<MediaByteBuffer> mInputBuffer;
// A task queue using the shared media thread pool. Used exclusively to
// initialize (i.e. call ReadMetadata on) decoders as they are created via

Просмотреть файл

@ -38,7 +38,7 @@ AppendStateToStr(TrackBuffersManager::AppendState aState)
}
TrackBuffersManager::TrackBuffersManager(dom::SourceBuffer* aParent, MediaSourceDecoder* aParentDecoder, const nsACString& aType)
: mInputBuffer(new MediaLargeByteBuffer)
: mInputBuffer(new MediaByteBuffer)
, mAppendState(AppendState::WAITING_FOR_SEGMENT)
, mBufferFull(false)
, mFirstInitializationSegmentReceived(false)
@ -65,7 +65,7 @@ TrackBuffersManager::TrackBuffersManager(dom::SourceBuffer* aParent, MediaSource
}
bool
TrackBuffersManager::AppendData(MediaLargeByteBuffer* aData,
TrackBuffersManager::AppendData(MediaByteBuffer* aData,
TimeUnit aTimestampOffset)
{
MOZ_ASSERT(NS_IsMainThread());
@ -316,13 +316,13 @@ TrackBuffersManager::CompleteResetParserState()
// during the next Segment Parser Loop and a new demuxer will be created and
// initialized.
if (mFirstInitializationSegmentReceived) {
nsRefPtr<MediaLargeByteBuffer> initData = mParser->InitData();
nsRefPtr<MediaByteBuffer> initData = mParser->InitData();
MOZ_ASSERT(initData->Length(), "we must have an init segment");
// The aim here is really to destroy our current demuxer.
CreateDemuxerforMIMEType();
// Recreate our input buffer. We can't directly assign the initData buffer
// to mInputBuffer as it will get modified in the Segment Parser Loop.
mInputBuffer = new MediaLargeByteBuffer;
mInputBuffer = new MediaByteBuffer;
MOZ_ALWAYS_TRUE(mInputBuffer->AppendElements(*initData, fallible));
}
RecreateParser();
@ -927,7 +927,7 @@ TrackBuffersManager::CodedFrameProcessing()
} else {
// The mediaRange is offset by the init segment position previously added.
length = mediaRange.mEnd - (mProcessedInput - mInputBuffer->Length());
nsRefPtr<MediaLargeByteBuffer> segment = new MediaLargeByteBuffer;
nsRefPtr<MediaByteBuffer> segment = new MediaByteBuffer;
MOZ_ASSERT(mInputBuffer->Length() >= length);
if (!segment->AppendElements(mInputBuffer->Elements(), length, fallible)) {
return CodedFrameProcessingPromise::CreateAndReject(NS_ERROR_OUT_OF_MEMORY, __func__);
@ -1380,7 +1380,7 @@ TrackBuffersManager::RecreateParser()
// as it has parsed the entire InputBuffer provided.
// Once the old TrackBuffer/MediaSource implementation is removed
// we can optimize this part. TODO
nsRefPtr<MediaLargeByteBuffer> initData = mParser->InitData();
nsRefPtr<MediaByteBuffer> initData = mParser->InitData();
mParser = ContainerParser::CreateForMIMEType(mType);
if (initData) {
int64_t start, end;

Просмотреть файл

@ -20,7 +20,7 @@
namespace mozilla {
class ContainerParser;
class MediaLargeByteBuffer;
class MediaByteBuffer;
class MediaRawData;
class MediaSourceDemuxer;
class SourceBuffer;
@ -40,7 +40,7 @@ public:
TrackBuffersManager(dom::SourceBuffer* aParent, MediaSourceDecoder* aParentDecoder, const nsACString& aType);
bool AppendData(MediaLargeByteBuffer* aData, TimeUnit aTimestampOffset) override;
bool AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) override;
nsRefPtr<AppendPromise> BufferAppend() override;
@ -116,12 +116,12 @@ private:
return mAudioTracks.mNumTracks > 0;
}
typedef Pair<nsRefPtr<MediaLargeByteBuffer>, TimeUnit> IncomingBuffer;
typedef Pair<nsRefPtr<MediaByteBuffer>, TimeUnit> IncomingBuffer;
void AppendIncomingBuffer(IncomingBuffer aData);
nsTArray<IncomingBuffer> mIncomingBuffers;
// The input buffer as per http://w3c.github.io/media-source/index.html#sourcebuffer-input-buffer
nsRefPtr<MediaLargeByteBuffer> mInputBuffer;
nsRefPtr<MediaByteBuffer> mInputBuffer;
// The current append state as per https://w3c.github.io/media-source/#sourcebuffer-append-state
// Accessed on both the main thread and the task queue.
Atomic<AppendState> mAppendState;

Просмотреть файл

@ -13,11 +13,11 @@ namespace mp4_demuxer {
BufferStream::BufferStream()
: mStartOffset(0)
, mData(new mozilla::MediaLargeByteBuffer)
, mData(new mozilla::MediaByteBuffer)
{
}
BufferStream::BufferStream(mozilla::MediaLargeByteBuffer* aBuffer)
BufferStream::BufferStream(mozilla::MediaByteBuffer* aBuffer)
: mStartOffset(0)
, mData(aBuffer)
{

Просмотреть файл

@ -10,7 +10,7 @@
#include "MediaResource.h"
namespace mozilla {
class MediaLargeByteBuffer;
class MediaByteBuffer;
}
namespace mp4_demuxer {
@ -22,7 +22,7 @@ public:
* Therefore BufferStream shouldn't get used after aData is destroyed.
*/
BufferStream();
explicit BufferStream(mozilla::MediaLargeByteBuffer* aBuffer);
explicit BufferStream(mozilla::MediaByteBuffer* aBuffer);
virtual bool ReadAt(int64_t aOffset, void* aData, size_t aLength,
size_t* aBytesRead) override;
@ -39,7 +39,7 @@ public:
private:
~BufferStream();
int64_t mStartOffset;
nsRefPtr<mozilla::MediaLargeByteBuffer> mData;
nsRefPtr<mozilla::MediaByteBuffer> mData;
};
}