From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/media/NextFrameSeekTask.h | 95 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 dom/media/NextFrameSeekTask.h (limited to 'dom/media/NextFrameSeekTask.h') diff --git a/dom/media/NextFrameSeekTask.h b/dom/media/NextFrameSeekTask.h new file mode 100644 index 000000000..debd58c66 --- /dev/null +++ b/dom/media/NextFrameSeekTask.h @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef NEXTFRAME_SEEK_TASK_H +#define NEXTFRAME_SEEK_TASK_H + +#include "SeekTask.h" +#include "MediaDecoderReader.h" + +namespace mozilla { +namespace media { + +/* + * While invoking a NextFrameSeekTask, we don't know the seek target time, what + * we know is the media's currant position. We use the media's currant position + * to find out what the next frame is, by traversing through the video queue or + * asking the decoder to decode more video frames. Once we confirm the next + * frame, we then know the target time of the NextFrameSeekTask and we update it + * so that the MDSM will be able to update the media element's position. + */ + +class NextFrameSeekTask final : public SeekTask { +public: + NextFrameSeekTask(const void* aDecoderID, + AbstractThread* aThread, + MediaDecoderReaderWrapper* aReader, + const SeekTarget& aTarget, + const MediaInfo& aInfo, + const media::TimeUnit& aDuration, + int64_t aCurrentTime, + MediaQueue& aAudioQueue, + MediaQueue& aVideoQueue); + + void Discard() override; + + RefPtr Seek(const media::TimeUnit& aDuration) override; + + bool NeedToResetMDSM() const override; + +private: + ~NextFrameSeekTask(); + + void RequestVideoData(); + + bool NeedMoreVideo() const; + + bool IsVideoRequestPending() const; + + bool IsAudioSeekComplete() const; + + bool IsVideoSeekComplete() const; + + void MaybeFinishSeek(); + + void OnAudioDecoded(MediaData* aAudioSample); + + void OnAudioNotDecoded(const MediaResult& aError); + + void OnVideoDecoded(MediaData* aVideoSample); + + void OnVideoNotDecoded(const MediaResult& aError); + + void SetCallbacks(); + + void CancelCallbacks(); + + // Update the seek target's time before resolving this seek task, the updated + // time will be used in the MDSM::SeekCompleted() to update the MDSM's position. + void UpdateSeekTargetTime(); + + /* + * Data shared with MDSM. + */ + MediaQueue& mAudioQueue; + MediaQueue& mVideoQueue; + + /* + * Internal state. + */ + const int64_t mCurrentTime; + media::TimeUnit mDuration; + + MediaEventListener mAudioCallback; + MediaEventListener mVideoCallback; + MediaEventListener mAudioWaitCallback; + MediaEventListener mVideoWaitCallback; +}; + +} // namespace media +} // namespace mozilla + +#endif /* NEXTFRAME_SEEK_TASK_H */ -- cgit v1.2.3