4
我需要調用CMSampleBufferCreateCopy函數來創建sampleBuffer的副本,但我無法真正弄清楚如何使用它。Swift中的UnsafeMutablePointer <Unmanaged <CMSampleBuffer>?>是什麼?
根據this solution它應該工作一樣,:
var bufferCopy: Unmanaged<CMSampleBuffer>!
let error = CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &bufferCopy)
但事實並非如此。
錯誤消息我得到:
Cannot invoke 'CMSampleBufferCreateCopy' with an argument list of type '(CFAllocator!, CMSampleBuffer!, inout Unmanaged<CMSampleBuffer>!)'
編輯:
@availability(iOS, introduced=4.0)
func CMSampleBufferCreateCopy(allocator: CFAllocator!, sbuf: CMSampleBuffer!, sbufCopyOut: UnsafeMutablePointer<Unmanaged<CMSampleBuffer>?>) -> OSStatus
/*! @param allocator
The allocator to use for allocating the CMSampleBuffer object.
Pass kCFAllocatorDefault to use the default allocator. */
/*! @param sbuf
CMSampleBuffer being copied. */
/*! @param sbufCopyOut
Returned newly created CMSampleBuffer. */
/*!
@function CMSampleBufferCreateCopyWithNewTiming
@abstract Creates a CMSampleBuffer with new timing information from another sample buffer.
@discussion This emulates CMSampleBufferCreateCopy, but changes the timing.
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, reuse them or whatever. Any outputPresentationTimestamp that has been set on the original Buffer
will not be copied because it is no longer relevant. On return, the caller owns the returned
CMSampleBuffer, and must release it when done with it.
*/
CMD-點擊'CMSampleBufferCreateCopy',讓我看看你會得到什麼 – Kametrixom
用結果編輯問題。 @Kametrixom – zzzel
如果將'Unmanaged!'更改爲'Unmanaged ,它可能會正常工作?'' –
Kametrixom