Functions
The following functions are available globally.
-
Deprecated
Will not be supported in TwilioVoice v7.0+
This method should be called any time the capturing or rendering format changes. If both formats change simultaneously its fine to call this method just once. As a result the media engine will read the new audio format, stop capturing and/or rendering by calling
stopCapturingand/orstopRenderingand then callstartRendering:and/orstartRendering:.Declaration
Objective-C
void TVOAudioDeviceFormatChanged(TVOAudioDeviceContext _Nonnull context)Swift
func TVOAudioDeviceFormatChanged(_ context: TVOAudioDeviceContext)Parameters
contextThe context pointer. You should use the same context provided in
startCapturing:and/orstartRendering:here. -
This method should be called when (1) capturing or rendering format is changed, (2) audio device is re-enabled, (3) audio session is uninterrupted, (4) audio route is changed. As a result, the media engine will read the new audio format, stop capturing and/or rendering by calling
stopCapturingand/orstopRendering, and then callstartRendering:and/orstartRendering:.Declaration
Objective-C
void TVOAudioDeviceReinitialize(TVOAudioDeviceContext _Nonnull context)Swift
func TVOAudioDeviceReinitialize(_ context: TVOAudioDeviceContext)Parameters
contextThe context pointer. You should use the same context provided in
startCapturing:and/orstartRendering:here. -
This method is called by your
TVOAudioDeviceCapturerto provide captured data to the media engine.See
Declaration
Objective-C
void TVOAudioDeviceWriteCaptureData(TVOAudioDeviceContext _Nonnull context, int8_t *_Nonnull data, size_t sizeInBytes)Swift
func TVOAudioDeviceWriteCaptureData(_ context: TVOAudioDeviceContext, _ data: UnsafeMutablePointer<Int8>, _ sizeInBytes: Int)Parameters
contextThe context pointer. You should use the same context provided in
startCapturing:here.dataA pointer to the audio data you wish to deliver.
sizeInBytesThe size (in bytes) of the audio data you are delivering. This must be less than or equal to the value returned by
TVOAudioFormat.bufferSize. -
This method is called by your
TVOAudioDeviceRendererto pull renderable audio data from the media engine.See
Declaration
Objective-C
void TVOAudioDeviceReadRenderData(TVOAudioDeviceContext _Nonnull context, int8_t *_Nonnull data, size_t sizeInBytes)Swift
func TVOAudioDeviceReadRenderData(_ context: TVOAudioDeviceContext, _ data: UnsafeMutablePointer<Int8>, _ sizeInBytes: Int)Parameters
contextThe context pointer. You should use the same context provided in
startRendering:here.dataA pointer to a buffer where the signed 16-bit LPCM audio data will be copied into.
sizeInBytesThe size (in bytes) of the audio data you are rendering. This must be less than or equal to the value returned by
TVOAudioFormat.bufferSize. -
A utility method to execute a block on the media engine’s worker thread asynchronously.
@discussion TVOAudioDevice invokes the callbacks on the media engine’s worker thread. If you wish to initialize, start or stop the audio device from your application code, to avoid the thread-safety problems, you should execute code from the media engine’s worker thread. Example: - (void)handleMediaServiceLost:(NSNotification *)notification { TVOAudioDeviceWorkerBlock workerBlock = ^{ [self stopAudioUnit]; }; TVOAudioDeviceExecuteWorkerBlock(context, workerBlock); }
Declaration
Objective-C
void TVOAudioDeviceExecuteWorkerBlock(TVOAudioDeviceContext _Nonnull context, TVOAudioDeviceWorkerBlock _Nonnull block)Swift
func TVOAudioDeviceExecuteWorkerBlock(_ context: TVOAudioDeviceContext, _ block: @escaping TVOAudioDeviceWorkerBlock)Parameters
contextThe context pointer. You should use the same context provided in
startRendering:orstartCapturing:here.blockA block which will be executed on the media engine’s worker thread.
-
Undocumented
Declaration
Objective-C
void TVOAudioSessionActivated(TVOAudioDeviceContext _Nonnull context)Swift
func TVOAudioSessionActivated(_ context: TVOAudioDeviceContext) -
Undocumented
Declaration
Objective-C
void TVOAudioSessionDeactivated(TVOAudioDeviceContext _Nonnull context)Swift
func TVOAudioSessionDeactivated(_ context: TVOAudioDeviceContext)
Functions Reference