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/. */
10 #include "TimeUnits.h"
11 #include "mozilla/DefineEnum.h"
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
27 MOZ_DEFINE_ENUM_WITH_TOSTRING_AT_CLASS_SCOPE(Track
,
28 (All
, AudioOnly
, VideoOnly
));
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
),
41 mTargetTrack(aOther
.mTargetTrack
) {
42 MOZ_ASSERT(mTime
.IsValid());
44 media::TimeUnit
GetTime() const {
45 MOZ_ASSERT(mTime
.IsValid(), "Invalid SeekTarget");
48 void SetTime(const media::TimeUnit
& aTime
) {
49 MOZ_ASSERT(aTime
.IsValid(), "Invalid SeekTarget destination");
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
; }
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.
72 } // namespace mozilla
74 #endif /* SEEK_TARGET_H */