Sound Manager
LibSoundmanager Class Reference

#include <libsoundmanager.hpp>

Public Types

enum  EventType_SM { Event_AsyncSetSourceState = 1 }
 
using handler_fun = std::function< void(struct json_object *)>
 

Public Member Functions

 LibSoundmanager ()
 
 ~LibSoundmanager ()
 
 LibSoundmanager (const LibSoundmanager &)=delete
 
LibSoundmanageroperator= (const LibSoundmanager &)=delete
 
int init (int port, const std::string &token)
 
int registerSource (const std::string &sourceName)
 
int connect (int sourceID, int sinkID)
 
int connect (int sourceID, const std::string &sinkName)
 
int disconnect (int connectionID)
 
int ackSetSourceState (int handle, int error)
 
int call (const std::string &verb, struct json_object *arg)
 
int call (const char *verb, struct json_object *arg)
 
int subscribe (const std::string &event_name)
 
int unsubscribe (const std::string &event_name)
 
void set_event_handler (enum EventType_SM et, handler_fun f)
 
void register_callback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
 
void register_callback (void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
 
void on_hangup (void *closure, struct afb_wsj1 *wsj)
 
void on_call (void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
 
void on_event (void *closure, const char *event, struct afb_wsj1_msg *msg)
 
void on_reply (void *closure, struct afb_wsj1_msg *msg)
 

Detailed Description

Definition at line 32 of file libsoundmanager.hpp.

Member Typedef Documentation

◆ handler_fun

using LibSoundmanager::handler_fun = std::function<void(struct json_object*)>

Definition at line 41 of file libsoundmanager.hpp.

Member Enumeration Documentation

◆ EventType_SM

Enumerator
Event_AsyncSetSourceState 

Definition at line 43 of file libsoundmanager.hpp.

Constructor & Destructor Documentation

◆ LibSoundmanager() [1/2]

LibSoundmanager::LibSoundmanager ( )

Definition at line 96 of file libsoundmanager.cpp.

◆ ~LibSoundmanager()

LibSoundmanager::~LibSoundmanager ( )

Definition at line 100 of file libsoundmanager.cpp.

◆ LibSoundmanager() [2/2]

LibSoundmanager::LibSoundmanager ( const LibSoundmanager )
delete

Member Function Documentation

◆ ackSetSourceState()

int LibSoundmanager::ackSetSourceState ( int  handle,
int  error 
)

This function calls the ackSetSourceState of Audio Manager via WebSocket

Parameters

  • sourceID [in] : This parameter is returned value of ackSetSourceState
  • handle [in] : This parameter is returned value of ackSetSourceState
  • errno [in] : If you have some errors, input ohter than 0. 0 means acknowledge

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function must be called when application get asyncSetSourceState event Input handle number attached in asyncSetSourceState and error number(0 is acknowledge)

Definition at line 374 of file libsoundmanager.cpp.

◆ call() [1/2]

int LibSoundmanager::call ( const std::string &  verb,
struct json_object *  arg 
)

◆ call() [2/2]

int LibSoundmanager::call ( const char *  verb,
struct json_object *  arg 
)

This function calls the API of Audio Manager via WebSocket This function is overload function of "call"

Parameters

  • verb [in] : This argument should be specified to the API name (e.g. "connect")
  • arg [in] : This argument should be specified to the argument of API. And this argument expects JSON object

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

To call Audio Manager's APIs, the application should set its function name, arguments to JSON format.

Definition at line 436 of file libsoundmanager.cpp.

◆ connect() [1/2]

int LibSoundmanager::connect ( int  sourceID,
int  sinkID 
)

This function calls connect of Audio Manager via WebSocket connect is to get sound right

Parameters

  • sourceID [in] : This argument should be specified to the sourceID as int. This parameter is returned value of registerSource
  • sinkID [in] : This argument should be specified to the sinkID as int. ID is specified by AudioManager

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function must be called to get source right connectionID is

Definition at line 287 of file libsoundmanager.cpp.

◆ connect() [2/2]

int LibSoundmanager::connect ( int  sourceID,
const std::string &  sinkName 
)

◆ disconnect()

int LibSoundmanager::disconnect ( int  connectionID)

This function calls the disconnect of Audio Manager via WebSocket

Parameters

  • connectionID [in] : This parameter is returned value of connect

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

Definition at line 347 of file libsoundmanager.cpp.

◆ init()

int LibSoundmanager::init ( int  port,
const std::string &  token 
)

This function is initialization function

Parameters

  • port [in] : This argument should be specified to the port number to be used for websocket
  • token [in] : This argument should be specified to the token to be used for websocket

Return

Returns 0 on success or -1 in case of transmission error.

Note

Definition at line 126 of file libsoundmanager.cpp.

◆ on_call()

void LibSoundmanager::on_call ( void *  closure,
const char *  api,
const char *  verb,
struct afb_wsj1_msg *  msg 
)

Definition at line 547 of file libsoundmanager.cpp.

◆ on_event()

void LibSoundmanager::on_event ( void *  closure,
const char *  event,
struct afb_wsj1_msg *  msg 
)

Definition at line 558 of file libsoundmanager.cpp.

◆ on_hangup()

void LibSoundmanager::on_hangup ( void *  closure,
struct afb_wsj1 *  wsj 
)

Definition at line 538 of file libsoundmanager.cpp.

◆ on_reply()

void LibSoundmanager::on_reply ( void *  closure,
struct afb_wsj1_msg *  msg 
)

Definition at line 578 of file libsoundmanager.cpp.

◆ operator=()

LibSoundmanager& LibSoundmanager::operator= ( const LibSoundmanager )
delete

◆ register_callback() [1/2]

void LibSoundmanager::register_callback ( void(*)(const std::string &event, struct json_object *event_contents)  event_cb,
void(*)(struct json_object *reply_contents)  reply_cb,
void(*)(void)  hangup_cb = nullptr 
)

◆ register_callback() [2/2]

void LibSoundmanager::register_callback ( void(*)(struct json_object *reply_contents)  reply_cb,
void(*)(void)  hangup_cb = nullptr 
)

This function is overload of register_callback. This registers callback function for reply/event message from sound manager

Parameters

  • reply_cb [in] : This argument should be specified to the reply callback for call function
  • hangup_cb [in] : This argument should be specified to the hangup callback for call function. nullptr is defaulty set.

Return

Note

Event callback is invoked by sound manager for event you subscribed. This function for convinience for user uses set_event_handler If you would like to get event, please call subscribe function before/after this function

Definition at line 236 of file libsoundmanager.cpp.

◆ registerSource()

int LibSoundmanager::registerSource ( const std::string &  sourceName)

This function calls registerSource of Audio Manager via WebSocket registerSource is registration as source for policy management

Parameters

  • sourceName [in] : This argument should be specified to the source name (e.g. "MediaPlayer")

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function must be called to get source ID mainConnectionID is returned by async reply function

Definition at line 259 of file libsoundmanager.cpp.

◆ set_event_handler()

void LibSoundmanager::set_event_handler ( enum EventType_SM  et,
handler_fun  f 
)

This function calls the ackSetSourceState of Audio Manager via WebSocket

Parameters

  • EventType_AsyncSetSourceState [in] : This parameter is EventType of soundmanager
  • handler_func [in] : This parameter is callback function

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function must be called when application get asyncSetSourceState event Input handle number attached in asyncSetSourceState and error number(0 is acknowledge)

Definition at line 528 of file libsoundmanager.cpp.

◆ subscribe()

int LibSoundmanager::subscribe ( const std::string &  event_name)

Register callback function for each event

Parameters

  • event_name [in] : This argument should be specified to the event name

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function enables to get an event to your callback function. Regarding the list of event name, please refer to CommandSender API and RountingSender API.

Definition at line 469 of file libsoundmanager.cpp.

◆ unsubscribe()

int LibSoundmanager::unsubscribe ( const std::string &  event_name)

Unregister callback function for each event

Parameters

  • event_name [in] : This argument should be specified to the event name

Return

  • Returns 0 on success or -1 in case of transmission error.

Note

This function disables to get an event to your callback function.

Definition at line 498 of file libsoundmanager.cpp.


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