Bug 1175768 - Dispatch NotifyDataArrived and remove the aBuffer argument. r=jya

It would be nice to remove the argument in a separate patch, but we can't
perform MediaResource reads on the main thread, so the SilentReadAt stuff
needs to happen at the same time as the off-main-thread stuff.
This commit is contained in:
Bobby Holley 2015-06-16 15:37:48 -07:00 committed by Jean-Yves Avenard
parent 880d8829bc
commit 23c16e6894
33 changed files with 131 additions and 116 deletions

View File

@ -117,7 +117,7 @@ public:
// Called by the reader's MediaResource as data arrives over the network.
// Must be called on the main thread.
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) = 0;
virtual void NotifyDataArrived(uint32_t aLength, int64_t aOffset) = 0;
// Set by Reader if the current audio track can be offloaded
virtual void SetPlatformCanOffloadAudio(bool aCanOffloadAudio) {}

View File

@ -466,7 +466,7 @@ nsresult MP3FrameParser::ParseBuffer(const uint8_t* aBuffer,
return NS_OK;
}
void MP3FrameParser::Parse(const char* aBuffer, uint32_t aLength, uint64_t aOffset)
void MP3FrameParser::Parse(const uint8_t* aBuffer, uint32_t aLength, uint64_t aOffset)
{
MutexAutoLock mon(mLock);
@ -475,7 +475,7 @@ void MP3FrameParser::Parse(const char* aBuffer, uint32_t aLength, uint64_t aOffs
return;
}
const uint8_t* buffer = reinterpret_cast<const uint8_t*>(aBuffer);
const uint8_t* buffer = aBuffer;
int32_t length = aLength;
uint64_t offset = aOffset;

View File

@ -112,7 +112,7 @@ public:
return mIsMP3 != NOT_MP3;
}
void Parse(const char* aBuffer, uint32_t aLength, uint64_t aStreamOffset);
void Parse(const uint8_t* aBuffer, uint32_t aLength, uint64_t aStreamOffset);
// Returns the duration, in microseconds. If the entire stream has not
// been parsed yet, this is an estimate based on the bitrate of the

View File

@ -1317,9 +1317,9 @@ size_t MediaDecoder::SizeOfAudioQueue() {
return 0;
}
void MediaDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) {
void MediaDecoder::NotifyDataArrived(uint32_t aLength, int64_t aOffset) {
if (mDecoderStateMachine) {
mDecoderStateMachine->NotifyDataArrived(aBuffer, aLength, aOffset);
mDecoderStateMachine->DispatchNotifyDataArrived(aLength, aOffset);
}
// ReadyState computation depends on MediaDecoder::CanPlayThrough, which

View File

@ -434,7 +434,7 @@ public:
// Called as data arrives on the stream and is read into the cache. Called
// on the main thread only.
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) override;
virtual void NotifyDataArrived(uint32_t aLength, int64_t aOffset) override;
// Called by MediaResource when the principal of the resource has
// changed. Called on main thread only.

View File

@ -239,9 +239,23 @@ public:
virtual size_t SizeOfVideoQueueInFrames();
virtual size_t SizeOfAudioQueueInFrames();
// Only used by WebMReader and MediaOmxReader for now, so stub here rather
// than in every reader than inherits from MediaDecoderReader.
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) {}
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }
void NotifyDataArrived(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(OnTaskQueue());
NS_ENSURE_TRUE_VOID(!mShutdown);
NotifyDataArrivedInternal(aLength, aOffset);
}
public:
void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset)
{
RefPtr<nsRunnable> r =
NS_NewRunnableMethodWithArgs<uint32_t, int64_t>(this, &MediaDecoderReader::NotifyDataArrived, aLength, aOffset);
TaskQueue()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
}
// Notify the reader that data from the resource was evicted (MediaSource only)
virtual void NotifyDataRemoved() {}
virtual int64_t GetEvictionOffset(double aTime) { return -1; }

View File

@ -1639,12 +1639,10 @@ void MediaDecoderStateMachine::LogicallySeekingChanged()
ScheduleStateMachine();
}
void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset)
void MediaDecoderStateMachine::NotifyDataArrived(uint32_t aLength,
int64_t aOffset)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
MOZ_ASSERT(OnTaskQueue());
// While playing an unseekable stream of unknown duration, mObservedDuration
// is updated (in AdvanceFrame()) as we play. But if data is being downloaded

View File

