AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
timebase.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef TIMEBASE_H
9 #define TIMEBASE_H
10 
11 #include "ajabase/common/public.h"
13 
19 {
20 public:
21 
22  AJATimeBase();
23 
29  AJATimeBase(AJA_FrameRate ajaFrameRate);
30 
37  AJATimeBase(int64_t frameTimeScale, int64_t frameDuration);
38 
46  AJATimeBase(int64_t frameTimeScale, int64_t frameDuration, int64_t audioRate);
47 
53  AJATimeBase(const AJATimeBase &other);
54 
55  virtual ~AJATimeBase();
56 
60  void SetToDefault(void);
61 
70  void SetFrameRate(int64_t frameTimeScale, int64_t frameDuration);
71 
79  void SetAJAFrameRate(AJA_FrameRate ajaFrameRate);
80 
89  void GetFrameRate(int64_t& frameTimeScale, int64_t& frameDuration) const;
90  void GetFrameRate(uint32_t& frameTimeScale, uint32_t& frameDuration) const;
91 
97  int64_t GetFrameTimeScale(void) const;
98 
104  void SetFrameTimeScale(int64_t timeScale);
105 
111  int64_t GetFrameDuration(void) const;
112 
118  void SetAudioRate(int64_t rate);
119 
125  int64_t GetAudioRate() const;
126 
132  AJA_FrameRate GetAJAFrameRate(void) const;
133 
140  void SetTickRate(int64_t rate);
141 
147  int64_t GetTickRate() const;
148 
156  int64_t FramesToSamples(int64_t frames, bool round = false) const;
157 
165  int64_t FramesToTicks(int64_t frames, bool round = false) const;
166 
173  double FramesToSeconds(int64_t frames) const;
174 
181  double ScaleUnitsToSeconds(int64_t num) const;
182 
190  int64_t FramesToMicroseconds(int64_t frames, bool round = false) const;
191 
199  int64_t FramesToNanoseconds100(int64_t frames, bool round = false) const;
200 
208  int64_t SamplesToFrames(int64_t samples, bool round = false) const;
209 
217  int64_t SamplesToTicks(int64_t samples, bool round = false) const;
218 
225  double SamplesToSeconds(int64_t samples);
226 
234  int64_t SamplesToMicroseconds(int64_t samples, bool round = false);
235 
243  int64_t TicksToFrames(int64_t ticks, bool round = false);
244 
252  int64_t TicksToSamples(int64_t ticks, bool round = false);
253 
260  double TicksToSeconds(int64_t ticks);
261 
269  int64_t TicksToMicroseconds(int64_t ticks, bool round = false);
270 
278  int64_t SecondsToFrames(double seconds, bool round = false);
279 
287  int64_t SecondsToSamples(double seconds, bool round = false);
288 
296  int64_t SecondsToTicks(double seconds, bool round = false);
297 
305  int64_t MicrosecondsToFrames(int64_t microseconds, bool round = false);
306 
314  int64_t Nanoseconds100ToFrames(int64_t nanoseconds100, bool round = false);
315 
323  int64_t MicrosecondsToSamples(int64_t microseconds, bool round = false);
324 
332  int64_t MicrosecondsToTicks(int64_t microseconds, bool round = false);
333 
339  int64_t GetSystemTicks();
340 
347  bool IsCloseTo(const AJATimeBase &timeBase) const;
348 
356  bool IsCloseTo(int64_t frameTimeScale, int64_t frameDuration) const;
357 
366  bool IsNonIntegralRatio(void) const;
367 
373  float GetFramesPerSecond(void) const;
374  double GetFramesPerSecondDouble(void) const;
375 
376  AJATimeBase& operator=(const AJATimeBase &t);
377  bool operator==(const AJATimeBase &val) const;
378  bool operator!=(const AJATimeBase &val) const;
379 
387  static int64_t SecondsToMicroseconds(double seconds, bool round = false);
388 
395  static double MicrosecondsToSeconds(int64_t microseconds);
396 
397  static int64_t Convert(int64_t inValue, int64_t inRate, int64_t outRate, bool round, bool large);
398  static int64_t Convert(int64_t inValue, int64_t inScale, int64_t inDuration,
399  int64_t outScale, int64_t outDuration, bool round, bool large);
400 
401 private:
402  void SetAJAFrameRatePrivate(AJA_FrameRate ajaFrameRate);
403 
404  int64_t mFrameTimeScale;
405  int64_t mFrameDuration;
406  int64_t mAudioRate;
407  int64_t mTickRate;
408 };
409 
410 #endif
411 
AJA_EXPORT
#define AJA_EXPORT
Definition: export.h:34
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::operator==
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14737
public.h
Master header for the ajabase library.
GetFramesPerSecond
double GetFramesPerSecond(const NTV2FrameRate inFrameRate)
Definition: ntv2utils.cpp:1737
AJA_FrameRate
AJA_FrameRate
Definition: videotypes.h:210
AJATimeBase
Definition: timebase.h:18
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::operator!=
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14762
videotypes.h
Declares the enumeration constants used in the ajabase library.