Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

audio_device.h File Reference

Audio device. More...

#include <stdlib.h>
#include "config.h"
#include "base.h"

Data Structures

struct  otc_audio_device_settings
struct  otc_audio_device_callbacks

Typedefs

typedef struct otc_audio_device otc_audio_device

Functions

size_t otc_audio_device_read_render_data (int16_t *buffer, size_t number_of_samples)
otc_status otc_audio_device_write_capture_data (const int16_t *buffer, size_t number_of_samples)
otc_status otc_set_audio_device (const struct otc_audio_device_callbacks *callbacks)

Detailed Description

Audio device.

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 the session.

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.

Typedef Documentation

◆ otc_audio_device

Audio device type definition.

Function Documentation

◆ otc_audio_device_read_render_data()

size_t otc_audio_device_read_render_data ( int16_t *  buffer,
size_t  number_of_samples 
)

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

Parameters
bufferThe buffer containing audio data.
number_of_samplesThe number of samples requested.
Returns
The number of samples copied out of the audio buffer.

◆ otc_audio_device_write_capture_data()

otc_status otc_audio_device_write_capture_data ( const int16_t *  buffer,
size_t  number_of_samples 
)

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
bufferThe buffer containing audio data.
number_of_samplesThe number of samples available for copying.
Returns
Return value indicating either error or success.

◆ otc_set_audio_device()

otc_status otc_set_audio_device ( const struct otc_audio_device_callbacks callbacks)

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
callbacksA pointer to a audio device function callback struct.
Returns
Return value indicating either error or success.