Contents

CMSampleBufferCreateCopyWithNewTiming(allocator:sampleBuffer:sampleTimingEntryCount:sampleTimingArray:sampleBufferOut:)

Creates a copy of a sample buffer with new timing information.

Declaration

func CMSampleBufferCreateCopyWithNewTiming(allocator: CFAllocator?, sampleBuffer originalSBuf: CMSampleBuffer, sampleTimingEntryCount numSampleTimingEntries: CMItemCount, sampleTimingArray: UnsafePointer<CMSampleTimingInfo>?, sampleBufferOut: UnsafeMutablePointer<CMSampleBuffer?>) -> OSStatus

Parameters

  • allocator:

    The allocator to use for allocating the CMSampleBuffer object. Pass kCFAllocatorDefault to use the default allocator.

  • originalSBuf:

    CMSampleBuffer containing the original samples.

  • numSampleTimingEntries:

    Number of entries in sampleTimingArray. Must be 0, 1, or the number of samples in originalSBuf.

  • sampleTimingArray:

    Array of CMSampleTimingInfo structs, one struct per sample. If all samples have the same duration and are in presentation order, you can pass a single CMSampleTimingInfo struct with duration set to the duration of one sample, presentationTimeStamp set to the presentation time of the numerically earliest sample, and decodeTimeStamp set to kCMTimeInvalid. Behavior is undefined if samples in a CMSampleBuffer (or even in multiple buffers in the same stream) have the same presentationTimeStamp. Can be NULL.

  • sampleBufferOut:

    On output, points to the newly created copy of CMSampleBuffer.

Return Value

A result code. See Sample Buffer Error Codes.

Discussion

This emulates CMSampleBufferCreateCopy, but changes the timing. The array parameters, sampleTimingArray, should have only one element if that same element applies to all samples.

All parameters are copied; on return, the caller can release them, free them, or reuse them. Any outputPresentationTimestamp that has been set on the original buffer isn’t copied because it’s no longer relevant. On return, the caller owns the returned CMSampleBuffer, and must release it when done with it.

See Also

Copying Sample Buffers