Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
gamp::av::PTS Class Reference

Presentation Timestamp (PTS) with added System Clock Reference (SCR) via set(long, int) and its interpolation via get(long), as well as giving raw access via getLast(). More...

#include <PTS.hpp>

Collaboration diagram for gamp::av::PTS:

Public Types

typedef jau::function< float()> FloatValue
 An external float value getter.
 

Public Member Functions

 PTS (FloatValue speed) noexcept
 Create new instance, initializing pts with TimeFrameI#INVALID_PTS and system-clock timestamp with zero.
 
 PTS (FloatValue speed, uint64_t scr, uint32_t pts) noexcept
 Create new instance.
 
constexpr_atomic uint32_t diff (uint64_t currentMillis, const PTS &rhs) const noexcept
 Returns get(long) - rhs.
 
constexpr_atomic uint32_t diffLast (const PTS &rhs) const noexcept
 Returns getLast() - rhs.
 
constexpr_atomic uint32_t get (uint64_t currentMillis) const noexcept
 Returns the last() updated PTS, interpolated by scr() System Clock Reference (SCR) delta to given currentMillis and playback getSpeed().
 
uint32_t getCurrent () const noexcept
 Returns get(long) passing Clock#currentMillis().
 
std::string getLastTimeStr (bool addFractions) const noexcept
 Returns getLast() as time string representation via toTimeStr(long, boolean).
 
std::string getSCRTimeStr (bool addFractions) const noexcept
 Returns scr() as time string representation via toTimeStr(long, boolean).
 
float getSpeed () const noexcept
 Returns the external playback speed.
 
std::string getTimeStr (uint64_t currentMillis, bool addFractions)
 Returns get(long) as time string representation via toTimeStr(long, boolean).
 
constexpr_atomic bool isEOS () const noexcept
 Returns true if getLast() equals to TimeFrameI#END_OF_STREAM_PTS, indicating end of stream (EOS).
 
constexpr_atomic bool isValid () const noexcept
 Returns true if getLast() is unequal to TimeFrameI#INVALID_PTS.
 
constexpr_atomic uint32_t last () const noexcept
 Returns the last updated PTS value via set(long, int) w/o System Clock Reference (SCR) interpolation.
 
constexpr_atomic uint64_t scr () const noexcept
 Returns the System Clock Reference (SCR) in milliseconds of last PTS update via set(long, int).
 
void set (const PTS &other) noexcept
 Updates the PTS value with values from other PTS instance.
 
void set (uint64_t scr, uint32_t pts) noexcept
 Updates the PTS value with given System Clock Reference (SCR) in milliseconds.
 
void setPTS (uint32_t pts) noexcept
 Sets the PTS value, see set(long, int).
 
void setSCR (uint64_t currentMillis) noexcept
 Sets the System Clock Reference (SCR) in milliseconds of last PTS update, see set(long, int).
 
std::string toString () noexcept
 
std::string toString (uint64_t currentMillis) noexcept
 
std::string toTimeStr (uint64_t millis)
 Returns a full time string representation 'HH:mm:ss.SSS'.
 
std::string toTimeStr (uint64_t millis, bool addFractions) const noexcept
 Returns a time string representation '[HH:]mm:ss[.SSS]', dropping unused hour quantities and fractions of seconds optionally.
 

Static Public Member Functions

static uint32_t toMillis (const std::string &datestr) noexcept
 Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'.
 

Detailed Description

Presentation Timestamp (PTS) with added System Clock Reference (SCR) via set(long, int) and its interpolation via get(long), as well as giving raw access via getLast().

The relative millisecond PTS since start of the presentation stored in uint32_t covers a time span of 4'294'967'293 ms or 4'294'967 seconds or 49 days.

Definition at line 41 of file PTS.hpp.

Member Typedef Documentation

◆ FloatValue

An external float value getter.

Definition at line 44 of file PTS.hpp.

Constructor & Destructor Documentation

◆ PTS() [1/2]

gamp::av::PTS::PTS ( FloatValue speed)
inlinenoexcept

Create new instance, initializing pts with TimeFrameI#INVALID_PTS and system-clock timestamp with zero.

Parameters
speedexternal FloatValue getter for playback speed.
See also
#set(long, int)

Definition at line 59 of file PTS.hpp.

Here is the caller graph for this function:

◆ PTS() [2/2]

gamp::av::PTS::PTS ( FloatValue speed,
uint64_t scr,
uint32_t pts )
inlinenoexcept

Create new instance.

Parameters
speedexternal FloatValue getter for playback speed.
scrSystem Clock Reference (SCR) in milliseconds of taken pts value, i.e. Clock#currentMillis().
ptsthe presentation timestamp (PTS) in milliseconds
See also
#set(long, int)

Definition at line 70 of file PTS.hpp.

Member Function Documentation

◆ isValid()

constexpr_atomic bool gamp::av::PTS::isValid ( ) const
inlinenoexcept

Returns true if getLast() is unequal to TimeFrameI#INVALID_PTS.

Definition at line 75 of file PTS.hpp.

◆ isEOS()

constexpr_atomic bool gamp::av::PTS::isEOS ( ) const
inlinenoexcept

Returns true if getLast() equals to TimeFrameI#END_OF_STREAM_PTS, indicating end of stream (EOS).

Definition at line 78 of file PTS.hpp.

◆ scr()

