audio_device.h

This file includes the type definition for an audio device, along with structures and functions you use with it.

Use an audio device to define a custom audio capturer for all publishers and a custom audio renderer for all publishers and subscribers. If you do not use a custom audio device, the application will use the default audio device using the system microphone and speaker.

A custom audio is used for any publisher and subscriber in any session the client connects to. Once the audio device is set it acts globally. The capturing and rendering bits in the audio device being set are used for rendering and capturing audio for all participants in the session. You cannot set an audio device for a given publisher or subscriber alone.

Instantiate an otc_audio_device_callbacks structure, setting callback functions for events related to the audio device. Then call otc_set_audio_device(const struct otc_audio_device_callbacks callbacks) to associate the callbacks with the audio device to be used. You must call this function before you connect to a session. Additionally, this is a global operation that must persist throughout the lifetime of an application.

Call the otc_audio_device_read_render_data function to retrieve unrendered audio samples.

Call the otc_audio_device_write_capture_data function to write audio samples that will be included in streams you publish.

Data structures: otc_audio_device_settings, otc_audio_device_callbacks

Includes: stdlib.h, config.h, base.h

typedef otc_audio_device

Audio device type definition.

typedef struct otc_audio_device otc_audio_device;

Functions

Name Description
otc_audio_device_read_render_data(buffer, number_of_samples) → {size_t} Retrieves unrendered audio samples from the session.
otc_audio_device_write_capture_data(buffer, number_of_samples) → {otc_status} Passes in audio data from the audio device to transmit to a session.
otc_set_audio_device(callbacks) → {otc_status} Sets the audio device to be used.
otc_audio_device_restart_input() → {otc_status} Restarts audio input device.
otc_audio_device_restart_output() → {otc_status} Restarts audio output device.

otc_audio_device_read_render_data(buffer, number_of_samples) → {size_t}

Retrieves unrendered audio samples from the session. These samples are mixed from the streams in the session you have subscribed to.

Parameters:
Name Type Description
buffer int16_t * The buffer containing audio data.
number_of_samples size_t The number of samples requested.
Returns:

The number of samples copied out of the audio buffer.

otc_audio_device_write_capture_data(buffer, number_of_samples) → {otc_status}

Passes in audio data from the audio device to transmit to a session. This audio data is used by streams you publish to the session.

Parameters:
Name Type Description
buffer const int16_t * The buffer containing audio data.
number_of_samples size_t The number of samples available for copying.
Returns:

Return value indicating either error or success.

otc_set_audio_device(callbacks) → {otc_status}

Sets the audio device to be used. You must call this function before you connect to a session. Additionally, this is a global operation that must persist throughout the lifetime of a session.

Parameters:
Name Type Description
callbacks const struct otc_audio_device_callbacks * A pointer to a audio device function callback struct.
Returns:

Return value indicating either error or success.

otc_audio_device_restart_input() → {otc_status}

Restarts audio input device. This method must be called whenever a change in input device happens in the custom audio device to let the SDK perform the necessary corrections for the new device. Also this will trigger the following otc_audio_device_callbacks methods in order:

  • stop_capturer
  • init_capturer (only if is_capturer_initialized returns false)
  • start_capturer (only if is_capturer_started returns false)
Returns:

Return value indicating either error or success.

otc_audio_device_restart_output() → {otc_status}

Restarts audio output device. This method must be called whenever a change in output device happens in the custom audio device to let the SDK perform the necessary corrections for the new device. Also this will trigger the following otc_audio_device_callbacks methods in order:

  • stop_renderer
  • init_renderer (only if is_renderer_initialized returns false)
  • start_renderer (only if is_renderer_started returns false)
Returns:

Return value indicating either error or success.