RDK Documentation (Open Sourced RDK Components)
Audio Capture Manager Data Types and API(s)

Description

This file provides the data types and API(s) used by the audiocapturemgr.

Data Structures

class  acm_iarm_interface
 
struct  acm_session_t
 
class  acm_session_mgr
 
class  audio_buffer
 
class  q_mgr
 
class  audio_capture_client
 
struct  iarmbus_enable_payload_t
 
struct  audio_properties_ifce_t
 
struct  iarmbus_request_payload_t
 
struct  iarmbus_notification_payload_t
 
struct  iarmbus_delivery_props_t
 
union  iarmbus_delivery_props_t.output
 
struct  iarmbus_open_args
 
struct  iarmbus_acm_arg_t
 
union  iarmbus_acm_arg_t.details
 
class  music_id_client
 
class  socket_adaptor
 

Macros

#define IARMBUS_AUDIOCAPTUREMGR_NAME   "audiocapturemgr"
 
#define IARMBUS_AUDIOCAPTUREMGR_ENABLE   "enableCapture"
 
#define IARMBUS_AUDIOCAPTUREMGR_REQUEST_SAMPLE   "requestSample"
 
#define IARMBUS_AUDIOCAPTUREMGR_OPEN   "open"
 
#define IARMBUS_AUDIOCAPTUREMGR_CLOSE   "close"
 
#define IARMBUS_AUDIOCAPTUREMGR_START   "start"
 
#define IARMBUS_AUDIOCAPTUREMGR_STOP   "stop"
 
#define IARMBUS_AUDIOCAPTUREMGR_GET_DEFAULT_AUDIO_PROPS   "getDefaultAudioProperties"
 
#define IARMBUS_AUDIOCAPTUREMGR_GET_AUDIO_PROPS   "getAudioProperties"
 
#define IARMBUS_AUDIOCAPTUREMGR_GET_OUTPUT_PROPS   "getOutputProperties"
 
#define IARMBUS_AUDIOCAPTUREMGR_SET_AUDIO_PROPERTIES   "setAudioProperties"
 
#define IARMBUS_AUDIOCAPTUREMGR_SET_OUTPUT_PROPERTIES   "setOutputProperties"
 
#define AUDIOCAPTUREMGR_FILENAME_PREFIX   "audio_sample"
 
#define AUDIOCAPTUREMGR_FILE_PATH   "/opt/"
 
#define MAX_OUTPUT_PATH_LEN   256
 

Typedefs

typedef int session_id_t
 
typedef void(* request_complete_callback_t) (void *data, std::string &file, int result)
 
typedef void(* socket_adaptor_cb_t) (void *data)
 

Enumerations

enum  iarmbus_output_type_t
 
enum  iarmbus_events_t
 
enum  iarmbus_audiocapturemgr_result_t
 
enum  iarmbus_acm_format
 
enum  iarmbus_acm_freq
 

Functions

audio_buffercreate_new_audio_buffer (const unsigned char *in_ptr, unsigned int in_size, unsigned int clip_length, unsigned int refcount)
 This API creates new audio buffer. More...
 
void unref_audio_buffer (audio_buffer *ptr)
 This API is to release the audio buffer. More...
 
void set_ref_audio_buffer (audio_buffer *ptr, unsigned int refcount)
 This API is used to update the buffer references. More...
 
void audio_buffer_get_global_lock ()
 Function to acquire lock.
 
void audio_buffer_release_global_lock ()
 Function to release lock.
 
void free_audio_buffer (audio_buffer *ptr)
 Deletes the audio buffer. More...
 

Data Structure Documentation

◆ acm_iarm_interface

class acm_iarm_interface

Definition at line 26 of file acm_iarm_interface.h.

Collaboration diagram for acm_iarm_interface:
Collaboration graph

Public Member Functions

int activate (music_id_client *client)
 This API initialize the message bus, registers event, RPC methods that can be used by other applications. More...
 
int deactivate ()
 This API disconnects application from the message bus, releases memory. More...
 
int enable_capture_handler (void *arg)
 This API starts the audio capture. More...
 
