зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1199155. Part 3 - rename mDecodedStream to mStreamSink. r=roc.
This commit is contained in:
Родитель
b853505d1f
Коммит
246dd8805c
|
@ -221,7 +221,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||||
mSentLoadedMetadataEvent(false),
|
mSentLoadedMetadataEvent(false),
|
||||||
mSentFirstFrameLoadedEvent(false),
|
mSentFirstFrameLoadedEvent(false),
|
||||||
mSentPlaybackEndedEvent(false),
|
mSentPlaybackEndedEvent(false),
|
||||||
mDecodedStream(new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue)),
|
mStreamSink(new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue)),
|
||||||
mResource(aDecoder->GetResource()),
|
mResource(aDecoder->GetResource()),
|
||||||
mBuffered(mTaskQueue, TimeIntervals(),
|
mBuffered(mTaskQueue, TimeIntervals(),
|
||||||
"MediaDecoderStateMachine::mBuffered (Mirror)"),
|
"MediaDecoderStateMachine::mBuffered (Mirror)"),
|
||||||
|
@ -1153,7 +1153,7 @@ void MediaDecoderStateMachine::VolumeChanged()
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
mAudioSink->SetVolume(mVolume);
|
mAudioSink->SetVolume(mVolume);
|
||||||
mDecodedStream->SetVolume(mVolume);
|
mStreamSink->SetVolume(mVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaDecoderStateMachine::RecomputeDuration()
|
void MediaDecoderStateMachine::RecomputeDuration()
|
||||||
|
@ -1407,7 +1407,7 @@ void MediaDecoderStateMachine::SameOriginMediaChanged()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
mDecodedStream->SetSameOrigin(mSameOriginMedia);
|
mStreamSink->SetSameOrigin(mSameOriginMedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaDecoderStateMachine::BufferedRangeUpdated()
|
void MediaDecoderStateMachine::BufferedRangeUpdated()
|
||||||
|
@ -1780,8 +1780,11 @@ MediaDecoderStateMachine::StopDecodedStream()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
AssertCurrentThreadInMonitor();
|
AssertCurrentThreadInMonitor();
|
||||||
mDecodedStream->StopPlayback();
|
|
||||||
|
if (mStreamSink->IsStarted()) {
|
||||||
|
mStreamSink->Stop();
|
||||||
mDecodedStreamPromise.DisconnectIfExists();
|
mDecodedStreamPromise.DisconnectIfExists();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1792,9 +1795,10 @@ MediaDecoderStateMachine::StartDecodedStream()
|
||||||
|
|
||||||
// Tell DecodedStream to start playback with specified start time and media
|
// Tell DecodedStream to start playback with specified start time and media
|
||||||
// info. This is consistent with how we create AudioSink in StartAudioThread().
|
// info. This is consistent with how we create AudioSink in StartAudioThread().
|
||||||
if (mAudioCaptured && !mDecodedStreamPromise.Exists()) {
|
if (mAudioCaptured && !mStreamSink->IsStarted()) {
|
||||||
|
mStreamSink->Start(GetMediaTime(), mInfo);
|
||||||
mDecodedStreamPromise.Begin(
|
mDecodedStreamPromise.Begin(
|
||||||
mDecodedStream->StartPlayback(GetMediaTime(), mInfo)->Then(
|
mStreamSink->OnEnded(TrackInfo::kAudioTrack)->Then(
|
||||||
OwnerThread(), __func__, this,
|
OwnerThread(), __func__, this,
|
||||||
&MediaDecoderStateMachine::OnDecodedStreamFinish,
|
&MediaDecoderStateMachine::OnDecodedStreamFinish,
|
||||||
&MediaDecoderStateMachine::OnDecodedStreamError));
|
&MediaDecoderStateMachine::OnDecodedStreamError));
|
||||||
|
@ -2186,6 +2190,15 @@ private:
|
||||||
nsRefPtr<MediaDecoderStateMachine> mStateMachine;
|
nsRefPtr<MediaDecoderStateMachine> mStateMachine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaDecoderStateMachine::DispatchShutdown()
|
||||||
|
{
|
||||||
|
mStreamSink->BeginShutdown();
|
||||||
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
|
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::Shutdown);
|
||||||
|
OwnerThread()->Dispatch(runnable.forget());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaDecoderStateMachine::FinishShutdown()
|
MediaDecoderStateMachine::FinishShutdown()
|
||||||
{
|
{
|
||||||
|
@ -2366,7 +2379,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
||||||
// end of the media, and so that we update the readyState.
|
// end of the media, and so that we update the readyState.
|
||||||
if (VideoQueue().GetSize() > 1 ||
|
if (VideoQueue().GetSize() > 1 ||
|
||||||
(HasAudio() && !mAudioCompleted) ||
|
(HasAudio() && !mAudioCompleted) ||
|
||||||
(mAudioCaptured && !mDecodedStream->IsFinished()))
|
(mAudioCaptured && !mStreamSink->IsFinished()))
|
||||||
{
|
{
|
||||||
// Start playback if necessary to play the remaining media.
|
// Start playback if necessary to play the remaining media.
|
||||||
MaybeStartPlayback();
|
MaybeStartPlayback();
|
||||||
|
@ -2558,13 +2571,6 @@ void MediaDecoderStateMachine::RenderVideoFrames(int32_t aMaxFrames,
|
||||||
container->SetCurrentFrames(frames[0]->As<VideoData>()->mDisplay, images);
|
container->SetCurrentFrames(frames[0]->As<VideoData>()->mDisplay, images);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t MediaDecoderStateMachine::GetStreamClock() const
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
|
||||||
AssertCurrentThreadInMonitor();
|
|
||||||
return mDecodedStream->GetPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t MediaDecoderStateMachine::GetClock(TimeStamp* aTimeStamp) const
|
int64_t MediaDecoderStateMachine::GetClock(TimeStamp* aTimeStamp) const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
|
@ -2580,7 +2586,7 @@ int64_t MediaDecoderStateMachine::GetClock(TimeStamp* aTimeStamp) const
|
||||||
clock_time = mPlayDuration;
|
clock_time = mPlayDuration;
|
||||||
} else {
|
} else {
|
||||||
if (mAudioCaptured) {
|
if (mAudioCaptured) {
|
||||||
clock_time = GetStreamClock();
|
clock_time = mStreamSink->GetPosition(&t);
|
||||||
} else {
|
} else {
|
||||||
clock_time = mAudioSink->GetPosition(&t);
|
clock_time = mAudioSink->GetPosition(&t);
|
||||||
}
|
}
|
||||||
|
@ -2875,10 +2881,7 @@ void MediaDecoderStateMachine::SetPlayStartTime(const TimeStamp& aTimeStamp)
|
||||||
mPlayStartTime = aTimeStamp;
|
mPlayStartTime = aTimeStamp;
|
||||||
|
|
||||||
mAudioSink->SetPlaying(!mPlayStartTime.IsNull());
|
mAudioSink->SetPlaying(!mPlayStartTime.IsNull());
|
||||||
// Have DecodedStream remember the playing state so it doesn't need to
|
mStreamSink->SetPlaying(!mPlayStartTime.IsNull());
|
||||||
// ask MDSM about IsPlaying(). Note we have to do this even before capture
|
|
||||||
// happens since capture could happen in the middle of playback.
|
|
||||||
mDecodedStream->SetPlaying(!mPlayStartTime.IsNull());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder()
|
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder()
|
||||||
|
@ -2982,7 +2985,7 @@ MediaDecoderStateMachine::AudioEndTime() const
|
||||||
if (mAudioSink->IsStarted()) {
|
if (mAudioSink->IsStarted()) {
|
||||||
return mAudioSink->GetEndTime(TrackInfo::kAudioTrack);
|
return mAudioSink->GetEndTime(TrackInfo::kAudioTrack);
|
||||||
} else if (mAudioCaptured) {
|
} else if (mAudioCaptured) {
|
||||||
return mDecodedStream->AudioEndTime();
|
return mStreamSink->GetEndTime(TrackInfo::kAudioTrack);
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(!HasAudio());
|
MOZ_ASSERT(!HasAudio());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3099,7 +3102,7 @@ void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
DECODER_LOG("AddOutputStream aStream=%p!", aStream);
|
DECODER_LOG("AddOutputStream aStream=%p!", aStream);
|
||||||
mDecodedStream->AddOutput(aStream, aFinishWhenEnded);
|
mStreamSink->AddOutput(aStream, aFinishWhenEnded);
|
||||||
DispatchAudioCaptured();
|
DispatchAudioCaptured();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3107,8 +3110,8 @@ void MediaDecoderStateMachine::RemoveOutputStream(MediaStream* aStream)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
DECODER_LOG("RemoveOutputStream=%p!", aStream);
|
DECODER_LOG("RemoveOutputStream=%p!", aStream);
|
||||||
mDecodedStream->RemoveOutput(aStream);
|
mStreamSink->RemoveOutput(aStream);
|
||||||
if (!mDecodedStream->HasConsumers()) {
|
if (!mStreamSink->HasConsumers()) {
|
||||||
DispatchAudioUncaptured();
|
DispatchAudioUncaptured();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,13 +173,7 @@ private:
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void DispatchShutdown()
|
void DispatchShutdown();
|
||||||
{
|
|
||||||
mDecodedStream->Shutdown();
|
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
|
||||||
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::Shutdown);
|
|
||||||
OwnerThread()->Dispatch(runnable.forget());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishShutdown();
|
void FinishShutdown();
|
||||||
|
|
||||||
|
@ -457,8 +451,6 @@ protected:
|
||||||
// parties.
|
// parties.
|
||||||
void UpdateNextFrameStatus();
|
void UpdateNextFrameStatus();
|
||||||
|
|
||||||
int64_t GetStreamClock() const;
|
|
||||||
|
|
||||||
// Return the current time, either the audio clock if available (if the media
|
// Return the current time, either the audio clock if available (if the media
|
||||||
// has audio, and the playback is possible), or a clock for the video.
|
// has audio, and the playback is possible), or a clock for the video.
|
||||||
// Called on the state machine thread.
|
// Called on the state machine thread.
|
||||||
|
@ -1273,7 +1265,7 @@ private:
|
||||||
// Only written on the main thread while holding the monitor. Therefore it
|
// Only written on the main thread while holding the monitor. Therefore it
|
||||||
// can be read on any thread while holding the monitor, or on the main thread
|
// can be read on any thread while holding the monitor, or on the main thread
|
||||||
// without holding the monitor.
|
// without holding the monitor.
|
||||||
nsRefPtr<DecodedStream> mDecodedStream;
|
nsRefPtr<DecodedStream> mStreamSink;
|
||||||
|
|
||||||
// Media data resource from the decoder.
|
// Media data resource from the decoder.
|
||||||
nsRefPtr<MediaResource> mResource;
|
nsRefPtr<MediaResource> mResource;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче