Telematics SDK - API Reference  v1.55.0
Audio Streams

Data Structures

struct  telux::audio::ChannelVolume
 
struct  telux::audio::StreamVolume
 
struct  telux::audio::StreamMute
 
struct  telux::audio::DtmfTone
 
class  telux::audio::IVoiceListener
 
class  telux::audio::IPlayListener
 
class  telux::audio::IAudioBuffer
 
class  telux::audio::IStreamBuffer
 
class  telux::audio::IAudioStream
 
class  telux::audio::IAudioVoiceStream
 
class  telux::audio::IAudioPlayStream
 
class  telux::audio::IAudioCaptureStream
 
class  telux::audio::IAudioLoopbackStream
 
class  telux::audio::IAudioToneGeneratorStream
 

Typedefs

using telux::audio::ChannelTypeMask = int
 
using telux::audio::GetStreamDeviceResponseCb = std::function< void(std::vector< DeviceType > devices, telux::common::ErrorCode error)>
 
using telux::audio::GetStreamVolumeResponseCb = std::function< void(StreamVolume volume, telux::common::ErrorCode error)>
 
using telux::audio::GetStreamMuteResponseCb = std::function< void(StreamMute mute, telux::common::ErrorCode error)>
 
using telux::audio::WriteResponseCb = std::function< void(std::shared_ptr< IStreamBuffer > buffer, uint32_t bytesWritten, telux::common::ErrorCode error)>
 
using telux::audio::ReadResponseCb = std::function< void(std::shared_ptr< IStreamBuffer > buffer, telux::common::ErrorCode error)>
 

Enumerations

enum  telux::audio::Direction { telux::audio::Direction::RX = 1, telux::audio::Direction::TX = 2 }
 
enum  telux::audio::ChannelType { telux::audio::LEFT = (1 << 0), telux::audio::RIGHT = (1 << 1) }
 
enum  telux::audio::AudioFormat {
  telux::audio::AudioFormat::UNKNOWN = -1, telux::audio::AudioFormat::PCM_16BIT_SIGNED = 1, telux::audio::AudioFormat::AMRNB = 20, telux::audio::AudioFormat::AMRWB,
  telux::audio::AudioFormat::AMRWB_PLUS
}
 
enum  telux::audio::DtmfLowFreq { telux::audio::DtmfLowFreq::FREQ_697 = 697, telux::audio::DtmfLowFreq::FREQ_770 = 770, telux::audio::DtmfLowFreq::FREQ_852 = 852, telux::audio::DtmfLowFreq::FREQ_941 = 941 }
 
enum  telux::audio::DtmfHighFreq { telux::audio::DtmfHighFreq::FREQ_1209 = 1209, telux::audio::DtmfHighFreq::FREQ_1336 = 1336, telux::audio::DtmfHighFreq::FREQ_1477 = 1477, telux::audio::DtmfHighFreq::FREQ_1633 = 1633 }
 
enum  telux::audio::StopType { telux::audio::StopType::FORCE_STOP, telux::audio::StopType::STOP_AFTER_PLAY }
 

Detailed Description

This section contains APIs related to Audio Stream operation.


Data Structure Documentation

struct telux::audio::ChannelVolume

Defines the volume levels for a given audio channel.

Data Fields
ChannelType channelType

ChannelType to which the volume level is associated

float vol

Volume level – minimum 0.0 and maximum 1.0

struct telux::audio::StreamVolume

Defines the volume levels for the audio device.

Data Fields
vector< ChannelVolume > volume

List of the volume levels per channel, specified by ChannelVolume

StreamDirection dir

StreamDirection associated with the device

struct telux::audio::StreamMute

Specifies the mute state of the audio device.

Data Fields
bool enable

True if the device is muted, False if the device is unmuted

StreamDirection dir

StreamDirection associated with the device

struct telux::audio::DtmfTone

Defines the characteristics of the DTMF tone.

Data Fields
DtmfLowFreq lowFreq

Lower frequency associated with the DTMF tone

DtmfHighFreq highFreq

Higher frequency associated with the DTMF tone

StreamDirection direction

StreamDirection associated with the stream

class telux::audio::IVoiceListener

Listener for a DTMF tone detected event on a StreamType::VOICE_CALL stream.

Public Member Functions

virtual void onDtmfToneDetection (DtmfTone dtmfTone)
 
virtual ~IVoiceListener ()
 

Constructor & Destructor Documentation

virtual telux::audio::IVoiceListener::~IVoiceListener ( )
virtual