int get_sample_handler (void *arg)
 This API grabs the precaptured sample, if the requested data has precapture flag true. Otherwise, capture fresh sample. More...
 
void set_filename_prefix (std::string &prefix)
 Function to add prefix to the audio filename. More...
 

Static Public Member Functions

static acm_iarm_interfaceget_instance ()
 

Private Attributes

bool m_is_active
 
bool m_enable_audio_input
 
music_id_clientm_client
 

Member Function Documentation

◆ activate()

int acm_iarm_interface::activate ( music_id_client client)

This API initialize the message bus, registers event, RPC methods that can be used by other applications.

Parameters
[in]clientIndicates the id ofthe client device.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 94 of file acm_iarm_interface.cpp.

◆ deactivate()

int acm_iarm_interface::deactivate ( )

This API disconnects application from the message bus, releases memory.

Also, unregisters the client from the application.

Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 126 of file acm_iarm_interface.cpp.

◆ enable_capture_handler()

int acm_iarm_interface::enable_capture_handler ( void *  arg)

This API starts the audio capture.

If incoming duration is 0, turn off precapturing otherwise turn it back on and set duration.

Parameters
[in]argPayload data
Returns
Returns ACM_RESULT_SUCCESS on success, appropiate error code otherwise.

Definition at line 143 of file acm_iarm_interface.cpp.

◆ get_sample_handler()

int acm_iarm_interface::get_sample_handler ( void *  arg)

This API grabs the precaptured sample, if the requested data has precapture flag true. Otherwise, capture fresh sample.

Parameters
[in]argPayload data
Returns
Returns ACM_RESULT_GENERAL_FAILURE on failure, 0 on success.

Definition at line 179 of file acm_iarm_interface.cpp.

◆ set_filename_prefix()

void acm_iarm_interface::set_filename_prefix ( std::string &  prefix)

Function to add prefix to the audio filename.

Parameters
[in]prefixPrefix to be added.

Definition at line 223 of file acm_iarm_interface.cpp.

◆ acm_session_t

struct acm_session_t

Definition at line 31 of file acm_session_mgr.h.

Collaboration diagram for acm_session_t:
Collaboration graph
Data Fields
int session_id
audio_capture_client * client
q_mgr * source
bool enable
iarmbus_output_type_t output_type

◆ acm_session_mgr

class acm_session_mgr

Definition at line 40 of file acm_session_mgr.h.

Collaboration diagram for acm_session_mgr:
Collaboration graph

Public Member Functions

int activate ()
 This API initializes the message bus, registers event, RPC methods to be used by other applications. More...
 
int deactivate ()
 This API disconnects application from the message bus, releases memory. More...
 
int get_sample_handler (void *arg)
 This API grabs the precaptured sample, if the requested data has precapture flag true. Otherwise, capture fresh sample. More...
 
int generic_handler (void *arg)
 
int open_handler (void *arg)
 This API creates the music id session. It's also used by bluetooth manager as an audio source. More...
 
int close_handler (void *arg)
 This API destroys the music id session, bluetooth manager session. More...
 
int get_default_audio_props_handler (void *arg)
 This API returns default capture settings. More...
 
int get_audio_props_handler (void *arg)
 This API returns the audio properties of a current session. More...
 
int get_output_props_handler (void *arg)
 This API returns the output properties of a current session. More...
 
int set_audio_props_handler (void *arg)
 This API is used to set the audio properties of a current session. More...
 
int set_output_props_handler (void *arg)
 This API is to set precapture duration of a client device. More...
 
int start_handler (void *arg)
 This API starts the client session. More...
 
int stop_handler (void *arg)
 This API stops the current session. More...
 
void set_filename_prefix (std::string &prefix)
 Function to add prefix to the audio filename. More...
 

Static Public Member Functions

static acm_session_mgrget_instance ()
 

Private Member Functions

q_mgrget_source (int source)
 
void lock ()
 
void unlock ()
 
acm_session_tget_session (int session_id)
 

Private Attributes

std::list< acm_session_t * > m_sessions
 
std::vector< q_mgr * > m_sources
 
pthread_mutex_t m_mutex
 
int m_session_counter
 

Member Function Documentation

◆ activate()

