Bug 1265634. Part 1 - add more proxy functions to MediaDecoderReaderWrapper and remove unused members from MDSM. r=kaku.
MozReview-Commit-ID: 6FO0JFrzSGH
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/MediaDecoderReaderWrapper.h
@@ -61,16 +61,25 @@ public:
bool ForceZeroStartTime() const { return mReader->ForceZeroStartTime(); }
bool VideoIsHardwareAccelerated() const {
return mReader->VideoIsHardwareAccelerated();
}
TimedMetadataEventSource& TimedMetadataEvent() {
return mReader->TimedMetadataEvent();
}
+ MediaEventSource<void>& OnMediaNotSeekable() {
+ return mReader->OnMediaNotSeekable();
+ }
+ size_t SizeOfVideoQueueInBytes() const {
+ return mReader->SizeOfVideoQueueInBytes();
+ }
+ size_t SizeOfAudioQueueInBytes() const {
+ return mReader->SizeOfAudioQueueInBytes();
+ }
size_t SizeOfAudioQueueInFrames() const {
return mReader->SizeOfAudioQueueInFrames();
}
size_t SizeOfVideoQueueInFrames() const {
return mReader->SizeOfVideoQueueInFrames();
}
void ReadUpdatedMetadata(MediaInfo* aInfo) {
mReader->ReadUpdatedMetadata(aInfo);
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -214,17 +214,16 @@ MediaDecoderStateMachine::MediaDecoderSt
mWatchManager(this, mTaskQueue),
mRealTime(aRealTime),
mDispatchedStateMachine(false),
mDelayedScheduler(mTaskQueue),
mState(DECODER_STATE_DECODING_METADATA, "MediaDecoderStateMachine::mState"),
mCurrentFrameID(0),
mObservedDuration(TimeUnit(), "MediaDecoderStateMachine::mObservedDuration"),
mFragmentEndTime(-1),
- mReader(aReader),
mReaderWrapper(new MediaDecoderReaderWrapper(aRealTime, mTaskQueue, aReader)),
mDecodedAudioEndTime(0),
mDecodedVideoEndTime(0),
mPlaybackRate(1.0),
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS),
mQuickBufferingLowDataThresholdUsecs(detail::QUICK_BUFFERING_LOW_DATA_USECS),
mIsAudioPrerolling(false),
@@ -2683,16 +2682,40 @@ void MediaDecoderStateMachine::RemoveOut
mOutputStreamManager->Remove(aStream);
if (mOutputStreamManager->IsEmpty()) {
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>(
this, &MediaDecoderStateMachine::SetAudioCaptured, false);
OwnerThread()->Dispatch(r.forget());
}
}
+size_t
+MediaDecoderStateMachine::SizeOfVideoQueue()
+{
+ return mReaderWrapper->SizeOfVideoQueueInBytes();
+}
+
+size_t
+MediaDecoderStateMachine::SizeOfAudioQueue()
+{
+ return mReaderWrapper->SizeOfAudioQueueInBytes();
+}
+
+AbstractCanonical<media::TimeIntervals>*
+MediaDecoderStateMachine::CanonicalBuffered()
+{
+ return mReaderWrapper->CanonicalBuffered();
+}
+
+MediaEventSource<void>&
+MediaDecoderStateMachine::OnMediaNotSeekable()
+{
+ return mReaderWrapper->OnMediaNotSeekable();
+}
+
} // namespace mozilla
// avoid redefined macro in unified build
#undef LOG
#undef DECODER_LOG
#undef VERBOSE_LOG
#undef DECODER_WARN
#undef DECODER_WARN_HELPER
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -217,19 +217,17 @@ public:
MOZ_ASSERT(NS_IsMainThread());
mResource = nullptr;
}
TimedMetadataEventSource& TimedMetadataEvent() {
return mMetadataManager.TimedMetadataEvent();
}
- MediaEventSource<void>& OnMediaNotSeekable() {
- return mReader->OnMediaNotSeekable();
- }
+ MediaEventSource<void>& OnMediaNotSeekable();
MediaEventSourceExc<nsAutoPtr<MediaInfo>,
nsAutoPtr<MetadataTags>,
MediaDecoderEventVisibility>&
MetadataLoadedEvent() { return mMetadataLoadedEvent; }
MediaEventSourceExc<nsAutoPtr<MediaInfo>,
MediaDecoderEventVisibility>&
@@ -239,23 +237,19 @@ public:
OnPlaybackEvent() { return mOnPlaybackEvent; }
MediaEventSource<MediaDecoderEventVisibility>&
OnSeekingStart() { return mOnSeekingStart; }
// Immutable after construction - may be called on any thread.
bool IsRealTime() const { return mRealTime; }
- size_t SizeOfVideoQueue() {
- return mReader->SizeOfVideoQueueInBytes();
- }
+ size_t SizeOfVideoQueue();
- size_t SizeOfAudioQueue() {
- return mReader->SizeOfAudioQueueInBytes();
- }
+ size_t SizeOfAudioQueue();
private:
// Functions used by assertions to ensure we're calling things
// on the appropriate threads.
bool OnTaskQueue() const;
// Initialization that needs to happen on the task queue. This is the first
// task that gets run on the task queue, and is dispatched from the MDSM
@@ -643,21 +637,16 @@ private:
// Queue of video frames. This queue is threadsafe, and is accessed from
// the decoder, state machine, and main threads.
MediaQueue<MediaData> mVideoQueue;
// The decoder monitor must be obtained before modifying this state.
// Accessed on state machine, audio, main, and AV thread.
Watchable<State> mState;
- // The task queue in which we run decode tasks. This is referred to as
- // the "decode thread", though in practise tasks can run on a different
- // thread every time they're called.
- TaskQueue* DecodeTaskQueue() const { return mReader->OwnerThread(); }
-
// Time that buffering started. Used for buffering timeout and only
// accessed on the state machine thread. This is null while we're not
// buffering.
TimeStamp mBufferingStart;
media::TimeUnit Duration() const { MOZ_ASSERT(OnTaskQueue()); return mDuration.Ref().ref(); }
// Recomputes the canonical duration from various sources.
@@ -694,20 +683,16 @@ private:
void OnSeekTaskRejected(SeekTaskRejectValue aValue);
// Media Fragment end time in microseconds. Access controlled by decoder monitor.
int64_t mFragmentEndTime;
// The media sink resource. Used on the state machine thread.
RefPtr<media::MediaSink> mMediaSink;
- // The reader, don't call its methods with the decoder monitor held.
- // This is created in the state machine's constructor.
- const RefPtr<MediaDecoderReader> mReader;
-
const RefPtr<MediaDecoderReaderWrapper> mReaderWrapper;
// 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
// of the audio stream, unless another frame is pushed to the hardware.
int64_t AudioEndTime() const;
// The end time of the last rendered video frame that's been sent to
@@ -1049,19 +1034,18 @@ private:
// Current playback position in the stream in bytes.
Canonical<int64_t> mPlaybackOffset;
// Used to distiguish whether the audio is producing sound.
Canonical<bool> mIsAudioDataAudible;
public:
- AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() {
- return mReader->CanonicalBuffered();
- }
+ AbstractCanonical<media::TimeIntervals>* CanonicalBuffered();
+
AbstractCanonical<media::NullableTimeUnit>* CanonicalDuration() {
return &mDuration;
}
AbstractCanonical<bool>* CanonicalIsShutdown() {
return &mIsShutdown;
}
AbstractCanonical<NextFrameStatus>* CanonicalNextFrameStatus() {
return &mNextFrameStatus;