TVOAudioDeviceCapturer

Objective-C

@protocol TVOAudioDeviceCapturer <NSObject>

Swift

protocol TVOAudioDeviceCapturer : NSObjectProtocol

TVOAudioDeviceCapturer defines the capturing half of TVOAudioDevice. An audio capturer produces samples by repeatedly calling TVOAudioDeviceWriteCaptureData() when it needs to deliver new data. A capturer need not record audio from the device microphone, it could perform other operations such as reading audio samples from disk instead.

  • @brief Provides the format to be used for capturing audio.

    @discussion This method is called once before capture starts. If you wish to change the format after you’ve started capturing audio then you should call TVOAudioDeviceReinitialize() and prepare for this method to be queried again.

    Declaration

    Objective-C

    - (nullable TVOAudioFormat *)captureFormat;

    Swift

    func captureFormat() -> TVOAudioFormat?

    Return Value

    A TVOAudioFormat instance which describes the audio which will be captured. Returning nil indicates that audio capture is not supported.

  • @brief Initializes the capturer.

    @discussion This method is called before startCapturing:. You should use this opportunity to pre-allocate any fixed size buffers or other resources that you need for audio processing.

    Declaration

    Objective-C

    - (BOOL)initializeCapturer;

    Swift

    func initializeCapturer() -> Bool

    Return Value

    YES if initialization succeeded, or NO if it did not.

  • @brief Starts the capturer.

    @discussion This method is called after initializeCapturer. Before your implementation returns it should have started your audio capturing pipeline. This may involve spinning up audio threads via CoreAudio or starting your own high priority capture thread.

    Declaration

    Objective-C

    - (BOOL)startCapturing:(nonnull TVOAudioDeviceContext)context;

    Swift

    func startCapturing(_ context: TVOAudioDeviceContext) -> Bool

    Parameters

    context

    A context pointer to be used with the audio capture function callbacks TVOAudioDeviceReinitialize(), TVOAudioDeviceWriteCaptureData() and TVOAudioDeviceExecuteWorkerBlock().

    Return Value

    YES if capturing started, or NO if it did not.

  • @brief Stops the capturer.

    @discussion This method is called some time after startCapturing when audio capturing is no longer needed by the media engine. Before your implementation returns it should have stopped your audio capturing pipeline.

    Declaration

    Objective-C

    - (BOOL)stopCapturing;

    Swift

    func stopCapturing() -> Bool

    Return Value

    YES if capturing stopped, or NO if it did not.