avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Public Member Functions | List of all members
av::Timestamp Class Reference

The Timestamp class represents timestamp value and it timebase. More...

#include <timestamp.h>

Public Member Functions

 Timestamp () noexcept
 
 Timestamp (int64_t timestamp, const Rational &timebase) noexcept
 
template<typename Duration , typename = typename Duration::period, typename = std::enable_if_t<std::is_integral_v<typename Duration::rep>>>
constexpr Timestamp (const Duration &duration)
 Create AvCpp/FFmpeg compatible timestamp value from the std::chrono::duration/boost::chrono::duration. More...
 
template<typename Duration , typename PrecisionPeriod , typename = typename Duration::period, typename = std::enable_if_t<std::is_floating_point_v<typename Duration::rep>>>
constexpr Timestamp (const Duration &duration, PrecisionPeriod)
 Create AvCpp/FFmpeg compatible timestamp value from the floating point std::chrono::duration/boost::chrono::duration with given precision. More...
 
template<typename Duration , typename = typename Duration::period, typename = std::enable_if_t<std::is_floating_point_v<typename Duration::rep>>>
constexpr Timestamp (const Duration &duration, const Rational &timebase)
 Create AvCpp/FFmpeg compatible timestamp value from the floating point std::chrono::duration/boost::chrono::duration with given precision. More...
 
int64_t timestamp () const noexcept
 
int64_t timestamp (const Rational &timebase) const noexcept
 
const Rational & timebase () const noexcept
 
 operator bool () const noexcept
 
bool isValid () const noexcept
 
bool isNoPts () const noexcept
 
 operator double () const noexcept
 
double seconds () const noexcept
 
template<typename Duration , typename = typename Duration::period, typename = typename Duration::rep>
constexpr Duration toDuration () const
 Convert to the std::chrono::duration compatible value. More...
 
Timestamp & operator+= (const Timestamp &other)
 
Timestamp & operator-= (const Timestamp &other)
 
Timestamp & operator*= (const Timestamp &other)
 
Timestamp & operator/= (const Timestamp &other)
 

Detailed Description

The Timestamp class represents timestamp value and it timebase.

Timestamp class can be treated as Fixed Point time representation where timestamp itself is a value and Time Base is a multiplicator. Be careful with construct Timestamp from the std::chrono::duration with floating point rep

Constructor & Destructor Documentation

◆ Timestamp() [1/5]

av::Timestamp::Timestamp ( )
noexcept

◆ Timestamp() [2/5]

av::Timestamp::Timestamp ( int64_t  timestamp,
const Rational &  timebase 
)
noexcept

◆ Timestamp() [3/5]

template<typename Duration , typename = typename Duration::period, typename = std::enable_if_t<std::is_integral_v<typename Duration::rep>>>
constexpr av::Timestamp::Timestamp ( const Duration &  duration)
inlineconstexpr

Create AvCpp/FFmpeg compatible timestamp value from the std::chrono::duration/boost::chrono::duration.

Duration class must not be a floating point to avoid lost precision: Timestamp in the FFmpeg internally are int64_t with integer AVRAtional as timebase that also uses int64_t internally to store numerator and denominator.

◆ Timestamp() [4/5]

template<typename Duration , typename PrecisionPeriod , typename = typename Duration::period, typename = std::enable_if_t<std::is_floating_point_v<typename Duration::rep>>>
constexpr av::Timestamp::Timestamp ( const Duration &  duration,
PrecisionPeriod   
)
inlineconstexpr

Create AvCpp/FFmpeg compatible timestamp value from the floating point std::chrono::duration/boost::chrono::duration with given precision.

PrecisionPeriod defines holded TimeBase

◆ Timestamp() [5/5]

template<typename Duration , typename = typename Duration::period, typename = std::enable_if_t<std::is_floating_point_v<typename Duration::rep>>>
constexpr av::Timestamp::Timestamp ( const Duration &  duration,
const Rational &  timebase 
)
inlineconstexpr

Create AvCpp/FFmpeg compatible timestamp value from the floating point std::chrono::duration/boost::chrono::duration with given precision.

Member Function Documentation

◆ isNoPts()

bool av::Timestamp::isNoPts ( ) const
noexcept

◆ isValid()

bool av::Timestamp::isValid ( ) const
noexcept

◆ operator bool()

av::Timestamp::operator bool ( ) const
noexcept

◆ operator double()

av::Timestamp::operator double ( ) const
noexcept

◆ operator*=()

Timestamp & av::Timestamp::operator*= ( const Timestamp &  other)

◆ operator+=()

Timestamp & av::Timestamp::operator+= ( const Timestamp &  other)

◆ operator-=()

Timestamp & av::Timestamp::operator-= ( const Timestamp &  other)

◆ operator/=()

Timestamp & av::Timestamp::operator/= ( const Timestamp &  other)

◆ seconds()

double av::Timestamp::seconds ( ) const
noexcept

◆ timebase()

const Rational & av::Timestamp::timebase ( ) const
noexcept

◆ timestamp() [1/2]

int64_t av::Timestamp::timestamp ( ) const
noexcept

◆ timestamp() [2/2]

int64_t av::Timestamp::timestamp ( const Rational &  timebase) const
noexcept

◆ toDuration()

template<typename Duration , typename = typename Duration::period, typename = typename Duration::rep>
constexpr Duration av::Timestamp::toDuration ( ) const
inlineconstexpr

Convert to the std::chrono::duration compatible value.

It possible to convert to the floating point duration without additional casts.


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