UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IMediaTimeSource.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Misc/Timespan.h"
7
8/*
9 Timestamp value for media playback
10
11 - Time:
12 Time value
13
14 - SequenceIndex
15 Sequence that is current for this time value
16
17 Within a single sequence time values will increase or decrease monotonically. A new sequence index is generated on each event that causes the time to no
18 longer be monotonic. (e.g. seek or loop)
19 A sequence index does not offer any information about the ordering of the time stamps on the timeline. Time values are comparable between all timestamps from a single playback,
20 though, one needs to be careful to consider non-monotonic behavior if the sequence indices are not identical.
21
22 Sequence indices can very much offer ordering information as far as playback progression is concerned. Higher indices are also later in playback. (even if time values may be smaller: e.g. looping)
23
24 All comparison operators of this class will operate to indicate ordering relative to playback, not position on the timeline!
25
26*/
28{
29public:
31 { }
33 { }
35 : Time(InTime)
36 , SequenceIndex(GetSequenceIndex(InSequenceValue))
37 , LoopIndex(GetLoopIndex(InSequenceValue))
38 { }
40 : Time(InTime)
41 , SequenceIndex(InSequenceIndex)
42 , LoopIndex(InLoopIndex)
43 { }
44
46 {
48 }
49 bool IsValid() const
50 {
51 return Time != FTimespan::MinValue();
52 }
53
55 {
56 return SequenceIndex == Other.SequenceIndex && LoopIndex == Other.LoopIndex && Time == Other.Time;
57 }
59 {
60 return SequenceIndex != Other.SequenceIndex || LoopIndex != Other.LoopIndex || Time != Other.Time;
61 }
63 {
64 return (GetSequenceIndex() < Other.GetSequenceIndex()) ||
65 (GetSequenceIndex() == Other.GetSequenceIndex() && GetLoopIndex() < Other.GetLoopIndex()) ||
66 (GetSequenceIndex() == Other.GetSequenceIndex() && GetLoopIndex() == Other.GetLoopIndex() && GetTime() < Other.GetTime());
67 }
69 {
70 return this->operator==(Other) || this->operator<(Other);
71 }
73 {
74 return !this->operator<=(Other);
75 }
77 {
78 return !this->operator<(Other);
79 }
80
82 {
83 Time = InTime;
84 SequenceIndex = GetSequenceIndex(InIndexValue);
85 LoopIndex = GetLoopIndex(InIndexValue);
86 return *this;
87 }
89 {
90 Time = InTime;
91 return *this;
92 }
93
95 {
96 SequenceIndex = InSequenceIndex;
97 return *this;
98 }
100 {
101 LoopIndex = InLoopIndex;
102 return *this;
103 }
104
105 const FTimespan& GetTime() const
106 {
107 return Time;
108 }
110 {
111 return (int64)(((uint64)SequenceIndex << 32) | (uint32)LoopIndex);
112 }
113
115 {
116 LoopIndex += Add;
117 return *this;
118 }
119
121 {
122 return SequenceIndex;
123 }
124
126 {
127 return LoopIndex;
128 }
129
130
135
137 {
138 return static_cast<int32>(InSequenceIndex >> 32);
139 }
140
142 {
143 return static_cast<int32>(((uint64)InSequenceIndex) & 0xffffffff);
144 }
145
147 {
148 return FMediaTimeStamp(Time + Other, SequenceIndex, LoopIndex);
149 }
151 {
152 return FMediaTimeStamp(Time - Other, SequenceIndex, LoopIndex);
153 }
154
156 {
157 if (Other.SequenceIndex == SequenceIndex && Other.LoopIndex == LoopIndex)
158 {
160 }
161 else if (Other.SequenceIndex <= SequenceIndex || Other.LoopIndex <= LoopIndex)
162 {
164 }
165 else
166 {
168 }
169 }
170
172 {
173 Time += Other;
174 return *this;
175 }
177 {
178 Time -= Other;
179 return *this;
180 }
181
183 {
184 Time -= Other.Time;
185 SequenceIndex = MAX_int32;
186 LoopIndex = MAX_int32;
187 return *this;
188 }
189
191private:
192 int32 SequenceIndex = 0;
193 int32 LoopIndex = 0;
194};
195
208
213{
214public:
215
221 virtual FTimespan GetTimecode() = 0;
222
223public:
224
226 virtual ~IMediaTimeSource() { }
227};
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define MAX_int32
Definition NumericLimits.h:25
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IMediaTimeSource.h:197
double SampledAtTime
Definition IMediaTimeSource.h:206
FMediaTimeStampSample()
Definition IMediaTimeSource.h:199
void Invalidate()
Definition IMediaTimeSource.h:202
FMediaTimeStampSample(const FMediaTimeStamp &InTimeStamp, double InSampledAtTime)
Definition IMediaTimeSource.h:200
FMediaTimeStamp TimeStamp
Definition IMediaTimeSource.h:205
bool IsValid() const
Definition IMediaTimeSource.h:203
Definition IMediaTimeSource.h:28
int32 GetSequenceIndex() const
Definition IMediaTimeSource.h:120
FMediaTimeStamp operator-(const FTimespan &Other) const
Definition IMediaTimeSource.h:150
FMediaTimeStamp operator+(const FTimespan &Other) const
Definition IMediaTimeSource.h:146
bool operator>=(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:76
bool operator<(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:62
FMediaTimeStamp()
Definition IMediaTimeSource.h:30
FMediaTimeStamp & SetLoopIndex(int32 InLoopIndex)
Definition IMediaTimeSource.h:99
bool operator!=(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:58
FMediaTimeStamp & AdjustLoopIndex(int32 Add)
Definition IMediaTimeSource.h:114
static int32 GetLoopIndex(int64 InSequenceIndex)
Definition IMediaTimeSource.h:141
void Invalidate()
Definition IMediaTimeSource.h:45
FMediaTimeStamp & SetSequenceIndex(int32 InSequenceIndex)
Definition IMediaTimeSource.h:94
int32 GetLoopIndex() const
Definition IMediaTimeSource.h:125
bool operator==(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:54
static int64 MakeIndexValue(int32 InSequenceIndex, int32 InLoopIndex)
Definition IMediaTimeSource.h:131
const FTimespan & GetTime() const
Definition IMediaTimeSource.h:105
FTimespan Time
Definition IMediaTimeSource.h:190
FMediaTimeStamp(const FTimespan &InTime, int32 InSequenceIndex, int32 InLoopIndex)
Definition IMediaTimeSource.h:39
FMediaTimeStamp & SetTimeAndIndexValue(const FTimespan &InTime, int64 InIndexValue)
Definition IMediaTimeSource.h:81
FMediaTimeStamp & SetTime(const FTimespan &InTime)
Definition IMediaTimeSource.h:88
int64 GetIndexValue() const
Definition IMediaTimeSource.h:109
FMediaTimeStamp & operator+=(const FTimespan &Other)
Definition IMediaTimeSource.h:171
static int32 GetSequenceIndex(int64 InSequenceIndex)
Definition IMediaTimeSource.h:136
FMediaTimeStamp & operator-=(const FTimespan &Other)
Definition IMediaTimeSource.h:176
bool operator>(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:72
bool operator<=(const FMediaTimeStamp &Other) const
Definition IMediaTimeSource.h:68
FMediaTimeStamp(const FTimespan &InTime, int64 InSequenceValue)
Definition IMediaTimeSource.h:34
bool IsValid() const
Definition IMediaTimeSource.h:49
FMediaTimeStamp(const FTimespan &InTime)
Definition IMediaTimeSource.h:32
Definition IMediaTimeSource.h:213
virtual FTimespan GetTimecode()=0
virtual ~IMediaTimeSource()
Definition IMediaTimeSource.h:226
Definition Timespan.h:76
static FTimespan MinValue()
Definition Timespan.h:699
static FTimespan MaxValue()
Definition Timespan.h:686