I want to store CMSampleBufferRef
in mutable array for that I am trying to use below code
NSMutableArray<CMSampleBufferRef> *buffers;
But I am getting this error
Type argument 'CMSampleBufferRef' (aka 'struct opaqueCMSampleBuffer *') is neither an Objective-C object nor a block type
In swift we can write like this, it's working good
var buffers = [CMSampleBuffer]()
I want to know how to write that in Objective-C and store sample buffers in mutable array. Suggest me solution for this.
// defining the mutable array
NSMutableArray* sampleBuffers = [[NSMutableArray alloc] init];
// adding a sample buffer:
CMSampleBufferRef sampleBuffer = (...)
[sampleBuffers addObject:(__bridge id)sampleBuffer];
Note: Adding the sample buffer to the array will increment the retain count of the buffer; the retain count will be decremented when the buffer is removed from the array. Make sure the source of your sample buffers is fine with retaining the buffers for an extended period of time (some buffer pools might not like this).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.