KTime
#include<ktime.h>

List of all members.

Detailed Description

Class to encapsulate time units.

Definition at line65of filektime.h.


Time Modes and Protocols

enum ETimeMode
 Time modes.More...
enum ETimeProtocol
 Time protocols.More...
static void SetGlobalTimeMode(ETimeModepTimeMode, double pFrameRate=0.0)
 Set default time mode.
staticETimeMode GetGlobalTimeMode()
 Get default time mode.
static void SetGlobalTimeProtocol(ETimeProtocolpTimeProtocol)
 Set default time protocol.
staticETimeProtocol GetGlobalTimeProtocol()
 Get default time protocol.
static double GetFrameRate(ETimeModepTimeMode)
 Get frame rate associated with time mode, in frames per second.
staticETimeMode ConvertFrameRateToTimeMode(double pFrameRate, double lPrecision=0.00000001)
 Get time mode associated with frame rate.

Time Conversion

void Set(kLongLong pTime)
 Set time in internal format.
const kLongLong& Get() const
 Get time in internal format.
void SetMilliSeconds(kLongLong pMilliSeconds)
 Set time in milliseconds.
kLongLong GetMilliSeconds() const
 Get time in milliseconds.
void SetSecondDouble(double pTime)
 Set time in seconds.
double GetSecondDouble() const
 Get time in seconds.
void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0)
 Set time in hour/minute/second/frame/field format.
void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, int pTimeMode, double pFramerate=0.0)
 Set time in hour/minute/second/frame/field/residual format.
