Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
viam::sdk::AudioIn Class Referenceabstract

An AudioIn is a deivce that can take audio input. More...

#include "components/audio_in.hpp"

+ Inheritance diagram for viam::sdk::AudioIn:

Classes

struct  audio_chunk
 A sequential chunk of audio data with timing information for continuous audio streams. More...
 

Public Member Functions

void get_audio (std::string const &codec, std::function< bool(audio_chunk &&chunk)> const &chunk_handler, double const &duration_seconds, int64_t const &previous_timestamp)
 Get a stream of audio from the device until completed or cancelled.
 
virtual void get_audio (std::string const &codec, std::function< bool(audio_chunk &&chunk)> const &chunk_handler, double const &duration_seconds, int64_t const &previous_timestamp, const ProtoStruct &extra)=0
 Get a stream of audio from the device until completed or cancelled.
 
audio_properties get_properties ()
 Returns properties of the audio in device (supported codecs, sample rate, number of channels)
 
virtual audio_properties get_properties (const ProtoStruct &extra)=0
 Returns properties of the audio in device (supported codecs, sample rate, number of channels)
 
virtual ProtoStruct do_command (const ProtoStruct &command)=0
 
std::vector< GeometryConfigget_geometries ()
 Returns GeometryConfigs associated with the calling AudioIn.
 
virtual std::vector< GeometryConfigget_geometries (const ProtoStruct &extra)=0
 Returns GeometryConfigs associated with the calling AudioIn.
 
API api () const override
 Returns the API associated with a particular resource.
 
- Public Member Functions inherited from viam::sdk::Component
Name get_resource_name () const override
 Returns the Name for a particular resource.
 
- Public Member Functions inherited from viam::sdk::Resource
 Resource (std::string name)
 
virtual std::string name () const
 Return the resource's name.
 
void set_log_level (log_level) const
 Set the log level for log messages originating from this Resource.
 

Protected Member Functions

 AudioIn (std::string name)
 
- Protected Member Functions inherited from viam::sdk::Component
 Component (std::string name)
 
- Protected Member Functions inherited from viam::sdk::Resource
Name get_resource_name (const std::string &type) const
 

Additional Inherited Members

- Protected Attributes inherited from viam::sdk::Resource
LogSource logger_
 

Detailed Description

An AudioIn is a deivce that can take audio input.

This acts as an abstract parent class to be inherited from by any drivers representing specific AudioIn implementations. This class cannot be used on its own.

Member Function Documentation

◆ api()

API viam::sdk::AudioIn::api ( ) const
overridevirtual

Returns the API associated with a particular resource.

Implements viam::sdk::Resource.

◆ do_command()

virtual ProtoStruct viam::sdk::AudioIn::do_command ( const ProtoStruct & command)
pure virtual
Parameters
Commandthe command to execute.
Returns
The result of the executed command.

Implemented in viam::sdk::impl::AudioInClient.

◆ get_audio() [1/2]

void viam::sdk::AudioIn::get_audio ( std::string const & codec,
std::function< bool(audio_chunk &&chunk)> const & chunk_handler,
double const & duration_seconds,
int64_t const & previous_timestamp )
inline

Get a stream of audio from the device until completed or cancelled.

Parameters
codecrequested codec of the audio data
chunk_handlercallback function to call when an audio response is received. This should return true to keep streaming audio and false to indicate that the stream should terminate. The callback function should not be blocking.
duration_secondsduration of audio stream. If not set, stream duration is indefinite.
previous_timestamptimestamp to start the audio stream from for continuity between multiple calls. If not set, will stream data

◆ get_audio() [2/2]

virtual void viam::sdk::AudioIn::get_audio ( std::string const & codec,
std::function< bool(audio_chunk &&chunk)> const & chunk_handler,
double const & duration_seconds,
int64_t const & previous_timestamp,
const ProtoStruct & extra )
pure virtual

Get a stream of audio from the device until completed or cancelled.

Parameters
codecrequested codec of the audio data
chunk_handlercallback function to call when an audio response is received. For an infinite stream this should return true to keep streaming audio and false to indicate that the stream should terminate. The callback function should not be blocking.
duration_secondsduration of audio stream. If zero, stream duration is indefinite.
previous_timestamptimestamp to start the audio stream from for continuity between multiple calls. If zero, will stream data
extraAny additional arguments to the method

Implemented in viam::sdk::impl::AudioInClient, and viam::sdk::impl::AudioInClient.

◆ get_geometries() [1/2]

std::vector< GeometryConfig > viam::sdk::AudioIn::get_geometries ( )
inline

Returns GeometryConfigs associated with the calling AudioIn.

Returns
The requested GeometryConfigs associated with the component.

◆ get_geometries() [2/2]

virtual std::vector< GeometryConfig > viam::sdk::AudioIn::get_geometries ( const ProtoStruct & extra)
pure virtual

Returns GeometryConfigs associated with the calling AudioIn.

Parameters
extraAny additional arguments to the method.
Returns
The requested GeometryConfigs associated with the component.

Implemented in viam::sdk::impl::AudioInClient, and viam::sdk::impl::AudioInClient.

◆ get_properties()

virtual audio_properties viam::sdk::AudioIn::get_properties ( const ProtoStruct & extra)
pure virtual

Returns properties of the audio in device (supported codecs, sample rate, number of channels)

Parameters
extraAny additional arguments to the method

Implemented in viam::sdk::impl::AudioInClient, and viam::sdk::impl::AudioInClient.


The documentation for this class was generated from the following file: