libdcp
Public Member Functions | Public Attributes | Private Member Functions | List of all members
dcp::Time Class Reference

A representation of time within a DCP. More...

#include <dcp_time.h>

Public Member Functions

 Time ()
 
 Time (int frame, double frames_per_second, int tcr)
 
 Time (int h_, int m_, int s_, int e_, int tcr_)
 
 Time (double seconds, int tcr)
 
 Time (std::string time, boost::optional< int > tcr)
 
std::string as_string (Standard standard) const
 
double as_seconds () const
 
int64_t as_editable_units_floor (int tcr_) const
 
int64_t as_editable_units_ceil (int tcr_) const
 
Time rebase (int tcr_) const
 
Timeoperator+= (Time const &o)
 
Timeoperator-= (Time const &o)
 

Public Attributes

int h = 0
 hours
 
int m = 0
 minutes
 
int s = 0
 seconds
 
int e = 0
 editable units (where 1 editable unit is 1 / tcr_ seconds)
 
int tcr = 1
 timecode rate: the number of editable units per second.
 

Private Member Functions

void set (double seconds, int tcr)
 

Detailed Description

A representation of time within a DCP.

Definition at line 72 of file dcp_time.h.

Constructor & Destructor Documentation

◆ Time() [1/5]

dcp::Time::Time ( )
inline

Construct a zero Time

Definition at line 76 of file dcp_time.h.

◆ Time() [2/5]

Time::Time ( int  frame,
double  frames_per_second,
int  tcr 
)

Construct a Time.

Parameters
frameFrame index (starting from 0).
frames_per_secondFrames per second.
tcrTimecode rate.

Definition at line 57 of file dcp_time.cc.

◆ Time() [3/5]

dcp::Time::Time ( int  h_,
int  m_,
int  s_,
int  e_,
int  tcr_ 
)
inline

Construct a Time from hours, minutes, seconds, editable units and a timecode rate.

Parameters
h_Hours.
m_Minutes.
s_Seconds.
e_Editable units (where 1 editable unit is 1 / tcr_ seconds)
tcr_Timecode rate; i.e. number of editable units per second.

Definition at line 92 of file dcp_time.h.

◆ Time() [4/5]

Time::Time ( double  seconds,
int  tcr 
)

Construct a Time from a number of seconds and a timecode rate

Parameters
secondsA number of seconds
tcr_Timecode rate

Definition at line 63 of file dcp_time.cc.

◆ Time() [5/5]

dcp::Time::Time ( std::string  time,
boost::optional< int >  tcr 
)
Parameters
timeString of the form HH:MM:SS:EE for SMPTE HH:MM:SS:E[E[E]] or HH:MM:SS.s[s[s]] for Interop where HH are hours, MM minutes, SS seconds, EE editable units and sss millseconds.
tcr_Timecode rate if this is a SMPTE time, otherwise empty for an Interop time

Member Function Documentation

◆ as_editable_units_ceil()

int64_t Time::as_editable_units_ceil ( int  tcr_) const
Parameters
tcr_Timecode rate with which the return value should be counted
Returns
the total number of editable units that this time consists of at the specified timecode rate, rounded up to the nearest editable unit. For example, as_editable_units_ceil(24) returns the total time in frames at 24fps.

Definition at line 350 of file dcp_time.cc.

◆ as_editable_units_floor()

int64_t Time::as_editable_units_floor ( int  tcr_) const
Parameters
tcr_Timecode rate with which the return value should be counted
Returns
the total number of editable units that this time consists of at the specified timecode rate, rounded down to the nearest editable unit. For example, as_editable_units_floor(24) returns the total time in frames at 24fps.

Definition at line 343 of file dcp_time.cc.

◆ as_seconds()

double Time::as_seconds ( ) const
Returns
the total number of seconds that this time consists of

Definition at line 357 of file dcp_time.cc.

◆ as_string()

string Time::as_string ( Standard  standard) const
Returns
A string of the form h:m:s:e padded as in 00:00:00:000 (for Interop) or 00:00:00:00 (for SMPTE)

Definition at line 328 of file dcp_time.cc.

◆ rebase()

Time Time::rebase ( int  tcr_) const
Parameters
tcr_New timecode rate
Returns
A new Time which is this time at the spcified new timecode rate

Definition at line 364 of file dcp_time.cc.

◆ set()

void Time::set ( double  seconds,
int  tcr_ 
)
private

Construct a Time with specified timecode rate and using the supplied number of seconds.

Parameters
secondsA number of seconds.
tcr_Timecode rate to use.

Definition at line 76 of file dcp_time.cc.


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