aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-23 20:47:40 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-26 14:15:04 +0900
commit42e6cf561a20ba6fd637f70340ac6eab2981df25 (patch)
tree94cafd8621e0bf310cd9958b54e7fa5a495ff0d1
parent77cf19f1a039ed3e13c6a7123e0b53d4d83bb65f (diff)
clean: devide source code into header and source
soundmanager.c becomes bigger, so devide header and source. Change-Id: Ia4ea1dc2a485f931f767defb423e222c82da31fb Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp> Add Change-Id: Ica2926bd592f7470e9c42d58bbbcc060fe769d3b Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/soundmanager.c700
-rw-r--r--src/soundmanager.h436
2 files changed, 599 insertions, 537 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 8c4c7db..829f6e3 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#define _GNU_SOURCE
-#define AFB_BINDING_VERSION 2
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -23,10 +21,9 @@
#include <unistd.h>
#include <json-c/json.h>
#include <glib.h>
-#include <afb/afb-binding.h>
+#include "soundmanager.h"
#include "sm-error.h"
#include "sm-helper.h"
-#include "dbus/audio_manager_interface.h"
#define AM_NAME "org.genivi.audiomanager"
#define AM_CMD_PATH "/org/genivi/audiomanager/commandinterface"
@@ -60,11 +57,6 @@ static GDBusConnection* system_conn = NULL;
static GMainLoop *loop = NULL;
static guint16 SOUNDMANAGER_DOMAIN_ID;
-/* To Do hash table is better */
-struct event{
- char* name;
- struct afb_event* event;
- };
static struct event command_event_list[COMMAND_EVENT_NUM];
static struct event routing_event_list[ROUTING_EVENT_NUM];
@@ -110,40 +102,12 @@ static struct afb_event ev_async_set_source_state;
#define KEY_LIST_VOLUMES "listVolumes"
#define KEY_PAYLOAD "payload"
#define KEY_CONNECTION_FORMAT "connectionFormat"
+
/*
********** Method of Sound Manager (API) **********
*/
-/**
- * Call "connect" function of Audio Manager.
- * Getting resource right to output audio stream.
- * Please input following keys with value into json string object in argument.
- * In case of using libsoundmanager,
- * json_object *jobj = json_object_new_object();
- * json_object_object_add(jobj, "sourceID", json_object_new_int(100));
- * json_object_object_add(jobj, "sinkID", json_object_new_int(100));
- * call("connect", jobj);
- *
- * The order of arguments is not important.
- *
- * #### Parameters
- * Request key
- * - sourceID : Source ID getting in return value in registerSource or appname.
- * - sinkID : Sink ID. This should be more than 0. If no request, defalut value is set by sound manager
- *
- * This will be changed in near future because these arguments should be aliased like
- * sinkID:100 -> sinkID:"speaker"
- *
- * This will be modified after integrating
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- * sourceID and sinkID should be more than 0
- *
- */
-static void connect (struct afb_req request)
+void connect (struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
guint16 source_id = 0, sink_id = 0;
@@ -152,11 +116,11 @@ static void connect (struct afb_req request)
REQ_ERROR req_err1 = REQ_FAIL;
REQ_ERROR req_err2 = REQ_FAIL;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_SOURCE_ID, &source_id);
- /* ToDo: Hardware abstraction for application user is needed.
+ /* ToDo: Hardware abstraction for application user is needed.
select appname(speaker) or sourceID(sinkID). If appname is desired, it changes to sourceID(sinkID) */
-
+
const char* default_sink = afb_req_value (request, KEY_SINK_ID);
if(default_sink != NULL){
if((strlen("default") == strlen(default_sink)) &&
@@ -168,7 +132,7 @@ static void connect (struct afb_req request)
req_err2 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
}
}
-
+
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
AFB_INFO("get_value_uint16 source ret = %d,sink ret = %d", source_id, sink_id);
@@ -187,12 +151,12 @@ static void connect (struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
/* ToDo Remember appname(key) and tie to sourceID(value) */
-
+
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
@@ -202,34 +166,18 @@ static void connect (struct afb_req request)
afb_req_success(request, res, info);
}
-/**
- * Call "disconnect" function of Audio Manager.
- * Release resource right to output audio stream.
- *
- * #### Parameters
- * Request key
- * - sourceID : Source ID getting in return value in registerSource or appname.
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- * sourceID should be more than 0
- *
- */
-static void disconnect (struct afb_req request)
+void disconnect (struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
-
+
guint16 id;
gint16 ret;
REQ_ERROR req_err;
GError *err = NULL;
-
+
req_err = get_value_uint16(request, KEY_MAIN_CONNECTION_ID, &id);
AFB_DEBUG( "requested %s = %d", KEY_MAIN_CONNECTION_ID, id);
-
+
if(req_err != REQ_OK)
{
afb_req_fail(request,"wrong-request",afb_req_value (request, KEY_MAIN_CONNECTION_ID));
@@ -244,7 +192,7 @@ static void disconnect (struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -256,30 +204,15 @@ static void disconnect (struct afb_req request)
afb_req_success(request, res_obj, info); /* return error num as status */
}
-/**
- * Call "setVolume" function of Audio Manager.
- * Set sink volume.
- *
- * #### Parameters
- * Request key
- * - volume : volume value. The range of value should be [0-100]
- * - sinkID : sinkID you would like to change volume at
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void setVolume (struct afb_req request)
+void setVolume (struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
-
+
guint16 sink_id, vol;
gint16 ret;
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
req_err2 = get_value_int16(request, KEY_VOLUME, &vol);
AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_VOLUME, vol);
@@ -299,7 +232,7 @@ static void setVolume (struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -311,31 +244,15 @@ static void setVolume (struct afb_req request)
afb_req_success(request, res_obj, info); /* return error num as status */
}
-/**
- * Call "volumeStep" function of Audio Manager.
- * Change volume step of sink
- *
- * #### Parameters
- * Request key
- * - sinkID : sinkID you would to change volume step
- * - volumeStep : Step size of volume
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void volumeStep (struct afb_req request)
+void volumeStep (struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
-
+
guint16 sink_id, vol;
gint16 ret;
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
req_err2 = get_value_int16(request, KEY_VOLUME_STEP, &vol);
AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_VOLUME_STEP, vol);
@@ -355,7 +272,7 @@ static void volumeStep (struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -367,31 +284,15 @@ static void volumeStep (struct afb_req request)
afb_req_success(request, res_obj, info); /* return error num as status */
}
-/**
- * Call "volumeStep" function of Audio Manager.
- * Change volume step of sink
- *
- * #### Parameters
- * Request key
- * - sinkID : sinkID you would like to change mute state
- * - muteState : muteState, 1 means mute, 2 means unmute. Or you can designate as "mute" or "unmute"
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void setSinkMuteState(struct afb_req request)
+void setSinkMuteState(struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
-
+
guint16 sink_id, mute;
gint16 ret;
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
req_err2 = get_value_int16(request, KEY_MUTE_STATE, &mute);
AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_MUTE_STATE, mute);
@@ -411,7 +312,7 @@ static void setSinkMuteState(struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -420,26 +321,10 @@ static void setSinkMuteState(struct afb_req request)
"error", ret);
char *info = get_response_audiomanager_massage_error(ret);
- afb_req_success(request, res_obj, info); /* return error num as status */
+ afb_req_success(request, res_obj, info); /* return error num as status */
}
-/**
- * Call "getListMainConnections" function of Audio Manager.
- * Get mainc connection list
- *
- * #### Parameters
- * Request key
- * None
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
- * Sound Manager return success.
- *
- * #### Note
- *
- */
-static void getListMainConnections(struct afb_req request)
+void getListMainConnections(struct afb_req request)
{
AFB_DEBUG("call getListMainConnections");
guint16 ret;
@@ -456,7 +341,7 @@ static void getListMainConnections(struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -477,7 +362,7 @@ static void getListMainConnections(struct afb_req request)
guint16 mcid, srcid, sinkid;
gint16 delay, constate;
g_variant_get_child(
- mainConnectionList,i,"(qqqnn)",
+ mainConnectionList,i,"(qqqnn)",
&mcid, &srcid, &sinkid, &delay, &constate
);
@@ -496,23 +381,7 @@ static void getListMainConnections(struct afb_req request)
afb_req_success(request, array_res, "Success to get main connection list");
}
-/**
- * Call "getListMainSources" function of Audio Manager.
- * Get main source list
- *
- * #### Parameters
- * Request key
- * None
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
- * Sound Manager return success.
- *
- * #### Note
- *
- */
-static void getListMainSources(struct afb_req request)
+void getListMainSources(struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
guint16 ret;
@@ -574,23 +443,7 @@ static void getListMainSources(struct afb_req request)
g_variant_unref(mainSourceList);
}
-/**
- * Call "getListMainSinks" function of Audio Manager.
- * Get main sink list
- *
- * #### Parameters
- * Request key
- * None
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
- * Sound Manager return success.
- *
- * #### Note
- *
- */
-static void getListMainSinks(struct afb_req request)
+void getListMainSinks(struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
guint16 ret;
@@ -607,7 +460,7 @@ static void getListMainSinks(struct afb_req request)
if(err != NULL)
{
- afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
return;
}
@@ -632,7 +485,7 @@ static void getListMainSinks(struct afb_req request)
gint16 volume, mutestate;
GVariant* child = g_variant_get_child_value(mainSinkList, i);
g_variant_get(
- child,"(qs(nn)nnq)",
+ child,"(qs(nn)nnq)",
&sinkid, &sinkname, &av, &avr, &volume, &mutestate, &sinkclassid);
AFB_DEBUG( "sinkID: %d, sinkName: %s, availability: %d, availableReason: %d, volume: %d, muteState: %d, sinkClassID: %d",
sinkid, sinkname, av, avr, volume, mutestate, sinkclassid);
@@ -661,26 +514,7 @@ static void getListMainSinks(struct afb_req request)
*
*/
-/**
- * Call "ackConnect" function of Audio Manager.
- * Return acknowledge of connect against asyncConnect
- *
- * #### Parameters
- * - handle : Handle id when you get on asyncConnect
- * - connectionID : connection id when you got on connect return value
- * - error : Error Number you would like to send. If error is 0, it means OK.
- * If an application has some error, send error number in function then AM release
- * resources the application got in connect.
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
- * Sound Manager return success. So you should check the contents size of return json object
- *
- * #### Note
- *
- */
-static void ackConnect(struct afb_req request)
+void ackConnect(struct afb_req request)
{
/* This function will be deprecated */
AFB_DEBUG("call %s", __FUNCTION__);
@@ -688,11 +522,11 @@ static void ackConnect(struct afb_req request)
guint16 ret = 0;
REQ_ERROR req_err1, req_err2 , req_err3;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
req_err2 = get_value_uint16(request, KEY_CONNECTION_ID, &connection_id);
req_err3 = get_value_uint16(request, KEY_ERROR, &error);
-
+
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
{
afb_req_fail(request,"wrong-request", NULL);
@@ -703,7 +537,7 @@ static void ackConnect(struct afb_req request)
afb_req_fail(request,"wrong-request", "connectionID is more than 0");
return;
}
-
+
audiomanager_routinginterface_call_ack_connect_sync(
am_route_bus,
handle,
@@ -719,30 +553,12 @@ static void ackConnect(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- KEY_ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
-/**
- * Call "ackDisconnect" function of Audio Manager.
- * Return acknowledge of disconnect against asyncDisconnect
- *
- * #### Parameters
- * - handle : Handle id when you get on asyncDisconnect
- * - connectionID : connection id when you got on connect return value
- * - error : Error Number you would like to send. If error is 0, it means OK.
- * If an application has some error, send error number in function then AM
- *
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
- * Sound Manager return success. So you should check the contents size of return json object
- *
- * #### Note
- *
- */
-static void ackDisconnect(struct afb_req request)
+void ackDisconnect(struct afb_req request)
{
/* This function will be deprecated */
AFB_DEBUG("call %s", __FUNCTION__);
@@ -750,14 +566,14 @@ static void ackDisconnect(struct afb_req request)
guint16 ret = 0;
REQ_ERROR req_err1, req_err2 , req_err3;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
req_err2 = get_value_uint16(request, KEY_CONNECTION_ID, &connection_id);
req_err3 = get_value_uint16(request, KEY_ERROR, &error);
-
+
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
{
- afb_req_fail(request,"wrong-request", "connectionID is more than 0");
+ afb_req_fail(request,"wrong-request", "connectionID is more than 0");
return;
}
if(connection_id == 0)
@@ -781,43 +597,26 @@ static void ackDisconnect(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- KEY_ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
-/**
- * Call "ackSetSourceState" function of Audio Manager.
- * Return acknowledge of setSourceState against asyncSetSourceState.
- *
- * #### Parameters
- * - handle : Handle id when you get on asyncSetSourceState
- * - error : Error Number you would like to send. If error is 0, it means OK.
- * If an application has some errors, send error number in function
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- * This function is very important for applications to realise the sequence of Audio Management.
- * An Application which matches with sourceID in the parameter of asyncSetSourceState has to return ack to use this function
- *
- */
-static void ackSetSourceState(struct afb_req request)
+void ackSetSourceState(struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
guint16 handle, error;
guint16 ret = 0;
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
-
+
req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
req_err2 = get_value_uint16(request, KEY_ERROR, &error);
-
+
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
AFB_DEBUG("wrong request");
- afb_req_fail(request,"wrong-request", NULL);
+ afb_req_fail(request,"wrong-request", NULL);
return;
}
@@ -835,42 +634,23 @@ static void ackSetSourceState(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- KEY_ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
-/**
- * Call "registerSource" function of Audio Manager.
- * Register source(application) to Audio Manager Policy Management
- * Application must call this function on its initialization
- *
- * #### Parameters
- * - appname : Application unieque name
- * [Option]
- * It is not necessary to designate following argument, because these are default value is selected y soundmanager
- * If you would like to set value, please input the following key and value
- * - sourceClassID :
- * - sourceState :
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void registerSource(struct afb_req request)
+void registerSource(struct afb_req request)
{
AFB_DEBUG("call %s", __FUNCTION__);
GError *err = NULL;
-
+
guint16 source_id; /* q 0 is for dynamic id*/
guint16 domain_id; /* q */
guint16 source_class_id; /* q */
gint32 source_state; /* i */
gint16 volume; /* n */
-
+
if(REQ_OK != get_value_uint16(request, KEY_SOURCE_ID, &source_id)){
source_id = DYNAMIC_SOURCE_ID; /* if 0, dynamic source id will be applied */
}
@@ -918,7 +698,7 @@ static void registerSource(struct afb_req request)
struct sound_property_s sound_property_list; /* a(in) */
sound_property_list.type = 0;
sound_property_list.value = 0; /* in reality, this is array of struct */
-
+
gint32 connection_format_list = DEFAULT_CONNECTION_FORMAT; /* ai */
struct main_sound_property_s main_property_list; /* a(in) */
main_property_list.type = 0;
@@ -938,7 +718,7 @@ static void registerSource(struct afb_req request)
guint16 acquire_source_id;
guint16 ret;
- GVariant* sourceData = create_source_data (source_id, domain_id, name, source_class_id,
+ GVariant* sourceData = create_source_data (source_id, domain_id, name, source_class_id,
source_state, volume, visible, available, interrupt,
sound_property_list, connection_format_list, main_property_list,
nconf_routing, nconf_command);
@@ -967,26 +747,13 @@ static void registerSource(struct afb_req request)
afb_req_success(request, res, info);
}
-/**
- * Call "deregisterSource" function of Audio Manager.
- * Deregister source(application) to Audio Manager Policy Management
- *
- * #### Parameters
- * - sourceID : sourceID returned in resisterSource
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void deregisterSource(struct afb_req request)
+void deregisterSource(struct afb_req request)
{
guint16 source_id;
guint16 ret;
-
+
GError *err = NULL;
-
+
if(REQ_OK != get_value_uint16(request, KEY_SOURCE_ID, &source_id)){
afb_req_fail(request, "wrong-request", NULL);
}
@@ -1010,41 +777,29 @@ static void deregisterSource(struct afb_req request)
}
-/**
- * Subscribe event
- *
- * #### Parameters
- * - event : Event name. Event list is written in libsoundmanager.hpp
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void subscribe(struct afb_req request)
+void subscribe(struct afb_req request)
{
const char *value = afb_req_value(request, "event");
AFB_DEBUG( "value is %s", value);
int ret = 0;
- if(value) {
+ if(value) {
int index = sm_search_event_name_index(value);
if(index < 0)
{
index = sm_search_routing_event_name_index(value);
if(index < 0)
{
- AFB_NOTICE( "dedicated event doesn't exist");
+ AFB_NOTICE( "dedicated event doesn't exist");
ret = EVENT_SUBSCRIBE_ERROR_CODE;
}
else
{
afb_req_subscribe(request, *routing_event_list[index].event);
- }
+ }
}
else
{
- afb_req_subscribe(request, *command_event_list[index].event);
+ afb_req_subscribe(request, *command_event_list[index].event);
}
}
else{
@@ -1059,19 +814,7 @@ static void subscribe(struct afb_req request)
afb_req_success(request, res, info);
}
-/**
- * Unsubscribe event
- *
- * #### Parameters
- * - event : Event name. Event list is written in libsoundmanager.hpp
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- *
- * #### Note
- *
- */
-static void unsubscribe(struct afb_req request)
+void unsubscribe(struct afb_req request)
{
const char *value = afb_req_value(request, "event");
AFB_DEBUG( "value is %s", value);
@@ -1083,17 +826,17 @@ static void unsubscribe(struct afb_req request)
index = sm_search_routing_event_name_index(value);
if(index < 0)
{
- AFB_NOTICE( "dedicated event doesn't exist");
+ AFB_NOTICE( "dedicated event doesn't exist");
ret = EVENT_SUBSCRIBE_ERROR_CODE;
}
else
{
afb_req_unsubscribe(request, *routing_event_list[index].event);
- }
+ }
}
else
{
- afb_req_unsubscribe(request, *command_event_list[index].event);
+ afb_req_unsubscribe(request, *command_event_list[index].event);
}
}
else{
@@ -1108,63 +851,20 @@ static void unsubscribe(struct afb_req request)
afb_req_success(request, res, info);
}
-/**
- * Application High Level API for AGL
- * This function opens "stream".
- * "strem" means the routing from source to sink.
- * This function calls registerSource and register the endpoint.
- * If the endpoint is not registered in AudioManager, Sound Manager uses default value.
- * audio_role will be translated to "sourceID", and "endpoint_id" will be translated to "sinkID".
- *
- * #### Parameters
- * - audio_role : audio role such like entertainment, emergency.
- * This name is depends on the system architect.
- * The name will be application name or will be the group(role) of application.
- * - endpoint_id : Same as sinkID in Sound Manager.
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- * - stream_id : Same as sourceID but key is different. This is for AHL.
- * #### Note
- * TODO : write note
- */
-static void streamOpen(struct afb_req req){
+/*
+*
+****** High Level API ***********
+*
+*/
+void streamOpen(struct afb_req req){
// TODO : wtite function
}
-/**
- * Application High Level API for AGL
- * This function closes "stream".
- * This function calls disconnect with registered connectionID translated with requested connection_id.
- * If the connection is not created in Sound Manager, Sound Manager just returns with error message.
- *
- * #### Parameters
- * - stream_id : Stream id which is returned in stream_open.
- *
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- * #### Note
- * TODO : write note
- */
-static void streamClose(struct afb_req req){
+void streamClose(struct afb_req req){
// TODO : wtite function
}
-/**
- * Application High Level API for AGL
- * This function set stream state.
- * This function set the availability and calls connect function of Audio Manager
- * and returns the result of policy check.
- *
- * #### Parameters
- * - stream_id : Stream id which is returned in stream_open.
- * - mute : Stream state as int
- * #### Return
- * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
- * #### Note
- * TODO : write note
- */
-static void setStreamState(struct afb_req req){
+void setStreamState(struct afb_req req){
// TODO : wtite function
}
@@ -1181,7 +881,7 @@ static void on_new_main_connection(AudiomanagerCommandinterface* interface,
gint16 delay, constate;
g_variant_get(
mainConnection,"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
-
+
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj,10,
KEY_MAIN_CONNECTION_ID, mcid,
@@ -1199,9 +899,9 @@ static void on_removed_main_connection(
AudiomanagerCommandinterface* interface, guint16 mainConnectionID)
{
AFB_DEBUG("%s is called",__FUNCTION__);
-
+
struct json_object* res_obj = json_object_new_object();
- sm_add_object_to_json_object(res_obj, 2,
+ sm_add_object_to_json_object(res_obj, 2,
KEY_MAIN_CONNECTION_ID, mainConnectionID);
afb_event_push(ev_removed_main_connection, res_obj);
}
@@ -1212,7 +912,7 @@ static void on_main_connection_state_changed(
AFB_DEBUG("%s is called",__FUNCTION__);
struct json_object* res_obj = json_object_new_object();
- sm_add_object_to_json_object(res_obj, 4,
+ sm_add_object_to_json_object(res_obj, 4,
KEY_CONNECTION_ID, connectionID,
KEY_CONNECTION_STATE, connectionState);
afb_event_push(ev_main_connection_state_changed, res_obj);
@@ -1271,7 +971,7 @@ static gboolean on_async_abort(
GDBusMethodInvocation *invocation,
guint16 arg_handle)
{
- AFB_DEBUG( "%s called", __FUNCTION__);
+ AFB_DEBUG( "%s called", __FUNCTION__);
/* Nothing To Do. If it is better to implement something, I will implement */
return TRUE;
}
@@ -1296,7 +996,7 @@ static gboolean on_async_connect(
KEY_CONNECTION_FORMAT, arg_connectionFormat);
afb_event_push(ev_async_connect, ev_obj);
- /* GError must be initialized here because it is same as grobal errno,
+ /* GError must be initialized here because it is same as grobal errno,
so if afb_event_push is failed due to something, number will be changed */
GError* err = NULL;
audiomanager_routinginterface_call_ack_connect_sync(
@@ -1310,7 +1010,7 @@ static gboolean on_async_connect(
AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
return FALSE;
}
- return TRUE;
+ return TRUE;
}
static gboolean on_async_disconnect(
@@ -1360,26 +1060,9 @@ static gboolean on_async_set_sink_volume(
AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
return FALSE;
}
- return TRUE;
+ return TRUE;
}
-/**
- * Event "asyncSetSourceState"
- * This event is one of the result of Audio Management for connect/disconnect.
- *
- * #### Parameters
- * Request key
- * - sourceID : sourceID to be commanded by Audio Manager. The contents of command is sourceState
- * - handle : handle is the dynamic number managed by Audio Manager. Please return this parameter to input ackSetSourceState as is
- * - sourceState : "on" is the instruction that application can output sound
- * "off" is the instruction that application sound right will be removed_main_connection
- * "pause" is the instruction that application must stop output sound because other applications temporaly got sound right and will output sound
- *
- * #### Note
- * This function is very important for applications to realise the sequence of Audio Management.
- * An Application which matches with sourceID in the parameter of asyncSetSourceState has to return ack to use this function
- *
- */
static gboolean on_async_set_source_state(
AudiomanagerRoutingSoundmanager *object,
GDBusMethodInvocation *invocation,
@@ -1387,7 +1070,7 @@ static gboolean on_async_set_source_state(
guint16 arg_sourceID,
gint arg_sourceState)
{
- AFB_DEBUG( "%s called", __FUNCTION__);
+ AFB_DEBUG( "%s called", __FUNCTION__);
struct json_object* ev_obj = json_object_new_object();
char* ss_key = get_source_state_key(arg_sourceState);
sm_add_object_to_json_object(ev_obj, 4,
@@ -1403,53 +1086,6 @@ static gboolean on_async_set_source_state(
NULL, &err);*/
}
-
-/*
- * array of the verbs exported to afb-daemon
- */
-static const struct afb_verb_v2 binding_verbs[]= {
-#ifdef ENABLE_AGL_AHL
-// High Level API of AGL
-{ .verb = "stream_open", .callback = streamOpen, .auth = NULL,
- .info = "Open stream." , .session = AFB_SESSION_NONE},
-{ .verb = "stream_close", .callback = streamClose, .auth = NULL,
- .info = "Close stream" , .session = AFB_SESSION_NONE},
-{ .verb = "set_stream_state", .callback = setStreamState, .auth = NULL,
- .info = "Set stream state" , .session = AFB_SESSION_NONE},
-#endif
-// Adaption API of Audio Manager
-{ .verb = "connect", .callback = connect, .auth = NULL,
- .info = "Connect source id and sink id" , .session = AFB_SESSION_NONE},
-{ .verb = "disconnect", .callback = disconnect, .auth = NULL,
- .info = "Disconnect source id and sink id" , .session = AFB_SESSION_NONE},
-{ .verb = "setVolume", .callback = setVolume, .auth = NULL,
- .info = "Set volume value" , .session = AFB_SESSION_NONE}, /* it is better to show the range*/
-{ .verb = "volumeStep", .callback = volumeStep, .auth = NULL,
- .info = "Set volume step range" , .session = AFB_SESSION_NONE},
-{ .verb = "setSinkMuteState", .callback = setSinkMuteState, .auth = NULL,
- .info = "Set Mute state: 1 means mute, 2 means umute. Others are invalid" ,.session = AFB_SESSION_NONE},
-{ .verb = "getListMainConnections", .callback = getListMainConnections, .auth = NULL,
- .info = "Get MainConnection List" , .session = AFB_SESSION_NONE},
-{ .verb = "getListMainSinks", .callback = getListMainSinks, .auth = NULL,
- .info = "Get MainSink List" , .session = AFB_SESSION_NONE},
-{ .verb = "getListMainSources", .callback = getListMainSources, .auth = NULL,
- .info = "Get MainSource List" , .session = AFB_SESSION_NONE},
-{ .verb = "registerSource", .callback = registerSource, .auth = NULL,
- .info = "Register autio role" , .session = AFB_SESSION_NONE},
-{ .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL,
- .info = "Deregister audio role" , .session = AFB_SESSION_NONE},
-{ .verb = "ackConnect", .callback = ackConnect, .auth = NULL,
- .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
-{ .verb = "ackDisconnect", .callback = ackDisconnect, .auth = NULL,
- .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
-{ .verb = "ackSetSourceState", .callback = ackSetSourceState, .auth = NULL,
- .info = "Acknowledge of asyncSetSourceState" , .session = AFB_SESSION_NONE},
-{ .verb = "subscribe", .callback = subscribe, .auth = NULL,
- .info = "Subscribe event" , .session = AFB_SESSION_NONE},
-{ .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL,
- .info = "Unsubscribe event" , .session = AFB_SESSION_NONE},
-{ .verb = NULL } /* marker for end of the array */};
-
/*
*
********** Internal Function used by Sound Manager **********
@@ -1477,11 +1113,11 @@ static int registerDomain()
guint16 error;
audiomanager_routinginterface_call_register_domain_sync(
- am_route_bus,
+ am_route_bus,
domainData,
- retBusName,
+ retBusName,
retPath,
- retInterface,
+ retInterface,
&domain_id, &error,
NULL, &err);
if(err != NULL){
@@ -1498,45 +1134,6 @@ static int registerDomain()
return 0;
}
-static int preinit()
-{
- int ret;
- AFB_INFO("Initialize Dbus object");
- /* Initialize Dbus interface */
- if(am_cmd_bus || am_route_bus)
- {
- AFB_ERROR( "Dbus object to Audio Manager is already created");
- goto out;
- }
- am_cmd_bus = audiomanager_commandinterface_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- AM_NAME,
- AM_CMD_PATH,
- NULL,
- NULL
- );
- am_route_bus = audiomanager_routinginterface_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- AM_NAME,
- AM_ROUTE_PATH,
- NULL,
- NULL
- );
-
- if(!am_cmd_bus || !am_route_bus)
- {
- goto out;
- }
-
- AFB_NOTICE( "Finish Initialize");
- return 0;
-out:
- AFB_ERROR("Failed to initialize");
- return -1;
-}
-
static int create_adapter()
{
GError *error = NULL;
@@ -1579,11 +1176,49 @@ static int create_adapter()
static void on_name_lost(GDBusServer *server, GDBusConnection *conn, gpointer data)
{
- AFB_WARNING("%s called", __FUNCTION__);
+ AFB_WARNING("%s called", __FUNCTION__);
}
+int preinit()
+{
+ int ret;
+ AFB_INFO("Initialize Dbus object");
+ /* Initialize Dbus interface */
+ if(am_cmd_bus || am_route_bus)
+ {
+ AFB_ERROR( "Dbus object to Audio Manager is already created");
+ goto out;
+ }
+ am_cmd_bus = audiomanager_commandinterface_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ AM_NAME,
+ AM_CMD_PATH,
+ NULL,
+ NULL
+ );
+ am_route_bus = audiomanager_routinginterface_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ AM_NAME,
+ AM_ROUTE_PATH,
+ NULL,
+ NULL
+ );
+
+ if(!am_cmd_bus || !am_route_bus)
+ {
+ goto out;
+ }
-static int sm_event_init()
+ AFB_NOTICE( "Finish Initialize");
+ return 0;
+out:
+ AFB_ERROR("Failed to initialize");
+ return -1;
+}
+
+int sm_init()
{
AFB_NOTICE("Initialize event receive setting");
printf("Initialize event receive setting");
@@ -1599,33 +1234,33 @@ static int sm_event_init()
ev_removed_main_connection = afb_daemon_make_event(cmd_evlist[2]);
ev_sink_mute_state_changed = afb_daemon_make_event(cmd_evlist[3]);
ev_main_connection_state_changed = afb_daemon_make_event(cmd_evlist[4]);
- command_event_list[0].name = cmd_evlist[0];
+ command_event_list[0].name = cmd_evlist[0];
command_event_list[0].event = &ev_volume_changed;
- command_event_list[1].name = cmd_evlist[1];
+ command_event_list[1].name = cmd_evlist[1];
command_event_list[1].event = &ev_new_connection;
- command_event_list[2].name = cmd_evlist[2];
+ command_event_list[2].name = cmd_evlist[2];
command_event_list[2].event = &ev_removed_main_connection;
- command_event_list[3].name = cmd_evlist[3];
+ command_event_list[3].name = cmd_evlist[3];
command_event_list[3].event = &ev_sink_mute_state_changed;
- command_event_list[4].name = cmd_evlist[4];
+ command_event_list[4].name = cmd_evlist[4];
command_event_list[4].event = &ev_main_connection_state_changed;
/* create routing event */
ev_set_routing_ready = afb_daemon_make_event(route_evlist[0]);
- ev_set_routing_rundown = afb_daemon_make_event(route_evlist[1]);
+ ev_set_routing_rundown = afb_daemon_make_event(route_evlist[1]);
ev_async_connect = afb_daemon_make_event(route_evlist[2]);
ev_async_set_source_state = afb_daemon_make_event(route_evlist[3]);
ev_async_disconnect = afb_daemon_make_event(route_evlist[4]);
-
- routing_event_list[0].name = route_evlist[0];
+
+ routing_event_list[0].name = route_evlist[0];
routing_event_list[0].event = &ev_set_routing_ready;
- routing_event_list[1].name = route_evlist[1];
+ routing_event_list[1].name = route_evlist[1];
routing_event_list[1].event = &ev_set_routing_rundown;
- routing_event_list[2].name = route_evlist[2];
+ routing_event_list[2].name = route_evlist[2];
routing_event_list[2].event = &ev_async_connect;
- routing_event_list[3].name = route_evlist[3];
+ routing_event_list[3].name = route_evlist[3];
routing_event_list[3].event = &ev_async_set_source_state;
- routing_event_list[4].name = route_evlist[4];
+ routing_event_list[4].name = route_evlist[4];
routing_event_list[4].event = &ev_async_disconnect;
/*for(size_t i = 0; i < size; ++i)
{
@@ -1638,7 +1273,7 @@ static int sm_event_init()
command_event_list[i] = ev;
search_result = hsearch(entry, FIND);
if(search_result)
- AFB_NOTICE( "event name is %s", search_result->key);
+ AFB_NOTICE( "event name is %s", search_result->key);
}*/
/* Initialize dbus event thread */
@@ -1647,33 +1282,33 @@ static int sm_event_init()
goto ev_init_out;
}
/* initialize signal from audio manager command interface */
- g_signal_connect(am_cmd_bus,
- "volume_changed",
- G_CALLBACK(on_volume_changed),
+ g_signal_connect(am_cmd_bus,
+ "volume_changed",
+ G_CALLBACK(on_volume_changed),
NULL);
- g_signal_connect(am_cmd_bus,
- "new_main_connection",
- G_CALLBACK(on_new_main_connection),
+ g_signal_connect(am_cmd_bus,
+ "new_main_connection",
+ G_CALLBACK(on_new_main_connection),
NULL);
- g_signal_connect(am_cmd_bus,
- "removed_main_connection",
- G_CALLBACK(on_removed_main_connection),
+ g_signal_connect(am_cmd_bus,
+ "removed_main_connection",
+ G_CALLBACK(on_removed_main_connection),
NULL);
- g_signal_connect(am_cmd_bus,
- "sink_mute_state_changed",
- G_CALLBACK(on_sink_mute_state_changed),
+ g_signal_connect(am_cmd_bus,
+ "sink_mute_state_changed",
+ G_CALLBACK(on_sink_mute_state_changed),
NULL);
- g_signal_connect(am_cmd_bus,
- "main_connection_state_changed",
- G_CALLBACK(on_main_connection_state_changed),
+ g_signal_connect(am_cmd_bus,
+ "main_connection_state_changed",
+ G_CALLBACK(on_main_connection_state_changed),
NULL);
- g_signal_connect(am_route_bus,
- "set_routing_ready",
- G_CALLBACK(on_set_routing_ready),
+ g_signal_connect(am_route_bus,
+ "set_routing_ready",
+ G_CALLBACK(on_set_routing_ready),
NULL);
- g_signal_connect(am_route_bus,
- "set_routing_rundown",
- G_CALLBACK(on_set_routing_rundown),
+ g_signal_connect(am_route_bus,
+ "set_routing_rundown",
+ G_CALLBACK(on_set_routing_rundown),
NULL);
/* Get soundmanager adapter bus */
@@ -1683,14 +1318,14 @@ static int sm_event_init()
ret = create_adapter();
if(ret != 0)
{
- goto ev_init_out;
+ goto ev_init_out;
}
ret = registerDomain();
if(ret != 0)
{
AFB_ERROR("registerDomain error: %s",get_response_audiomanager_massage_error(ret));
- goto ev_init_out;
+ goto ev_init_out;
}
AFB_INFO("Finish Initialize event receive setting");
@@ -1701,16 +1336,7 @@ ev_init_out:
return -1;
}
-static void onevent(const char *event, struct json_object *object)
+void onevent(const char *event, struct json_object *object)
{
AFB_NOTICE("on_event %s", event);
}
-
-const struct afb_binding_v2 afbBindingV2 = {
- .api = "soundmanager",
- .specification = NULL,
- .verbs = binding_verbs,
- .preinit = preinit,
- .init = sm_event_init,
- .onevent = onevent
-};
diff --git a/src/soundmanager.h b/src/soundmanager.h
new file mode 100644
index 0000000..34d82fd
--- /dev/null
+++ b/src/soundmanager.h
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef SOUNDMANAGER_H
+#define SOUNDMANAGER_H
+
+#define _GNU_SOURCE
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include "dbus/audio_manager_interface.h"
+
+struct event{
+ char* name;
+ struct afb_event* event;
+ };
+
+/*
+********** Method of Sound Manager (API) **********
+*/
+
+/**
+ * Call "connect" function of Audio Manager.
+ * Getting resource right to output audio stream.
+ * Please input following keys with value into json string object in argument.
+ * In case of using libsoundmanager,
+ * json_object *jobj = json_object_new_object();
+ * json_object_object_add(jobj, "sourceID", json_object_new_int(100));
+ * json_object_object_add(jobj, "sinkID", json_object_new_int(100));
+ * call("connect", jobj);
+ *
+ * The order of arguments is not important.
+ *
+ * #### Parameters
+ * Request key
+ * - sourceID : Source ID getting in return value in registerSource or appname.
+ * - sinkID : Sink ID. This should be more than 0. If no request, defalut value is set by sound manager
+ *
+ * This will be changed in near future because these arguments should be aliased like
+ * sinkID:100 -> sinkID:"speaker"
+ *
+ * This will be modified after integrating
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ * sourceID and sinkID should be more than 0
+ *
+ */
+void connect (struct afb_req request);
+
+/**
+ * Call "disconnect" function of Audio Manager.
+ * Release resource right to output audio stream.
+ *
+ * #### Parameters
+ * Request key
+ * - sourceID : Source ID getting in return value in registerSource or appname.
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ * sourceID should be more than 0
+ *
+ */
+void disconnect (struct afb_req request);
+
+/**
+ * Call "setVolume" function of Audio Manager.
+ * Set sink volume.
+ *
+ * #### Parameters
+ * Request key
+ * - volume : volume value. The range of value should be [0-100]
+ * - sinkID : sinkID you would like to change volume at
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void setVolume (struct afb_req request);
+
+/**
+ * Call "volumeStep" function of Audio Manager.
+ * Change volume step of sink
+ *
+ * #### Parameters
+ * Request key
+ * - sinkID : sinkID you would to change volume step
+ * - volumeStep : Step size of volume
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void volumeStep (struct afb_req request);
+
+/**
+ * Call "volumeStep" function of Audio Manager.
+ * Change volume step of sink
+ *
+ * #### Parameters
+ * Request key
+ * - sinkID : sinkID you would like to change mute state
+ * - muteState : muteState, 1 means mute, 2 means unmute. Or you can designate as "mute" or "unmute"
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void setSinkMuteState(struct afb_req request);
+
+/**
+ * Call "getListMainConnections" function of Audio Manager.
+ * Get mainc connection list
+ *
+ * #### Parameters
+ * Request key
+ * None
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
+ * Sound Manager return success.
+ *
+ * #### Note
+ *
+ */
+void getListMainConnections(struct afb_req request);
+
+/**
+ * Call "getListMainSources" function of Audio Manager.
+ * Get main source list
+ *
+ * #### Parameters
+ * Request key
+ * None
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
+ * Sound Manager return success.
+ *
+ * #### Note
+ *
+ */
+void getListMainSources(struct afb_req request);
+
+/**
+ * Call "getListMainSinks" function of Audio Manager.
+ * Get main sink list
+ *
+ * #### Parameters
+ * Request key
+ * None
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
+ * Sound Manager return success.
+ *
+ * #### Note
+ *
+ */
+void getListMainSinks(struct afb_req request);
+
+/**
+ * Call "ackConnect" function of Audio Manager.
+ * Return acknowledge of connect against asyncConnect
+ *
+ * #### Parameters
+ * - handle : Handle id when you get on asyncConnect
+ * - connectionID : connection id when you got on connect return value
+ * - error : Error Number you would like to send. If error is 0, it means OK.
+ * If an application has some error, send error number in function then AM release
+ * resources the application got in connect.
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
+ * Sound Manager return success. So you should check the contents size of return json object
+ *
+ * #### Note
+ *
+ */
+void ackConnect(struct afb_req request);
+
+/**
+ * Call "ackDisconnect" function of Audio Manager.
+ * Return acknowledge of disconnect against asyncDisconnect
+ *
+ * #### Parameters
+ * - handle : Handle id when you get on asyncDisconnect
+ * - connectionID : connection id when you got on connect return value
+ * - error : Error Number you would like to send. If error is 0, it means OK.
+ * If an application has some error, send error number in function then AM
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list,
+ * Sound Manager return success. So you should check the contents size of return json object
+ *
+ * #### Note
+ *
+ */
+void ackDisconnect(struct afb_req request);
+
+/**
+ * Call "ackSetSourceState" function of Audio Manager.
+ * Return acknowledge of setSourceState against asyncSetSourceState.
+ *
+ * #### Parameters
+ * - handle : Handle id when you get on asyncSetSourceState
+ * - error : Error Number you would like to send. If error is 0, it means OK.
+ * If an application has some errors, send error number in function
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ * This function is very important for applications to realise the sequence of Audio Management.
+ * An Application which matches with sourceID in the parameter of asyncSetSourceState has to return ack to use this function
+ *
+ */
+void ackSetSourceState(struct afb_req request);
+
+/**
+ * Call "registerSource" function of Audio Manager.
+ * Register source(application) to Audio Manager Policy Management
+ * Application must call this function on its initialization
+ *
+ * #### Parameters
+ * - appname : Application unieque name
+ * [Option]
+ * It is not necessary to designate following argument, because these are default value is selected y soundmanager
+ * If you would like to set value, please input the following key and value
+ * - sourceClassID :
+ * - sourceState :
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void registerSource(struct afb_req request);
+
+/**
+ * Call "deregisterSource" function of Audio Manager.
+ * Deregister source(application) to Audio Manager Policy Management
+ *
+ * #### Parameters
+ * - sourceID : sourceID returned in resisterSource
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void deregisterSource(struct afb_req request);
+
+/**
+ * Subscribe event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libsoundmanager.hpp
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void subscribe(struct afb_req request);
+
+/**
+ * Unsubscribe event
+ *
+ * #### Parameters
+ * - event : Event name. Event list is written in libsoundmanager.hpp
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ *
+ * #### Note
+ *
+ */
+void unsubscribe(struct afb_req request);
+
+/**
+ * Application High Level API for AGL
+ * This function opens "stream".
+ * "strem" means the routing from source to sink.
+ * This function calls registerSource and register the endpoint.
+ * If the endpoint is not registered in AudioManager, Sound Manager uses default value.
+ * audio_role will be translated to "sourceID", and "endpoint_id" will be translated to "sinkID".
+ *
+ * #### Parameters
+ * - audio_role : audio role such like entertainment, emergency.
+ * This name is depends on the system architect.
+ * The name will be application name or will be the group(role) of application.
+ * - endpoint_id : Same as sinkID in Sound Manager.
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ * - stream_id : Same as sourceID but key is different. This is for AHL.
+ * #### Note
+ * TODO : write note
+ */
+void streamOpen(struct afb_req req);
+
+/**
+ * Application High Level API for AGL
+ * This function closes "stream".
+ * This function calls disconnect with registered connectionID translated with requested connection_id.
+ * If the connection is not created in Sound Manager, Sound Manager just returns with error message.
+ *
+ * #### Parameters
+ * - stream_id : Stream id which is returned in stream_open.
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ * #### Note
+ * TODO : write note
+ */
+void streamClose(struct afb_req req);
+
+/**
+ * Application High Level API for AGL
+ * This function set stream state.
+ * This function set the availability and calls connect function of Audio Manager
+ * and returns the result of policy check.
+ *
+ * #### Parameters
+ * - stream_id : Stream id which is returned in stream_open.
+ * - mute : Stream state as int
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ * #### Note
+ * TODO : write note
+ */
+void setStreamState(struct afb_req req);
+
+/*
+********** Event list from Sound Manager **********
+*/
+
+
+
+/*
+********** Application Framework Imprement **********
+*/
+
+/*
+ * array of the verbs exported to afb-daemon
+ */
+const struct afb_verb_v2 binding_verbs[]= {
+#ifdef ENABLE_AGL_AHL
+// High Level API of AGL
+{ .verb = "stream_open", .callback = streamOpen, .auth = NULL,
+ .info = "Open stream." , .session = AFB_SESSION_NONE},
+{ .verb = "stream_close", .callback = streamClose, .auth = NULL,
+ .info = "Close stream" , .session = AFB_SESSION_NONE},
+{ .verb = "set_stream_state", .callback = setStreamState, .auth = NULL,
+ .info = "Set stream state" , .session = AFB_SESSION_NONE},
+#endif
+// Adaption API of Audio Manager
+{ .verb = "connect", .callback = connect, .auth = NULL,
+ .info = "Connect source id and sink id" , .session = AFB_SESSION_NONE},
+{ .verb = "disconnect", .callback = disconnect, .auth = NULL,
+ .info = "Disconnect source id and sink id" , .session = AFB_SESSION_NONE},
+{ .verb = "setVolume", .callback = setVolume, .auth = NULL,
+ .info = "Set volume value" , .session = AFB_SESSION_NONE}, /* it is better to show the range*/
+{ .verb = "volumeStep", .callback = volumeStep, .auth = NULL,
+ .info = "Set volume step range" , .session = AFB_SESSION_NONE},
+{ .verb = "setSinkMuteState", .callback = setSinkMuteState, .auth = NULL,
+ .info = "Set Mute state: 1 means mute, 2 means umute. Others are invalid" ,.session = AFB_SESSION_NONE},
+{ .verb = "getListMainConnections", .callback = getListMainConnections, .auth = NULL,
+ .info = "Get MainConnection List" , .session = AFB_SESSION_NONE},
+{ .verb = "getListMainSinks", .callback = getListMainSinks, .auth = NULL,
+ .info = "Get MainSink List" , .session = AFB_SESSION_NONE},
+{ .verb = "getListMainSources", .callback = getListMainSources, .auth = NULL,
+ .info = "Get MainSource List" , .session = AFB_SESSION_NONE},
+{ .verb = "registerSource", .callback = registerSource, .auth = NULL,
+ .info = "Register autio role" , .session = AFB_SESSION_NONE},
+{ .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL,
+ .info = "Deregister audio role" , .session = AFB_SESSION_NONE},
+{ .verb = "ackConnect", .callback = ackConnect, .auth = NULL,
+ .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
+{ .verb = "ackDisconnect", .callback = ackDisconnect, .auth = NULL,
+ .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
+{ .verb = "ackSetSourceState", .callback = ackSetSourceState, .auth = NULL,
+ .info = "Acknowledge of asyncSetSourceState" , .session = AFB_SESSION_NONE},
+{ .verb = "subscribe", .callback = subscribe, .auth = NULL,
+ .info = "Subscribe event" , .session = AFB_SESSION_NONE},
+{ .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL,
+ .info = "Unsubscribe event" , .session = AFB_SESSION_NONE},
+{ .verb = NULL } /* marker for end of the array */};
+
+int preinit();
+int sm_init();
+void onevent(const char *event, struct json_object *object);
+
+const struct afb_binding_v2 afbBindingV2 = {
+ .api = "soundmanager",
+ .specification = NULL,
+ .verbs = binding_verbs,
+ .preinit = preinit,
+ .init = sm_init,
+ .onevent = onevent
+};
+
+#endif //SOUNDMANAGER_H \ No newline at end of file