Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/SeekTarget.h
Line
Count
Source (jump to first uncovered line)
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
15
{
16
  Observable,
17
  Suppressed
18
};
19
20
// Stores the seek target; the time to seek to, and whether an Accurate,
21
// "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was
22
// requested.
23
struct SeekTarget
24
{
25
  enum Type
26
  {
27
    Invalid,
28
    PrevSyncPoint,
29
    Accurate,
30
    NextFrame,
31
  };
32
  SeekTarget()
33
    : mTime(media::TimeUnit::Invalid())
34
    , mType(SeekTarget::Invalid)
35
    , mVideoOnly(false)
36
0
  {
37
0
  }
38
  SeekTarget(int64_t aTimeUsecs, Type aType, bool aVideoOnly = false)
39
    : mTime(media::TimeUnit::FromMicroseconds(aTimeUsecs))
40
    , mType(aType)
41
    , mVideoOnly(aVideoOnly)
42
0
  {
43
0
  }
44
  SeekTarget(const media::TimeUnit& aTime, Type aType, bool aVideoOnly = false)
45
    : mTime(aTime)
46
    , mType(aType)
47
    , mVideoOnly(aVideoOnly)
48
0
  {
49
0
  }
50
  SeekTarget(const SeekTarget& aOther)
51
    : mTime(aOther.mTime)
52
    , mType(aOther.mType)
53
    , mVideoOnly(aOther.mVideoOnly)
54
0
  {
55
0
  }
56
0
  bool IsValid() const { return mType != SeekTarget::Invalid; }
57
  void Reset()
58
0
  {
59
0
    mTime = media::TimeUnit::Invalid();
60
0
    mType = SeekTarget::Invalid;
61
0
    mVideoOnly = false;
62
0
  }
63
  media::TimeUnit GetTime() const
64
0
  {
65
0
    NS_ASSERTION(mTime.IsValid(), "Invalid SeekTarget");
66
0
    return mTime;
67
0
  }
68
  void SetTime(const media::TimeUnit& aTime)
69
0
  {
70
0
    NS_ASSERTION(aTime.IsValid(), "Invalid SeekTarget destination");
71
0
    mTime = aTime;
72
0
  }
73
0
  void SetType(Type aType) { mType = aType; }
74
0
  void SetVideoOnly(bool aVideoOnly) { mVideoOnly = aVideoOnly; }
75
0
  bool IsFast() const { return mType == SeekTarget::Type::PrevSyncPoint; }
76
0
  bool IsAccurate() const { return mType == SeekTarget::Type::Accurate; }
77
0
  bool IsNextFrame() const { return mType == SeekTarget::Type::NextFrame; }
78
0
  bool IsVideoOnly() const { return mVideoOnly; }
79
80
private:
81
  // Seek target time.
82
  media::TimeUnit mTime;
83
  // Whether we should seek "Fast", or "Accurate".
84
  // "Fast" seeks to the seek point preceding mTime, whereas
85
  // "Accurate" seeks as close as possible to mTime.
86
  Type mType;
87
  bool mVideoOnly;
88
};
89
90
} // namespace mozilla
91
92
#endif /* SEEK_TARGET_H */