WZAudioSink

Extends Protocol:
Declared In:

Introduction

WZAudioSink defines a protocol for callbacks that occur when audio frames are captured, or audio level changes.



Methods

-audioFrameWasCaptured:size:time:sampleRate:
-audioLevelDidChange:
-audioPCMFrameWasCaptured:bufferList:time:sampleRate:
-canConvertStreamWithDescription:

audioFrameWasCaptured:size:time:sampleRate:


@optional

- (void) audioFrameWasCaptured:(nonnull void *)data size:(uint32_t)size time:(CMTime)time sampleRate:(Float64)sampleRate;
Parameters
data

The audio frame data.

size

The size, in bytes, of the captured frame

time

The audio frame time, represented in a CMTime structure

sampleRate

The audio sample rate

Discussion

Called for each frame of audio recorded by an audio device. The format of the data is uninteresting to the protocol adopter; this protocol should be used for timing information only. If you wish to access raw audio data, please implement the audioPCMFrameWasCaptured protocol method instead of this one.


audioLevelDidChange:


@optional

- (void) audioLevelDidChange:(float)level;
Parameters
level

The current level value.

Discussion

Called whenever the audio level value changes.


audioPCMFrameWasCaptured:bufferList:time:sampleRate:


@optional

- (void) audioPCMFrameWasCaptured:(nonnull const AudioStreamBasicDescription *)pcmASBD bufferList:(nonnull const AudioBufferList *)bufferList time:(CMTime)time sampleRate:(Float64)sampleRate;
Parameters
pcmASBD

The AudioStreamBasicDescription of the PCM data

bufferList

The AudioBufferList representation of the PCM data.

time

The audio frame time, represented in a CMTime structure

sampleRate

The audio sample rate

Discussion

Called for each frame of audio recorded by an audio device. Clients implementing this protocol should be aware that doing so causes the SDK to go through a PCM to AAC audio conversion process before broadcasting. Thus, please DO NOT IMPLEMENT THIS PROTOCOL UNLESS YOU HAVE A SPECIFIC NEED FOR THE UN-ENCODED AUDIO DATA. If you implement this protocol, the audioFrameWasCaptured protocol method will never be called.

Note that implementing this protocol doesn't guarentee that it will be called. If the audio converter is unable for any reason to convert from PCM to AAC, then the capture hardware will fall back to capturing AAC directly; in which case the audioFrameWasCaptured protocol above will be called instead.


canConvertStreamWithDescription:


@optional

- (BOOL) canConvertStreamWithDescription:(nonnull const AudioStreamBasicDescription *)asbd;
Parameters
asbd

The AudioStreamBasicDescription of the format being converted from

Return Value

True if the format can be converted from; otherwise false

Discussion

Test whether or not the audio sink adopting this protocol can convert from the specified format description. It would be very unusual for a client to implement this protocol; it is implemented by the WZAACEncoder class.