Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / dom / media / SeekTarget.h
bloba7d145eccddaba0ff3d7dfab7833e3a27e295347
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef SEEK_TARGET_H
8 #define SEEK_TARGET_H
10 #include "TimeUnits.h"
11 #include "mozilla/DefineEnum.h"
13 namespace mozilla {
15 enum class MediaDecoderEventVisibility : int8_t { Observable, Suppressed };
17 // Stores the seek target. It includes (1) the time to seek to (2) type of seek
18 // (accurate, previous keyframe, next keyframe) (3) the type of track needs to
19 // performs seeking.
20 struct SeekTarget {
21 enum Type {
22 Invalid,
23 PrevSyncPoint,
24 Accurate,
25 NextFrame,
27 MOZ_DEFINE_ENUM_WITH_TOSTRING_AT_CLASS_SCOPE(Track,
28 (All, AudioOnly, VideoOnly));
29 SeekTarget()
30 : mTime(media::TimeUnit::Invalid()),
31 mType(SeekTarget::Invalid),
32 mTargetTrack(Track::All) {}
33 SeekTarget(const media::TimeUnit& aTime, Type aType,
34 Track aTrack = Track::All)
35 : mTime(aTime), mType(aType), mTargetTrack(aTrack) {
36 MOZ_ASSERT(mTime.IsValid());
38 SeekTarget(const SeekTarget& aOther)
39 : mTime(aOther.mTime),
40 mType(aOther.mType),
41 mTargetTrack(aOther.mTargetTrack) {
42 MOZ_ASSERT(mTime.IsValid());
44 media::TimeUnit GetTime() const {
45 MOZ_ASSERT(mTime.IsValid(), "Invalid SeekTarget");
46 return mTime;
48 void SetTime(const media::TimeUnit& aTime) {
49 MOZ_ASSERT(aTime.IsValid(), "Invalid SeekTarget destination");
50 mTime = aTime;
52 void SetType(Type aType) { mType = aType; }
53 bool IsFast() const { return mType == SeekTarget::Type::PrevSyncPoint; }
54 bool IsAccurate() const { return mType == SeekTarget::Type::Accurate; }
55 bool IsNextFrame() const { return mType == SeekTarget::Type::NextFrame; }
56 bool IsVideoOnly() const { return mTargetTrack == Track::VideoOnly; }
57 bool IsAudioOnly() const { return mTargetTrack == Track::AudioOnly; }
58 bool IsAllTracks() const { return mTargetTrack == Track::All; }
59 Type GetType() const { return mType; }
60 Track GetTrack() const { return mTargetTrack; }
62 private:
63 // Seek target time.
64 media::TimeUnit mTime;
65 // Whether we should seek "Fast", or "Accurate".
66 // "Fast" seeks to the seek point preceding mTime, whereas
67 // "Accurate" seeks as close as possible to mTime.
68 Type mType;
69 Track mTargetTrack;
72 } // namespace mozilla
74 #endif /* SEEK_TARGET_H */