@ -271,7 +271,16 @@ public:
return 0;
}
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
private:
void NotifyDataArrived(uint32_t aLength, int64_t aOffset);
public:
void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset)
{
RefPtr<nsRunnable> r =
NS_NewRunnableMethodWithArgs<uint32_t, int64_t>(this, &MediaDecoderStateMachine::NotifyDataArrived, aLength, aOffset);
TaskQueue()->Dispatch(r.forget());
mReader->DispatchNotifyDataArrived(aLength, aOffset);
}
// Returns the state machine task queue.
MediaTaskQueue* TaskQueue() const { return mTaskQueue; }

View File

@ -1539,11 +1539,10 @@ MediaFormatReader::NotifyDemuxer(uint32_t aLength, int64_t aOffset)
}
void
MediaFormatReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
MediaFormatReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aBuffer || aLength);
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aLength);
if (mDataRange.IsEmpty()) {
mDataRange = ByteInterval(aOffset, aOffset + aLength);
} else {

View File

@ -68,9 +68,9 @@ public:
}
int64_t GetEvictionOffset(double aTime) override;
void NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset) override;
protected:
void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
public:
void NotifyDataRemoved() override;
media::TimeIntervals GetBuffered() override;

View File

@ -463,7 +463,7 @@ ChannelMediaResource::CopySegmentToCache(nsIInputStream *aInStream,
{
CopySegmentClosure* closure = static_cast<CopySegmentClosure*>(aClosure);
closure->mResource->mDecoder->NotifyDataArrived(aFromSegment, aCount, closure->mResource->mOffset);
closure->mResource->mDecoder->NotifyDataArrived(aCount, closure->mResource->mOffset);
// Keep track of where we're up to.
RESOURCE_LOG("%p [ChannelMediaResource]: CopySegmentToCache at mOffset [%lld] add "

View File

@ -387,7 +387,7 @@ AppleMP3Reader::ReadMetadata(MediaInfo* aInfo,
bytes,
0 /* flags */);
mMP3FrameParser.Parse(bytes, numBytes, offset);
mMP3FrameParser.Parse(reinterpret_cast<uint8_t*>(bytes), numBytes, offset);
offset += numBytes;
@ -525,16 +525,16 @@ AppleMP3Reader::Seek(int64_t aTime, int64_t aEndTime)
}
void
AppleMP3Reader::NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset)
AppleMP3Reader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(OnTaskQueue());
if (!mMP3FrameParser.NeedsData()) {
return;
}
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
mMP3FrameParser.Parse(bytes->Elements(), aLength, aOffset);
if (!mMP3FrameParser.IsMP3()) {
return;
}

View File

@ -45,9 +45,10 @@ public:
AudioFileStreamPropertyID aPropertyID,
UInt32 *aFlags);
virtual void NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset) override;
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset) override;
public:
virtual bool IsMediaSeekable() override;

View File

@ -84,7 +84,7 @@ ParseMP3Headers(MP3FrameParser *aParser, MediaResource *aResource)
return NS_ERROR_FAILURE;
}
aParser->Parse(buffer, bytesRead, offset);
aParser->Parse(reinterpret_cast<uint8_t*>(buffer), bytesRead, offset);
offset += bytesRead;
}
@ -401,14 +401,16 @@ DirectShowReader::SeekInternal(int64_t aTargetUs)
}
void
DirectShowReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
DirectShowReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(OnTaskQueue());
if (!mMP3FrameParser.NeedsData()) {
return;
}
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
mMP3FrameParser.Parse(bytes->Elements(), aLength, aOffset);
if (!mMP3FrameParser.IsMP3()) {
return;
}

View File

@ -58,9 +58,10 @@ public:
nsRefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
void NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset) override;
protected:
void NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset) override;
public:
bool IsMediaSeekable() override;

View File

@ -1146,14 +1146,9 @@ MP4Reader::VideoIsHardwareAccelerated() const
}
void
MP4Reader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
MP4Reader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShutdown) {
return;
}
MOZ_ASSERT(OnTaskQueue());
if (mLastSeenEnd < 0) {
MonitorAutoLock mon(mDemuxerMonitor);
mLastSeenEnd = mDecoder->GetResource()->GetLength();

View File

@ -62,7 +62,10 @@ public:
virtual bool IsMediaSeekable() override;
virtual int64_t GetEvictionOffset(double aTime) override;
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) override;
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
public:
virtual media::TimeIntervals GetBuffered() override;

View File

@ -335,7 +335,7 @@ nsresult GStreamerReader::ParseMP3Headers()
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(bytesRead, NS_ERROR_FAILURE);
mMP3FrameParser.Parse(bytes, bytesRead, offset);
mMP3FrameParser.Parse(reinterpret_cast<uint8_t*>(bytes), bytesRead, offset);
offset += bytesRead;
} while (!mMP3FrameParser.ParsedHeaders());
@ -1272,11 +1272,10 @@ GStreamerReader::AutoplugSortCb(GstElement* aElement, GstPad* aPad,
* If this is an MP3 stream, pass any new data we get to the MP3 frame parser
* for duration estimation.
*/
void GStreamerReader::NotifyDataArrived(const char *aBuffer,
uint32_t aLength,
int64_t aOffset)
void GStreamerReader::NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(OnTaskQueue());
if (HasVideo()) {
return;
}
@ -1284,7 +1283,9 @@ void GStreamerReader::NotifyDataArrived(const char *aBuffer,
return;
}
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
mMP3FrameParser.Parse(bytes->Elements(), aLength, aOffset);
if (!mMP3FrameParser.IsMP3()) {
return;
}

View File

@ -51,9 +51,10 @@ public:
Seek(int64_t aTime, int64_t aEndTime) override;
virtual media::TimeIntervals GetBuffered() override;
virtual void NotifyDataArrived(const char *aBuffer,
uint32_t aLength,
int64_t aOffset) override;
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset) override;
public:
virtual bool HasAudio() override {
return mInfo.HasAudio();

View File

@ -297,7 +297,7 @@ SourceBuffer::Ended()
mContentManager->Ended();
// We want the MediaSourceReader to refresh its buffered range as it may
// have been modified (end lined up).
mMediaSource->GetDecoder()->NotifyDataArrived(nullptr, 1, mReportedOffset++);
mMediaSource->GetDecoder()->NotifyDataArrived(1, mReportedOffset++);
}
SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
@ -492,7 +492,7 @@ SourceBuffer::AppendDataCompletedWithSuccess(bool aHasActiveTracks)
// Tell our parent decoder that we have received new data.
// The information provided do not matter much so long as it is monotonically
// increasing.
mMediaSource->GetDecoder()->NotifyDataArrived(nullptr, 1, mReportedOffset++);
mMediaSource->GetDecoder()->NotifyDataArrived(1, mReportedOffset++);
// Send progress event.
mMediaSource->GetDecoder()->NotifyBytesDownloaded();
}

View File

@ -197,15 +197,15 @@ SourceBufferDecoder::GetOwner()
}
void
SourceBufferDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
SourceBufferDecoder::NotifyDataArrived(uint32_t aLength, int64_t aOffset)
{
mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
mReader->DispatchNotifyDataArrived(aLength, aOffset);
// XXX: Params make no sense to parent decoder as it relates to a
// specific SourceBufferDecoder's data stream. Pass bogus values here to
// force parent decoder's state machine to recompute end time for
// infinite length media.
mParentDecoder->NotifyDataArrived(nullptr, 0, 0);
mParentDecoder->NotifyDataArrived(0, 0);
}
media::TimeIntervals

View File

@ -47,7 +47,7 @@ public:
virtual void FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility) final override;
virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) final override;
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) final override;
virtual void NotifyDataArrived(uint32_t aLength, int64_t aOffset) final override;
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded, uint32_t aDropped) final override;
virtual void NotifyWaitingForResourcesStatusChanged() final override;
virtual void OnReadMetadataCompleted() final override;

View File

