2016-02-01 07:05:25 +03:00
|
|
|
/* -*- 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 SEEK_TARGET_H
|
|
|
|
#define SEEK_TARGET_H
|
|
|
|
|
|
|
|
#include "TimeUnits.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-05-22 10:33:18 +03:00
|
|
|
enum class MediaDecoderEventVisibility : int8_t { Observable, Suppressed };
|
2016-02-01 07:05:25 +03:00
|
|
|
|
|
|
|
// Stores the seek target; the time to seek to, and whether an Accurate,
|
2016-04-18 09:33:52 +03:00
|
|
|
// "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was
|
|
|
|
// requested.
|
2017-05-22 10:33:18 +03:00
|
|
|
struct SeekTarget {
|
|
|
|
enum Type {
|
2016-02-01 07:05:25 +03:00
|
|
|
Invalid,
|
|
|
|
PrevSyncPoint,
|
2016-04-18 09:33:52 +03:00
|
|
|
Accurate,
|
2016-05-24 06:03:12 +03:00
|
|
|
NextFrame,
|
2016-02-01 07:05:25 +03:00
|
|
|
};
|
|
|
|
SeekTarget()
|
2016-11-03 10:34:11 +03:00
|
|
|
: mTime(media::TimeUnit::Invalid()),
|
2016-01-28 15:24:06 +03:00
|
|
|
mType(SeekTarget::Invalid),
|
2016-08-12 06:45:02 +03:00
|
|
|
mVideoOnly(false) {}
|
2017-05-22 10:33:18 +03:00
|
|
|
SeekTarget(const media::TimeUnit& aTime, Type aType, bool aVideoOnly = false)
|
2019-04-24 20:07:40 +03:00
|
|
|
: mTime(aTime), mType(aType), mVideoOnly(aVideoOnly) {
|
|
|
|
MOZ_ASSERT(mTime.IsValid());
|
|
|
|
}
|
2016-02-01 07:05:25 +03:00
|
|
|
SeekTarget(const SeekTarget& aOther)
|
2016-11-03 10:34:11 +03:00
|
|
|
: mTime(aOther.mTime),
|
2016-01-28 15:24:06 +03:00
|
|
|
mType(aOther.mType),
|
2019-04-24 20:07:40 +03:00
|
|
|
mVideoOnly(aOther.mVideoOnly) {
|
|
|
|
MOZ_ASSERT(mTime.IsValid());
|
|
|
|
}
|
2017-05-22 10:33:18 +03:00
|
|
|
bool IsValid() const { return mType != SeekTarget::Invalid; }
|
|
|
|
void Reset() {
|
2016-01-28 13:24:30 +03:00
|
|
|
mTime = media::TimeUnit::Invalid();
|
2016-02-01 07:05:25 +03:00
|
|
|
mType = SeekTarget::Invalid;
|
2016-08-12 06:45:02 +03:00
|
|
|
mVideoOnly = false;
|
2016-02-01 07:05:25 +03:00
|
|
|
}
|
2017-05-22 10:33:18 +03:00
|
|
|
media::TimeUnit GetTime() const {
|
2019-04-24 20:07:40 +03:00
|
|
|
MOZ_ASSERT(mTime.IsValid(), "Invalid SeekTarget");
|
2016-01-28 13:24:30 +03:00
|
|
|
return mTime;
|
|
|
|
}
|
2017-05-22 10:33:18 +03:00
|
|
|
void SetTime(const media::TimeUnit& aTime) {
|
2019-04-24 20:07:40 +03:00
|
|
|
MOZ_ASSERT(aTime.IsValid(), "Invalid SeekTarget destination");
|
2016-01-28 13:24:30 +03:00
|
|
|
mTime = aTime;
|
|
|
|
}
|
2017-05-22 10:33:18 +03:00
|
|
|
void SetType(Type aType) { mType = aType; }
|
|
|
|
void SetVideoOnly(bool aVideoOnly) { mVideoOnly = aVideoOnly; }
|
|
|
|
bool IsFast() const { return mType == SeekTarget::Type::PrevSyncPoint; }
|
|
|
|
bool IsAccurate() const { return mType == SeekTarget::Type::Accurate; }
|
|
|
|
bool IsNextFrame() const { return mType == SeekTarget::Type::NextFrame; }
|
|
|
|
bool IsVideoOnly() const { return mVideoOnly; }
|
2020-01-09 20:10:08 +03:00
|
|
|
Type GetType() const { return mType; }
|
2016-01-28 13:24:30 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Seek target time.
|
|
|
|
media::TimeUnit mTime;
|
2016-01-28 15:24:06 +03:00
|
|
|
// Whether we should seek "Fast", or "Accurate".
|
2016-04-18 09:33:52 +03:00
|
|
|
// "Fast" seeks to the seek point preceding mTime, whereas
|
2016-01-28 15:24:06 +03:00
|
|
|
// "Accurate" seeks as close as possible to mTime.
|
|
|
|
Type mType;
|
2016-08-12 06:45:02 +03:00
|
|
|
bool mVideoOnly;
|
2016-02-01 07:05:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* SEEK_TARGET_H */
|