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 {
|
|
|
|
|
|
|
|
enum class MediaDecoderEventVisibility : int8_t {
|
|
|
|
Observable,
|
|
|
|
Suppressed
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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.
|
2016-02-01 07:05:25 +03:00
|
|
|
struct SeekTarget {
|
|
|
|
enum Type {
|
|
|
|
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-01-28 15:24:06 +03:00
|
|
|
: mEventVisibility(MediaDecoderEventVisibility::Observable)
|
2016-01-28 13:24:30 +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)
|
2016-02-01 07:05:25 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SeekTarget(int64_t aTimeUsecs,
|
|
|
|
Type aType,
|
|
|
|
MediaDecoderEventVisibility aEventVisibility =
|
2016-08-12 06:45:02 +03:00
|
|
|
MediaDecoderEventVisibility::Observable,
|
|
|
|
bool aVideoOnly = false)
|
2016-01-28 15:24:06 +03:00
|
|
|
: mEventVisibility(aEventVisibility)
|
2016-01-28 13:24:30 +03:00
|
|
|
, mTime(media::TimeUnit::FromMicroseconds(aTimeUsecs))
|
2016-01-28 15:24:06 +03:00
|
|
|
, mType(aType)
|
2016-08-12 06:45:02 +03:00
|
|
|
, mVideoOnly(aVideoOnly)
|
2016-01-28 13:24:30 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SeekTarget(const media::TimeUnit& aTime,
|
|
|
|
Type aType,
|
|
|
|
MediaDecoderEventVisibility aEventVisibility =
|
2016-08-12 06:45:02 +03:00
|
|
|
MediaDecoderEventVisibility::Observable,
|
|
|
|
bool aVideoOnly = false)
|
2016-01-28 15:24:06 +03:00
|
|
|
: mEventVisibility(aEventVisibility)
|
2016-01-28 13:24:30 +03:00
|
|
|
, mTime(aTime)
|
2016-01-28 15:24:06 +03:00
|
|
|
, mType(aType)
|
2016-08-12 06:45:02 +03:00
|
|
|
, mVideoOnly(aVideoOnly)
|
2016-02-01 07:05:25 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SeekTarget(const SeekTarget& aOther)
|
2016-01-28 15:24:06 +03:00
|
|
|
: mEventVisibility(aOther.mEventVisibility)
|
2016-01-28 13:24:30 +03:00
|
|
|
, mTime(aOther.mTime)
|
2016-01-28 15:24:06 +03:00
|
|
|
, mType(aOther.mType)
|
2016-08-12 06:45:02 +03:00
|
|
|
, mVideoOnly(aOther.mVideoOnly)
|
2016-02-01 07:05:25 +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
|
|
|
}
|
2016-01-28 13:24:30 +03:00
|
|
|
media::TimeUnit GetTime() const {
|
|
|
|
NS_ASSERTION(mTime.IsValid(), "Invalid SeekTarget");
|
|
|
|
return mTime;
|
|
|
|
}
|
|
|
|
void SetTime(const media::TimeUnit& aTime) {
|
|
|
|
NS_ASSERTION(aTime.IsValid(), "Invalid SeekTarget destination");
|
|
|
|
mTime = aTime;
|
|
|
|
}
|
2016-01-28 15:24:06 +03:00
|
|
|
void SetType(Type aType) {
|
|
|
|
mType = aType;
|
|
|
|
}
|
2016-08-12 06:45:02 +03:00
|
|
|
void SetVideoOnly(bool aVideoOnly) {
|
|
|
|
mVideoOnly = aVideoOnly;
|
|
|
|
}
|
2016-01-28 15:24:06 +03:00
|
|
|
bool IsFast() const {
|
|
|
|
return mType == SeekTarget::Type::PrevSyncPoint;
|
|
|
|
}
|
|
|
|
bool IsAccurate() const {
|
|
|
|
return mType == SeekTarget::Type::Accurate;
|
|
|
|
}
|
2016-05-24 06:03:12 +03:00
|
|
|
bool IsNextFrame() const {
|
|
|
|
return mType == SeekTarget::Type::NextFrame;
|
|
|
|
}
|
2016-08-12 06:45:02 +03:00
|
|
|
bool IsVideoOnly() const {
|
|
|
|
return mVideoOnly;
|
|
|
|
}
|
2016-01-28 13:24:30 +03:00
|
|
|
|
2016-02-01 07:05:25 +03:00
|
|
|
MediaDecoderEventVisibility mEventVisibility;
|
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 */
|