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; int32_t mFrameID; uint32_t mFrameID; VideoData(int64_t aOffset, const media::TimeUnit& aTime, const media::TimeUnit& aDuration, bool aKeyframe, Loading dom/media/MediaDecoderStateMachine.cpp +50 −34 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 int AUDIO_DURATION_USECS = 40000; static const uint32_t AUDIO_DURATION_USECS = 40000; namespace detail { Loading Loading @@ -210,7 +210,8 @@ class MediaDecoderStateMachine::StateObject { virtual void HandleVideoCanceled() { Crash("Unexpected event!", __func__); } virtual void HandleEndOfVideo() { Crash("Unexpected event!", __func__); } virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget); virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget); virtual RefPtr<ShutdownPromise> HandleShutdown(); Loading Loading @@ -269,7 +270,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 @@ -342,7 +343,8 @@ class MediaDecoderStateMachine::DecodeMetadataState State GetState() const override { return DECODER_STATE_DECODING_METADATA; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading Loading @@ -422,7 +424,8 @@ class MediaDecoderStateMachine::DormantState State GetState() const override { return DECODER_STATE_DORMANT; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override; RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override; void HandleVideoSuspendTimeout() override { // Do nothing since we've released decoders in Enter(). Loading Loading @@ -532,7 +535,8 @@ class MediaDecoderStateMachine::DecodingFirstFrameState MOZ_ASSERT(false, "Shouldn't have suspended video decoding."); } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { if (mMaster->mIsMSE) { return StateObject::HandleSeek(aTarget); } Loading Loading @@ -701,8 +705,9 @@ class MediaDecoderStateMachine::DecodingState } uint32_t VideoPrerollFrames() const { return std::min<uint32_t>( (mMaster->GetAmpleVideoFrames() / 2) * mMaster->mPlaybackRate + 1, return std::min( static_cast<uint32_t>( mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1), sVideoQueueDefaultSize); } Loading Loading @@ -736,7 +741,9 @@ class MediaDecoderStateMachine::DecodingState if (timeout < 0) { // Disabled when timeout is negative. return; } else if (timeout == 0) { } if (timeout == 0) { // Enter dormant immediately without scheduling a timer. SetState<DormantState>(); return; Loading Loading @@ -901,7 +908,7 @@ class MediaDecoderStateMachine::LoopingDecodingState ->RequestAudioData() ->Then( OwnerThread(), __func__, [this](RefPtr<AudioData> aAudio) { [this](const RefPtr<AudioData>& aAudio) { AUTO_PROFILER_LABEL( "LoopingDecodingState::" "RequestAudioDataFromStartPosition:" Loading Loading @@ -1090,13 +1097,14 @@ class MediaDecoderStateMachine::SeekingState // We specially handle next frame seeks by ignoring them if we're already // seeking. RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const 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(/* aIgnored = */ true, __func__); return MediaDecoder::SeekPromise::CreateAndReject( /* aRejectValue = */ true, __func__); } return StateObject::HandleSeek(aTarget); Loading Loading @@ -1891,7 +1899,7 @@ constexpr TimeUnit MediaDecoderStateMachine::VideoOnlySeekingState:: sSkipToNextKeyFrameThreshold; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget) { MediaDecoderStateMachine::DormantState::HandleSeek(const 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 @@ -2141,7 +2149,8 @@ class MediaDecoderStateMachine::ShutdownState State GetState() const override { return DECODER_STATE_SHUTDOWN; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading @@ -2161,7 +2170,7 @@ class MediaDecoderStateMachine::ShutdownState }; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::StateObject::HandleSeek(SeekTarget aTarget) { MediaDecoderStateMachine::StateObject::HandleSeek(const SeekTarget& aTarget) { SLOG("Changed state to SEEKING (to %" PRId64 ")", aTarget.GetTime().ToMicroseconds()); SeekJob seekJob; Loading Loading @@ -2207,9 +2216,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, uint32_t(duration_ms + 0.5)); static_cast<uint32_t>(lround(duration_ms))); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, "All"_ns, uint32_t(duration_ms + 0.5)); static_cast<uint32_t>(lround(duration_ms))); } void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( Loading @@ -2224,7 +2233,7 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( TimeStamp start = TimeStamp::Now(); // Local reference to mInfo, so that it will be copied in the lambda below. auto& info = Info(); const auto& info = Info(); bool hw = Reader()->VideoIsHardwareAccelerated(); // Start video-only seek to the current time. Loading Loading @@ -2674,7 +2683,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 @@ -2912,7 +2921,8 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio() const { bool MediaDecoderStateMachine::HaveEnoughDecodedVideo() const { MOZ_ASSERT(OnTaskQueue()); return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1 && return VideoQueue().GetSize() >= static_cast<size_t>(GetAmpleVideoFrames() * mPlaybackRate + 1) && IsVideoDataEnoughComparedWithAudio(); } Loading Loading @@ -3252,13 +3262,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(/* aIgnored = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, __func__); } if (aTarget.IsNextFrame() && !HasVideo()) { LOGW("Ignore a NextFrameSeekTask on a media file without video track."); return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, __func__); } Loading Loading @@ -3300,7 +3310,7 @@ void MediaDecoderStateMachine::RequestAudioData() { ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( RefPtr<AudioData> aAudio) mutable { const RefPtr<AudioData>& aAudio) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestAudioData:Resolved", Loading Loading @@ -3362,7 +3372,7 @@ void MediaDecoderStateMachine::RequestVideoData( ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( RefPtr<VideoData> aVideo) mutable { const RefPtr<VideoData>& aVideo) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestVideoData:Resolved", Loading Loading @@ -3498,7 +3508,8 @@ bool MediaDecoderStateMachine::HasLowDecodedAudio() { bool MediaDecoderStateMachine::HasLowDecodedVideo() { MOZ_ASSERT(OnTaskQueue()); return IsVideoDecoding() && VideoQueue().GetSize() < LOW_VIDEO_FRAMES * mPlaybackRate; VideoQueue().GetSize() < static_cast<size_t>(ceill(LOW_VIDEO_FRAMES * mPlaybackRate)); } bool MediaDecoderStateMachine::HasLowDecodedData() { Loading Loading @@ -3623,7 +3634,7 @@ void MediaDecoderStateMachine::RunStateMachine() { mStateObj->Step(); } void MediaDecoderStateMachine::ResetDecode(TrackSet aTracks) { void MediaDecoderStateMachine::ResetDecode(const TrackSet& aTracks) { MOZ_ASSERT(OnTaskQueue()); LOG("MediaDecoderStateMachine::Reset"); Loading Loading @@ -3697,7 +3708,8 @@ 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, AUDIO_DURATION_USECS / mPlaybackRate); int64_t delay = std::max<int64_t>( 1, static_cast<int64_t>(AUDIO_DURATION_USECS / mPlaybackRate)); ScheduleStateMachineIn(TimeUnit::FromMicroseconds(delay)); // Notify the listener as we progress in the playback offset. Note it would Loading Loading @@ -3844,7 +3856,7 @@ void MediaDecoderStateMachine::OutputPrincipalChanged() { } RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( RefPtr<AudioDeviceInfo> aSink) { const RefPtr<AudioDeviceInfo>& aSink) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aSink); Loading @@ -3853,7 +3865,7 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( } RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( RefPtr<AudioDeviceInfo> aSinkDevice) { const RefPtr<AudioDeviceInfo>& aDevice) { MOZ_ASSERT(OnTaskQueue()); if (mIsMediaSinkSuspended) { // Don't change sink id in a suspended sink. Loading @@ -3865,12 +3877,12 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( return GenericPromise::CreateAndReject(NS_ERROR_ABORT, __func__); } if (mSinkDevice.Ref() != aSinkDevice) { if (mSinkDevice.Ref() != aDevice) { // A new sink was set before this ran. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } if (mMediaSink->AudioDevice() == aSinkDevice) { if (mMediaSink->AudioDevice() == aDevice) { // The sink has not changed. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } Loading Loading @@ -4131,7 +4143,9 @@ const char* MediaDecoderStateMachine::AudioRequestStatus() const { if (IsRequestingAudioData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingAudioData()); return "pending"; } else if (IsWaitingAudioData()) { } if (IsWaitingAudioData()) { return "waiting"; } return "idle"; Loading @@ -4142,7 +4156,9 @@ const char* MediaDecoderStateMachine::VideoRequestStatus() const { if (IsRequestingVideoData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingVideoData()); return "pending"; } else if (IsWaitingVideoData()) { } 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(RefPtr<AudioDeviceInfo> aSink); RefPtr<GenericPromise> InvokeSetSink(const 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(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, void ResetDecode(const 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(RefPtr<AudioDeviceInfo> aSink); RefPtr<GenericPromise> SetSink(const RefPtr<AudioDeviceInfo>& aDevice); // Shutdown MediaSink on suspend to clean up resources. void SuspendMediaSink(); 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; int32_t mFrameID; uint32_t mFrameID; VideoData(int64_t aOffset, const media::TimeUnit& aTime, const media::TimeUnit& aDuration, bool aKeyframe, Loading
dom/media/MediaDecoderStateMachine.cpp +50 −34 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 int AUDIO_DURATION_USECS = 40000; static const uint32_t AUDIO_DURATION_USECS = 40000; namespace detail { Loading Loading @@ -210,7 +210,8 @@ class MediaDecoderStateMachine::StateObject { virtual void HandleVideoCanceled() { Crash("Unexpected event!", __func__); } virtual void HandleEndOfVideo() { Crash("Unexpected event!", __func__); } virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget); virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget); virtual RefPtr<ShutdownPromise> HandleShutdown(); Loading Loading @@ -269,7 +270,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 @@ -342,7 +343,8 @@ class MediaDecoderStateMachine::DecodeMetadataState State GetState() const override { return DECODER_STATE_DECODING_METADATA; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading Loading @@ -422,7 +424,8 @@ class MediaDecoderStateMachine::DormantState State GetState() const override { return DECODER_STATE_DORMANT; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override; RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override; void HandleVideoSuspendTimeout() override { // Do nothing since we've released decoders in Enter(). Loading Loading @@ -532,7 +535,8 @@ class MediaDecoderStateMachine::DecodingFirstFrameState MOZ_ASSERT(false, "Shouldn't have suspended video decoding."); } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { if (mMaster->mIsMSE) { return StateObject::HandleSeek(aTarget); } Loading Loading @@ -701,8 +705,9 @@ class MediaDecoderStateMachine::DecodingState } uint32_t VideoPrerollFrames() const { return std::min<uint32_t>( (mMaster->GetAmpleVideoFrames() / 2) * mMaster->mPlaybackRate + 1, return std::min( static_cast<uint32_t>( mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1), sVideoQueueDefaultSize); } Loading Loading @@ -736,7 +741,9 @@ class MediaDecoderStateMachine::DecodingState if (timeout < 0) { // Disabled when timeout is negative. return; } else if (timeout == 0) { } if (timeout == 0) { // Enter dormant immediately without scheduling a timer. SetState<DormantState>(); return; Loading Loading @@ -901,7 +908,7 @@ class MediaDecoderStateMachine::LoopingDecodingState ->RequestAudioData() ->Then( OwnerThread(), __func__, [this](RefPtr<AudioData> aAudio) { [this](const RefPtr<AudioData>& aAudio) { AUTO_PROFILER_LABEL( "LoopingDecodingState::" "RequestAudioDataFromStartPosition:" Loading Loading @@ -1090,13 +1097,14 @@ class MediaDecoderStateMachine::SeekingState // We specially handle next frame seeks by ignoring them if we're already // seeking. RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const 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(/* aIgnored = */ true, __func__); return MediaDecoder::SeekPromise::CreateAndReject( /* aRejectValue = */ true, __func__); } return StateObject::HandleSeek(aTarget); Loading Loading @@ -1891,7 +1899,7 @@ constexpr TimeUnit MediaDecoderStateMachine::VideoOnlySeekingState:: sSkipToNextKeyFrameThreshold; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget) { MediaDecoderStateMachine::DormantState::HandleSeek(const 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 @@ -2141,7 +2149,8 @@ class MediaDecoderStateMachine::ShutdownState State GetState() const override { return DECODER_STATE_SHUTDOWN; } RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override { RefPtr<MediaDecoder::SeekPromise> HandleSeek( const SeekTarget& aTarget) override { MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek in shutdown state."); return MediaDecoder::SeekPromise::CreateAndReject(true, __func__); } Loading @@ -2161,7 +2170,7 @@ class MediaDecoderStateMachine::ShutdownState }; RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::StateObject::HandleSeek(SeekTarget aTarget) { MediaDecoderStateMachine::StateObject::HandleSeek(const SeekTarget& aTarget) { SLOG("Changed state to SEEKING (to %" PRId64 ")", aTarget.GetTime().ToMicroseconds()); SeekJob seekJob; Loading Loading @@ -2207,9 +2216,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, uint32_t(duration_ms + 0.5)); static_cast<uint32_t>(lround(duration_ms))); Telemetry::Accumulate(Telemetry::VIDEO_SUSPEND_RECOVERY_TIME_MS, "All"_ns, uint32_t(duration_ms + 0.5)); static_cast<uint32_t>(lround(duration_ms))); } void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( Loading @@ -2224,7 +2233,7 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( TimeStamp start = TimeStamp::Now(); // Local reference to mInfo, so that it will be copied in the lambda below. auto& info = Info(); const auto& info = Info(); bool hw = Reader()->VideoIsHardwareAccelerated(); // Start video-only seek to the current time. Loading Loading @@ -2674,7 +2683,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 @@ -2912,7 +2921,8 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio() const { bool MediaDecoderStateMachine::HaveEnoughDecodedVideo() const { MOZ_ASSERT(OnTaskQueue()); return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1 && return VideoQueue().GetSize() >= static_cast<size_t>(GetAmpleVideoFrames() * mPlaybackRate + 1) && IsVideoDataEnoughComparedWithAudio(); } Loading Loading @@ -3252,13 +3262,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(/* aIgnored = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, __func__); } if (aTarget.IsNextFrame() && !HasVideo()) { LOGW("Ignore a NextFrameSeekTask on a media file without video track."); return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, return MediaDecoder::SeekPromise::CreateAndReject(/* aRejectValue = */ true, __func__); } Loading Loading @@ -3300,7 +3310,7 @@ void MediaDecoderStateMachine::RequestAudioData() { ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( RefPtr<AudioData> aAudio) mutable { const RefPtr<AudioData>& aAudio) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestAudioData:Resolved", Loading Loading @@ -3362,7 +3372,7 @@ void MediaDecoderStateMachine::RequestVideoData( ->Then( OwnerThread(), __func__, [this, self, perfRecorder(std::move(perfRecorder))]( RefPtr<VideoData> aVideo) mutable { const RefPtr<VideoData>& aVideo) mutable { perfRecorder.End(); AUTO_PROFILER_LABEL( "MediaDecoderStateMachine::RequestVideoData:Resolved", Loading Loading @@ -3498,7 +3508,8 @@ bool MediaDecoderStateMachine::HasLowDecodedAudio() { bool MediaDecoderStateMachine::HasLowDecodedVideo() { MOZ_ASSERT(OnTaskQueue()); return IsVideoDecoding() && VideoQueue().GetSize() < LOW_VIDEO_FRAMES * mPlaybackRate; VideoQueue().GetSize() < static_cast<size_t>(ceill(LOW_VIDEO_FRAMES * mPlaybackRate)); } bool MediaDecoderStateMachine::HasLowDecodedData() { Loading Loading @@ -3623,7 +3634,7 @@ void MediaDecoderStateMachine::RunStateMachine() { mStateObj->Step(); } void MediaDecoderStateMachine::ResetDecode(TrackSet aTracks) { void MediaDecoderStateMachine::ResetDecode(const TrackSet& aTracks) { MOZ_ASSERT(OnTaskQueue()); LOG("MediaDecoderStateMachine::Reset"); Loading Loading @@ -3697,7 +3708,8 @@ 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, AUDIO_DURATION_USECS / mPlaybackRate); int64_t delay = std::max<int64_t>( 1, static_cast<int64_t>(AUDIO_DURATION_USECS / mPlaybackRate)); ScheduleStateMachineIn(TimeUnit::FromMicroseconds(delay)); // Notify the listener as we progress in the playback offset. Note it would Loading Loading @@ -3844,7 +3856,7 @@ void MediaDecoderStateMachine::OutputPrincipalChanged() { } RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( RefPtr<AudioDeviceInfo> aSink) { const RefPtr<AudioDeviceInfo>& aSink) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aSink); Loading @@ -3853,7 +3865,7 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::InvokeSetSink( } RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( RefPtr<AudioDeviceInfo> aSinkDevice) { const RefPtr<AudioDeviceInfo>& aDevice) { MOZ_ASSERT(OnTaskQueue()); if (mIsMediaSinkSuspended) { // Don't change sink id in a suspended sink. Loading @@ -3865,12 +3877,12 @@ RefPtr<GenericPromise> MediaDecoderStateMachine::SetSink( return GenericPromise::CreateAndReject(NS_ERROR_ABORT, __func__); } if (mSinkDevice.Ref() != aSinkDevice) { if (mSinkDevice.Ref() != aDevice) { // A new sink was set before this ran. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } if (mMediaSink->AudioDevice() == aSinkDevice) { if (mMediaSink->AudioDevice() == aDevice) { // The sink has not changed. return GenericPromise::CreateAndResolve(IsPlaying(), __func__); } Loading Loading @@ -4131,7 +4143,9 @@ const char* MediaDecoderStateMachine::AudioRequestStatus() const { if (IsRequestingAudioData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingAudioData()); return "pending"; } else if (IsWaitingAudioData()) { } if (IsWaitingAudioData()) { return "waiting"; } return "idle"; Loading @@ -4142,7 +4156,9 @@ const char* MediaDecoderStateMachine::VideoRequestStatus() const { if (IsRequestingVideoData()) { MOZ_DIAGNOSTIC_ASSERT(!IsWaitingVideoData()); return "pending"; } else if (IsWaitingVideoData()) { } 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(RefPtr<AudioDeviceInfo> aSink); RefPtr<GenericPromise> InvokeSetSink(const 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(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, void ResetDecode(const 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(RefPtr<AudioDeviceInfo> aSink); RefPtr<GenericPromise> SetSink(const RefPtr<AudioDeviceInfo>& aDevice); // Shutdown MediaSink on suspend to clean up resources. void SuspendMediaSink(); Loading