|Microsoft DirectX 9.0|
The CRefTime class is a helper class for managing
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.
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.|
|GetUnits||Retrieves the reference time in 100-nanosecond units.|
|Millisecs||Converts the reference time to milliseconds.|
|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.|