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 stopCapturing and/or stopRendering and then call startRendering: and/or startRendering:.

    Declaration

    Objective-C

    void TVOAudioDeviceFormatChanged(TVOAudioDeviceContext _Nonnull context)

    Swift

    func TVOAudioDeviceFormatChanged(_ context: TVOAudioDeviceContext)

    Parameters

    context

    The context pointer. You should use the same context provided in startCapturing: and/or startRendering: 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 stopCapturing and/or stopRendering, and then call startRendering: and/or startRendering:.

    Declaration

    Objective-C

    void TVOAudioDeviceReinitialize(TVOAudioDeviceContext _Nonnull context)

    Swift

    func TVOAudioDeviceReinitialize(_ context: TVOAudioDeviceContext)

    Parameters

    context

    The context pointer. You should use the same context provided in startCapturing: and/or startRendering: here.

  • This method is called by your TVOAudioDeviceCapturer to provide captured data to the media engine.

    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

    context

    The context pointer. You should use the same context provided in startCapturing: here.

    data

    A pointer to the audio data you wish to deliver.

    sizeInBytes

    The 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 TVOAudioDeviceRenderer to pull renderable audio data from the media engine.

    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

    context

    The context pointer. You should use the same context provided in startRendering: here.

    data

    A pointer to a buffer where the signed 16-bit LPCM audio data will be copied into.

    sizeInBytes

    The 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

    context

    The context pointer. You should use the same context provided in startRendering: or startCapturing: here.

    block

    A 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)