libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Timecode Class Reference

Class for holding and manipulating timecode. More...

#include <timecode.h>

Classes

class  Mode
 Describes the timecode mode (frame rate and drop-frame status). More...
 

Public Types

enum  TimecodeType { NDF24 , NDF25 , NDF30 , DF30 }
 Standard timecode types. More...
 
enum  Flags { DropFrame = 0x00000001 , FirstField = 0x00000002 }
 Timecode flag bits. More...
 
using FrameNumber = uint64_t
 Type used to represent absolute frame numbers.
 
using DigitType = uint8_t
 Type used for individual timecode digit fields.
 
using FlagsType = uint32_t
 Type used for timecode flag bitmasks.
 

Public Member Functions

 Timecode ()=default
 Constructs a default (invalid) timecode.
 
 Timecode (const Mode &md)
 Constructs a timecode with the given mode and zeroed digits.
 
 Timecode (DigitType h, DigitType m, DigitType s, DigitType f)
 Constructs a timecode with explicit digit values and no specific mode.
 
 Timecode (const Mode &md, DigitType h, DigitType m, DigitType s, DigitType f)
 Constructs a timecode with a mode and explicit digit values.
 
 Timecode (const String &str)
 Constructs a timecode by parsing a string representation.
 
bool operator== (const Timecode &other) const
 
bool operator!= (const Timecode &other) const
 
bool operator> (const Timecode &other) const
 
bool operator< (const Timecode &other) const
 
bool operator>= (const Timecode &other) const
 
bool operator<= (const Timecode &other) const
 
bool isValid () const
 Returns true if the timecode mode is valid.
 
bool isDropFrame () const
 Returns true if the timecode uses drop-frame counting.
 
bool isFirstField () const
 Returns true if this timecode represents the first field of an interlaced frame.
 
uint32_t fps () const
 Returns the frames-per-second rate.
 
Mode mode () const
 Returns the timecode mode.
 
Timecodeoperator++ ()
 Pre-increment: advances the timecode by one frame.
 
Timecode operator++ (int)
 Post-increment: advances the timecode by one frame, returning the previous value.
 
Timecodeoperator-- ()
 Pre-decrement: moves the timecode back by one frame.
 
Timecode operator-- (int)
 Post-decrement: moves the timecode back by one frame, returning the previous value.
 
void set (DigitType h, DigitType m, DigitType s, DigitType f)
 Sets the timecode digit fields directly.
 
DigitType hour () const
 Returns the hour digit.
 
DigitType min () const
 Returns the minute digit.
 
DigitType sec () const
 Returns the second digit.
 
DigitType frame () const
 Returns the frame digit.
 
const VtcFormatvtcFormat () const
 Returns the underlying libvtc format pointer from the mode.
 
 operator String () const
 Implicit conversion to String using SMPTE format.
 
std::pair< String, ErrortoString (const VtcStringFormat *fmt=&VTC_STR_FMT_SMPTE) const
 Converts the timecode to a string.
 
std::pair< FrameNumber, ErrortoFrameNumber () const
 Converts the timecode to an absolute frame number.
 

Static Public Member Functions

static Timecode fromFrameNumber (const Mode &mode, FrameNumber frameNumber)
 Constructs a Timecode from a mode and absolute frame number.
 
static std::pair< Timecode, ErrorfromString (const String &str)
 Parses a Timecode from its string representation.
 

Detailed Description

Class for holding and manipulating timecode.

While this class supports all the capabilities of SMPTE timecode, it exceeds it in many ways. It makes no restrictions on hour counts above 23, or frame rates above 30. It will, of course, attempt to do the best it can when asked to output a SMPTE timecode (i.e. the hours will be modulo 24).

Example
// Create a 24fps timecode at 01:00:00:00
++tc; // advance to 01:00:00:01
// Convert to string
auto [str, err] = tc.toString(); // "01:00:00:01"
// From absolute frame number
// Parse from string
auto [tc3, err2] = Timecode::fromString("10:30:00:00");
Dynamic array container wrapping std::vector.
Definition list.h:40
Class for holding and manipulating timecode.
Definition timecode.h:45
static std::pair< Timecode, Error > fromString(const String &str)
Parses a Timecode from its string representation.
static Timecode fromFrameNumber(const Mode &mode, FrameNumber frameNumber)
Constructs a Timecode from a mode and absolute frame number.
@ NDF24
24 fps non-drop-frame (maps to VTC_FORMAT_24)
Definition timecode.h:53
Internally delegates all timecode logic to libvtc.

Member Enumeration Documentation

◆ Flags

Timecode flag bits.

Enumerator
DropFrame 

Indicates drop-frame timecode.

FirstField 

Indicates the first field of an interlaced frame.

◆ TimecodeType

Standard timecode types.

Enumerator
NDF24 

24 fps non-drop-frame (maps to VTC_FORMAT_24)

NDF25 

25 fps non-drop-frame (maps to VTC_FORMAT_25)

NDF30 

30 fps non-drop-frame (maps to VTC_FORMAT_30_NDF)

DF30 

29.97 fps drop-frame (maps to VTC_FORMAT_29_97_DF)

Constructor & Destructor Documentation

◆ Timecode() [1/4]

Timecode::Timecode ( const Mode md)
inline

Constructs a timecode with the given mode and zeroed digits.

Parameters
mdThe timecode mode.

◆ Timecode() [2/4]

Timecode::Timecode ( DigitType  h,
DigitType  m,
DigitType  s,
DigitType  f 
)
inline

Constructs a timecode with explicit digit values and no specific mode.

Parameters
hHour digit.
mMinute digit.
sSecond digit.
fFrame digit.

◆ Timecode() [3/4]

Timecode::Timecode ( const Mode md,
DigitType  h,
DigitType  m,
DigitType  s,
DigitType  f 
)
inline

Constructs a timecode with a mode and explicit digit values.

Parameters
mdThe timecode mode.
hHour digit.
mMinute digit.
sSecond digit.
fFrame digit.

◆ Timecode() [4/4]

Timecode::Timecode ( const String str)
inline

Constructs a timecode by parsing a string representation.

Parameters
strThe string to parse.

Member Function Documentation

◆ fromFrameNumber()

static Timecode Timecode::fromFrameNumber ( const Mode mode,
FrameNumber  frameNumber 
)
static

Constructs a Timecode from a mode and absolute frame number.

Parameters
modeThe timecode mode (frame rate / drop-frame).
frameNumberThe absolute frame number to convert.
Returns
A Timecode representing the given frame number.

◆ fromString()

static std::pair< Timecode, Error > Timecode::fromString ( const String str)
static

Parses a Timecode from its string representation.

Parameters
strThe string to parse (e.g. "01:00:00:00").
Returns
A pair of the parsed Timecode and an Error indicating success or failure.

◆ set()

void Timecode::set ( DigitType  h,
DigitType  m,
DigitType  s,
DigitType  f 
)
inline

Sets the timecode digit fields directly.

Parameters
hHour digit.
mMinute digit.
sSecond digit.
fFrame digit.

◆ toFrameNumber()

std::pair< FrameNumber, Error > Timecode::toFrameNumber ( ) const

Converts the timecode to an absolute frame number.

Returns
A pair of the frame number and an Error.

◆ toString()

std::pair< String, Error > Timecode::toString ( const VtcStringFormat fmt = &VTC_STR_FMT_SMPTE) const

Converts the timecode to a string.

Parameters
fmtThe string format to use (default: SMPTE).
Returns
A pair of the formatted string and an Error.

The documentation for this class was generated from the following file: