CBaseReferenceClock Class
CBaseReferenceClock Class
.gif)
The CBaseReferenceClock class implements a reference clock.
This class implements a reference clock that supports the IReferenceClock and IReferenceClockTimerControl interfaces. If a filter can provide a reference clock for the filter graph—for example, by accessing a hardware device—it can use this class to implement the clock.
The CBaseReferenceClock object maintains two distinct time values:
It is valid for the internal clock to run backward over brief periods. For example, if the clock drifts forward, the filter can adjust it backward. (See CBaseReferenceClock::SetTimeDelta.) The GetTime method uses the time values reported by GetPrivateTime. However, the reference time is monotonically increasing; in other words, it never runs backward. Therefore, if the internal clock runs backward, GetTime continues to report the old time until the internal clock catches up.
For example, the two methods might return the following sequences:
GetPrivateTime: 105, 106, 103, 104, 105, 106, 107, 108
GetTime: 105, 106, 106, 106, 106, 106, 107, 108
On the third clock tick, the internal clock jumps backward to 103. The GetTime method continues to report 106 until the internal clock catches up.
By default, GetPrivateTime returns the system time, through a call to the timeGetTime function. A filter that is providing a reference clock from an external device can do one of the following:
- Override GetPrivateTime to return the time from the device.
- Monitor the discrepancy between the device time and the system time, and call SetTimeDelta to make corrections.
This class uses a CAMSchedule object to handle scheduling of advise requests. For details, see the documentation for the CAMSchedule class.
Requirements
Header: Declared in Refclock.h; include Streams.h.
Library: Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).