author | Jean-Yves Avenard <jyavenard@mozilla.com> |
Mon, 24 Aug 2015 11:32:49 +1000 | |
changeset 259364 | 83fc1d3d82bdaa2c6a4053a86e33dafbebb4a088 |
parent 259363 | e6b24f3de23fcc466bd3f9a24352cf85bdf28fa9 |
child 259365 | 06df6f0426568638ffecf58e58c6f7dde1a689fa |
push id | 29277 |
push user | ryanvm@gmail.com |
push date | Wed, 26 Aug 2015 18:32:23 +0000 |
treeherder | mozilla-central@fea87cbeaa6b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jya, bholley, edwin |
bugs | 1197075, 1171257 |
milestone | 43.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -295,18 +295,17 @@ public: } NS_METHOD Run() { MOZ_ASSERT(mReader->OnTaskQueue()); // Make sure ResetDecode hasn't been called in the mean time. if (!mReader->mBaseVideoPromise.IsEmpty()) { - mReader->RequestVideoData(/* aSkip = */ true, mTimeThreshold, - /* aForceDecodeAhead = */ false); + mReader->RequestVideoData(/* aSkip = */ true, mTimeThreshold); } return NS_OK; } private: nsRefPtr<MediaDecoderReader> mReader; const int64_t mTimeThreshold; @@ -333,18 +332,17 @@ public: } private: nsRefPtr<MediaDecoderReader> mReader; }; nsRefPtr<MediaDecoderReader::VideoDataPromise> MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) + int64_t aTimeThreshold) { nsRefPtr<VideoDataPromise> p = mBaseVideoPromise.Ensure(__func__); bool skip = aSkipToNextKeyframe; while (VideoQueue().GetSize() == 0 && !VideoQueue().IsFinished()) { if (!DecodeVideoFrame(skip, aTimeThreshold)) { VideoQueue().Finish(); } else if (skip) {
--- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -143,17 +143,17 @@ public: // Requests one video sample from the reader. // // Don't hold the decoder monitor while calling this, as the implementation // may try to wait on something that needs the monitor and deadlock. // If aSkipToKeyframe is true, the decode should skip ahead to the // the next keyframe at or after aTimeThreshold microseconds. virtual nsRefPtr<VideoDataPromise> - RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold, bool aForceDecodeAhead); + RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold); friend class ReRequestVideoWithSkipTask; friend class ReRequestAudioTask; // By default, the state machine polls the reader once per second when it's // in buffering mode. Some readers support a promise-based mechanism by which // they notify the state machine when the data arrives. virtual bool IsWaitForDataSupported() { return false; }
--- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -166,17 +166,16 @@ static TimeDuration UsecsToDuration(int6 } static int64_t DurationToUsecs(TimeDuration aDuration) { return static_cast<int64_t>(aDuration.ToSeconds() * USECS_PER_S); } static const uint32_t MIN_VIDEO_QUEUE_SIZE = 3; static const uint32_t MAX_VIDEO_QUEUE_SIZE = 10; -static const uint32_t SCARCE_VIDEO_QUEUE_SIZE = 1; static const uint32_t VIDEO_QUEUE_SEND_TO_COMPOSITOR_SIZE = 9999; static uint32_t sVideoQueueDefaultSize = MAX_VIDEO_QUEUE_SIZE; static uint32_t sVideoQueueHWAccelSize = MIN_VIDEO_QUEUE_SIZE; static uint32_t sVideoQueueSendToCompositorSize = VIDEO_QUEUE_SEND_TO_COMPOSITOR_SIZE; MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder, MediaDecoderReader* aReader, @@ -1705,36 +1704,34 @@ MediaDecoderStateMachine::RequestVideoDa // Time the video decode, so that if it's slow, we can increase our low // audio threshold to reduce the chance of an audio underrun while we're // waiting for a video decode to complete. mVideoDecodeStartTime = TimeStamp::Now(); bool skipToNextKeyFrame = mSentFirstFrameLoadedEvent && NeedToSkipToNextKeyframe(); int64_t currentTime = mState == DECODER_STATE_SEEKING ? 0 : GetMediaTime(); - bool forceDecodeAhead = mSentFirstFrameLoadedEvent && - static_cast<uint32_t>(VideoQueue().GetSize()) <= SCARCE_VIDEO_QUEUE_SIZE; SAMPLE_LOG("Queueing video task - queued=%i, decoder-queued=%o, skip=%i, time=%lld", VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames(), skipToNextKeyFrame, currentTime); if (mSentFirstFrameLoadedEvent) { mVideoDataRequest.Begin( InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__, &MediaDecoderReader::RequestVideoData, - skipToNextKeyFrame, currentTime, forceDecodeAhead) + skipToNextKeyFrame, currentTime) ->Then(OwnerThread(), __func__, this, &MediaDecoderStateMachine::OnVideoDecoded, &MediaDecoderStateMachine::OnVideoNotDecoded)); } else { mVideoDataRequest.Begin( InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__, &MediaDecoderReader::RequestVideoData, - skipToNextKeyFrame, currentTime, forceDecodeAhead) + skipToNextKeyFrame, currentTime) ->Then(OwnerThread(), __func__, mStartTimeRendezvous.get(), &StartTimeRendezvous::ProcessFirstSample<VideoDataPromise>, &StartTimeRendezvous::FirstSampleRejected<VideoData>) ->CompletionPromise() ->Then(OwnerThread(), __func__, this, &MediaDecoderStateMachine::OnVideoDecoded, &MediaDecoderStateMachine::OnVideoNotDecoded)); }
--- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -632,18 +632,17 @@ MediaFormatReader::ShouldSkip(bool aSkip if (NS_FAILED(rv)) { return aSkipToNextKeyframe; } return nextKeyframe < aTimeThreshold && nextKeyframe.ToMicroseconds() >= 0; } nsRefPtr<MediaDecoderReader::VideoDataPromise> MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) + int64_t aTimeThreshold) { MOZ_ASSERT(OnTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(), "No sample requests allowed while seeking"); MOZ_DIAGNOSTIC_ASSERT(!mVideo.HasPromise(), "No duplicate sample requests"); MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists() || mVideo.mTimeThreshold.isSome()); MOZ_DIAGNOSTIC_ASSERT(!mSkipRequest.Exists(), "called mid-skipping"); MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek"); @@ -659,17 +658,16 @@ MediaFormatReader::RequestVideoData(bool return VideoDataPromise::CreateAndReject(CANCELED, __func__); } if (mShutdown) { NS_WARNING("RequestVideoData on shutdown MediaFormatReader!"); return VideoDataPromise::CreateAndReject(CANCELED, __func__); } - mVideo.mForceDecodeAhead = aForceDecodeAhead; media::TimeUnit timeThreshold{media::TimeUnit::FromMicroseconds(aTimeThreshold)}; if (ShouldSkip(aSkipToNextKeyframe, timeThreshold)) { Flush(TrackInfo::kVideoTrack); nsRefPtr<VideoDataPromise> p = mVideo.mPromise.Ensure(__func__); SkipVideoDemuxToNextKeyFrame(timeThreshold); return p; } @@ -859,22 +857,21 @@ MediaFormatReader::NeedInput(DecoderData // We try to keep a few more compressed samples input than decoded samples // have been output, provided the state machine has requested we send it a // decoded sample. To account for H.264 streams which may require a longer // run of input than we input, decoders fire an "input exhausted" callback, // which overrides our "few more samples" threshold. return !aDecoder.mDraining && !aDecoder.mError && - (aDecoder.HasPromise() || aDecoder.mForceDecodeAhead) && + aDecoder.HasPromise() && !aDecoder.mDemuxRequest.Exists() && aDecoder.mOutput.IsEmpty() && (aDecoder.mInputExhausted || !aDecoder.mQueuedSamples.IsEmpty() || aDecoder.mTimeThreshold.isSome() || - aDecoder.mForceDecodeAhead || aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput < aDecoder.mDecodeAhead); } void MediaFormatReader::ScheduleUpdate(TrackType aTrack) { MOZ_ASSERT(OnTaskQueue()); if (mShutdown) {
--- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -30,17 +30,17 @@ public: virtual ~MediaFormatReader(); nsresult Init(MediaDecoderReader* aCloneDonor) override; size_t SizeOfVideoQueueInFrames() override; size_t SizeOfAudioQueueInFrames() override; nsRefPtr<VideoDataPromise> - RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold, bool aForceDecodeAhead) override; + RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override; nsRefPtr<AudioDataPromise> RequestAudioData() override; bool HasVideo() override { return mVideo.mTrackDemuxer; } @@ -186,17 +186,16 @@ private: struct DecoderData { DecoderData(MediaFormatReader* aOwner, MediaData::Type aType, uint32_t aDecodeAhead) : mOwner(aOwner) , mType(aType) , mDecodeAhead(aDecodeAhead) - , mForceDecodeAhead(false) , mUpdateScheduled(false) , mDemuxEOS(false) , mWaitingForData(false) , mReceivedNewData(false) , mDiscontinuity(true) , mDecoderInitialized(false) , mOutputRequested(false) , mInputExhausted(false) @@ -221,17 +220,16 @@ private: // TaskQueue on which decoder can choose to decode. // Only non-null up until the decoder is created. nsRefPtr<FlushableTaskQueue> mTaskQueue; // Callback that receives output and error notifications from the decoder. nsAutoPtr<DecoderCallback> mCallback; // Only accessed from reader's task queue. uint32_t mDecodeAhead; - bool mForceDecodeAhead; bool mUpdateScheduled; bool mDemuxEOS; bool mWaitingForData; bool mReceivedNewData; bool mDiscontinuity; // Pending seek. MozPromiseRequestHolder<MediaTrackDemuxer::SeekPromise> mSeekRequest; @@ -277,17 +275,16 @@ private: // Clear demuxer related data. mDemuxRequest.DisconnectIfExists(); mTrackDemuxer->Reset(); } void ResetState() { MOZ_ASSERT(mOwner->OnTaskQueue()); - mForceDecodeAhead = false; mDemuxEOS = false; mWaitingForData = false; mReceivedNewData = false; mDiscontinuity = true; mQueuedSamples.Clear(); mOutputRequested = false; mInputExhausted = false; mNeedDraining = false;
--- a/dom/media/mediasource/MediaSourceReader.cpp +++ b/dom/media/mediasource/MediaSourceReader.cpp @@ -41,17 +41,16 @@ extern PRLogModuleInfo* GetMediaSourceLo #define EOS_FUZZ_US 125000 namespace mozilla { MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder) : MediaDecoderReader(aDecoder) , mLastAudioTime(0) , mLastVideoTime(0) - , mForceVideoDecodeAhead(false) , mOriginalSeekTime(-1) , mPendingSeekTime(-1) , mWaitingForSeekData(false) , mSeekToEnd(false) , mTimeThreshold(0) , mDropAudioBeforeThreshold(false) , mDropVideoBeforeThreshold(false) , mAudioDiscontinuity(false) @@ -302,19 +301,17 @@ MediaSourceReader::OnAudioNotDecoded(Not if (mLastAudioTime - lastAudioTime >= EOS_FUZZ_US) { // No decoders are available to switch to. We will re-attempt from the last // failing position. mLastAudioTime = lastAudioTime; } } nsRefPtr<MediaDecoderReader::VideoDataPromise> -MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) +MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) { MOZ_ASSERT(OnTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(), "No sample requests allowed while seeking"); MOZ_DIAGNOSTIC_ASSERT(mVideoPromise.IsEmpty(), "No duplicate sample requests"); nsRefPtr<VideoDataPromise> p = mVideoPromise.Ensure(__func__); MSE_DEBUGV("RequestVideoData(%d, %lld), mLastVideoTime=%lld", aSkipToNextKeyframe, aTimeThreshold, mLastVideoTime); if (!mVideoTrack) { @@ -328,17 +325,16 @@ MediaSourceReader::RequestVideoData(bool mDropVideoBeforeThreshold = true; } if (IsSeeking()) { MSE_DEBUG("called mid-seek. Rejecting."); mVideoPromise.Reject(CANCELED, __func__); return p; } MOZ_DIAGNOSTIC_ASSERT(!mVideoSeekRequest.Exists()); - mForceVideoDecodeAhead = aForceDecodeAhead; SwitchSourceResult ret = SwitchVideoSource(&mLastVideoTime); switch (ret) { case SOURCE_NEW: GetVideoReader()->ResetDecode(); mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mLastVideoTime), 0) ->Then(OwnerThread(), __func__, this, &MediaSourceReader::CompleteVideoSeekAndDoRequest, @@ -362,18 +358,17 @@ MediaSourceReader::RequestVideoData(bool return p; } void MediaSourceReader::DoVideoRequest() { mVideoRequest.Begin(GetVideoReader()->RequestVideoData(mDropVideoBeforeThreshold, - GetReaderVideoTime(mTimeThreshold), - mForceVideoDecodeAhead) + GetReaderVideoTime(mTimeThreshold)) ->Then(OwnerThread(), __func__, this, &MediaSourceReader::OnVideoDecoded, &MediaSourceReader::OnVideoNotDecoded)); } void MediaSourceReader::OnVideoDecoded(VideoData* aSample) { @@ -889,19 +884,16 @@ MediaSourceReader::ResetDecode() // Do the same for any data wait promises. mAudioWaitPromise.RejectIfExists(WaitForDataRejectValue(MediaData::AUDIO_DATA, WaitForDataRejectValue::CANCELED), __func__); mVideoWaitPromise.RejectIfExists(WaitForDataRejectValue(MediaData::VIDEO_DATA, WaitForDataRejectValue::CANCELED), __func__); // Reset miscellaneous seeking state. mWaitingForSeekData = false; mPendingSeekTime = -1; - // Reset force video decode ahead. - mForceVideoDecodeAhead = false; - // Reset all the readers. if (GetAudioReader()) { GetAudioReader()->ResetDecode(); } if (GetVideoReader()) { GetVideoReader()->ResetDecode(); }
--- a/dom/media/mediasource/MediaSourceReader.h +++ b/dom/media/mediasource/MediaSourceReader.h @@ -44,17 +44,17 @@ public: // registered TrackBuffers essential for initialization. void PrepareInitialization(); bool IsWaitingMediaResources() override; bool IsWaitingOnCDMResource() override; nsRefPtr<AudioDataPromise> RequestAudioData() override; nsRefPtr<VideoDataPromise> - RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold, bool aForceDecodeAhead) override; + RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override; virtual size_t SizeOfVideoQueueInFrames() override; virtual size_t SizeOfAudioQueueInFrames() override; virtual void ReleaseMediaResources() override; void OnAudioDecoded(AudioData* aSample); void OnAudioNotDecoded(NotDecodedReason aReason); @@ -250,18 +250,16 @@ private: #ifdef MOZ_EME nsRefPtr<CDMProxy> mCDMProxy; #endif // These are read and written on the decode task queue threads. int64_t mLastAudioTime; int64_t mLastVideoTime; - bool mForceVideoDecodeAhead; - MozPromiseRequestHolder<SeekPromise> mAudioSeekRequest; MozPromiseRequestHolder<SeekPromise> mVideoSeekRequest; MozPromiseHolder<SeekPromise> mSeekPromise; // Temporary seek information while we wait for the data // to be added to the track buffer. int64_t mOriginalSeekTime; int64_t mPendingSeekTime;
--- a/dom/media/omx/MediaCodecReader.cpp +++ b/dom/media/omx/MediaCodecReader.cpp @@ -348,18 +348,17 @@ MediaCodecReader::RequestAudioData() DispatchAudioTask(); } MOZ_ASSERT(mAudioTrack.mAudioPromise.IsEmpty()); return mAudioTrack.mAudioPromise.Ensure(__func__); } nsRefPtr<MediaDecoderReader::VideoDataPromise> MediaCodecReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) + int64_t aTimeThreshold) { MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(HasVideo()); int64_t threshold = sInvalidTimestampUs; if (aSkipToNextKeyframe && IsValidTimestampUs(aTimeThreshold)) { threshold = aTimeThreshold; }
--- a/dom/media/omx/MediaCodecReader.h +++ b/dom/media/omx/MediaCodecReader.h @@ -78,18 +78,17 @@ protected: public: // Flush the TaskQueue, flush MediaCodec and raise the mDiscontinuity. virtual nsresult ResetDecode() override; // Disptach a DecodeVideoFrameTask to decode video data. virtual nsRefPtr<VideoDataPromise> RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) override; + int64_t aTimeThreshold) override; // Disptach a DecodeAduioDataTask to decode video data. virtual nsRefPtr<AudioDataPromise> RequestAudioData() override; virtual bool HasAudio(); virtual bool HasVideo(); virtual nsRefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
--- a/dom/media/omx/RtspMediaCodecReader.cpp +++ b/dom/media/omx/RtspMediaCodecReader.cpp @@ -77,23 +77,20 @@ nsRefPtr<MediaDecoderReader::AudioDataPr RtspMediaCodecReader::RequestAudioData() { EnsureActive(); return MediaCodecReader::RequestAudioData(); } nsRefPtr<MediaDecoderReader::VideoDataPromise> RtspMediaCodecReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) + int64_t aTimeThreshold) { EnsureActive(); - return MediaCodecReader::RequestVideoData(aSkipToNextKeyframe, - aTimeThreshold, - aForceDecodeAhead); + return MediaCodecReader::RequestVideoData(aSkipToNextKeyframe, aTimeThreshold); } nsRefPtr<MediaDecoderReader::MetadataPromise> RtspMediaCodecReader::AsyncReadMetadata() { mRtspResource->DisablePlayoutDelay(); EnsureActive();
--- a/dom/media/omx/RtspMediaCodecReader.h +++ b/dom/media/omx/RtspMediaCodecReader.h @@ -48,18 +48,17 @@ public: return media::TimeIntervals::Invalid(); } virtual void SetIdle() override; // Disptach a DecodeVideoFrameTask to decode video data. virtual nsRefPtr<VideoDataPromise> RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold, - bool aForceDecodeAhead) override; + int64_t aTimeThreshold) override; // Disptach a DecodeAudioDataTask to decode audio data. virtual nsRefPtr<AudioDataPromise> RequestAudioData() override; virtual nsRefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override; virtual void HandleResourceAllocated() override;