Partager via


CRefTime Class

 
Microsoft DirectShow 9.0

CRefTime Class

CRefTime Class Hierarchy

The CRefTime class is a helper class for managing reference times .

A reference time is a unit of time represented in 100-nanosecond units. This class shares the same data layout as the REFERENCE_TIME data type, but adds some methods and operators that provide comparison, conversion, and arithmetic functions. For more information about reference times, see Time and Clocks in DirectShow.

There is a potential pitfall with using this class. If you apply the += operator with a CRefTime object as the left operand and a variable of type LONG as the right operand, the compiler will implicitly coerce the right operand into a CRefTime object. This coercion uses the CRefTime constructor that converts milliseconds into REFERENCE_TIME units; as a result, the right operand is multiplied by 10,000:

CRefTime rt;   // rt.m_time is 0.
LONG val = 20;
rt += val;    // Coerce val to CRefTime, rt.m_time is now 200,000.

However, the same thing does not happen using the + operator:

CRefTime rt;   // rt.m_time is 0.
LONG val = 20;
rt = rt + val; // CRefTime, rt.m_time is 20.

Requirements

**  Header:** Declared in Reftime.h; include Streams.h.

**  Library:** Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

Public Member Variables  
m_time Specifies the REFERENCE_TIME value.
Public Methods  
CRefTime Constructor method.
GetUnits Retrieves the reference time in 100-nanosecond units.
Millisecs Converts the reference time to milliseconds.
Operators  
operator REFERENCE_TIME() Casts the object to a REFERENCE_TIME data type.
operator = Assigns a new reference time.
operator += Adds two reference times.
operator –= Subtracts one reference time from another.