Loading dom/media/MediaData.h +1 −1 Original line number Diff line number Diff line Loading @@ -494,7 +494,7 @@ class VideoData : public MediaData { // This frame's image. RefPtr<Image> mImage; uint32_t mFrameID; int32_t mFrameID; VideoData(int64_t aOffset, const media::TimeUnit& aTime, const media::TimeUnit& aDuration, bool aKeyframe, Loading dom/media/MediaDecoderStateMachine.cpp +34 −50 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ static constexpr auto AMPLE_AUDIO_THRESHOLD = static const uint32_t LOW_VIDEO_FRAMES = 2; // Arbitrary "frame duration" when playing only audio. static const uint32_t AUDIO_DURATION_USECS = 40000; static const int AUDIO_DURATION_USECS = 40000; namespace detail { Loading Loading @@ -210,8 +210,7 @@ class MediaDecoderStateMachine::StateObject { virtual void HandleVideoCanceled() { Crash("Unexpected event!", __func__); } virtual void HandleEndOfVideo() { Crash("Unexpected event!", __func__); } virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget); virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget); virtual RefPtr<ShutdownPromise> HandleShutdown(); Loading Loading @@ -270,7 +269,7 @@ class MediaDecoderStateMachine::StateObject { auto copiedArgs = MakeTuple(std::forward<Ts>(aArgs)...); // Copy mMaster which will reset to null. auto* master = mMaster; auto master = mMaster; auto* s = new S(master); Loading Loading @@ -343,8 +342,7 @@ class MediaDecoderStateMachine::DecodeMetadataState State GetState() const override { return DECODER_STATE_DECODING_METADATA; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading Loading @@ -424,8 +422,7 @@ class MediaDecoderStateMachine::DormantState State GetState() const override { return DECODER_STATE_DORMANT; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override; RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override; void HandleVideoSuspendTimeout() override { // Do nothing since we've released decoders in Enter(). Loading Loading @@ -535,8 +532,7 @@ class MediaDecoderStateMachine::DecodingFirstFrameState MOZ_ASSERT(false, "Shouldn't have suspended video decoding."); } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { if (mMaster->mIsMSE) { return StateObject::HandleSeek(aTarget); } Loading Loading @@ -705,9 +701,8 @@ class MediaDecoderStateMachine::DecodingState } uint32_t VideoPrerollFrames() const { return std::min( static_cast<uint32_t>( mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1), return std::min<uint32_t>( (mMaster->GetAmpleVideoFrames() / 2) * mMaster->mPlaybackRate + 1, sVideoQueueDefaultSize); } Loading Loading @@ -741,9 +736,7 @@ class MediaDecoderStateMachine::DecodingState if (timeout < 0) { // Disabled when timeout is negative. return; } if (timeout == 0) { } else if (timeout == 0) { // Enter dormant immediately without scheduling a timer. SetState<DormantState>(); return; Loading Loading @@ -908,7 +901,7 @@ class MediaDecoderStateMachine::LoopingDecodingState ->RequestAudioData() ->Then( OwnerThread(), __func__, [this](const RefPtr<AudioData>& aAudio) { [this](RefPtr<AudioData> aAudio) { AUTO_PROFILER_LABEL( "LoopingDecodingState::" "RequestAudioDataFromStartPosition:" Loading Loading @@ -1097,14 +1090,13 @@ class MediaDecoderStateMachine::SeekingState // We specially handle next frame seeks by ignoring them if we're already // seeking. RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { if (aTarget.IsNextFrame()) { // We ignore next frame seeks if we already have a seek pending SLOG("Already SEEKING, ignoring seekToNextFrame"); MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished"); return MediaDecoder::SeekPromise::CreateAndReject( /* aRejectValue = */ true, __func__); return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } return StateObject::HandleSeek(aTarget); Loading Loading @@ -1899,7 +1891,7 @@ constexpr TimeUnit MediaDecoderStateMachine::VideoOnlySeekingState:: sSkipToNextKeyFrameThreshold; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::DormantState::HandleSeek(const SeekTarget& aTarget) { MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget) { if (aTarget.IsNextFrame()) { // NextFrameSeekingState doesn't reset the decoder unlike // AccurateSeekingState. So we first must come out of dormant by seeking to Loading Loading @@ -2149,8 +2141,7 @@ class MediaDecoderStateMachine::ShutdownState State GetState() const override { return DECODER_STATE_SHUTDOWN; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading @@ -2170,7 +2161,7 @@ class MediaDecoderStateMachine::ShutdownState }; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::StateObject::HandleSeek(const SeekTarget& aTarget) { MediaDecoderStateMachine::StateObject::HandleSeek(SeekTarget aTarget) { SLOG("Changed state to SEEKING (to %" PRId64 ")", aTarget.GetTime().ToMicroseconds()); SeekJob seekJob; Loading Loading @@ -2216,9 +2207,9 @@ static void ReportRecoveryTelemetry(const TimeStamp& aRecoveryStart, TimeDuration duration = TimeStamp::Now() - aRecoveryStart; double duration_ms = duration.ToMilliseconds(); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, key, static_cast<uint32_t>(lround(duration_ms))); uint32_t(duration_ms + 0.5)); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, "All"_ns, static_cast<uint32_t>(lround(duration_ms))); uint32_t(duration_ms + 0.5)); } void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( Loading @@ -2233,7 +2224,7 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( TimeStamp start = TimeStamp::Now(); // Local reference to mInfo, so that it will be copied in the lambda below. const auto& info = Info(); auto& info = Info(); bool hw = Reader()->VideoIsHardwareAccelerated(); // Start video-only seek to the current time. Loading Loading @@ -2683,7 +2674,7 @@ void MediaDecoderStateMachine::BufferingState::HandleEndOfVideo() { RefPtr<ShutdownPromise> MediaDecoderStateMachine::ShutdownState::Enter() { PROFILER_MARKER_UNTYPED("MDSM::EnterShutdownState", MEDIA_PLAYBACK); auto* master = mMaster; auto master = mMaster; master->mDelayedScheduler.Reset(); Loading Loading @@ -2921,8 +2912,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio() const { bool MediaDecoderStateMachine::HaveEnoughDecodedVideo() const { MOZ_ASSERT(OnTaskQueue()); return VideoQueue().GetSize() >= static_cast<size_t>(GetAmpleVideoFrames() * mPlaybackRate + 1) && return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1 && IsVideoDataEnoughComparedWithAudio(); } Loading Loading @@ -3262,13 +3252,13 @@ RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::Seek( // We need to be able to seek in some way if (!mMediaSeekable && !mMediaSeekableOnlyInBufferedRanges) { LOGW("Seek() should not be called on a non-seekable media"); return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } if (aTarget.IsNextFrame() && !HasVideo()) { LOGW("Ignore a NextFrameSeekTask on a media file without video track."); return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } Loading Loading @@ -3310,7 +3300,7 @@ void MediaDecoderStateMachine::RequestAudioData() { ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( const RefPtr<AudioData>& aAudio) mutable { RefPtr<AudioData> aAudio) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestAudioData:Resolved", Loading Loading @@ -3372,7 +3362,7 @@ void MediaDecoderStateMachine::RequestVideoData( ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( const RefPtr<VideoData>& aVideo) mutable { RefPtr<VideoData> aVideo) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestVideoData:Resolved", Loading Loading @@ -3508,8 +3498,7 @@ bool MediaDecoderStateMachine::HasLowDecodedAudio() { bool MediaDecoderStateMachine::HasLowDecodedVideo() { MOZ_ASSERT(OnTaskQueue()); return IsVideoDecoding() && VideoQueue().GetSize() < static_cast<size_t>(ceill(LOW_VIDEO_FRAMES * mPlaybackRate)); VideoQueue().GetSize() < LOW_VIDEO_FRAMES * mPlaybackRate; } bool MediaDecoderStateMachine::HasLowDecodedData() { Loading Loading @@ -3634,7 +3623,7 @@ void MediaDecoderStateMachine::RunStateMachine() { mStateObj->Step(); } void MediaDecoderStateMachine::ResetDecode(const TrackSet& aTracks) { void MediaDecoderStateMachine::ResetDecode(TrackSet aTracks) { MOZ_ASSERT(OnTaskQueue()); LOG("MediaDecoderStateMachine::Reset"); Loading Loading @@ -3708,8 +3697,7 @@ void MediaDecoderStateMachine::UpdatePlaybackPositionPeriodically() { // the monitor and get a staled value from GetCurrentTimeUs() which hits the // assertion in GetClock(). int64_t delay = std::max<int64_t>( 1, static_cast<int64_t>(AUDIO_DURATION_USECS / mPlaybackRate)); int64_t delay = std::max<int64_t>(1, AUDIO_DURATION_USECS / mPlaybackRate); ScheduleStateMachineIn(TimeUnit::FromMicroseconds(delay)); // Notify the listener as we progress in the playback offset. Note it would Loading Loading @@ -3856,7 +3844,7 @@ void MediaDecoderStateMachine::OutputPrincipalChanged() { } RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( const RefPtr<AudioDeviceInfo>& aSink) { RefPtr<AudioDeviceInfo> aSink) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aSink); Loading @@ -3865,7 +3853,7 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( } RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( const RefPtr<AudioDeviceInfo>& aDevice) { RefPtr<AudioDeviceInfo> aSinkDevice) { MOZ_ASSERT(OnTaskQueue()); if (mIsMediaSinkSuspended) { // Don't change sink id in a suspended sink. Loading @@ -3877,12 +3865,12 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( return GenericPromise::CreateAndReject(NS_ERROR_ABORT, __func__); } if (mSinkDevice.Ref() != aDevice) { if (mSinkDevice.Ref() != aSinkDevice) { // A new sink was set before this ran. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } if (mMediaSink->AudioDevice() == aDevice) { if (mMediaSink->AudioDevice() == aSinkDevice) { // The sink has not changed. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } Loading Loading @@ -4143,9 +4131,7 @@ const char* MediaDecoderStateMachine::AudioRequestStatus() const { if (IsRequestingAudioData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingAudioData()); return "pending"; } if (IsWaitingAudioData()) { } else if (IsWaitingAudioData()) { return "waiting"; } return "idle"; Loading @@ -4156,9 +4142,7 @@ const char* MediaDecoderStateMachine::VideoRequestStatus() const { if (IsRequestingVideoData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingVideoData()); return "pending"; } if (IsWaitingVideoData()) { } else if (IsWaitingVideoData()) { return "waiting"; } return "idle"; Loading dom/media/MediaDecoderStateMachine.h +4 −4 Original line number Diff line number Diff line Loading @@ -275,7 +275,7 @@ class MediaDecoderStateMachine // Sets the video decode mode. Used by the suspend-video-decoder feature. void SetVideoDecodeMode(VideoDecodeMode aMode); RefPtr<GenericPromise> InvokeSetSink(const RefPtr<AudioDeviceInfo>& aSink); RefPtr<GenericPromise> InvokeSetSink(RefPtr<AudioDeviceInfo> aSink); void InvokeSuspendMediaSink(); void InvokeResumeMediaSink(); Loading Loading @@ -351,7 +351,7 @@ class MediaDecoderStateMachine // Resets all states related to decoding and aborts all pending requests // to the decoders. void ResetDecode(const TrackSet& aTracks = TrackSet(TrackInfo::kAudioTrack, void ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, TrackInfo::kVideoTrack)); void SetVideoDecodeModeInternal(VideoDecodeMode aMode); Loading @@ -364,7 +364,7 @@ class MediaDecoderStateMachine // If there are multiple pending requests only the last one will be // executed, for all previous requests the promise will be resolved // with true or false similar to above. RefPtr<GenericPromise> SetSink(const RefPtr<AudioDeviceInfo>& aDevice); RefPtr<GenericPromise> SetSink(RefPtr<AudioDeviceInfo> aSink); // Shutdown MediaSink on suspend to clean up resources. void SuspendMediaSink(); Loading dom/webidl/MediaDebugInfo.webidl +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ dictionary AudioSinkDebugInfo { boolean isPlaying = false; boolean isStarted = false; boolean audioEnded = false; unsigned long outputRate = 0; long outputRate = 0; long long written = 0; boolean hasErrored = false; boolean playbackComplete = false; Loading Loading
dom/media/MediaData.h +1 −1 Original line number Diff line number Diff line Loading @@ -494,7 +494,7 @@ class VideoData : public MediaData { // This frame's image. RefPtr<Image> mImage; uint32_t mFrameID; int32_t mFrameID; VideoData(int64_t aOffset, const media::TimeUnit& aTime, const media::TimeUnit& aDuration, bool aKeyframe, Loading
dom/media/MediaDecoderStateMachine.cpp +34 −50 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ static constexpr auto AMPLE_AUDIO_THRESHOLD = static const uint32_t LOW_VIDEO_FRAMES = 2; // Arbitrary "frame duration" when playing only audio. static const uint32_t AUDIO_DURATION_USECS = 40000; static const int AUDIO_DURATION_USECS = 40000; namespace detail { Loading Loading @@ -210,8 +210,7 @@ class MediaDecoderStateMachine::StateObject { virtual void HandleVideoCanceled() { Crash("Unexpected event!", __func__); } virtual void HandleEndOfVideo() { Crash("Unexpected event!", __func__); } virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget); virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget); virtual RefPtr<ShutdownPromise> HandleShutdown(); Loading Loading @@ -270,7 +269,7 @@ class MediaDecoderStateMachine::StateObject { auto copiedArgs = MakeTuple(std::forward<Ts>(aArgs)...); // Copy mMaster which will reset to null. auto* master = mMaster; auto master = mMaster; auto* s = new S(master); Loading Loading @@ -343,8 +342,7 @@ class MediaDecoderStateMachine::DecodeMetadataState State GetState() const override { return DECODER_STATE_DECODING_METADATA; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading Loading @@ -424,8 +422,7 @@ class MediaDecoderStateMachine::DormantState State GetState() const override { return DECODER_STATE_DORMANT; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override; RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override; void HandleVideoSuspendTimeout() override { // Do nothing since we've released decoders in Enter(). Loading Loading @@ -535,8 +532,7 @@ class MediaDecoderStateMachine::DecodingFirstFrameState MOZ_ASSERT(false, "Shouldn't have suspended video decoding."); } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { if (mMaster->mIsMSE) { return StateObject::HandleSeek(aTarget); } Loading Loading @@ -705,9 +701,8 @@ class MediaDecoderStateMachine::DecodingState } uint32_t VideoPrerollFrames() const { return std::min( static_cast<uint32_t>( mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1), return std::min<uint32_t>( (mMaster->GetAmpleVideoFrames() / 2) * mMaster->mPlaybackRate + 1, sVideoQueueDefaultSize); } Loading Loading @@ -741,9 +736,7 @@ class MediaDecoderStateMachine::DecodingState if (timeout < 0) { // Disabled when timeout is negative. return; } if (timeout == 0) { } else if (timeout == 0) { // Enter dormant immediately without scheduling a timer. SetState<DormantState>(); return; Loading Loading @@ -908,7 +901,7 @@ class MediaDecoderStateMachine::LoopingDecodingState ->RequestAudioData() ->Then( OwnerThread(), __func__, [this](const RefPtr<AudioData>& aAudio) { [this](RefPtr<AudioData> aAudio) { AUTO_PROFILER_LABEL( "LoopingDecodingState::" "RequestAudioDataFromStartPosition:" Loading Loading @@ -1097,14 +1090,13 @@ class MediaDecoderStateMachine::SeekingState // We specially handle next frame seeks by ignoring them if we're already // seeking. RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { if (aTarget.IsNextFrame()) { // We ignore next frame seeks if we already have a seek pending SLOG("Already SEEKING, ignoring seekToNextFrame"); MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished"); return MediaDecoder::SeekPromise::CreateAndReject( /* aRejectValue = */ true, __func__); return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } return StateObject::HandleSeek(aTarget); Loading Loading @@ -1899,7 +1891,7 @@ constexpr TimeUnit MediaDecoderStateMachine::VideoOnlySeekingState:: sSkipToNextKeyFrameThreshold; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::DormantState::HandleSeek(const SeekTarget& aTarget) { MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget) { if (aTarget.IsNextFrame()) { // NextFrameSeekingState doesn't reset the decoder unlike // AccurateSeekingState. So we first must come out of dormant by seeking to Loading Loading @@ -2149,8 +2141,7 @@ class MediaDecoderStateMachine::ShutdownState State GetState() const override { return DECODER_STATE_SHUTDOWN; } RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading @@ -2170,7 +2161,7 @@ class MediaDecoderStateMachine::ShutdownState }; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::StateObject::HandleSeek(const SeekTarget& aTarget) { MediaDecoderStateMachine::StateObject::HandleSeek(SeekTarget aTarget) { SLOG("Changed state to SEEKING (to %" PRId64 ")", aTarget.GetTime().ToMicroseconds()); SeekJob seekJob; Loading Loading @@ -2216,9 +2207,9 @@ static void ReportRecoveryTelemetry(const TimeStamp& aRecoveryStart, TimeDuration duration = TimeStamp::Now() - aRecoveryStart; double duration_ms = duration.ToMilliseconds(); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, key, static_cast<uint32_t>(lround(duration_ms))); uint32_t(duration_ms + 0.5)); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, "All"_ns, static_cast<uint32_t>(lround(duration_ms))); uint32_t(duration_ms + 0.5)); } void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( Loading @@ -2233,7 +2224,7 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( TimeStamp start = TimeStamp::Now(); // Local reference to mInfo, so that it will be copied in the lambda below. const auto& info = Info(); auto& info = Info(); bool hw = Reader()->VideoIsHardwareAccelerated(); // Start video-only seek to the current time. Loading Loading @@ -2683,7 +2674,7 @@ void MediaDecoderStateMachine::BufferingState::HandleEndOfVideo() { RefPtr<ShutdownPromise> MediaDecoderStateMachine::ShutdownState::Enter() { PROFILER_MARKER_UNTYPED("MDSM::EnterShutdownState", MEDIA_PLAYBACK); auto* master = mMaster; auto master = mMaster; master->mDelayedScheduler.Reset(); Loading Loading @@ -2921,8 +2912,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio() const { bool MediaDecoderStateMachine::HaveEnoughDecodedVideo() const { MOZ_ASSERT(OnTaskQueue()); return VideoQueue().GetSize() >= static_cast<size_t>(GetAmpleVideoFrames() * mPlaybackRate + 1) && return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1 && IsVideoDataEnoughComparedWithAudio(); } Loading Loading @@ -3262,13 +3252,13 @@ RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::Seek( // We need to be able to seek in some way if (!mMediaSeekable && !mMediaSeekableOnlyInBufferedRanges) { LOGW("Seek() should not be called on a non-seekable media"); return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } if (aTarget.IsNextFrame() && !HasVideo()) { LOGW("Ignore a NextFrameSeekTask on a media file without video track."); return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__); } Loading Loading @@ -3310,7 +3300,7 @@ void MediaDecoderStateMachine::RequestAudioData() { ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( const RefPtr<AudioData>& aAudio) mutable { RefPtr<AudioData> aAudio) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestAudioData:Resolved", Loading Loading @@ -3372,7 +3362,7 @@ void MediaDecoderStateMachine::RequestVideoData( ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( const RefPtr<VideoData>& aVideo) mutable { RefPtr<VideoData> aVideo) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestVideoData:Resolved", Loading Loading @@ -3508,8 +3498,7 @@ bool MediaDecoderStateMachine::HasLowDecodedAudio() { bool MediaDecoderStateMachine::HasLowDecodedVideo() { MOZ_ASSERT(OnTaskQueue()); return IsVideoDecoding() && VideoQueue().GetSize() < static_cast<size_t>(ceill(LOW_VIDEO_FRAMES * mPlaybackRate)); VideoQueue().GetSize() < LOW_VIDEO_FRAMES * mPlaybackRate; } bool MediaDecoderStateMachine::HasLowDecodedData() { Loading Loading @@ -3634,7 +3623,7 @@ void MediaDecoderStateMachine::RunStateMachine() { mStateObj->Step(); } void MediaDecoderStateMachine::ResetDecode(const TrackSet& aTracks) { void MediaDecoderStateMachine::ResetDecode(TrackSet aTracks) { MOZ_ASSERT(OnTaskQueue()); LOG("MediaDecoderStateMachine::Reset"); Loading Loading @@ -3708,8 +3697,7 @@ void MediaDecoderStateMachine::UpdatePlaybackPositionPeriodically() { // the monitor and get a staled value from GetCurrentTimeUs() which hits the // assertion in GetClock(). int64_t delay = std::max<int64_t>( 1, static_cast<int64_t>(AUDIO_DURATION_USECS / mPlaybackRate)); int64_t delay = std::max<int64_t>(1, AUDIO_DURATION_USECS / mPlaybackRate); ScheduleStateMachineIn(TimeUnit::FromMicroseconds(delay)); // Notify the listener as we progress in the playback offset. Note it would Loading Loading @@ -3856,7 +3844,7 @@ void MediaDecoderStateMachine::OutputPrincipalChanged() { } RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( const RefPtr<AudioDeviceInfo>& aSink) { RefPtr<AudioDeviceInfo> aSink) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aSink); Loading @@ -3865,7 +3853,7 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( } RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( const RefPtr<AudioDeviceInfo>& aDevice) { RefPtr<AudioDeviceInfo> aSinkDevice) { MOZ_ASSERT(OnTaskQueue()); if (mIsMediaSinkSuspended) { // Don't change sink id in a suspended sink. Loading @@ -3877,12 +3865,12 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( return GenericPromise::CreateAndReject(NS_ERROR_ABORT, __func__); } if (mSinkDevice.Ref() != aDevice) { if (mSinkDevice.Ref() != aSinkDevice) { // A new sink was set before this ran. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } if (mMediaSink->AudioDevice() == aDevice) { if (mMediaSink->AudioDevice() == aSinkDevice) { // The sink has not changed. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } Loading Loading @@ -4143,9 +4131,7 @@ const char* MediaDecoderStateMachine::AudioRequestStatus() const { if (IsRequestingAudioData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingAudioData()); return "pending"; } if (IsWaitingAudioData()) { } else if (IsWaitingAudioData()) { return "waiting"; } return "idle"; Loading @@ -4156,9 +4142,7 @@ const char* MediaDecoderStateMachine::VideoRequestStatus() const { if (IsRequestingVideoData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingVideoData()); return "pending"; } if (IsWaitingVideoData()) { } else if (IsWaitingVideoData()) { return "waiting"; } return "idle"; Loading
dom/media/MediaDecoderStateMachine.h +4 −4 Original line number Diff line number Diff line Loading @@ -275,7 +275,7 @@ class MediaDecoderStateMachine // Sets the video decode mode. Used by the suspend-video-decoder feature. void SetVideoDecodeMode(VideoDecodeMode aMode); RefPtr<GenericPromise> InvokeSetSink(const RefPtr<AudioDeviceInfo>& aSink); RefPtr<GenericPromise> InvokeSetSink(RefPtr<AudioDeviceInfo> aSink); void InvokeSuspendMediaSink(); void InvokeResumeMediaSink(); Loading Loading @@ -351,7 +351,7 @@ class MediaDecoderStateMachine // Resets all states related to decoding and aborts all pending requests // to the decoders. void ResetDecode(const TrackSet& aTracks = TrackSet(TrackInfo::kAudioTrack, void ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, TrackInfo::kVideoTrack)); void SetVideoDecodeModeInternal(VideoDecodeMode aMode); Loading @@ -364,7 +364,7 @@ class MediaDecoderStateMachine // If there are multiple pending requests only the last one will be // executed, for all previous requests the promise will be resolved // with true or false similar to above. RefPtr<GenericPromise> SetSink(const RefPtr<AudioDeviceInfo>& aDevice); RefPtr<GenericPromise> SetSink(RefPtr<AudioDeviceInfo> aSink); // Shutdown MediaSink on suspend to clean up resources. void SuspendMediaSink(); Loading
dom/webidl/MediaDebugInfo.webidl +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ dictionary AudioSinkDebugInfo { boolean isPlaying = false; boolean isStarted = false; boolean audioEnded = false; unsigned long outputRate = 0; long outputRate = 0; long long written = 0; boolean hasErrored = false; boolean playbackComplete = false; Loading