Bug 1384836 - rename MediaDecoderReaderWrapper to ReaderProxy. r=kaku

MozReview-Commit-ID: 7WeNblTnTCG

--HG--
rename : dom/media/MediaDecoderReaderWrapper.cpp => dom/media/ReaderProxy.cpp
rename : dom/media/MediaDecoderReaderWrapper.h => dom/media/ReaderProxy.h
extra : rebase_source : a03573610a8d375fa30b89d90cdf4dc9a4ea3441
This commit is contained in:
JW Wang 2017-07-27 14:49:57 +08:00
parent dcd26c7c3a
commit b9cda6f285
5 changed files with 50 additions and 52 deletions

View File

@ -44,11 +44,11 @@
#include "DOMMediaStream.h"
#include "ImageContainer.h"
#include "MediaDecoder.h"
#include "MediaDecoderReaderWrapper.h"
#include "MediaDecoderStateMachine.h"
#include "MediaShutdownManager.h"
#include "MediaPrefs.h"
#include "MediaTimer.h"
#include "ReaderProxy.h"
#include "TimeUnits.h"
#include "VideoSegment.h"
#include "VideoUtils.h"
@ -258,7 +258,7 @@ protected:
explicit StateObject(Master* aPtr) : mMaster(aPtr) { }
TaskQueue* OwnerThread() const { return mMaster->mTaskQueue; }
MediaResource* Resource() const { return mMaster->mResource; }
MediaDecoderReaderWrapper* Reader() const { return mMaster->mReader; }
ReaderProxy* Reader() const { return mMaster->mReader; }
const MediaInfo& Info() const { return mMaster->Info(); }
bool IsExpectingMoreData() const
{
@ -1000,7 +1000,7 @@ public:
// Disconnect MediaDecoder.
mSeekJob.RejectIfExists(__func__);
// Disconnect MediaDecoderReaderWrapper.
// Disconnect ReaderProxy.
mSeekRequest.DisconnectIfExists();
mWaitRequest.DisconnectIfExists();
@ -2720,7 +2720,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mDelayedScheduler(mTaskQueue),
mCurrentFrameID(0),
INIT_WATCHABLE(mObservedDuration, TimeUnit()),
mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
mReader(new ReaderProxy(mTaskQueue, aReader)),
mPlaybackRate(1.0),
mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD),
mAudioCaptured(false),

View File

@ -108,8 +108,8 @@ class MediaSink;
class AbstractThread;
class AudioSegment;
class DecodedStream;
class MediaDecoderReaderWrapper;
class OutputStreamManager;
class ReaderProxy;
class TaskQueue;
extern LazyLogModule gMediaDecoderLog;
@ -548,7 +548,7 @@ private:
// The media sink resource. Used on the state machine thread.
RefPtr<media::MediaSink> mMediaSink;
const RefPtr<MediaDecoderReaderWrapper> mReader;
const RefPtr<ReaderProxy> mReader;
// The end time of the last audio frame that's been pushed onto the media sink
// in microseconds. This will approximately be the end time

View File

@ -5,39 +5,39 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/MozPromise.h"
#include "MediaDecoderReaderWrapper.h"
#include "MediaFormatReader.h"
#include "ReaderProxy.h"
#include "TimeUnits.h"
namespace mozilla {
MediaDecoderReaderWrapper::MediaDecoderReaderWrapper(
AbstractThread* aOwnerThread,
MediaFormatReader* aReader)
ReaderProxy::ReaderProxy(AbstractThread* aOwnerThread,
MediaFormatReader* aReader)
: mOwnerThread(aOwnerThread)
, mReader(aReader)
, mWatchManager(this, aReader->OwnerThread())
, mDuration(aReader->OwnerThread(),
NullableTimeUnit(),
"MediaDecoderReaderWrapper::mDuration (Mirror)")
media::NullableTimeUnit(),
"ReaderProxy::mDuration (Mirror)")
{
// Must support either heuristic buffering or WaitForData().
MOZ_ASSERT(mReader->UseBufferingHeuristics() ||
mReader->IsWaitForDataSupported());
}
MediaDecoderReaderWrapper::~MediaDecoderReaderWrapper()
ReaderProxy::~ReaderProxy()
{}
media::TimeUnit
MediaDecoderReaderWrapper::StartTime() const
ReaderProxy::StartTime() const
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
return mStartTime.ref();
}
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
MediaDecoderReaderWrapper::ReadMetadata()
RefPtr<ReaderProxy::MetadataPromise>
ReaderProxy::ReadMetadata()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
@ -48,12 +48,12 @@ MediaDecoderReaderWrapper::ReadMetadata()
->Then(mOwnerThread,
__func__,
this,
&MediaDecoderReaderWrapper::OnMetadataRead,
&MediaDecoderReaderWrapper::OnMetadataNotRead);
&ReaderProxy::OnMetadataRead,
&ReaderProxy::OnMetadataNotRead);
}
RefPtr<MediaDecoderReaderWrapper::AudioDataPromise>
MediaDecoderReaderWrapper::RequestAudioData()
RefPtr<ReaderProxy::AudioDataPromise>
ReaderProxy::RequestAudioData()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
@ -74,8 +74,8 @@ MediaDecoderReaderWrapper::RequestAudioData()
});
}
RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
MediaDecoderReaderWrapper::RequestVideoData(const media::TimeUnit& aTimeThreshold)
RefPtr<ReaderProxy::VideoDataPromise>
ReaderProxy::RequestVideoData(const media::TimeUnit& aTimeThreshold)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
@ -102,8 +102,8 @@ MediaDecoderReaderWrapper::RequestVideoData(const media::TimeUnit& aTimeThreshol
});
}
RefPtr<MediaDecoderReaderWrapper::SeekPromise>
MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget)
RefPtr<ReaderProxy::SeekPromise>
ReaderProxy::Seek(const SeekTarget& aTarget)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
SeekTarget adjustedTarget = aTarget;
@ -115,8 +115,8 @@ MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget)
Move(adjustedTarget));
}
RefPtr<MediaDecoderReaderWrapper::WaitForDataPromise>
MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
RefPtr<ReaderProxy::WaitForDataPromise>
ReaderProxy::WaitForData(MediaData::Type aType)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(mReader->IsWaitForDataSupported());
@ -128,7 +128,7 @@ MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
}
void
MediaDecoderReaderWrapper::ReleaseResources()
ReaderProxy::ReleaseResources()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
@ -139,7 +139,7 @@ MediaDecoderReaderWrapper::ReleaseResources()
}
void
MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks)
ReaderProxy::ResetDecode(TrackSet aTracks)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
@ -151,11 +151,11 @@ MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks)
}
RefPtr<ShutdownPromise>
MediaDecoderReaderWrapper::Shutdown()
ReaderProxy::Shutdown()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
mShutdown = true;
RefPtr<MediaDecoderReaderWrapper> self = this;
RefPtr<ReaderProxy> self = this;
return InvokeAsync(mReader->OwnerThread(), __func__, [self]() {
self->mDuration.DisconnectIfConnected();
self->mWatchManager.Shutdown();
@ -163,8 +163,8 @@ MediaDecoderReaderWrapper::Shutdown()
});
}
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder&& aMetadata)
RefPtr<ReaderProxy::MetadataPromise>
ReaderProxy::OnMetadataRead(MetadataHolder&& aMetadata)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
if (mShutdown) {
@ -178,14 +178,14 @@ MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder&& aMetadata)
return MetadataPromise::CreateAndResolve(Move(aMetadata), __func__);
}
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
MediaDecoderReaderWrapper::OnMetadataNotRead(const MediaResult& aError)
RefPtr<ReaderProxy::MetadataPromise>
ReaderProxy::OnMetadataNotRead(const MediaResult& aError)
{
return MetadataPromise::CreateAndReject(aError, __func__);
}
void
MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
ReaderProxy::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
@ -197,25 +197,23 @@ MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
}
void
MediaDecoderReaderWrapper::UpdateDuration()
ReaderProxy::UpdateDuration()
{
MOZ_ASSERT(mReader->OwnerThread()->IsCurrentThreadIn());
mReader->UpdateDuration(mDuration.Ref().ref());
}
void
MediaDecoderReaderWrapper::SetCanonicalDuration(
ReaderProxy::SetCanonicalDuration(
AbstractCanonical<media::NullableTimeUnit>* aCanonical)
{
using DurationT = AbstractCanonical<media::NullableTimeUnit>;
RefPtr<MediaDecoderReaderWrapper> self = this;
RefPtr<ReaderProxy> self = this;
RefPtr<DurationT> canonical = aCanonical;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"MediaDecoderReaderWrapper::SetCanonicalDuration",
[this, self, canonical]() {
"ReaderProxy::SetCanonicalDuration", [this, self, canonical]() {
mDuration.Connect(canonical);
mWatchManager.Watch(mDuration,
&MediaDecoderReaderWrapper::UpdateDuration);
mWatchManager.Watch(mDuration, &ReaderProxy::UpdateDuration);
});
mReader->OwnerThread()->Dispatch(r.forget());
}

View File

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MediaDecoderReaderWrapper_h_
#define MediaDecoderReaderWrapper_h_
#ifndef ReaderProxy_h_
#define ReaderProxy_h_
#include "mozilla/AbstractThread.h"
#include "mozilla/RefPtr.h"
@ -23,18 +23,18 @@ namespace mozilla {
* It also adjusts the seek target passed to Seek() to ensure correct seek time
* is passed to the underlying reader.
*/
class MediaDecoderReaderWrapper {
class ReaderProxy
{
using MetadataPromise = MediaFormatReader::MetadataPromise;
using AudioDataPromise = MediaFormatReader::AudioDataPromise;
using VideoDataPromise = MediaFormatReader::VideoDataPromise;
using SeekPromise = MediaFormatReader::SeekPromise;
using WaitForDataPromise = MediaFormatReader::WaitForDataPromise;
using TrackSet = MediaFormatReader::TrackSet;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ReaderProxy);
public:
MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
MediaFormatReader* aReader);
ReaderProxy(AbstractThread* aOwnerThread, MediaFormatReader* aReader);
media::TimeUnit StartTime() const;
RefPtr<MetadataPromise> ReadMetadata();
@ -85,7 +85,7 @@ public:
AbstractCanonical<media::NullableTimeUnit>* aCanonical);
private:
~MediaDecoderReaderWrapper();
~ReaderProxy();
RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder&& aMetadata);
RefPtr<MetadataPromise> OnMetadataNotRead(const MediaResult& aError);
void UpdateDuration();
@ -97,7 +97,7 @@ private:
Maybe<media::TimeUnit> mStartTime;
// State-watching manager.
WatchManager<MediaDecoderReaderWrapper> mWatchManager;
WatchManager<ReaderProxy> mWatchManager;
// Duration, mirrored from the state machine task queue.
Mirror<media::NullableTimeUnit> mDuration;
@ -105,4 +105,4 @@ private:
} // namespace mozilla
#endif // MediaDecoderReaderWrapper_h_
#endif // ReaderProxy_h_

View File

@ -223,7 +223,6 @@ UNIFIED_SOURCES += [
'MediaContainerType.cpp',
'MediaData.cpp',
'MediaDecoder.cpp',
'MediaDecoderReaderWrapper.cpp',
'MediaDecoderStateMachine.cpp',
'MediaDeviceInfo.cpp',
'MediaDevices.cpp',
@ -245,6 +244,7 @@ UNIFIED_SOURCES += [
'MediaTrackList.cpp',
'MemoryBlockCache.cpp',
'QueueObject.cpp',
'ReaderProxy.cpp',
'SeekJob.cpp',
'StreamTracks.cpp',
'TextTrack.cpp',