int acm_session_mgr::activate ( )

This API initializes the message bus, registers event, RPC methods to be used by other applications.

RPC methods like

  • request audiocapture sample
  • open
  • close
  • start
  • stop
  • get default audio properties
  • get audio properties
  • get output properties
  • set audio properties
  • set output properties
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 152 of file acm_session_mgr.cpp.

◆ deactivate()

int acm_session_mgr::deactivate ( )

This API disconnects application from the message bus, releases memory.

Also, unregisters the client from the application.

Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 179 of file acm_session_mgr.cpp.

◆ get_sample_handler()

int acm_session_mgr::get_sample_handler ( void *  arg)

This API grabs the precaptured sample, if the requested data has precapture flag true. Otherwise, capture fresh sample.

Parameters
[in]argPayload data
Returns
Returns ACM_RESULT_GENERAL_FAILURE on failure, 0 on success.

Definition at line 684 of file acm_session_mgr.cpp.

◆ open_handler()

int acm_session_mgr::open_handler ( void *  arg)

This API creates the music id session. It's also used by bluetooth manager as an audio source.

Accepts only one instance of music id client per source type.

Parameters
[in]argStructure variable that holds the details like audio source, output types etc.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 205 of file acm_session_mgr.cpp.

◆ close_handler()

int acm_session_mgr::close_handler ( void *  arg)

This API destroys the music id session, bluetooth manager session.

Parameters
[in]argStructure variable that holds the details like audio source, output types etc.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 275 of file acm_session_mgr.cpp.

◆ get_default_audio_props_handler()

int acm_session_mgr::get_default_audio_props_handler ( void *  arg)

This API returns default capture settings.

Settings like format, sampling frequency, FIFO size, threshold etc.

Parameters
[in]argIndicates the audio properties.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 383 of file acm_session_mgr.cpp.

◆ get_audio_props_handler()

int acm_session_mgr::get_audio_props_handler ( void *  arg)

This API returns the audio properties of a current session.

Parameters
[in]argIndicates the audio properties.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 456 of file acm_session_mgr.cpp.

◆ get_output_props_handler()

int acm_session_mgr::get_output_props_handler ( void *  arg)

This API returns the output properties of a current session.

Depending on the output type socket or file output.

Parameters
[in]argIndicates the output properties.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 530 of file acm_session_mgr.cpp.

◆ set_audio_props_handler()

int acm_session_mgr::set_audio_props_handler ( void *  arg)

This API is used to set the audio properties of a current session.

Properties like Format, Frequency, FIFO size, threshold, delay etc.

Parameters
[in]argIndicates the audio properties to set.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 572 of file acm_session_mgr.cpp.

◆ set_output_props_handler()

int acm_session_mgr::set_output_props_handler ( void *  arg)

This API is to set precapture duration of a client device.

Parameters
[in]argIndicates the output type.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 649 of file acm_session_mgr.cpp.

◆ start_handler()

int acm_session_mgr::start_handler ( void *  arg)

This API starts the client session.

Parameters
[in]argIARM bus arguments.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 333 of file acm_session_mgr.cpp.

◆ stop_handler()

int acm_session_mgr::stop_handler ( void *  arg)

This API stops the current session.

Parameters
[in]argIARM bus arguments.
Returns
Returns 0 on success, appropriate error code otherwise.

Definition at line 358 of file acm_session_mgr.cpp.

◆ set_filename_prefix()

void acm_session_mgr::set_filename_prefix ( std::string &  prefix)

Function to add prefix to the audio filename.

Parameters
[in]prefixPrefix to be added.

Definition at line 751 of file acm_session_mgr.cpp.

◆ audio_buffer

class audio_buffer

Definition at line 25 of file audio_buffer.h.

Collaboration diagram for audio_buffer:
Collaboration graph

Public Member Functions

 audio_buffer (const unsigned char *in_ptr, unsigned int in_size, unsigned int clip_length, unsigned int refcount)
 

Data Fields

unsigned char * m_start_ptr
 
unsigned int m_size
 
unsigned int m_clip_length
 
unsigned int m_refcount
 

◆ q_mgr

class q_mgr

