summaryrefslogtreecommitdiffstats
path: root/dom/media/NextFrameSeekTask.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/NextFrameSeekTask.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/NextFrameSeekTask.h')
-rw-r--r--dom/media/NextFrameSeekTask.h95
1 files changed, 95 insertions, 0 deletions
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<MediaData>& aAudioQueue,
+ MediaQueue<MediaData>& aVideoQueue);
+
+ void Discard() override;
+
+ RefPtr<SeekTaskPromise> 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<MediaData>& mAudioQueue;
+ MediaQueue<MediaData>& 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 */