Instance Property

masterClock

A clock object used for output synchronization.

Declaration

@property(nonatomic, readonly) CMClockRef masterClock;

Discussion

The returned CMClockRef object is read-only and provides a timebase for all sample buffers in capture output. This can be used in conjunction with the clock from an AVCaptureInputPort object to synchronize capture output with external data sources such as motion samples.

For example, to synchronize output timestamps to the original timestamps provided by an input device, you can do the following in your captureOutput:didOutputSampleBuffer:fromConnection: method:

AVCaptureInputPort *port = [[connection inputPorts] objectAtIndex:0];
CMClockRef originalClock = [port clock];
 
CMTime syncedPTS = CMSampleBufferGetPresentationTime( sampleBuffer );
CMTime originalPTS = CMSyncConvertTime( syncedPTS, [session masterClock], originalClock );

You can observe the value of this property using Key-value observing.