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/. */ 6 7 #ifndef SEEK_TARGET_H 8 #define SEEK_TARGET_H 9 10 #include "TimeUnits.h" 11 12 namespace mozilla { 13 14 enum class MediaDecoderEventVisibility : int8_t { Observable, Suppressed }; 15 16 // Stores the seek target; the time to seek to, and whether an Accurate, 17 // "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was 18 // requested. 19 struct SeekTarget { 20 enum Type { 21 Invalid, 22 PrevSyncPoint, 23 Accurate, 24 NextFrame, 25 }; SeekTargetSeekTarget26 SeekTarget() 27 : mTime(media::TimeUnit::Invalid()), 28 mType(SeekTarget::Invalid), 29 mVideoOnly(false) {} 30 SeekTarget(const media::TimeUnit& aTime, Type aType, bool aVideoOnly = false) mTimeSeekTarget31 : mTime(aTime), mType(aType), mVideoOnly(aVideoOnly) { 32 MOZ_ASSERT(mTime.IsValid()); 33 } SeekTargetSeekTarget34 SeekTarget(const SeekTarget& aOther) 35 : mTime(aOther.mTime), 36 mType(aOther.mType), 37 mVideoOnly(aOther.mVideoOnly) { 38 MOZ_ASSERT(mTime.IsValid()); 39 } IsValidSeekTarget40 bool IsValid() const { return mType != SeekTarget::Invalid; } ResetSeekTarget41 void Reset() { 42 mTime = media::TimeUnit::Invalid(); 43 mType = SeekTarget::Invalid; 44 mVideoOnly = false; 45 } GetTimeSeekTarget46 media::TimeUnit GetTime() const { 47 MOZ_ASSERT(mTime.IsValid(), "Invalid SeekTarget"); 48 return mTime; 49 } SetTimeSeekTarget50 void SetTime(const media::TimeUnit& aTime) { 51 MOZ_ASSERT(aTime.IsValid(), "Invalid SeekTarget destination"); 52 mTime = aTime; 53 } SetTypeSeekTarget54 void SetType(Type aType) { mType = aType; } SetVideoOnlySeekTarget55 void SetVideoOnly(bool aVideoOnly) { mVideoOnly = aVideoOnly; } IsFastSeekTarget56 bool IsFast() const { return mType == SeekTarget::Type::PrevSyncPoint; } IsAccurateSeekTarget57 bool IsAccurate() const { return mType == SeekTarget::Type::Accurate; } IsNextFrameSeekTarget58 bool IsNextFrame() const { return mType == SeekTarget::Type::NextFrame; } IsVideoOnlySeekTarget59 bool IsVideoOnly() const { return mVideoOnly; } GetTypeSeekTarget60 Type GetType() const { return mType; } 61 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 bool mVideoOnly; 70 }; 71 72 } // namespace mozilla 73 74 #endif /* SEEK_TARGET_H */ 75