AVCaptureAudioDataOutput Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in OS X v10.7 and later.
Declared in
AVCaptureOutput.h
Related sample code

Overview

AVCaptureAudioDataOutput is a concrete sub-class of AVCaptureOutput that you use, via its delegate, to process audio sample buffers from the audio being captured.

Tasks

Managing the Delegate

Getting and Setting Audio Settings

Properties

audioSettings

The settings used to decode or re-encode audio before it is output.

@property(nonatomic, copy) NSDictionary *audioSettings
Discussion

The value of this property is a dictionary containing values for audio settings keys defined in AV Foundation Audio Settings Constants.

If the value of this property is nil, samples are output in their device native format.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

sampleBufferCallbackQueue

The queue on which delegate callbacks are invoked (read-only)

@property(nonatomic, readonly) dispatch_queue_t sampleBufferCallbackQueue
Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

sampleBufferDelegate

The capture object’s delegate. (read-only)

@property(nonatomic, readonly) id<AVCaptureAudioDataOutputSampleBufferDelegate> sampleBufferDelegate
Discussion

You use the delegate to manage incoming data.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

Instance Methods

setSampleBufferDelegate:queue:

Sets the delegate that will accept captured buffers and dispatch queue on which the delegate will be called.

- (void)setSampleBufferDelegate:(id<AVCaptureAudioDataOutputSampleBufferDelegate>)sampleBufferDelegate queue:(dispatch_queue_t)sampleBufferCallbackQueue
Parameters
sampleBufferDelegate

An object conforming to the AVCaptureAudioDataOutputSampleBufferDelegate protocol that will receive sample buffers after they are captured..

sampleBufferCallbackQueue

You must pass a serial dispatch to guarantee that audio samples will be delivered in order.

The value may not be NULL, except when setting the sampleBufferDelegate to nil.

Discussion

When a new audio sample buffer is captured it is vended to the sample buffer delegate using the captureOutput:didOutputSampleBuffer:fromConnection: delegate method. All delegate methods are called on the specified dispatch queue.

If the queue is blocked when new samples are captured, those samples will be automatically dropped when they become sufficiently late. This allows you to process existing samples on the same queue without having to manage the potential memory usage increases that would otherwise occur when that processing is unable to keep up with the rate of incoming samples.

If you need to minimize the chances of samples being dropped, you should specify a queue on which a sufficiently small amount of processing is being done outside of receiving sample buffers. When migrating extra processing to another queue, you are responsible for ensuring that memory usage does not grow without bound from samples that have not been processed.

Special Considerations

This method uses dispatch_retain and dispatch_release to manage the queue.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h