@ -273,9 +273,7 @@ TrackBuffer::AppendDataToCurrentResource(MediaByteBuffer* aData, uint32_t aDurat
int64_t appendOffset = resource->GetLength();
resource->AppendData(aData);
mCurrentDecoder->SetRealMediaDuration(mCurrentDecoder->GetRealMediaDuration() + aDuration);
// XXX: For future reference: NDA call must run on the main thread.
mCurrentDecoder->NotifyDataArrived(reinterpret_cast<const char*>(aData->Elements()),
aData->Length(), appendOffset);
mCurrentDecoder->NotifyDataArrived(aData->Length(), appendOffset);
mParentDecoder->NotifyBytesDownloaded();
NotifyTimeRangesChanged();

View File

@ -522,10 +522,12 @@ MediaCodecReader::HasVideo()
}
void
MediaCodecReader::NotifyDataArrived(const char* aBuffer,
uint32_t aLength,
int64_t aOffset)
MediaCodecReader::NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset)
{
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
MonitorAutoLock monLock(mParserMonitor);
if (mNextParserPosition == mParsedDataLength &&
mNextParserPosition >= aOffset &&
@ -533,7 +535,7 @@ MediaCodecReader::NotifyDataArrived(const char* aBuffer,
// No pending parsing runnable currently. And available data are adjacent to
// parsed data.
int64_t shift = mNextParserPosition - aOffset;
const char* buffer = aBuffer + shift;
const char* buffer = reinterpret_cast<const char*>(bytes->Elements()) + shift;
uint32_t length = aLength - shift;
int64_t offset = mNextParserPosition;
if (length > 0) {
@ -630,7 +632,7 @@ MediaCodecReader::ParseDataSegment(const char* aBuffer,
return true; // NO-OP
}
mMP3FrameParser->Parse(aBuffer, aLength, aOffset);
mMP3FrameParser->Parse(reinterpret_cast<const uint8_t*>(aBuffer), aLength, aOffset);
duration = mMP3FrameParser->GetDuration();
}

View File

@ -73,10 +73,12 @@ public:
// irreversible, whereas ReleaseMediaResources() is reversible.
virtual nsRefPtr<ShutdownPromise> Shutdown();
protected:
// Used to retrieve some special information that can only be retrieved after
// all contents have been continuously parsed. (ex. total duration of some
// variable-bit-rate MP3 files.)
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
public:
// Flush the MediaTaskQueue, flush MediaCodec and raise the mDiscontinuity.
virtual nsresult ResetDecode() override;

View File

@ -43,7 +43,7 @@ public:
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(mOmxReader.get());
mOmxReader->ProcessCachedData(mOffset, false);
mOmxReader->ProcessCachedData(mOffset);
}
private:
@ -70,24 +70,20 @@ class MediaOmxReader::NotifyDataArrivedRunnable : public nsRunnable
{
public:
NotifyDataArrivedRunnable(MediaOmxReader* aOmxReader,
const char* aBuffer, uint64_t aLength,
int64_t aOffset, uint64_t aFullLength)
uint64_t aLength,
int64_t aOffset, uint64_t aFullLength)
: mOmxReader(aOmxReader),
mBuffer(aBuffer),
mLength(aLength),
mOffset(aOffset),
mFullLength(aFullLength)
{
MOZ_ASSERT(mOmxReader.get());
MOZ_ASSERT(mBuffer.get() || !mLength);
}
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MOZ_ASSERT(mOmxReader->OnTaskQueue());
NotifyDataArrived();
return NS_OK;
}
@ -97,13 +93,10 @@ private:
if (mOmxReader->IsShutdown()) {
return;
}
const char* buffer = mBuffer.get();
while (mLength) {
uint32_t length = std::min<uint64_t>(mLength, UINT32_MAX);
mOmxReader->NotifyDataArrived(buffer, length,
mOffset);
buffer += length;
mOmxReader->NotifyDataArrived(length, mOffset);
mLength -= length;
mOffset += length;
}
@ -118,7 +111,6 @@ private:
}
nsRefPtr<MediaOmxReader> mOmxReader;
nsAutoArrayPtr<const char> mBuffer;
uint64_t mLength;
int64_t mOffset;
uint64_t mFullLength;
@ -245,7 +237,7 @@ MediaOmxReader::AsyncReadMetadata()
// the mDecoder->GetResource()->GetLength() would return -1.
// Delay set the total duration on this function.
mMP3FrameParser.SetLength(mDecoder->GetResource()->GetLength());
ProcessCachedData(0, true);
ProcessCachedData(0);
}
nsRefPtr<MediaDecoderReader::MetadataPromise> p = mMetadataPromise.Ensure(__func__);
@ -468,9 +460,9 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
return true;
}
void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
void MediaOmxReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(OnTaskQueue());
nsRefPtr<AbstractMediaDecoder> decoder = SafeGetDecoder();
if (!decoder) { // reader has shut down
return;
@ -482,7 +474,9 @@ void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, in
return;
}
mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
mMP3FrameParser.Parse(bytes->Elements(), aLength, aOffset);
if (!mMP3FrameParser.IsMP3()) {
return;
}
@ -573,7 +567,7 @@ void MediaOmxReader::EnsureActive() {
NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding");
}
int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset, bool aWaitForCompletion)
int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset)
{
// Could run on decoder thread or IO thread.
nsRefPtr<AbstractMediaDecoder> decoder = SafeGetDecoder();
@ -597,22 +591,14 @@ int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset, bool aWaitForCompleti
}
int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
nsAutoArrayPtr<char> buffer(new char[bufferLength]);
nsresult rv = decoder->GetResource()->ReadFromCache(buffer.get(),
aOffset, bufferLength);
NS_ENSURE_SUCCESS(rv, -1);
nsRefPtr<NotifyDataArrivedRunnable> runnable(
new NotifyDataArrivedRunnable(this, buffer.forget(), bufferLength,
aOffset, resourceLength));
if (aWaitForCompletion) {
rv = NS_DispatchToMainThread(runnable.get(), NS_DISPATCH_SYNC);
new NotifyDataArrivedRunnable(this, bufferLength, aOffset, resourceLength));
if (OnTaskQueue()) {
runnable->Run();
} else {
rv = NS_DispatchToMainThread(runnable.get());
TaskQueue()->Dispatch(runnable.forget());
}
NS_ENSURE_SUCCESS(rv, -1);
return resourceLength - aOffset - bufferLength;
}