Destructor of the IVoiceListener.

Member Function Documentation

virtual void telux::audio::IVoiceListener::onDtmfToneDetection ( DtmfTone  dtmfTone)
virtual

Called when a DTMF tone is detected on a StreamType::VOICE_CALL stream. Used in conjuction with IAudioVoiceStream::registerListener().

Parameters
[in]dtmfToneContains details of the tone detected
class telux::audio::IPlayListener

Listener for events on a playback stream.

Public Member Functions

virtual void onReadyForWrite ()
 
virtual void onPlayStopped ()
 
virtual ~IPlayListener ()
 

Constructor & Destructor Documentation

virtual telux::audio::IPlayListener::~IPlayListener ( )
virtual

Destructor of IPlayListener.

Member Function Documentation

virtual void telux::audio::IPlayListener::onReadyForWrite ( )
virtual

Called when the audio pipeline is ready to accept the next buffer to play during compressed playback.

virtual void telux::audio::IPlayListener::onPlayStopped ( )
virtual

Called when the compressed playback has stopped.

class telux::audio::IAudioBuffer

Represents the buffer containing the audio data for playback when used with the StreamType::PLAY stream. Represents the audio data received when used with the StreamType::CAPTURE stream.

Public Member Functions

virtual size_t getMinSize ()=0
 
virtual size_t getMaxSize ()=0
 
virtual uint8_t * getRawBuffer ()=0
 
virtual uint32_t getDataSize ()=0
 
virtual void setDataSize (uint32_t size)=0
 
virtual telux::common::Status reset ()=0
 
virtual ~IAudioBuffer ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioBuffer::~IAudioBuffer ( )
virtual

Destructor of the IAudioBuffer.

Member Function Documentation

virtual size_t telux::audio::IAudioBuffer::getMinSize ( )
pure virtual

For the StreamType::PLAY stream, specifies the minimum number of bytes that must be sent for playback. For the StreamType::CAPTURE stream, specifies the minimum number of bytes that can be read.

Returns
Minimum size (in bytes)
virtual size_t telux::audio::IAudioBuffer::getMaxSize ( )
pure virtual

For the StreamType::PLAY stream, specifies the maximum number of bytes that can be sent for playback. For the StreamType::CAPTURE stream, specifies the maximum number of bytes that can be read.

Returns
Maximum size (in bytes)
virtual uint8_t* telux::audio::IAudioBuffer::getRawBuffer ( )
pure virtual

Gives the managed raw buffer. It is freed when IAudioBuffer is destructed. For the StreamType::PLAY stream, the actual audio samples should be copied into this raw buffer for playback. For the StreamType::CAPTURE stream, the actual audio contents are obtained from this buffer.

Returns
Managed raw buffer
virtual uint32_t telux::audio::IAudioBuffer::getDataSize ( )
pure virtual

For the StreamType::CAPTURE stream, specifies how many bytes were read. Not used for the StreamType::PLAY stream.

Returns
Size of the valid data bytes in the raw buffer
virtual void telux::audio::IAudioBuffer::setDataSize ( uint32_t  size)
pure virtual

For the StreamType::PLAY stream, specifies how many bytes should be played. Not used for the StreamType::CAPTURE stream.

Returns
Size of the valid data bytes in the raw buffer
virtual telux::common::Status telux::audio::IAudioBuffer::reset ( )
pure virtual

Clears the contents of the managed raw buffer.

Returns
telux::common::Status::SUCCESS if the buffer is cleared successfully, otherwise, an appropriate error code
class telux::audio::IStreamBuffer

Implements the IAudioBuffer interface to give contexual meaning to its methods based on the StreamType type associated with the stream, with which this buffer will be used.

Public Member Functions

virtual ~IStreamBuffer ()
 
- Public Member Functions inherited from telux::audio::IAudioBuffer
virtual size_t getMinSize ()=0
 
virtual size_t getMaxSize ()=0
 
virtual uint8_t * getRawBuffer ()=0
 
virtual uint32_t getDataSize ()=0
 
virtual void setDataSize (uint32_t size)=0
 
virtual telux::common::Status reset ()=0
 
virtual ~IAudioBuffer ()
 

Constructor & Destructor Documentation

virtual telux::audio::IStreamBuffer::~IStreamBuffer ( )
virtual

Destructor of the IStreamBuffer.

class telux::audio::IAudioStream

Base class for all audio stream types. Contains the common properties and methods.