Definition at line 70 of file audio_capture_manager.h.

Collaboration diagram for q_mgr:
Collaboration graph

Public Member Functions

int set_audio_properties (audiocapturemgr::audio_properties_t &in_properties)
 This API is used to set the audio properties to the client device. More...
 
void get_audio_properties (audiocapturemgr::audio_properties_t &out_properties)
 This API returns the current audio properties of the device. More...
 
void get_default_audio_properties (audiocapturemgr::audio_properties_t &out_properties)
 This function will return default RMF_AudioCapture_Settings settings. More...
 
unsigned int get_data_rate ()
 Returns data rate in bytes per second. More...
 
void add_data (unsigned char *buf, unsigned int size)
 This API creates new audio buffer and pushes the data to the queue. More...
 
void data_processor_thread ()
 This API processes the audio buffers available in the queue. More...
 
int register_client (audio_capture_client *client)
 This API registers the client. More...
 
int unregister_client (audio_capture_client *client)
 Removes the client. More...
 
int start ()
 This function will start the Audio capture. More...
 
int stop ()
 This function will stop the audio capture. More...
 

Static Public Member Functions

static rmf_Error data_callback (void *context, void *buf, unsigned int size)
 This function invokes an API for adding data to the audio buffer. More...
 

Private Member Functions

void lock (pthread_mutex_t &mutex)
 
void unlock (pthread_mutex_t &mutex)
 
void notify_data_ready ()
 
void swap_queues ()
 
void flush_queue (std::vector< audio_buffer * > *q)
 
void flush_system ()
 
void process_data ()
 
void update_buffer_references ()
 
void data_monitor ()
 

Private Attributes

std::vector< audio_buffer * > * m_current_incoming_q
 
std::vector< audio_buffer * > * m_current_outgoing_q
 
std::vector< audio_capture_client * > m_clients
 
audiocapturemgr::audio_properties_t m_audio_properties
 
unsigned int m_bytes_per_second
 
unsigned int m_inflow_byte_counter
 
unsigned int m_num_clients
 
pthread_mutex_t m_q_mutex
 
pthread_mutex_t m_client_mutex
 
sem_t m_sem
 
pthread_t m_thread
 
bool m_processing_thread_alive
 
bool m_notify_new_data
 
bool m_started
 
RMF_AudioCaptureHandle m_device_handle
 
unsigned int m_max_queue_size
 
std::thread m_data_monitor_thread
 
std::mutex m_data_monitor_mutex
 
std::condition_variable m_data_monitor_cv
 
bool m_stop_data_monitor
 

Member Function Documentation

◆ set_audio_properties()

int q_mgr::set_audio_properties ( audiocapturemgr::audio_properties_t in_properties)

This API is used to set the audio properties to the client device.

Properties like format,sampling_frequency,fifo_size,threshold,delay_compensation_ms. Checks if audio playback is started, restarted the client device after settings are applied.

Parameters
[in]in_propertiesStructure which holds the audio properties.
Returns
0 on success, appropiate errorcode otherwise.

Definition at line 223 of file audio_capture_manager.cpp.

◆ get_audio_properties()

void q_mgr::get_audio_properties ( audiocapturemgr::audio_properties_t out_properties)

This API returns the current audio properties of the device.

Parameters
[out]out_propertiesStructure which holds the audio properties.

Definition at line 270 of file audio_capture_manager.cpp.

◆ get_default_audio_properties()

void q_mgr::get_default_audio_properties ( audiocapturemgr::audio_properties_t out_properties)

This function will return default RMF_AudioCapture_Settings settings.

Once AudioCaptureStart gets called with RMF_AudioCapture_Status argument this should still continue to return the default capture settings.

Parameters
[out]out_propertiesStructure which holds the audio properties.
Returns
Device Settings error code
Return values
dsERR_NONEIndicates dsGetAudioPort API was successfully called using iarmbus call.
dsERR_GENERALIndicates error due to general failure.

Definition at line 275 of file audio_capture_manager.cpp.

◆ get_data_rate()

unsigned int q_mgr::get_data_rate ( )

Returns data rate in bytes per second.

The data rate is a term to denote the transmission speed, or the number of bytes per second transferred. Datarate is calculated as bits_per_sample * sampling_rate * num_channels / 8;

Returns
Number of bytes per second transferred.

Definition at line 285 of file audio_capture_manager.cpp.

◆ add_data()

void q_mgr::add_data ( unsigned char *  buf,
unsigned int  size 
)

This API creates new audio buffer and pushes the data to the queue.

Parameters
[in]bufData to be inserted into the queue.
[in]sizesize of the buffer.

Definition at line 290 of file audio_capture_manager.cpp.

◆ data_processor_thread()

void q_mgr::data_processor_thread ( )

This API processes the audio buffers available in the queue.

Definition at line 306 of file audio_capture_manager.cpp.

◆ register_client()

int q_mgr::register_client ( audio_capture_client client)

This API registers the client.

Client is the consumer of audio data.

Parameters
[in]clientClient info for registering.
Returns
0 on success, appropiate errorcode otherwise.

Definition at line 390 of file audio_capture_manager.cpp.

◆ unregister_client()

int q_mgr::unregister_client ( audio_capture_client client)

Removes the client.

Parameters
[in]clientClient info for registering.
Returns
0 on success, appropiate errorcode otherwise.

Definition at line 411 of file audio_capture_manager.cpp.

◆ start()

int q_mgr::start ( )

This function will start the Audio capture.

If Settings is not null, reconfigure the settings with the provided capture settings and starts the audio capture . If it is NULL, start with the default capture settings.

Returns
Returns 0 on success, appropiate error code otherwise.

Definition at line 482 of file audio_capture_manager.cpp.

◆ stop()

int q_mgr::stop ( )

This function will stop the audio capture.

Start can be called again after a Stop, as long as Close has not been called.

Returns
Returns 0 on success, appropiate error code otherwise.

Definition at line 515 of file audio_capture_manager.cpp.

◆ data_callback()

rmf_Error q_mgr::data_callback ( void *  context,
void *  buf,
unsigned int  size 
)
static

This function invokes an API for adding data to the audio buffer.

Parameters
[in]contextdata callback context
[in]bufData to be inserted into the queue.
[in]sizesize of the buffer.
Returns
Returns RMF_SUCCESS on success, appropiate error code otherwise.

Definition at line 43 of file audio_capture_manager.cpp.

◆ audio_capture_client

class audio_capture_client

Definition at line 219 of file audio_capture_manager.h.

Inheritance diagram for audio_capture_client:
Inheritance graph
Collaboration diagram for audio_capture_client:
Collaboration graph

Public Member Functions

virtual int data_callback (audio_buffer *buf)
 
 audio_capture_client (q_mgr *manager)
 
unsigned int get_priority ()
 
void set_manager (q_mgr *manager)
 
virtual int set_audio_properties (audiocapturemgr::audio_properties_t &properties)
 
virtual void get_audio_properties (audiocapturemgr::audio_properties_t &properties)
 
void get_default_audio_properties (audiocapturemgr::audio_properties_t &properties)
 
virtual void notify_event (audio_capture_events_t event)
 
virtual int start ()
 
virtual int stop ()
 

Protected Member Functions

void release_buffer (audio_buffer *ptr)
 
void lock ()
 
void unlock ()
 

Protected Attributes

q_mgrm_manager
 

Private Attributes

unsigned int m_priority
 
pthread_mutex_t m_mutex
 

◆ iarmbus_enable_payload_t

struct iarmbus_enable_payload_t

Definition at line 107 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_enable_payload_t:
Collaboration graph
Data Fields
unsigned int result
float max_duration

◆ audio_properties_ifce_t

struct audio_properties_ifce_t

Definition at line 113 of file audiocapturemgr_iarm.h.

Collaboration diagram for audio_properties_ifce_t:
Collaboration graph
Data Fields
iarmbus_acm_format format
iarmbus_acm_freq sampling_frequency
size_t fifo_size
size_t threshold
unsigned int delay_compensation_ms

◆ iarmbus_request_payload_t

struct iarmbus_request_payload_t

Definition at line 124 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_request_payload_t:
Collaboration graph
Data Fields
float duration
bool is_precapture