bool GetTime(kLongLong&pHour, kLongLong&pMinute, kLongLong&pSecond, kLongLong&pFrame, kLongLong&pField, kLongLong&pResidual, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get time in hour/minute/second/frame/field/residual format.
KTime GetFramedTime(bool pRound=true)
 Set time in internal format.
kLongLong GetHour(bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get number of hours in time.
kLongLong GetMinute(bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get number of minutes in time.
kLongLong GetSecond(bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get number of seconds in time.
kLongLong GetFrame(bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get number of frames in time.
kLongLong GetField(bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get number of fields in time.
kLongLong GetResidual(int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
 Get residual time exceeding last full field.
char * GetTimeString(char *pTimeString, int pInfo=5, int pTimeMode=eDEFAULT_MODE, int pTimeFormat=eDEFAULT_PROTOCOL, double pFramerate=0.0) const
 Get time in a human readable format.
void SetTimeString(char *pTime, int pTimeMode=eDEFAULT_MODE, int pTimeFormat=eDEFAULT_PROTOCOL, double pFramerate=0.0)
 Set time in a human readable format.

Time Operators

bool operator==(constKTime&pTime) const
 Equality operator.
bool operator!=(constKTime&pTime) const
 Inequality operator.
bool operator>=(constKTime&pTime) const
 Superior or equal to operator.
bool operator<=(constKTime&pTime) const
 Inferior or equal to operator.
bool operator>(constKTime&pTime) const
 Superior to operator.
bool operator<(constKTime&pTime) const
 Inferior to operator.
KTimeoperator=(constKTime&pTime)
 Assignment operator.
KTimeoperator+=(constKTime&pTime)
 Addition operator.
KTimeoperator-=(constKTime&pTime)
 Subtraction operator.
KTime operator+(constKTime&pTime) const
 Addition operator.
KTime operator-(constKTime&pTime) const
 Subtraction operator.
KTime operator*(const int Mult) const
 Multiplication operator.
KTime operator/(constKTime&pTime) const
 Division operator.
KTime operator*(constKTime&pTime) const
 Multiplication operator.
KTimeoperator++()
 Increment time of one unit of the internal format.
KTimeoperator--()
 Decrement time of one unit of the internal format.

Public Member Functions

 KTime(kLongLong pTime=0)
 Constructor.

Member Enumeration Documentation

Time modes.

Remarks:
ModeeNTSC_DROP_FRAMEis used for broadcasting operations where clock time must be (almost) in sync with timecode. To bring back color NTSC timecode with clock time, this mode drops 2 frames per minute except for every 10 minutes (00, 10, 20, 30, 40, 50). 108 frames are dropped per hour. Over 24 hours the error is 2 frames and 1/4 of a frame.
ModeeNTSC_FULL_FRAMErepresents a time address and therefore is NOT IN SYNC with clock time. A timecode of 01:00:00:00 equals a clock time of 01:00:03:18.
ModeeFRAMES30_DROPdrops 2 frames every minutes except for every 10 minutes (00, 10, 20, 30, 40, 50). This timecode represents a time address and is therefore NOT IN SYNC with clock time. A timecode of 01:00:03:18 equals a clock time of 01:00:00:00. It is the close counterpart of modeeNTSC_FULL_FRAME. Time modes.
  • eDEFAULT_MODE
  • eFRAMES120120 frames/s
  • eFRAMES100100 frames/s
  • eFRAMES6060 frames/s
  • eFRAMES5050 frames/s
  • eFRAMES4848 frame/s
  • eFRAMES3030 frames/s BLACK&WHITE NTSC
  • eFRAMES30_DROP30 frames/s use when diplay in frame is selected(equivalent to NTSC_DROP)
  • eNTSC_DROP_FRAME29.97002617 frames/s drop COLOR NTSC
  • eNTSC_FULL_FRAME29.97002617 frames/s COLOR NTSC
  • ePAL25 frames/s PAL/SECAM
  • eCINEMA24 frames/s
  • eFRAMES10001000 milli/s (use for datetime)
  • eCINEMA_ND23.976 frames/s
  • eCUSTOMCustom Framerate value

Definition at line123of filektime.h.

Time protocols.

  • eSMPTESMPTE Protocol
  • eFRAMEFrame count
  • eDEFAULT_PROTOCOLDefault protocol (initialized to eFRAMES)

Definition at line148of filektime.h.

Constructor&Destructor Documentation

KTime(kLongLong pTime=0 ) [inline]

Constructor.

Parameters:
pTime Initial value.

Definition at line73of filektime.h.

Member Function Documentation

static void SetGlobalTimeMode(ETimeMode pTimeMode,
double pFrameRate=0.0 
)[static]

Set default time mode.

Parameters:
pTimeMode Time mode identifier.
pFrameRate in case of timemode = custom, we specify the custom framerate to use: EX:12.5
Remarks:
It is meaningless to set default time mode toeDEFAULT_MODE.

staticETimeModeGetGlobalTimeMode( ) [static]

Get default time mode.

Returns:
Currently set time mode identifier.
Remarks:
Default time mode initial value is eFRAMES30.

static void SetGlobalTimeProtocol(ETimeProtocol pTimeProtocol ) [static]

Set default time protocol.

Parameters:
pTimeProtocol Time protocol identifier.
Remarks:
It is meaningless to set default time protocol toeDEFAULT_PROTOCOL.

staticETimeProtocolGetGlobalTimeProtocol( ) [static]

Get default time protocol.

Returns:
Currently set time protocol identifier.
Remarks:
Default time protocol initial value is eSMPTE.

static double GetFrameRate(ETimeMode pTimeMode ) [static]

Get frame rate associated with time mode, in frames per second.

Parameters:
pTimeMode Time mode identifier.
Returns:
Frame rate value.

staticETimeModeConvertFrameRateToTimeMode(double pFrameRate,
double lPrecision=0.00000001 
)[static]

Get time mode associated with frame rate.

Parameters:
pFrameRate The frame rate value.
lPrecision The tolerance value.
Returns:
The corresponding time mode identifier oreDEFAULT_MODEif no time mode associated to the given frame rate is found.

void Set(kLongLong pTime ) [inline]

Set time in internal format.

Parameters:
pTime Time value to set.

Definition at line205of filektime.h.

const kLongLong&Get( ) const[inline]

Get time in internal format.

Returns:
Time value.

Definition at line210of filektime.h.

void SetMilliSeconds(kLongLong pMilliSeconds ) [inline]

Set time in milliseconds.

Parameters:
pMilliSeconds Time value to set.

Definition at line215of filektime.h.

kLongLong GetMilliSeconds( ) const[inline]

Get time in milliseconds.

Returns:
Time value.

Definition at line220of filektime.h.

void SetSecondDouble(double pTime ) 

Set time in seconds.

Parameters:
pTime Time value to set.

double GetSecondDouble( ) const

Get time in seconds.

Returns:
Time value.

void SetTime(int pHour,
int pMinute,
int pSecond,
int pFrame=0,
int pField=0,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)

Set time in hour/minute/second/frame/field format.

Parameters:
pHour The hours value.
pMinute The minutes value.
pSecond The seconds value.
pFrame The frames values.
pField The field value.
pTimeMode A time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Remarks:
Parameters pHour, pMinute, pSecond, pFrame and pField are summed together. For example, it is possible to set the time to 83 seconds in the following ways: SetTime(0,1,23) or SetTime(0,0,83).

void SetTime(int pHour,
int pMinute,
int pSecond,
int pFrame,
int pField,
int pResidual,
int pTimeMode,
double pFramerate=0.0 
)

Set time in hour/minute/second/frame/field/residual format.

Parameters:
pHour The hours value.
pMinute The minutes value.
pSecond The seconds value.
pFrame The frames values.
pField The field value.
pResidual The hundreths of frame value.
pTimeMode A time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Remarks:
Parameters pHour, pMinute, pSecond, pFrame, pField and pResidual are summed together, just like above. pResidual represents hundreths of frame, and won't necessarily correspond to an exact internal value.

The time mode can't have a default value, because otherwise SetTime(int, int, int, int, int, int) would be ambiguous. Please specify DEFAULT_MODE.

bool GetTime(kLongLong& pHour,
kLongLong& pMinute,
kLongLong& pSecond,
kLongLong& pFrame,
kLongLong& pField,
kLongLong& pResidual,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get time in hour/minute/second/frame/field/residual format.

Parameters:
pHour The returned hours value.
pMinute The returned minutes value.
pSecond The returned seconds value.
pFrame The returned frames values.
pField The returned field value.
pResidual The returned hundreths of frame value.
pTimeMode The time mode identifier which will dictate the extraction algorithm.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
trueif the pTimeMode parameter is a valid identifier and thus the extraction succeeded. If the function returnsfalse, all the values are set to 0.

KTimeGetFramedTime(bool pRound=true ) 

Set time in internal format.

Parameters:
pTime Time value to set.

kLongLong GetHour(bool pCummul=false,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get number of hours in time.

Parameters:
pCummul This parameter has no effect.
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Hours value.

kLongLong GetMinute(bool pCummul=false,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get number of minutes in time.

Parameters:
pCummul Iftrue, get total number of minutes. Iffalse, get number of minutes exceeding last full hour.
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Minutes value.

kLongLong GetSecond(bool pCummul=false,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get number of seconds in time.

Parameters:
pCummul Iftrue, get total number of seconds. Iffalse, get number of seconds exceeding last full minute.
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Seconds value.

kLongLong GetFrame(bool pCummul=false,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get number of frames in time.

Parameters:
pCummul Iftrue, get total number of frames. Iffalse, get number of frames exceeding last full second.
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Frames values.

kLongLong GetField(bool pCummul=false,
int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get number of fields in time.

Parameters:
pCummul Iftrue, get total number of fields. Iffalse, get number of fields exceeding last full frame.
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Fields value.

kLongLong GetResidual(int pTimeMode=eDEFAULT_MODE,
double pFramerate=0.0 
)const

Get residual time exceeding last full field.

Parameters:
pTimeMode Time mode identifier.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
Residual value.

char* GetTimeString(char * pTimeString,
int pInfo=5,
int pTimeMode=eDEFAULT_MODE,
int pTimeFormat=eDEFAULT_PROTOCOL,
double pFramerate=0.0 
)const

Get time in a human readable format.

Parameters:
pTimeString An array large enough to contain a minimum of 19 characters.
pInfo The amount of information if time protocol iseSMPTE:
  • 1 means hours only
  • 2 means hours and minutes
  • 3 means hours, minutes and seconds
  • 4 means hours, minutes, seconds and frames
  • 5 means hours, minutes, seconds, frames and field
  • 6 means hours, minutes, seconds, frames, field and residual value
pTimeMode Requested time mode.
pTimeFormat Requested time protocol.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM
Returns:
pTimeString parameter filled with a time value or set to a empty string if parameter pInfo is not valid.

void SetTimeString(char * pTime,
int pTimeMode=eDEFAULT_MODE,
int pTimeFormat=eDEFAULT_PROTOCOL,
double pFramerate=0.0 
)

Set time in a human readable format.

Parameters:
pTime An array of a maximum of 18 characters. If time protocol iseSMPTE, pTimeString must be formatted this way: "[hours:]minutes[:seconds[.frames[.fields]]]". Hours, minutes, seconds, frames and fields are parsed as integers and brackets indicate optional parts. If time protocol iseFRAME, pTimeString must be formatted this way: "frames". Frames is parsed as a 64 bits integer.
pTimeMode Given time mode.
pTimeFormat Given time protocol.
pFramerate indicate custom framerate in case of ptimemode = eCUSTOM

bool operator==(constKTimepTime ) const[inline]

Equality operator.

Definition at line411of filektime.h.

bool operator!=(constKTimepTime ) const[inline]

Inequality operator.

Definition at line414of filektime.h.

bool operator>=(constKTimepTime ) const[inline]

Superior or equal to operator.

Definition at line417of filektime.h.

bool operator<=(constKTimepTime ) const[inline]

Inferior or equal to operator.

Definition at line420of filektime.h.

bool operator>(constKTimepTime ) const[inline]

Superior to operator.

Definition at line423of filektime.h.

bool operator<(constKTimepTime ) const[inline]

Inferior to operator.

Definition at line426of filektime.h.

KTime&operator=(constKTimepTime ) [inline]

Assignment operator.

Definition at line429of filektime.h.

KTime&operator+=(constKTimepTime ) [inline]

Addition operator.

Definition at line432of filektime.h.

KTime&operator-=(constKTimepTime ) [inline]

Subtraction operator.

Definition at line435of filektime.h.

KTimeoperator+(constKTimepTime ) const

Addition operator.

KTimeoperator-(constKTimepTime ) const

Subtraction operator.

KTimeoperator*(const int Mult ) const

Multiplication operator.

KTimeoperator/(constKTimepTime ) const

Division operator.

KTimeoperator*(constKTimepTime ) const

Multiplication operator.

KTime&operator++( ) [inline]

Increment time of one unit of the internal format.

Definition at line453of filektime.h.

KTime&operator--( ) [inline]

Decrement time of one unit of the internal format.

Definition at line456of filektime.h.