Public Member Functions

virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioStream::~IAudioStream ( )
virtual

Destructor of the IAudioStream.

Member Function Documentation

virtual StreamType telux::audio::IAudioStream::getType ( )
pure virtual

Gets the StreamType associated with the stream.

Returns
Type of the stream
virtual telux::common::Status telux::audio::IAudioStream::setDevice ( std::vector< DeviceType devices,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Associates the given audio device with the stream.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

For StreamType::VOICE_CALL, the stream must be started using IAudioVoiceStream::startAudio() to make the device effective.

Parameters
[in]devicesList of the audio devices to use with the stream
[in]callbackInvoked to confirm if the device is associated
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioStream::getDevice ( GetStreamDeviceResponseCb  callback = nullptr)
pure virtual

Gets the list of the audio devices associated with the stream.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

Parameters
[in]callbackInvoked to pass the associated device
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioStream::setVolume ( StreamVolume  volume,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Sets the volume level of the audio device.

For StreamType::VOICE_CALL, direction must be StreamDirection::TX.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

Parameters
[in]volumeSpecifies the volume level and the stream's direction
[in]callbackInvoked to confirm if the volume level is set
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioStream::getVolume ( StreamDirection  dir,
GetStreamVolumeResponseCb  callback = nullptr 
)
pure virtual

Gets the current volume level of the audio device.

For StreamType::VOICE_CALL, direction must be StreamDirection::TX.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

Parameters
[in]dirDirection of the stream associated with the device
[in]callbackInvoked to pass the volume read
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioStream::setMute ( StreamMute  mute,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Mute or unmute the stream as specified by the StreamMute provided.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

For StreamType::VOICE_CALL, the stream must be started using IAudioVoiceStream::startAudio() before setting the mute state.

For StreamType::PLAY and StreamType::CAPTURE, direction of the stream is ignored (all channels will be muted/unmuted).

Parameters
[in]muteDefines the stream is to be muted or unmuted
[in]callbackInvoked to confirm if the stream is muted/unmuted
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioStream::getMute ( StreamDirection  dir,
GetStreamMuteResponseCb  callback = nullptr 
)
pure virtual

Gets the current mute state of the audio stream.

Applicable for StreamType::VOICE_CALL, StreamType::PLAY, and StreamType::CAPTURE only.

For StreamType::VOICE_CALL, the stream must be started using IAudioVoiceStream::startAudio() before reading the mute state.

Parameters
[in]dirDirection of the stream
[in]callbackInvoked to pass the mute state
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
class telux::audio::IAudioVoiceStream

Represents the stream created with the StreamType::VOICE_CALL type. Provides methods to establish a voice call on a cellular network, and play and detect DTMF tones.

Public Member Functions

virtual telux::common::Status startAudio (telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status stopAudio (telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status playDtmfTone (DtmfTone dtmfTone, uint16_t duration, uint16_t gain, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status stopDtmfTone (StreamDirection direction, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status registerListener (std::weak_ptr< IVoiceListener > listener, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status deRegisterListener (std::weak_ptr< IVoiceListener > listener)=0
 
virtual ~IAudioVoiceStream ()
 
- Public Member Functions inherited from telux::audio::IAudioStream
virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioVoiceStream::~IAudioVoiceStream ( )
virtual

Destructor of the IAudioVoiceStream.

Member Function Documentation

virtual telux::common::Status telux::audio::IAudioVoiceStream::startAudio ( telux::common::ResponseCallback  callback = nullptr)
pure virtual

Starts a voice call stream.

Parameters
[in]callbackOptional, invoked to confirm if the stream has started
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioVoiceStream::stopAudio ( telux::common::ResponseCallback  callback = nullptr)
pure virtual

Stops a voice call stream.

Parameters
[in]callbackOptional, invoked to confirm if the stream has stopped
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioVoiceStream::playDtmfTone ( DtmfTone  dtmfTone,
uint16_t  duration,
uint16_t  gain,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Generates a DTMF tone on a local device (on RX path) associated with the active voice call stream.

Parameters
[in]dtmfToneSpecifies the tone's properties
[in]durationDuration (in milliseconds) for which the tone is played. Set it to INFINITE_TONE_DURATION to play indefinitely
[in]gainVolume level of the tone, valid value range is 0 to 4000
[in]callbackOptional, invoked to confirm if the tone play has started
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioVoiceStream::stopDtmfTone ( StreamDirection  direction,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

If IAudioVoiceStream::playDtmfTone() was called with the duration set to INFINITE_DTMF_DURATION, then this method stops playing the DTMF tone.

Parameters
[in]directionDirection of the stream
[in]callbackOptional, invoked to confirm if the tone play has stopped
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioVoiceStream::registerListener ( std::weak_ptr< IVoiceListener listener,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Registers the given listener to get notified whenever a DTMF tone is detected on a voice call stream. Used in conjunction with IVoiceListener::onDtmfToneDetection().

Parameters
[in]listenerReceives the DTMF tone detected event
[in]callbackInvoked to confirm if the registration is successful
Returns
telux::common::Status::SUCCESS if the listener is registered, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioVoiceStream::deRegisterListener ( std::weak_ptr< IVoiceListener listener)
pure virtual

Unregisters the given listener registered with IAudioVoiceStream::registerListener().

Parameters
[in]listenerListener to unregister
Returns
telux::common::Status::SUCCESS if the listener is unregistered, otherwise, an appropriate error code
class telux::audio::IAudioPlayStream

Represents the stream created with the StreamType::PLAY type. Provides the methods to play the audio.

Public Member Functions

virtual std::shared_ptr< IStreamBuffergetStreamBuffer ()=0
 
virtual telux::common::Status write (std::shared_ptr< IStreamBuffer > buffer, WriteResponseCb callback=nullptr)=0
 
virtual telux::common::Status stopAudio (StopType stopType, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status registerListener (std::weak_ptr< IPlayListener > listener)=0
 
virtual telux::common::Status deRegisterListener (std::weak_ptr< IPlayListener > listener)=0
 
virtual ~IAudioPlayStream ()
 
- Public Member Functions inherited from telux::audio::IAudioStream
virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioPlayStream::~IAudioPlayStream ( )
virtual

Destructor of the IAudioPlayStream.

Member Function Documentation

virtual std::shared_ptr<IStreamBuffer> telux::audio::IAudioPlayStream::getStreamBuffer ( )
pure virtual

Gets an audio buffer containing the audio samples to play.

Returns
IStreamBuffer instance or nullptr if memory allocation fails
virtual telux::common::Status telux::audio::IAudioPlayStream::write ( std::shared_ptr< IStreamBuffer buffer,
WriteResponseCb  callback = nullptr 
)
pure virtual

Sends the audio data for playback. First write starts the playback operation.

For uncompressed playback (for example, AudioFormat::PCM_16BIT_SIGNED), the next buffer can be sent the moment telux::common::ErrorCode::SUCCESS is received by WriteResponseCb.

For compressed playback (for example, AudioFormat::AMR*), the next buffer should be sent only after both; (a) telux::common::ErrorCode::SUCCESS is received by WriteResponseCb (indicating that the current buffer has been pushed in the pipeline for playback) and (b) IPlayListener::onReadyForWrite() has been invoked (indicating that the pipeline can accommodate the next buffer).

Parameters
[in]bufferContains the audio data to play
[in]callbackOptional, invoked to confirm if the data is played successfully
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioPlayStream::stopAudio ( StopType  stopType,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Finishes the ongoing compressed playback in a way specified by the StopType provided.

Parameters
[in]callbackInvoked to confirm if the playback has finished
[in]stopTypeDefines how to finish playback
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioPlayStream::registerListener ( std::weak_ptr< IPlayListener listener)
pure virtual

Registers the given listener to receive events; (a) pipeline is ready to accept the next buffer for compressed playback (b) compressed playback has stopped. Events are received by the listener implementing the IPlayListener interface.

Parameters
[in]listenerReceives the playstream events
Returns
telux::common::Status::SUCCESS if the listener is registered, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioPlayStream::deRegisterListener ( std::weak_ptr< IPlayListener listener)
pure virtual

Unregisters the given listener registered with IAudioPlayStream::registerListener().

Parameters
[in]listenerListener to unregister
Returns
telux::common::Status::SUCCESS if the listener is unregistered, otherwise, an appropriate error code
class telux::audio::IAudioCaptureStream

Represents the stream created with the StreamType::CAPTURE type. Provides the methods to read the captured audio.

Public Member Functions

virtual std::shared_ptr< IStreamBuffergetStreamBuffer ()=0
 
virtual telux::common::Status read (std::shared_ptr< IStreamBuffer > buffer, uint32_t bytesToRead, ReadResponseCb callback=nullptr)=0
 
virtual ~IAudioCaptureStream ()
 
- Public Member Functions inherited from telux::audio::IAudioStream
virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioCaptureStream::~IAudioCaptureStream ( )
virtual

Destructor of the IAudioCaptureStream.

Member Function Documentation

virtual std::shared_ptr<IStreamBuffer> telux::audio::IAudioCaptureStream::getStreamBuffer ( )
pure virtual

Gets an audio buffer that will contain the audio data read.

Returns
IStreamBuffer instance or nullptr if memory allocation fails
virtual telux::common::Status telux::audio::IAudioCaptureStream::read ( std::shared_ptr< IStreamBuffer buffer,
uint32_t  bytesToRead,
ReadResponseCb  callback = nullptr 
)
pure virtual

Read the audio data from the source device associated with this stream. Data captured will be received by the ReadResponseCb callback.

First read call starts the capture operation.

Parameters
[in]bufferBuffer in which data should be read
[in]bytesToReadLength of the data (in bytes) to read
[in]callbackReceives the captured data
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
class telux::audio::IAudioLoopbackStream

Represents the stream created with the StreamType::LOOPBACK type. Provides the methods to start and stop the audio loopback operation.

Public Member Functions

virtual telux::common::Status startLoopback (telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status stopLoopback (telux::common::ResponseCallback callback=nullptr)=0
 
virtual ~IAudioLoopbackStream ()
 
- Public Member Functions inherited from telux::audio::IAudioStream
virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioLoopbackStream::~IAudioLoopbackStream ( )
virtual

Destructor of the IAudioLoopbackStream.

Member Function Documentation

virtual telux::common::Status telux::audio::IAudioLoopbackStream::startLoopback ( telux::common::ResponseCallback  callback = nullptr)
pure virtual

Starts looping back the audio between the source and sink devices associated with this stream.

Parameters
[in]callbackInvoked to confirm if the loopback has started
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioLoopbackStream::stopLoopback ( telux::common::ResponseCallback  callback = nullptr)
pure virtual

Starts looping back the audio between the source and sink devices associated with this stream.

Parameters
[in]callbackOptional, invoked to confirm if the loopback has stopped
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
class telux::audio::IAudioToneGeneratorStream

Represents the stream created with the StreamType::TONE_GENERATOR type. Provides the methods to play an audio tone.

Public Member Functions

virtual telux::common::Status playTone (std::vector< uint16_t > freq, uint16_t duration, uint16_t gain, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status stopTone (telux::common::ResponseCallback callback=nullptr)=0
 
virtual ~IAudioToneGeneratorStream ()
 
- Public Member Functions inherited from telux::audio::IAudioStream
virtual StreamType getType ()=0
 
virtual telux::common::Status setDevice (std::vector< DeviceType > devices, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getDevice (GetStreamDeviceResponseCb callback=nullptr)=0
 
virtual telux::common::Status setVolume (StreamVolume volume, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getVolume (StreamDirection dir, GetStreamVolumeResponseCb callback=nullptr)=0
 
virtual telux::common::Status setMute (StreamMute mute, telux::common::ResponseCallback callback=nullptr)=0
 
virtual telux::common::Status getMute (StreamDirection dir, GetStreamMuteResponseCb callback=nullptr)=0
 
virtual ~IAudioStream ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioToneGeneratorStream::~IAudioToneGeneratorStream ( )
virtual

Destructor of the IAudioToneGeneratorStream.

Member Function Documentation

virtual telux::common::Status telux::audio::IAudioToneGeneratorStream::playTone ( std::vector< uint16_t >  freq,
uint16_t  duration,
uint16_t  gain,
telux::common::ResponseCallback  callback = nullptr 
)
pure virtual

Plays an audio tone with the given parameters.

Parameters
[in]freqFrequency of the tone. For single tone, freq[0] should be provided. For dual tone, both freq[0] and freq[1] should be provided.
[in]durationDuration (in milliseconds) for which the tone is played. Set it to INFINITE_TONE_DURATION to play indefinitely
[in]gainDefines the volume level of the tone, valid value range is 0 to 4000
[in]callbackOptional, invoked to confirm if the tone play started
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code
virtual telux::common::Status telux::audio::IAudioToneGeneratorStream::stopTone ( telux::common::ResponseCallback  callback = nullptr)
pure virtual

If the IAudioToneGeneratorStream::playTone() was called with the INFINITE_TONE_DURATION duration, then this method stops playing the tone.

Parameters
[in]callbackOptional, invoked to confirm if the tone play has stopped
Returns
Status telux::common::Status::SUCCESS if the request is initiated successfully, otherwise, an appropriate error code

Typedef Documentation

using telux::audio::ChannelTypeMask = typedef int

Describes the arrangment of audio samples in a given audio frame through ChannelType.

using telux::audio::GetStreamDeviceResponseCb = typedef std::function<void(std::vector<DeviceType> devices, telux::common::ErrorCode error)>

Invoked to pass the list of the audio devices associated with the stream. Used in conjunction with IAudioStream::getDevice().

Parameters
[in]devicesList of the devices
[in]errortelux::common::ErrorCode::SUCCESS if the device list is is sent successfully, otherwise, an appropriate error code
using telux::audio::GetStreamVolumeResponseCb = typedef std::function<void(StreamVolume volume, telux::common::ErrorCode error)>

Invoked to pass the current volume level of the audio device. Used in conjunction with IAudioStream::getVolume().

Parameters
[in]volumeDetails of the volume
[in]errortelux::common::ErrorCode::SUCCESS if the volume level is read successfully, otherwise, an appropriate error code
using telux::audio::GetStreamMuteResponseCb = typedef std::function<void(StreamMute mute, telux::common::ErrorCode error)>

Invoked to pass the current mute state of the stream. Used in conjunction with IAudioStream::getMute().

Parameters
[in]muteDetails about the mute state
[in]errortelux::common::ErrorCode::SUCCESS if the mute state is read successfully, otherwise, an appropriate error code
using telux::audio::WriteResponseCb = typedef std::function<void(std::shared_ptr<IStreamBuffer> buffer, uint32_t bytesWritten, telux::common::ErrorCode error)>

Used in conjunction with IAudioPlayStream::write(). Invoked to pass the audio data length (in bytes) played from the given buffer.

Application can clear the contents of the buffer by calling IAudioBuffer::reset() before reusing it for the subsequent write operation.

Parameters
[in]bufferBuffer passed in the call to IAudioPlayStream::write()
[in]errortelux::common::ErrorCode::SUCCESS if the playback was successful, otherwise, an appropriate error code
using telux::audio::ReadResponseCb = typedef std::function<void(std::shared_ptr<IStreamBuffer> buffer, telux::common::ErrorCode error)>

Used in conjunction with IAudioCaptureStream::read(). Invoked to pass the captured audio samples. The IAudioBuffer::getDataSize() gives the length of the data (in bytes).

After the samples have been processed by the application, it can clear the contents of the buffer by calling IAudioBuffer::reset().

Parameters
[in]bufferBuffer passed in the call to IAudioCaptureStream::read()
[in]errortelux::common::ErrorCode::SUCCESS if the capture was successful, otherwise, an appropriate error code

Enumeration Type Documentation

Used for an in-call audio usecase. Represents the direction of the audio data flow.

Enumerator
RX 

Defines that playback should occur on a voice downlink path (cellular network to a device)

TX 

Defines that playback should occur on voice uplink path (device to a cellular network)

Adds positional perspective to the audio data in a given audio frame. For example, in a 2-speaker audio system, ChannelType::LEFT may represent audio played on speaker-1 while ChannelType::RIGHT represents audio played on speaker-2.

Enumerator
LEFT 

Specifies the left channel

RIGHT 

Specifies the right channel

Specifies how audio data is represented (for example, endianness and number of bits) for storage or exchanging among various audio software and hardware layers.

Enumerator
UNKNOWN 

Default format (invalid)

PCM_16BIT_SIGNED 

PCM signed 16 bits

AMRNB 

Adaptive multirate narrow band format

AMRWB 

Adaptive multirate wide band format

AMRWB_PLUS 

Extended adaptive multirate wide band format

When generating a DTMF tone, defines the value of the low frequency component.

Enumerator
FREQ_697 

697 Hz

FREQ_770 

770 Hz

FREQ_852 

852 Hz

FREQ_941 

941 Hz

When generating a DTMF tone, defines the value of the high frequency component.

Enumerator
FREQ_1209 

1209 Hz

FREQ_1336 

1336 Hz

FREQ_1477 

1477 Hz

FREQ_1633 

1633 Hz

Defines the behavior for how a compressed audio format playback should be finished.

Enumerator
FORCE_STOP 

Stop playing immediately and discard all pending audio samples

STOP_AFTER_PLAY 

Stop playing after all samples in the pipeline have been played