зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1228923 - Merge some MediaEventSource for MDSM. r=jya.
This commit is contained in:
Родитель
05fead0b21
Коммит
f304127126
|
@ -615,11 +615,7 @@ MediaDecoder::Shutdown()
|
|||
mTimedMetadataListener.Disconnect();
|
||||
mMetadataLoadedListener.Disconnect();
|
||||
mFirstFrameLoadedListener.Disconnect();
|
||||
mOnPlaybackStart.Disconnect();
|
||||
mOnPlaybackStop.Disconnect();
|
||||
mOnPlaybackEnded.Disconnect();
|
||||
mOnDecodeError.Disconnect();
|
||||
mOnInvalidate.Disconnect();
|
||||
mOnPlaybackEvent.Disconnect();
|
||||
mOnSeekingStart.Disconnect();
|
||||
}
|
||||
|
||||
|
@ -644,6 +640,29 @@ MediaDecoder::~MediaDecoder()
|
|||
MOZ_COUNT_DTOR(MediaDecoder);
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoder::OnPlaybackEvent(MediaEventType aEvent)
|
||||
{
|
||||
switch (aEvent) {
|
||||
case MediaEventType::PlaybackStarted:
|
||||
mPlaybackStatistics->Start();
|
||||
break;
|
||||
case MediaEventType::PlaybackStopped:
|
||||
mPlaybackStatistics->Stop();
|
||||
ComputePlaybackRate();
|
||||
break;
|
||||
case MediaEventType::PlaybackEnded:
|
||||
PlaybackEnded();
|
||||
break;
|
||||
case MediaEventType::DecodeError:
|
||||
DecodeError();
|
||||
break;
|
||||
case MediaEventType::Invalidate:
|
||||
Invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MediaResourceCallback*
|
||||
MediaDecoder::GetResourceCallback() const
|
||||
{
|
||||
|
@ -705,16 +724,8 @@ MediaDecoder::SetStateMachineParameters()
|
|||
mFirstFrameLoadedListener = mDecoderStateMachine->FirstFrameLoadedEvent().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::FirstFrameLoaded);
|
||||
|
||||
mOnPlaybackStart = mDecoderStateMachine->OnPlaybackStart().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackStarted);
|
||||
mOnPlaybackStop = mDecoderStateMachine->OnPlaybackStop().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackStopped);
|
||||
mOnPlaybackEnded = mDecoderStateMachine->OnPlaybackEnded().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::PlaybackEnded);
|
||||
mOnDecodeError = mDecoderStateMachine->OnDecodeError().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::DecodeError);
|
||||
mOnInvalidate = mDecoderStateMachine->OnInvalidate().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::Invalidate);
|
||||
mOnPlaybackEvent = mDecoderStateMachine->OnPlaybackEvent().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackEvent);
|
||||
mOnSeekingStart = mDecoderStateMachine->OnSeekingStart().Connect(
|
||||
AbstractThread::MainThread(), this, &MediaDecoder::SeekingStarted);
|
||||
}
|
||||
|
|
|
@ -222,6 +222,8 @@ namespace mozilla {
|
|||
class VideoFrameContainer;
|
||||
class MediaDecoderStateMachine;
|
||||
|
||||
enum class MediaEventType : int8_t;
|
||||
|
||||
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
|
||||
// GetTickCount() and conflicts with MediaDecoder::GetCurrentTime implementation.
|
||||
#ifdef GetCurrentTime
|
||||
|
@ -800,17 +802,7 @@ private:
|
|||
MediaEventSource<void>*
|
||||
DataArrivedEvent() override { return &mDataArrivedEvent; }
|
||||
|
||||
// Used to estimate rates of data passing through the decoder's channel.
|
||||
// Records activity stopping on the channel.
|
||||
void OnPlaybackStarted() { mPlaybackStatistics->Start(); }
|
||||
|
||||
// Used to estimate rates of data passing through the decoder's channel.
|
||||
// Records activity stopping on the channel.
|
||||
void OnPlaybackStopped()
|
||||
{
|
||||
mPlaybackStatistics->Stop();
|
||||
ComputePlaybackRate();
|
||||
}
|
||||
void OnPlaybackEvent(MediaEventType aEvent);
|
||||
|
||||
MediaEventProducer<void> mDataArrivedEvent;
|
||||
|
||||
|
@ -933,11 +925,7 @@ protected:
|
|||
MediaEventListener mMetadataLoadedListener;
|
||||
MediaEventListener mFirstFrameLoadedListener;
|
||||
|
||||
MediaEventListener mOnPlaybackStart;
|
||||
MediaEventListener mOnPlaybackStop;
|
||||
MediaEventListener mOnPlaybackEnded;
|
||||
MediaEventListener mOnDecodeError;
|
||||
MediaEventListener mOnInvalidate;
|
||||
MediaEventListener mOnPlaybackEvent;
|
||||
MediaEventListener mOnSeekingStart;
|
||||
|
||||
protected:
|
||||
|
@ -1094,7 +1082,7 @@ private:
|
|||
// download has ended. Called on the main thread only. aStatus is
|
||||
// the result from OnStopRequest.
|
||||
void NotifyDownloadEnded(nsresult aStatus);
|
||||
|
||||
|
||||
bool mTelemetryReported;
|
||||
};
|
||||
|
||||
|
|
|
@ -1054,7 +1054,7 @@ void MediaDecoderStateMachine::StopPlayback()
|
|||
MOZ_ASSERT(OnTaskQueue());
|
||||
DECODER_LOG("StopPlayback()");
|
||||
|
||||
mOnPlaybackStop.Notify();
|
||||
mOnPlaybackEvent.Notify(MediaEventType::PlaybackStopped);
|
||||
|
||||
if (IsPlaying()) {
|
||||
mMediaSink->SetPlaying(false);
|
||||
|
@ -1087,7 +1087,7 @@ void MediaDecoderStateMachine::MaybeStartPlayback()
|
|||
}
|
||||
|
||||
DECODER_LOG("MaybeStartPlayback() starting playback");
|
||||
mOnPlaybackStart.Notify();
|
||||
mOnPlaybackEvent.Notify(MediaEventType::PlaybackStarted);
|
||||
StartMediaSink();
|
||||
|
||||
if (!IsPlaying()) {
|
||||
|
@ -1892,7 +1892,7 @@ MediaDecoderStateMachine::DecodeError()
|
|||
|
||||
// MediaDecoder::DecodeError notifies the owner, and then shuts down the state
|
||||
// machine.
|
||||
mOnDecodeError.Notify();
|
||||
mOnPlaybackEvent.Notify(MediaEventType::DecodeError);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2151,7 +2151,7 @@ MediaDecoderStateMachine::SeekCompleted()
|
|||
|
||||
if (video) {
|
||||
mMediaSink->Redraw();
|
||||
mOnInvalidate.Notify();
|
||||
mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2404,7 +2404,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|||
// Ensure readyState is updated before firing the 'ended' event.
|
||||
UpdateNextFrameStatus();
|
||||
|
||||
mOnPlaybackEnded.Notify();
|
||||
mOnPlaybackEvent.Notify(MediaEventType::PlaybackEnded);
|
||||
|
||||
mSentPlaybackEndedEvent = true;
|
||||
|
||||
|
|
|
@ -110,6 +110,14 @@ class TaskQueue;
|
|||
extern LazyLogModule gMediaDecoderLog;
|
||||
extern LazyLogModule gMediaSampleLog;
|
||||
|
||||
enum class MediaEventType : int8_t {
|
||||
PlaybackStarted,
|
||||
PlaybackStopped,
|
||||
PlaybackEnded,
|
||||
DecodeError,
|
||||
Invalidate
|
||||
};
|
||||
|
||||
/*
|
||||
The state machine class. This manages the decoding and seeking in the
|
||||
MediaDecoderReader on the decode task queue, and A/V sync on the shared
|
||||
|
@ -233,11 +241,8 @@ public:
|
|||
MediaDecoderEventVisibility>&
|
||||
FirstFrameLoadedEvent() { return mFirstFrameLoadedEvent; }
|
||||
|
||||
MediaEventSource<void>& OnPlaybackStart() { return mOnPlaybackStart; }
|
||||
MediaEventSource<void>& OnPlaybackStop() { return mOnPlaybackStop; }
|
||||
MediaEventSource<void>& OnPlaybackEnded() { return mOnPlaybackEnded; }
|
||||
MediaEventSource<void>& OnDecodeError() { return mOnDecodeError; }
|
||||
MediaEventSource<void>& OnInvalidate() { return mOnInvalidate; }
|
||||
MediaEventSource<MediaEventType>&
|
||||
OnPlaybackEvent() { return mOnPlaybackEvent; }
|
||||
|
||||
MediaEventSource<MediaDecoderEventVisibility>&
|
||||
OnSeekingStart() { return mOnSeekingStart; }
|
||||
|
@ -1210,11 +1215,7 @@ private:
|
|||
MediaEventProducerExc<nsAutoPtr<MediaInfo>,
|
||||
MediaDecoderEventVisibility> mFirstFrameLoadedEvent;
|
||||
|
||||
MediaEventProducer<void> mOnPlaybackStart;
|
||||
MediaEventProducer<void> mOnPlaybackStop;
|
||||
MediaEventProducer<void> mOnPlaybackEnded;
|
||||
MediaEventProducer<void> mOnDecodeError;
|
||||
MediaEventProducer<void> mOnInvalidate;
|
||||
MediaEventProducer<MediaEventType> mOnPlaybackEvent;
|
||||
MediaEventProducer<MediaDecoderEventVisibility> mOnSeekingStart;
|
||||
|
||||
// True if audio is offloading.
|
||||
|
|
Загрузка…
Ссылка в новой задаче