I am trying to get the size of CMSampleBufferRef from AVFoundation call-back
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
According to documentation https://developer.apple.com/library/mac/documentation/CoreMedia/Reference/CMSampleBuffer/index.html#//apple_ref/c/func/CMSampleBufferGetSampleSize
size_t CMSampleBufferGetTotalSampleSize ( CMSampleBufferRef sbuf );
If I understand it correctly, I should use this method to get buffer size. But I always got 0 from the return. and It is said that "If there are no sample sizes in this CMSampleBuffer, a size of 0 will be returned." In this case, I wonder if AVFoundation framework does not provide a buffer size information or I mis-understand document.
A follow up question: By the way, I wonder in this case if I could use
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
from pixelBuffer to get the size of sampleBuffer?