title: How to convert CMSampleBufferRef to NSData
body: <p>How do you convert CMSampleBufferRef to NSData?</p>
  
  <p>I've managed to get the data for an <code>MPMediaItem</code> by following Erik Aigner's answer on <a href="https://stackoverflow.com/questions/1656124/mpmediaitems-raw-song-data">this thread</a>, however the data is of type <code>CMSampleBufferRef</code>. </p>
  
  <p>I know CMSampleBufferRef is a struct and is defined in the <a href="http://developer.apple.com/library/ios/#documentation/CoreMedia/Reference/CMSampleBuffer/Reference/reference.html" rel="nofollow noreferrer">CMSampleBuffer Reference</a> in the iOS Dev Library, but I don't think I fully understand what it is. None of the CMSampleBuffer functions seem to be an obvious solution.</p>