View File

@ -69,7 +69,9 @@ public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
public:
virtual bool DecodeAudioData();
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
@ -114,7 +116,7 @@ private:
return mIsShutdown;
}
int64_t ProcessCachedData(int64_t aOffset, bool aWaitForCompletion);
int64_t ProcessCachedData(int64_t aOffset);
already_AddRefed<AbstractMediaDecoder> SafeGetDecoder();
};

View File

@ -154,7 +154,7 @@ BufferDecoder::NotifyWaitingForResourcesStatusChanged()
}
void
BufferDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
BufferDecoder::NotifyDataArrived(uint32_t aLength, int64_t aOffset)
{
// ignore
}

View File

@ -69,7 +69,7 @@ public:
virtual void NotifyWaitingForResourcesStatusChanged() final override;
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset) final override;
virtual void NotifyDataArrived(uint32_t aLength, int64_t aOffset) final override;
private:
virtual ~BufferDecoder();

View File

@ -300,9 +300,8 @@ bool WebMBufferedState::GetOffsetForTime(uint64_t aTime, int64_t* aOffset)
return true;
}
void WebMBufferedState::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
void WebMBufferedState::NotifyDataArrived(const unsigned char* aBuffer, uint32_t aLength, int64_t aOffset)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
uint32_t idx = mRangeParsers.IndexOfFirstElementGt(aOffset - 1);
if (idx == 0 || !(mRangeParsers[idx-1] == aOffset)) {
// If the incoming data overlaps an already parsed range, adjust the
@ -329,7 +328,7 @@ void WebMBufferedState::NotifyDataArrived(const char* aBuffer, uint32_t aLength,
}
}
mRangeParsers[idx].Append(reinterpret_cast<const unsigned char*>(aBuffer),
mRangeParsers[idx].Append(aBuffer,
aLength,
mTimeMapping,
mReentrantMonitor);

View File

@ -228,7 +228,7 @@ public:
MOZ_COUNT_CTOR(WebMBufferedState);
}
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
void NotifyDataArrived(const unsigned char* aBuffer, uint32_t aLength, int64_t aOffset);
bool CalculateBufferedForRange(int64_t aStartOffset, int64_t aEndOffset,
uint64_t* aStartTime, uint64_t* aEndTime);

View File

@ -1145,10 +1145,12 @@ media::TimeIntervals WebMReader::GetBuffered()
return buffered;
}
void WebMReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength,
int64_t aOffset)
void WebMReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
{
mBufferedState->NotifyDataArrived(aBuffer, aLength, aOffset);
MOZ_ASSERT(OnTaskQueue());
nsRefPtr<MediaByteBuffer> bytes = mDecoder->GetResource()->SilentReadAt(aOffset, aLength);
NS_ENSURE_TRUE_VOID(bytes);
mBufferedState->NotifyDataArrived(bytes->Elements(), aLength, aOffset);
}
int64_t WebMReader::GetEvictionOffset(double aTime)

View File

@ -173,8 +173,6 @@ public:
Seek(int64_t aTime, int64_t aEndTime) override;
virtual media::TimeIntervals GetBuffered() override;
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength,
int64_t aOffset) override;
virtual int64_t GetEvictionOffset(double aTime) override;
virtual bool IsMediaSeekable() override;
@ -206,6 +204,8 @@ protected:
// Setup opus decoder
bool InitOpusDecoder();
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
// Decode a nestegg packet of audio data. Push the audio data on the
// audio queue. Returns true when there's more audio to decode,
// false if the audio is finished, end of file has been reached,