constexpr_atomic uint64_t gamp::av::PTS::scr ( ) const
inlinenoexcept

Returns the System Clock Reference (SCR) in milliseconds of last PTS update via set(long, int).

Definition at line 81 of file PTS.hpp.

Here is the caller graph for this function:

◆ getSCRTimeStr()

std::string gamp::av::PTS::getSCRTimeStr ( bool addFractions) const
inlinenoexcept

Returns scr() as time string representation via toTimeStr(long, boolean).

Definition at line 84 of file PTS.hpp.

◆ last()

constexpr_atomic uint32_t gamp::av::PTS::last ( ) const
inlinenoexcept

Returns the last updated PTS value via set(long, int) w/o System Clock Reference (SCR) interpolation.

Definition at line 89 of file PTS.hpp.

Here is the caller graph for this function:

◆ getLastTimeStr()

std::string gamp::av::PTS::getLastTimeStr ( bool addFractions) const
inlinenoexcept

Returns getLast() as time string representation via toTimeStr(long, boolean).

Definition at line 92 of file PTS.hpp.

◆ getSpeed()

float gamp::av::PTS::getSpeed ( ) const
inlinenoexcept

Returns the external playback speed.

Definition at line 97 of file PTS.hpp.

◆ set() [1/2]

void gamp::av::PTS::set ( uint64_t scr,
uint32_t pts )
inlinenoexcept

Updates the PTS value with given System Clock Reference (SCR) in milliseconds.

Parameters
scrSystem Clock Reference (SCR) in milliseconds of taken PTS value, i.e. Clock#currentMillis().
ptsthe presentation timestamp (PTS) in milliseconds

Definition at line 104 of file PTS.hpp.

◆ setPTS()

void gamp::av::PTS::setPTS ( uint32_t pts)
inlinenoexcept

Sets the PTS value, see set(long, int).

Definition at line 109 of file PTS.hpp.

◆ setSCR()

void gamp::av::PTS::setSCR ( uint64_t currentMillis)
inlinenoexcept

Sets the System Clock Reference (SCR) in milliseconds of last PTS update, see set(long, int).

Definition at line 111 of file PTS.hpp.

◆ set() [2/2]

void gamp::av::PTS::set ( const PTS & other)
inlinenoexcept

Updates the PTS value with values from other PTS instance.

Parameters
othersource PTS values
See also
#get(long)

Definition at line 118 of file PTS.hpp.

◆ get()

constexpr_atomic uint32_t gamp::av::PTS::get ( uint64_t currentMillis) const
inlinenoexcept

Returns the last() updated PTS, interpolated by scr() System Clock Reference (SCR) delta to given currentMillis and playback getSpeed().

     last_pts + (uint32_t) ( ( currentMillis - SCR ) * speed + 0.5f )
Parameters
currentMilliscurrent system clock in milliseconds, i.e. Clock#currentMillis().
See also
#set(long, int)

Definition at line 131 of file PTS.hpp.

Here is the caller graph for this function:

◆ getCurrent()

uint32_t gamp::av::PTS::getCurrent ( ) const
inlinenoexcept

Returns get(long) passing Clock#currentMillis().

Definition at line 136 of file PTS.hpp.

◆ getTimeStr()

std::string gamp::av::PTS::getTimeStr ( uint64_t currentMillis,
bool addFractions )
inline

Returns get(long) as time string representation via toTimeStr(long, boolean).

Definition at line 139 of file PTS.hpp.

◆ diffLast()

constexpr_atomic uint32_t gamp::av::PTS::diffLast ( const PTS & rhs) const
inlinenoexcept

Returns getLast() - rhs.

getLast().

Definition at line 144 of file PTS.hpp.

◆ diff()

constexpr_atomic uint32_t gamp::av::PTS::diff ( uint64_t currentMillis,
const PTS & rhs ) const
inlinenoexcept

Returns get(long) - rhs.

get(long).

Definition at line 149 of file PTS.hpp.

◆ toString() [1/2]

std::string gamp::av::PTS::toString ( )
inlinenoexcept

Definition at line 153 of file PTS.hpp.

◆ toString() [2/2]

std::string gamp::av::PTS::toString ( uint64_t currentMillis)
inlinenoexcept

Definition at line 155 of file PTS.hpp.

◆ toTimeStr() [1/2]

std::string gamp::av::PTS::toTimeStr ( uint64_t millis,
bool addFractions ) const
inlinenoexcept

Returns a time string representation '[HH:]mm:ss[.SSS]', dropping unused hour quantities and fractions of seconds optionally.

Parameters
milliscomplete time in milliseconds
addFractionstoggle for fractions of seconds
See also
#toTimeStr(long)

Definition at line 163 of file PTS.hpp.

Here is the caller graph for this function:

◆ toTimeStr() [2/2]

std::string gamp::av::PTS::toTimeStr ( uint64_t millis)
inline

Returns a full time string representation 'HH:mm:ss.SSS'.

Parameters
milliscomplete time in milliseconds
See also
#toTimeStr(long, boolean)

Definition at line 193 of file PTS.hpp.

◆ toMillis()

uint32_t gamp::av::PTS::toMillis ( const std::string & datestr)
staticnoexcept

Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'.

Parameters
vthe timestamp string to parse.

Definition at line 44 of file gamp_av_base.cpp.

Here is the caller graph for this function:

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