◆ iarmbus_notification_payload_t

struct iarmbus_notification_payload_t

Definition at line 130 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_notification_payload_t:
Collaboration graph
Data Fields
char dataLocator[64]

◆ iarmbus_delivery_props_t

struct iarmbus_delivery_props_t

Definition at line 136 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_delivery_props_t:
Collaboration graph
Data Fields
union iarmbus_delivery_props_t output

◆ iarmbus_delivery_props_t.output

union iarmbus_delivery_props_t.output

Definition at line 138 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_delivery_props_t.output:
Collaboration graph
Data Fields
char file_path[256] get unix domain socket name (ip out)
unsigned int buffer_duration set precapture duration (music id)
unsigned int max_buffer_duration get max supported buffer duration (music id)

◆ iarmbus_open_args

struct iarmbus_open_args

Definition at line 146 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_open_args:
Collaboration graph
Data Fields
int source 0 for primary, increasing by 1 for each new source.
iarmbus_output_type_t output_type

◆ iarmbus_acm_arg_t

struct iarmbus_acm_arg_t

Definition at line 152 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_acm_arg_t:
Collaboration graph
Data Fields
session_id_t session_id
int result
union iarmbus_acm_arg_t details

◆ iarmbus_acm_arg_t.details

union iarmbus_acm_arg_t.details

Definition at line 156 of file audiocapturemgr_iarm.h.

Collaboration diagram for iarmbus_acm_arg_t.details:
Collaboration graph
Data Fields
iarmbus_open_args arg_open
audio_properties_ifce_t arg_audio_properties
iarmbus_request_payload_t arg_sample_request
iarmbus_delivery_props_t arg_output_props

◆ music_id_client

class music_id_client

Definition at line 37 of file music_id.h.

Inheritance diagram for music_id_client:
Inheritance graph
Collaboration diagram for music_id_client:
Collaboration graph

Public Types

enum  preferred_delivery_method_t
 

Public Member Functions

 music_id_client (q_mgr *manager, preferred_delivery_method_t mode)
 
virtual int data_callback (audio_buffer *buf)
 
int grab_precaptured_sample (const std::string &filename=nullptr)
 This API writes the precaptured sample to a file for file mode and in socket mode, sample is written to the unix socket connection established to the client. More...
 
request_id_t grab_fresh_sample (unsigned int seconds, const std::string &filename=nullptr, request_complete_callback_t cb=nullptr, void *cb_data=nullptr)
 This API requests for new sample. More...
 
virtual int set_audio_properties (audiocapturemgr::audio_properties_t &properties)
 Invokes an API for setting the audio specific properties of the audio capture client. More...
 
virtual void get_audio_properties (audiocapturemgr::audio_properties_t &properties)
 Invokes an API for getting the audio specific properties of the audio capture client. More...
 
int set_precapture_duration (unsigned int seconds)
 This API is used to set the precapture duration. More...
 
void worker_thread ()
 This function manages a queue of requests for music id samples.
 
unsigned int get_max_supported_duration ()
 This API returns maximum precaptured length. More...
 
unsigned int enable_wav_header (bool isEnabled)
 This API is to enable/disable WAV header. More...
 
void enable_output_conversion (bool isEnabled)
 This API enables audio downsampling without anti-aliasing. More...
 
void send_clip_via_socket ()
 This API writes the captured clip data to the socket. More...
 
const std::string & get_sock_path ()
 
- Public Member Functions inherited from audio_capture_client
 audio_capture_client (q_mgr *manager)
 
unsigned int get_priority ()
 
void set_manager (q_mgr *manager)
 
void get_default_audio_properties (audiocapturemgr::audio_properties_t &properties)
 
virtual void notify_event (audio_capture_events_t event)
 
virtual int start ()
 
virtual int stop ()
 

Private Types

typedef int request_id_t
 

Private Member Functions

void trim_queue ()
 
int write_default_file_header (std::ofstream &file)
 
int update_file_header_size (std::ofstream &file, unsigned int data_size)
 
int grab_last_n_seconds (const std::string &filename, unsigned int seconds)
 
int grab_last_n_seconds (unsigned int seconds)
 
void compute_queue_size ()
 

Private Attributes

std::list< audio_buffer * > m_queue
 
std::list< request_t * > m_requests
 
std::list< audio_converter_memory_sink * > m_outbox
 
std::thread m_worker_thread
 
bool m_worker_thread_alive
 
unsigned int m_total_size
 
unsigned int m_precapture_duration_seconds
 
unsigned int m_precapture_size_bytes
 
unsigned int m_queue_upper_limit_bytes
 
unsigned int m_request_counter
 
bool m_enable_wav_header_output
 
audiocapturemgr::audio_properties_t m_output_properties
 
bool m_convert_output
 
preferred_delivery_method_t m_delivery_method
 
socket_adaptorm_sock_adaptor
 
const std::string m_sock_path
 

Additional Inherited Members

- Protected Member Functions inherited from audio_capture_client
void release_buffer (audio_buffer *ptr)
 
void lock ()
 
void unlock ()
 
- Protected Attributes inherited from audio_capture_client
q_mgrm_manager
 

Member Function Documentation

◆ grab_precaptured_sample()

int music_id_client::grab_precaptured_sample ( const std::string &  filename = nullptr)

This API writes the precaptured sample to a file for file mode and in socket mode, sample is written to the unix socket connection established to the client.

Parameters
[in]filenameFile name, where precaptured output is written to in the case of file mode.
Returns
Return 0 on success, appropiate error code otherwise.

Definition at line 185 of file music_id.cpp.

◆ grab_fresh_sample()

music_id_client::request_id_t music_id_client::grab_fresh_sample ( unsigned int  seconds,
const std::string &  filename = nullptr,
request_complete_callback_t  cb = nullptr,
void *  cb_data = nullptr 
)

This API requests for new sample.

Parameters
[in]secondslength of the sample.
[in]filenameOutput file name.
[in]cbCallback function.
[in]cb_dataCallback data.
Returns
Return 0 on success, appropiate error code otherwise.

Definition at line 285 of file music_id.cpp.

◆ set_audio_properties()

int music_id_client::set_audio_properties ( audiocapturemgr::audio_properties_t properties)
virtual

Invokes an API for setting the audio specific properties of the audio capture client.

Parameters
[in]propertiesProperties to set.
Returns
Return 0 on success, appropiate error code otherwise.

Reimplemented from audio_capture_client.

Definition at line 115 of file music_id.cpp.

◆ get_audio_properties()

void music_id_client::get_audio_properties ( audiocapturemgr::audio_properties_t properties)
virtual

Invokes an API for getting the audio specific properties of the audio capture client.

Parameters
[out]propertiesReturns the audio properties like frequency,format of the device.

Reimplemented from audio_capture_client.

Definition at line 127 of file music_id.cpp.

◆ set_precapture_duration()

int music_id_client::set_precapture_duration ( unsigned int  seconds)

This API is used to set the precapture duration.

It is in seconds.

Parameters
[in]secondsTime in seconds.
Returns
Return 0 on success, appropiate error code otherwise.

Definition at line 100 of file music_id.cpp.

◆ get_max_supported_duration()

unsigned int music_id_client::get_max_supported_duration ( )

This API returns maximum precaptured length.

Returns
Returns maximum precaptured length in seconds.

Definition at line 490 of file music_id.cpp.

◆ enable_wav_header()

unsigned int music_id_client::enable_wav_header ( bool  isEnabled)

This API is to enable/disable WAV header.

Parameters
[in]isEnabledBoolean value indicates enabled/disabled.
Returns
Return 0 on success, appropiate error code otherwise.

Definition at line 496 of file music_id.cpp.

◆ enable_output_conversion()

void music_id_client::enable_output_conversion ( bool  isEnabled)
inline

This API enables audio downsampling without anti-aliasing.

Parameters
[in]isEnabledBoolean value indicates enabled/disabled.

Definition at line 162 of file music_id.h.

◆ send_clip_via_socket()

void music_id_client::send_clip_via_socket ( )

This API writes the captured clip data to the socket.

Also it terminates the current connection.

Definition at line 160 of file music_id.cpp.

