AJA NTV2 SDK  18.1.0.2439
NTV2 SDK 18.1.0.2439
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 
91 #if !defined(NTV2_DEPRECATE_18_1)
92  void GetFrameRate(uint32_t& frameTimeScale, uint32_t& frameDuration) const;
93 #endif
94 
100  int64_t GetFrameTimeScale(void) const;
101 
107  void SetFrameTimeScale(int64_t timeScale);
108 
114  int64_t GetFrameDuration(void) const;
115 
121  void SetAudioRate(int64_t rate);
122 
128  int64_t GetAudioRate() const;
129 
135  AJA_FrameRate GetAJAFrameRate(void) const;
136 
143  void SetTickRate(int64_t rate);
144 
150  int64_t GetTickRate() const;
151 
159  int64_t FramesToSamples(int64_t frames, bool round = false) const;
160 
168  int64_t FramesToTicks(int64_t frames, bool round = false) const;
169 
176  double FramesToSeconds(int64_t frames) const;
177 
184  double ScaleUnitsToSeconds(int64_t num) const;
185 
193  int64_t FramesToMicroseconds(int64_t frames, bool round = false) const;
194 
202  int64_t FramesToNanoseconds100(int64_t frames, bool round = false) const;
203 
211  int64_t SamplesToFrames(int64_t samples, bool round = false) const;
212 
220  int64_t SamplesToTicks(int64_t samples, bool round = false) const;
221 
228  double SamplesToSeconds(int64_t samples);
229 
237  int64_t SamplesToMicroseconds(int64_t samples, bool round = false);
238 
246  int64_t TicksToFrames(int64_t ticks, bool round = false);
247 
255  int64_t TicksToSamples(int64_t ticks, bool round = false);
256 
263  double TicksToSeconds(int64_t ticks);
264 
272  int64_t TicksToMicroseconds(int64_t ticks, bool round = false);
273 
281  int64_t SecondsToFrames(double seconds, bool round = false);
282 
290  int64_t SecondsToSamples(double seconds, bool round = false);
291 
299  int64_t SecondsToTicks(double seconds, bool round = false);
300 
308  int64_t MicrosecondsToFrames(int64_t microseconds, bool round = false);
309 
317  int64_t Nanoseconds100ToFrames(int64_t nanoseconds100, bool round = false);
318 
326  int64_t MicrosecondsToSamples(int64_t microseconds, bool round = false);
327 
335  int64_t MicrosecondsToTicks(int64_t microseconds, bool round = false);
336 
342  int64_t GetSystemTicks();
343 
350  bool IsCloseTo(const AJATimeBase &timeBase) const;
351 
359  bool IsCloseTo(int64_t frameTimeScale, int64_t frameDuration) const;
360 
369  bool IsNonIntegralRatio(void) const;
370 
376  float GetFramesPerSecond(void) const;
377  double GetFramesPerSecondDouble(void) const;
378 
379  AJATimeBase& operator=(const AJATimeBase &t);
380  bool operator==(const AJATimeBase &val) const;
381  bool operator!=(const AJATimeBase &val) const;
382 
390  static int64_t SecondsToMicroseconds(double seconds, bool round = false);
391 
398  static double MicrosecondsToSeconds(int64_t microseconds);
399 
400  static int64_t Convert(int64_t inValue, int64_t inRate, int64_t outRate, bool round, bool large);
401  static int64_t Convert(int64_t inValue, int64_t inScale, int64_t inDuration,
402  int64_t outScale, int64_t outDuration, bool round, bool large);
403 
404 private:
405  void SetAJAFrameRatePrivate(AJA_FrameRate ajaFrameRate);
406 
407  int64_t mFrameTimeScale;
408  int64_t mFrameDuration;
409  int64_t mAudioRate;
410  int64_t mTickRate;
411 };
412 
413 #endif
414 
#define AJA_EXPORT
Definition: export.h:34
double GetFramesPerSecond(const NTV2FrameRate inFrameRate)
Definition: ntv2utils.cpp:1833
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14762
Master header for the ajabase library.
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14737
Declares the enumeration constants used in the ajabase library.
AJA_FrameRate
Definition: videotypes.h:210