зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1206578 - Group public and private functions respectively for MDSM. r=gsquelart.
This commit is contained in:
Родитель
9f60378309
Коммит
aeb8ca2f81
|
@ -155,13 +155,98 @@ public:
|
|||
// Remove an output stream added with AddOutputStream.
|
||||
void RemoveOutputStream(MediaStream* aStream);
|
||||
|
||||
// Seeks to the decoder to aTarget asynchronously.
|
||||
nsRefPtr<MediaDecoder::SeekPromise> InvokeSeek(SeekTarget aTarget);
|
||||
|
||||
// Set/Unset dormant state.
|
||||
void DispatchSetDormant(bool aDormant);
|
||||
|
||||
void DispatchShutdown();
|
||||
|
||||
void DispatchStartBuffering()
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering);
|
||||
OwnerThread()->Dispatch(runnable.forget());
|
||||
}
|
||||
|
||||
void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset, bool aThrottleUpdates)
|
||||
{
|
||||
mReader->DispatchNotifyDataArrived(aLength, aOffset, aThrottleUpdates);
|
||||
}
|
||||
|
||||
// Called when the reader may have acquired the hardware resources required
|
||||
// to begin decoding.
|
||||
void DispatchWaitingForResourcesStatusChanged();
|
||||
|
||||
// Notifies the state machine that should minimize the number of samples
|
||||
// decoded we preroll, until playback starts. The first time playback starts
|
||||
// the state machine is free to return to prerolling normally. Note
|
||||
// "prerolling" in this context refers to when we decode and buffer decoded
|
||||
// samples in advance of when they're needed for playback.
|
||||
void DispatchMinimizePrerollUntilPlaybackStarts()
|
||||
{
|
||||
nsRefPtr<MediaDecoderStateMachine> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self] () -> void
|
||||
{
|
||||
MOZ_ASSERT(self->OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
|
||||
self->mMinimizePreroll = true;
|
||||
|
||||
// Make sure that this arrives before playback starts, otherwise this won't
|
||||
// have the intended effect.
|
||||
MOZ_DIAGNOSTIC_ASSERT(self->mPlayState == MediaDecoder::PLAY_STATE_LOADING);
|
||||
});
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
// Set the media fragment end time. aEndTime is in microseconds.
|
||||
void DispatchSetFragmentEndTime(int64_t aEndTime)
|
||||
{
|
||||
nsRefPtr<MediaDecoderStateMachine> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self, aEndTime] () {
|
||||
self->mFragmentEndTime = aEndTime;
|
||||
});
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
// Drop reference to decoder. Only called during shutdown dance.
|
||||
void BreakCycles() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mReader) {
|
||||
mReader->BreakCycles();
|
||||
}
|
||||
mResource = nullptr;
|
||||
mDecoder = nullptr;
|
||||
}
|
||||
|
||||
TimedMetadataEventSource& TimedMetadataEvent() {
|
||||
return mMetadataManager.TimedMetadataEvent();
|
||||
}
|
||||
|
||||
// Immutable after construction - may be called on any thread.
|
||||
bool IsRealTime() const { return mRealTime; }
|
||||
|
||||
// Functions used by assertions to ensure we're calling things
|
||||
// on the appropriate threads.
|
||||
bool OnDecodeTaskQueue() const;
|
||||
|
||||
bool OnTaskQueue() const;
|
||||
|
||||
size_t SizeOfVideoQueue() {
|
||||
if (mReader) {
|
||||
return mReader->SizeOfVideoQueueInBytes();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t SizeOfAudioQueue() {
|
||||
if (mReader) {
|
||||
return mReader->SizeOfAudioQueueInBytes();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// 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
|
||||
|
@ -178,22 +263,8 @@ private:
|
|||
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
void DispatchShutdown();
|
||||
|
||||
void FinishShutdown();
|
||||
|
||||
// Immutable after construction - may be called on any thread.
|
||||
bool IsRealTime() const { return mRealTime; }
|
||||
|
||||
// Functions used by assertions to ensure we're calling things
|
||||
// on the appropriate threads.
|
||||
bool OnDecodeTaskQueue() const;
|
||||
bool OnTaskQueue() const;
|
||||
|
||||
// Seeks to the decoder to aTarget asynchronously.
|
||||
nsRefPtr<MediaDecoder::SeekPromise> InvokeSeek(SeekTarget aTarget);
|
||||
|
||||
// Clear the flag indicating that a playback position change event
|
||||
// is currently queued. This is called from the main thread and must
|
||||
// be called with the decode monitor held.
|
||||
|
@ -206,7 +277,6 @@ public:
|
|||
// the decode monitor held.
|
||||
void UpdatePlaybackPosition(int64_t aTime);
|
||||
|
||||
private:
|
||||
// Causes the state machine to switch to buffering state, and to
|
||||
// immediately stop playback and buffer downloaded data. Called on
|
||||
// the state machine thread.
|
||||
|
@ -216,14 +286,6 @@ private:
|
|||
|
||||
MediaStatistics GetStatistics();
|
||||
|
||||
public:
|
||||
void DispatchStartBuffering()
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering);
|
||||
OwnerThread()->Dispatch(runnable.forget());
|
||||
}
|
||||
|
||||
// This is called on the state machine thread and audio thread.
|
||||
// The decoder monitor must be obtained before calling this.
|
||||
bool HasAudio() const {
|
||||
|
@ -257,25 +319,6 @@ public:
|
|||
return mState == DECODER_STATE_SEEKING;
|
||||
}
|
||||
|
||||
size_t SizeOfVideoQueue() {
|
||||
if (mReader) {
|
||||
return mReader->SizeOfVideoQueueInBytes();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t SizeOfAudioQueue() {
|
||||
if (mReader) {
|
||||
return mReader->SizeOfAudioQueueInBytes();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset, bool aThrottleUpdates)
|
||||
{
|
||||
mReader->DispatchNotifyDataArrived(aLength, aOffset, aThrottleUpdates);
|
||||
}
|
||||
|
||||
// Returns the state machine task queue.
|
||||
TaskQueue* OwnerThread() const { return mTaskQueue; }
|
||||
|
||||
|
@ -311,26 +354,6 @@ public:
|
|||
|
||||
void NotReached() { MOZ_DIAGNOSTIC_ASSERT(false); }
|
||||
|
||||
// Set the media fragment end time. aEndTime is in microseconds.
|
||||
void DispatchSetFragmentEndTime(int64_t aEndTime)
|
||||
{
|
||||
nsRefPtr<MediaDecoderStateMachine> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self, aEndTime] () {
|
||||
self->mFragmentEndTime = aEndTime;
|
||||
});
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
// Drop reference to decoder. Only called during shutdown dance.
|
||||
void BreakCycles() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mReader) {
|
||||
mReader->BreakCycles();
|
||||
}
|
||||
mResource = nullptr;
|
||||
mDecoder = nullptr;
|
||||
}
|
||||
|
||||
// Discard audio/video data that are already played by MSG.
|
||||
void DiscardStreamData();
|
||||
bool HaveEnoughDecodedAudio(int64_t aAmpleAudioUSecs);
|
||||
|
@ -344,31 +367,6 @@ public:
|
|||
// be held.
|
||||
bool IsPlaying() const;
|
||||
|
||||
// Called when the reader may have acquired the hardware resources required
|
||||
// to begin decoding.
|
||||
void DispatchWaitingForResourcesStatusChanged();
|
||||
|
||||
// Notifies the state machine that should minimize the number of samples
|
||||
// decoded we preroll, until playback starts. The first time playback starts
|
||||
// the state machine is free to return to prerolling normally. Note
|
||||
// "prerolling" in this context refers to when we decode and buffer decoded
|
||||
// samples in advance of when they're needed for playback.
|
||||
void DispatchMinimizePrerollUntilPlaybackStarts()
|
||||
{
|
||||
nsRefPtr<MediaDecoderStateMachine> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([self] () -> void
|
||||
{
|
||||
MOZ_ASSERT(self->OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
|
||||
self->mMinimizePreroll = true;
|
||||
|
||||
// Make sure that this arrives before playback starts, otherwise this won't
|
||||
// have the intended effect.
|
||||
MOZ_DIAGNOSTIC_ASSERT(self->mPlayState == MediaDecoder::PLAY_STATE_LOADING);
|
||||
});
|
||||
OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
void OnAudioDecoded(MediaData* aAudioSample);
|
||||
void OnVideoDecoded(MediaData* aVideoSample);
|
||||
void OnNotDecoded(MediaData::Type aType, MediaDecoderReader::NotDecodedReason aReason);
|
||||
|
|
Загрузка…
Ссылка в новой задаче