◆ socket_adaptor

class socket_adaptor

Definition at line 33 of file socket_adaptor.h.

Collaboration diagram for socket_adaptor:
Collaboration graph

Public Types

enum  control_code_t
 

Public Member Functions

int start_listening (const std::string &path)
 This function makes the audiocapturemgr listen for incoming unix domain connections to the given path. More...
 
std::string & get_path ()
 This api returns the data path. More...
 
int write_data (const char *buffer, const unsigned int size)
 This api invokes unix write() to write data to the socket. More...
 
void terminate_current_connection ()
 This api invokes close() to terminate the current connection.
 
unsigned int get_active_connections ()
 This api returns the number of active connections. More...
 
void register_data_ready_callback (socket_adaptor_cb_t cb, void *data)
 

Private Member Functions

void process_new_connection ()
 
void process_control_message (control_code_t message)
 
void stop_listening ()
 
void lock ()
 
void unlock ()
 
void worker_thread ()
 

Private Attributes

std::string m_path
 
int m_listen_fd
 
int m_write_fd
 
int m_control_pipe [2]
 
unsigned int m_num_connections
 
std::thread m_thread
 
std::mutex m_mutex
 
socket_adaptor_cb_t m_callback
 
void * m_callback_data
 

Member Function Documentation

◆ start_listening()

int socket_adaptor::start_listening ( const std::string &  path)

This function makes the audiocapturemgr listen for incoming unix domain connections to the given path.

Parameters
[in]pathbinding path.
Returns
Returns 0 on success, appropiate error code otherwise.

Definition at line 93 of file socket_adaptor.cpp.

◆ get_path()

std::string & socket_adaptor::get_path ( )

This api returns the data path.

It is the path of unix domain server that ip-out clients must connect to in order to receive real-time audio data.

Returns
Returns the data path in string.

Definition at line 88 of file socket_adaptor.cpp.

◆ write_data()

int socket_adaptor::write_data ( const char *  buffer,
const unsigned int  size 
)

This api invokes unix write() to write data to the socket.

Parameters
[in]bufferData buffer.
[in]sizeSize of the buffer
Returns
Returns 0 on success, appropiate errorcode otherwise.

Definition at line 64 of file socket_adaptor.cpp.

◆ get_active_connections()

unsigned int socket_adaptor::get_active_connections ( )

This api returns the number of active connections.

Returns
Returns the number of active connections.

Definition at line 319 of file socket_adaptor.cpp.

Enumeration Type Documentation

◆ iarmbus_acm_freq

Enumerator
acmFreqe16000 

16KHz

acmFreqe24000 

24kHz

acmFreqe32000 

32KHz

acmFreqe44100 

44.1KHz

acmFreqe48000 

48KHz

Definition at line 97 of file audiocapturemgr_iarm.h.

Function Documentation

◆ create_new_audio_buffer()

audio_buffer* create_new_audio_buffer ( const unsigned char *  in_ptr,
unsigned int  in_size,
unsigned int  clip_length,
unsigned int  refcount 
)

This API creates new audio buffer.

It is used by the Data processor thread.

Parameters
[in]in_ptrstart_ptr
[in]in_sizeinput size @parampin] clip_length Duration of the audio data
[in]refcountreference count of the buffer.

Definition at line 45 of file audio_buffer.cpp.

◆ unref_audio_buffer()

void unref_audio_buffer ( audio_buffer ptr)

This API is to release the audio buffer.

Parameters
[in]ptrIndicates the starting address of buffer

Definition at line 51 of file audio_buffer.cpp.

◆ set_ref_audio_buffer()

void set_ref_audio_buffer ( audio_buffer ptr,
unsigned int  refcount 
)
inline

This API is used to update the buffer references.

Parameters
[in]ptrBuffer pointer.
[in]refcountNumber of clients connected.

Definition at line 62 of file audio_buffer.h.

◆ free_audio_buffer()

void free_audio_buffer ( audio_buffer ptr)

Deletes the audio buffer.

Parameters
[in]ptrIndicates the starting address of buffer to be deleted.

Definition at line 69 of file audio_buffer.cpp.