18 #define AFB_BINDING_VERSION 2 24 #include <json-c/json.h> 27 #include <afb/afb-binding.h> 32 #define AM_NAME "org.genivi.audiomanager" 33 #define AM_CMD_PATH "/org/genivi/audiomanager/commandinterface" 34 #define AM_ROUTE_PATH "/org/genivi/audiomanager/routinginterface" 35 #define AM_ROUTE_NAME "org.genivi.audiomanager.routinginterface" 36 #define SOUND_MANAGER_RETURN_INTERFACE "org.genivi.audiomanager.routing.soundmanager" 37 #define SOUND_MANAGER_BUS_NAME "org.genivi.audiomanager.routing.soundmanager" 38 #define SOUND_MANAGER_PATH "/org/genivi/audiomanager/routing/soundmanager" 40 #define COMMAND_EVENT_NUM 10 41 #define ROUTING_EVENT_NUM 10 42 #define DEFAULT_SINK 1 43 #define DEFAULT_SOURCE_CLASS_ID 100 44 #define DYNAMIC_DOMAIN_ID 100 45 #define DEFAULT_DOMAIN_ID 0 46 #define DYNAMIC_SOURCE_ID 0 47 #define DEFAULT_VOLUME 100 48 #define DEFAULT_AVAILABLES 1 49 #define DEFAULT_CONNECTION_FORMAT 2 50 #define DEFAULT_INTERRUPT 0 51 #define DEFAULT_SOURCE_STATE 2 52 #define DS_CONTROLLED 1 54 #define EVENT_SUBSCRIBE_ERROR_CODE 100 56 const static struct afb_binding_interface *afbitf;
61 static GDBusConnection* system_conn = NULL;
63 static GMainLoop *loop = NULL;
64 static guint16 SOUNDMANAGER_DOMAIN_ID;
73 static struct afb_event ev_new_connection;
74 static struct afb_event ev_removed_main_connection;
75 static struct afb_event ev_volume_changed;
76 static struct afb_event ev_sink_mute_state_changed;
77 static struct afb_event ev_main_connection_state_changed;
80 static struct afb_event ev_set_routing_ready;
81 static struct afb_event ev_set_routing_rundown;
82 static struct afb_event ev_async_connect;
83 static struct afb_event ev_async_disconnect;
84 static struct afb_event ev_async_set_source_state;
86 static const char _source_id[] =
"sourceID";
87 static const char _sink_id[] =
"sinkID" ;
88 static const char _sink_name[] =
"sinkName" ;
89 static const char _main_connection_id[] =
"mainConnectionID";
90 static const char _delay[] =
"delay";
91 static const char _connection_state[] =
"connectionState";
92 static const char _connection_id[] =
"connectionID";
93 static const char _volume[] =
"volume";
94 static const char _volume_step[] =
"volumeStep";
95 static const char _interrupt[] =
"interrupt";
96 static const char _mute_state[] =
"muteState";
98 static const char _domain_id[] =
"domainID";
99 static const char _handle[] =
"handle";
100 static const char _appname[] =
"appname";
101 static const char _ramp[] =
"ramp";
102 static const char _time[] =
"time";
103 static const char _source_state[] =
"sourceState";
104 static const char _source_class_id[] =
"sourceClassID";
105 static const char _sink_class_id[] =
"sinkClassID";
106 static const char _error[] =
"error";
107 static const char _sink_data[] =
"sinkData";
108 static const char _source_data[] =
"sourceData";
109 static const char _interrupt_state[] =
"interruptState";
110 static const char _availability[] =
"availability";
111 static const char _list_volumes[] =
"listVolumes";
112 static const char _payload[] =
"payload";
113 static const char _connection_format[] =
"connectionFormat";
147 static void connect (
struct afb_req request)
149 AFB_DEBUG(
"call %s", __FUNCTION__);
150 guint16 source_id = 0, sink_id = 0;
151 guint16 main_connectionID = 0;
161 const char* default_sink = afb_req_value (request, _sink_id);
162 if(default_sink != NULL){
163 if((strlen(
"default") == strlen(default_sink)) &&
164 (0 == strncmp(
"default", default_sink, strlen(
"default")))){
175 AFB_INFO(
"get_value_uint16 source ret = %d,sink ret = %d", source_id, sink_id);
176 AFB_NOTICE(
"wrong request");
177 afb_req_fail(request,
"wrong-request",NULL);
191 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
198 struct json_object *res = json_object_new_object();
201 _main_connection_id, main_connectionID);
203 afb_req_success(request, res, info);
222 static void disconnect (
struct afb_req request)
224 AFB_DEBUG(
"call %s", __FUNCTION__);
232 AFB_DEBUG(
"requested %s = %d", _main_connection_id,
id);
236 afb_req_fail(request,
"wrong-request",afb_req_value (request, _main_connection_id));
244 AFB_DEBUG(
"ret = %d", ret);
248 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
252 struct json_object* res_obj = json_object_new_object();
257 afb_req_success(request, res_obj, info);
275 static void setVolume (
struct afb_req request)
277 AFB_DEBUG(
"call %s", __FUNCTION__);
279 guint16 sink_id, vol;
286 AFB_DEBUG(
"requested %s = %d, %s = %d",_sink_id, sink_id, _volume, vol);
289 afb_req_fail(request,
"wrong-request", NULL);
299 AFB_DEBUG(
"ret = %d", ret);
303 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
307 struct json_object* res_obj = json_object_new_object();
312 afb_req_success(request, res_obj, info);
331 static void volumeStep (
struct afb_req request)
333 AFB_DEBUG(
"call %s", __FUNCTION__);
335 guint16 sink_id, vol;
342 AFB_DEBUG(
"requested %s = %d, %s = %d",_sink_id, sink_id, _volume_step, vol);
345 afb_req_fail(request,
"wrong-request", NULL);
355 AFB_DEBUG(
"ret = %d", ret);
359 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
363 struct json_object* res_obj = json_object_new_object();
368 afb_req_success(request, res_obj, info);
387 static void setSinkMuteState(
struct afb_req request)
389 AFB_DEBUG(
"call %s", __FUNCTION__);
391 guint16 sink_id, mute;
398 AFB_DEBUG(
"requested %s = %d, %s = %d",_sink_id, sink_id, _mute_state, mute);
401 afb_req_fail(request,
"wrong-request", NULL);
411 AFB_DEBUG(
"ret = %d", ret);
415 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
419 struct json_object* res_obj = json_object_new_object();
424 afb_req_success(request, res_obj, info);
443 static void getListMainConnections(
struct afb_req request)
445 AFB_DEBUG(
"call getListMainConnections");
447 GVariant* mainConnectionList;
460 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
465 struct json_object *array_res = json_object_new_array();
466 gsize size = g_variant_n_children(mainConnectionList);
467 AFB_DEBUG(
"mainConnectionList size is %u",(uint16_t)size);
468 struct json_object *verb_obj = json_object_new_object();
470 json_object_array_add(array_res, verb_obj);
473 AFB_NOTICE(
"mainConnectionList size is 0");
476 for(
int i = 0; i < size; ++i)
478 guint16 mcid, srcid, sinkid;
479 gint16 delay, constate;
481 mainConnectionList,i,
"(qqqnn)",
482 &mcid, &srcid, &sinkid, &delay, &constate
485 struct json_object* res_obj = json_object_new_object();
487 _main_connection_id, mcid,
491 _connection_state, constate
493 json_object_array_add(array_res,res_obj);
496 AFB_DEBUG(
"json object :%s:",json_object_to_json_string(array_res));
497 afb_req_success(request, array_res,
"Success to get main connection list");
516 static void getListMainSinks(
struct afb_req request)
518 AFB_DEBUG(
"call %s", __FUNCTION__);
520 GVariant* mainSinkList;
533 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
538 struct json_object *array_res = json_object_new_array();
539 gsize size = g_variant_n_children(mainSinkList);
540 AFB_DEBUG(
"%s size is %u",__FUNCTION__, (uint16_t)size);
541 struct json_object *verb_obj = json_object_new_object();
543 json_object_array_add(array_res, verb_obj);
546 AFB_NOTICE(
"%s size is 0", __FUNCTION__);
568 AFB_DEBUG(
"json object :%s:",json_object_to_json_string(array_res));
570 afb_req_success(request, array_res,
"This is not implemented yet");
597 static void ackConnect(
struct afb_req request)
600 AFB_DEBUG(
"call %s", __FUNCTION__);
601 guint16 handle, connection_id, error;
612 afb_req_fail(request,
"wrong-request", NULL);
615 if(connection_id == 0)
617 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
630 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
634 struct json_object *res = json_object_new_object();
638 afb_req_success(request, res, info);
659 static void ackDisconnect(
struct afb_req request)
662 AFB_DEBUG(
"call %s", __FUNCTION__);
663 guint16 handle, connection_id, error;
674 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
677 if(connection_id == 0)
679 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
692 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
696 struct json_object *res = json_object_new_object();
700 afb_req_success(request, res, info);
720 static void ackSetSourceState(
struct afb_req request)
722 AFB_DEBUG(
"call %s", __FUNCTION__);
723 guint16 handle, error;
733 AFB_DEBUG(
"wrong request");
734 afb_req_fail(request,
"wrong-request", NULL);
746 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
750 struct json_object *res = json_object_new_object();
754 afb_req_success(request, res, info);
776 static void registerSource(
struct afb_req request)
778 AFB_DEBUG(
"call %s", __FUNCTION__);
784 guint16 source_class_id;
795 domain_id = SOUNDMANAGER_DOMAIN_ID;
798 afb_req_fail(request,
"wrong-request",
"Please input domainID as uint16, otherwise no value is OK");
804 afb_req_fail(request,
"wrong-request",
"domainID should be more than 0");
807 const gchar*
name = afb_req_value(request, _appname);
810 char* info =
"Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
811 afb_req_fail(request, NULL, info);
823 gboolean visible = TRUE;
826 available.avalilable_reason = 0;
833 sound_property_list.
type = 0;
834 sound_property_list.value = 0;
838 main_property_list.
type = 0;
839 main_property_list.value = 0;
843 nconf_routing.
type = 0;
844 nconf_routing.status = 0;
845 nconf_routing.parameter = 0;
847 nconf_command.type = 0;
848 nconf_command.status = 0;
849 nconf_command.parameter = 0;
852 guint16 acquire_source_id;
855 GVariant* sourceData =
create_source_data (source_id, domain_id, name, source_class_id,
856 source_state, volume, visible, available, interrupt,
857 sound_property_list, connection_format_list, main_property_list,
858 nconf_routing, nconf_command);
860 GVariant* input = g_variant_ref_sink(sourceData);
867 g_variant_unref(input);
871 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
876 struct json_object *res = json_object_new_object();
879 _source_id, acquire_source_id);
881 afb_req_success(request, res, info);
897 static void deregisterSource(
struct afb_req request)
905 afb_req_fail(request,
"wrong-request", NULL);
915 afb_req_fail_f(request,
"failed",
"Unable to call %s", __FUNCTION__);
919 struct json_object *res = json_object_new_object();
923 afb_req_success(request, res, info);
939 static void subscribe(
struct afb_req request)
941 const char *value = afb_req_value(request,
"event");
942 AFB_DEBUG(
"value is %s", value);
951 AFB_NOTICE(
"dedicated event doesn't exist");
956 afb_req_subscribe(request, *routing_event_list[index].
event);
961 afb_req_subscribe(request, *command_event_list[index].
event);
965 AFB_NOTICE(
"Please input event name");
969 struct json_object *res = json_object_new_object();
973 afb_req_success(request, res, info);
988 static void unsubscribe(
struct afb_req request)
990 const char *value = afb_req_value(request,
"event");
991 AFB_DEBUG(
"value is %s", value);
1000 AFB_NOTICE(
"dedicated event doesn't exist");
1005 afb_req_unsubscribe(request, *routing_event_list[index].
event);
1010 afb_req_unsubscribe(request, *command_event_list[index].
event);
1014 AFB_NOTICE(
"Please input event name");
1018 struct json_object *res = json_object_new_object();
1022 afb_req_success(request, res, info);
1030 GVariant* mainConnection)
1032 AFB_DEBUG(
"%s is called",__FUNCTION__);
1034 guint16 mcid, srcid, sinkid;
1035 gint16 delay, constate;
1037 mainConnection,
"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
1039 struct json_object* res_obj = json_object_new_object();
1041 _main_connection_id, mcid,
1045 _connection_state, constate
1047 AFB_DEBUG(
"json object :%s:",json_object_to_json_string(res_obj));
1049 afb_event_push(ev_new_connection, res_obj);
1052 static void on_removed_main_connection(
1055 AFB_DEBUG(
"%s is called",__FUNCTION__);
1057 struct json_object* res_obj = json_object_new_object();
1059 _main_connection_id, mainConnectionID);
1060 afb_event_push(ev_removed_main_connection, res_obj);
1063 static void on_main_connection_state_changed(
1066 AFB_DEBUG(
"%s is called",__FUNCTION__);
1068 struct json_object* res_obj = json_object_new_object();
1070 _connection_id, connectionID,
1071 _connection_state, connectionState);
1072 afb_event_push(ev_main_connection_state_changed, res_obj);
1075 static void on_volume_changed(
1078 AFB_DEBUG(
"%s is called",__FUNCTION__);
1079 struct json_object* res_obj = json_object_new_object();
1083 afb_event_push(ev_volume_changed, res_obj);
1086 static void on_sink_mute_state_changed(
1089 AFB_DEBUG(
"%s is called",__FUNCTION__);
1090 struct json_object* res_obj = json_object_new_object();
1094 afb_event_push(ev_sink_mute_state_changed, res_obj);
1100 static void on_set_routing_ready(
1103 AFB_DEBUG(
"%s is called",__FUNCTION__);
1104 afb_event_push(ev_set_routing_ready, NULL);
1107 static void on_set_routing_rundown(
1110 AFB_DEBUG(
"%s is called",__FUNCTION__);
1111 afb_event_push(ev_set_routing_ready, NULL);
1123 static gboolean on_async_abort(
1125 GDBusMethodInvocation *invocation,
1128 AFB_DEBUG(
"%s called", __FUNCTION__);
1133 static gboolean on_async_connect(
1135 GDBusMethodInvocation *invocation,
1137 guint16 arg_connectionID,
1138 guint16 arg_sourceID,
1140 gint arg_connectionFormat)
1142 AFB_DEBUG(
"%s called", __FUNCTION__);
1144 struct json_object* ev_obj = json_object_new_object();
1146 _handle, arg_handle,
1147 _connection_id, arg_connectionID,
1148 _source_id, arg_sourceID,
1149 _sink_id, arg_sinkID,
1150 _connection_format, arg_connectionFormat);
1151 afb_event_push(ev_async_connect, ev_obj);
1164 AFB_ERROR(
"Can't send ack to sound manager adapter %s", __FUNCTION__);
1170 static gboolean on_async_disconnect(
1172 GDBusMethodInvocation *invocation,
1174 guint16 arg_connectionID)
1176 AFB_DEBUG(
"%s called", __FUNCTION__);
1177 struct json_object* ev_obj = json_object_new_object();
1179 _handle, arg_handle,
1180 _connection_id, arg_connectionID);
1181 afb_event_push(ev_async_disconnect, ev_obj);
1191 AFB_ERROR(
"Can't send ack to sound manager adapter %s", __FUNCTION__);
1197 static gboolean on_async_set_sink_volume(
1199 GDBusMethodInvocation *invocation,
1206 AFB_DEBUG(
"%s called", __FUNCTION__);
1214 AFB_ERROR(
"Can't send ack to sound manager adapter %s", __FUNCTION__);
1237 static gboolean on_async_set_source_state(
1239 GDBusMethodInvocation *invocation,
1241 guint16 arg_sourceID,
1242 gint arg_sourceState)
1244 AFB_DEBUG(
"%s called", __FUNCTION__);
1245 struct json_object* ev_obj = json_object_new_object();
1248 _handle, arg_handle,
1249 _source_id, arg_sourceID);
1250 json_object_object_add(ev_obj, _source_state, json_object_new_string(ss_key));
1251 afb_event_push(ev_async_set_source_state, ev_obj);
1264 static const struct afb_verb_v2 binding_verbs[]= {
1265 { .verb =
"connect", .callback = connect, .auth = NULL,
1266 .info =
"Connect source id and sink id" , .session = AFB_SESSION_NONE},
1267 { .verb =
"disconnect", .callback = disconnect, .auth = NULL,
1268 .info =
"Disconnect source id and sink id" , .session = AFB_SESSION_NONE},
1269 { .verb =
"setVolume", .callback = setVolume, .auth = NULL,
1270 .info =
"Set volume value" , .session = AFB_SESSION_NONE},
1271 { .verb =
"volumeStep", .callback = volumeStep, .auth = NULL,
1272 .info =
"Set volume step range" , .session = AFB_SESSION_NONE},
1273 { .verb =
"setSinkMuteState", .callback = setSinkMuteState, .auth = NULL,
1274 .info =
"Set Mute state: 1 means mute, 2 means umute. Others are invalid" ,.session = AFB_SESSION_NONE},
1275 { .verb =
"getListMainConnections", .callback = getListMainConnections, .auth = NULL,
1276 .info =
"Get MainConnection List" , .session = AFB_SESSION_NONE},
1277 { .verb =
"getListMainSinks", .callback = getListMainSinks, .auth = NULL,
1278 .info =
"Get MainSink List" , .session = AFB_SESSION_NONE},
1279 { .verb =
"registerSource", .callback = registerSource, .auth = NULL,
1280 .info =
"Register Application" , .session = AFB_SESSION_NONE},
1281 { .verb =
"deregisterSource", .callback = deregisterSource, .auth = NULL,
1282 .info =
"Deregister Application" , .session = AFB_SESSION_NONE},
1283 { .verb =
"ackConnect", .callback = ackConnect, .auth = NULL,
1284 .info =
"Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
1285 { .verb =
"ackDisconnect", .callback = ackDisconnect, .auth = NULL,
1286 .info =
"Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
1287 { .verb =
"ackSetSourceState", .callback = ackSetSourceState, .auth = NULL,
1288 .info =
"Acknowledge of asyncSetSourceState" , .session = AFB_SESSION_NONE},
1289 { .verb =
"subscribe", .callback = subscribe, .auth = NULL,
1290 .info =
"Subscribe event" , .session = AFB_SESSION_NONE},
1291 { .verb =
"unsubscribe", .callback = unsubscribe, .auth = NULL,
1292 .info =
"Unsubscribe event" , .session = AFB_SESSION_NONE},
1295 static void *dbus_event_loop_run(
void *args)
1297 loop = g_main_loop_new(NULL, FALSE);
1298 g_main_loop_run(loop);
1307 static int registerDomain()
1312 .name =
"SoundManager",
1314 .nodename =
"soundmanager",
1336 AFB_ERROR(
"Failed to call %s", __FUNCTION__);
1341 AFB_ERROR(
"Failed to register domain");
1344 SOUNDMANAGER_DOMAIN_ID = domain_id;
1345 AFB_NOTICE(
"Complete registered domain id:%d",SOUNDMANAGER_DOMAIN_ID);
1349 static int preinit()
1352 AFB_INFO(
"Initialize Dbus object");
1354 if(am_cmd_bus || am_route_bus)
1356 AFB_ERROR(
"Dbus object to Audio Manager is already created");
1361 G_DBUS_PROXY_FLAGS_NONE,
1369 G_DBUS_PROXY_FLAGS_NONE,
1376 if(!am_cmd_bus || !am_route_bus)
1381 AFB_NOTICE(
"Finish Initialize");
1384 AFB_ERROR(
"Failed to initialize");
1388 static int create_adapter()
1390 GError *error = NULL;
1393 system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
1396 g_error_free(error);
1409 int sigret = g_signal_connect(sm_adapter,
"handle-async-abort", G_CALLBACK(on_async_abort),NULL);
1410 sigret = g_signal_connect(sm_adapter,
"handle-async-connect", G_CALLBACK(on_async_connect),NULL);
1411 sigret = g_signal_connect(sm_adapter,
"handle-async-disconnect", G_CALLBACK(on_async_disconnect),NULL);
1412 sigret = g_signal_connect(sm_adapter,
"handle-async-set-sink-volume", G_CALLBACK(on_async_set_sink_volume),NULL);
1413 sigret = g_signal_connect(sm_adapter,
"handle-async-set-source-state", G_CALLBACK(on_async_set_source_state),NULL);
1414 ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), system_conn,
SOUND_MANAGER_PATH, &error);
1417 AFB_ERROR(
"failed to export");
1418 g_error_free(error);
1419 g_object_unref(system_conn);
1428 static void on_name_lost(GDBusServer *server, GDBusConnection *conn, gpointer data)
1430 AFB_WARNING(
"%s called", __FUNCTION__);
1434 static int sm_event_init()
1436 AFB_NOTICE(
"Initialize event receive setting");
1437 printf(
"Initialize event receive setting");
1440 size_t size =
sizeof cmd_evlist /
sizeof *cmd_evlist;
1445 ev_volume_changed = afb_daemon_make_event(cmd_evlist[0]);
1446 ev_new_connection = afb_daemon_make_event(cmd_evlist[1]);
1447 ev_removed_main_connection = afb_daemon_make_event(cmd_evlist[2]);
1448 ev_sink_mute_state_changed = afb_daemon_make_event(cmd_evlist[3]);
1449 ev_main_connection_state_changed = afb_daemon_make_event(cmd_evlist[4]);
1450 command_event_list[0].
name = cmd_evlist[0];
1451 command_event_list[0].
event = &ev_volume_changed;
1452 command_event_list[1].
name = cmd_evlist[1];
1453 command_event_list[1].
event = &ev_new_connection;
1454 command_event_list[2].
name = cmd_evlist[2];
1455 command_event_list[2].
event = &ev_removed_main_connection;
1456 command_event_list[3].
name = cmd_evlist[3];
1457 command_event_list[3].
event = &ev_sink_mute_state_changed;
1458 command_event_list[4].
name = cmd_evlist[4];
1459 command_event_list[4].
event = &ev_main_connection_state_changed;
1462 ev_set_routing_ready = afb_daemon_make_event(route_evlist[0]);
1463 ev_set_routing_rundown = afb_daemon_make_event(route_evlist[1]);
1464 ev_async_connect = afb_daemon_make_event(route_evlist[2]);
1465 ev_async_set_source_state = afb_daemon_make_event(route_evlist[3]);
1466 ev_async_disconnect = afb_daemon_make_event(route_evlist[4]);
1468 routing_event_list[0].
name = route_evlist[0];
1469 routing_event_list[0].
event = &ev_set_routing_ready;
1470 routing_event_list[1].
name = route_evlist[1];
1471 routing_event_list[1].
event = &ev_set_routing_rundown;
1472 routing_event_list[2].
name = route_evlist[2];
1473 routing_event_list[2].
event = &ev_async_connect;
1474 routing_event_list[3].
name = route_evlist[3];
1475 routing_event_list[3].
event = &ev_async_set_source_state;
1476 routing_event_list[4].
name = route_evlist[4];
1477 routing_event_list[4].
event = &ev_async_disconnect;
1493 if(!am_cmd_bus || !am_route_bus)
1497 pthread_t thread_id;
1498 ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
1504 g_signal_connect(am_cmd_bus,
1506 G_CALLBACK(on_volume_changed),
1508 g_signal_connect(am_cmd_bus,
1509 "new_main_connection",
1510 G_CALLBACK(on_new_main_connection),
1512 g_signal_connect(am_cmd_bus,
1513 "removed_main_connection",
1514 G_CALLBACK(on_removed_main_connection),
1516 g_signal_connect(am_cmd_bus,
1517 "sink_mute_state_changed",
1518 G_CALLBACK(on_sink_mute_state_changed),
1520 g_signal_connect(am_cmd_bus,
1521 "main_connection_state_changed",
1522 G_CALLBACK(on_main_connection_state_changed),
1524 g_signal_connect(am_route_bus,
1525 "set_routing_ready",
1526 G_CALLBACK(on_set_routing_ready),
1528 g_signal_connect(am_route_bus,
1529 "set_routing_rundown",
1530 G_CALLBACK(on_set_routing_rundown),
1535 NULL,NULL, NULL, NULL, NULL);
1536 AFB_DEBUG(
"g_bus_own_name ret: %d", ret);
1537 ret = create_adapter();
1542 ret = registerDomain();
1550 AFB_INFO(
"Finish Initialize event receive setting");
1556 g_main_loop_unref(loop);
1558 AFB_WARNING(
"DBus connection is not created");
1562 static void onevent(
const char *
event,
struct json_object *
object)
1564 AFB_NOTICE(
"on_event %s", event);
1568 .api =
"soundmanager",
1569 .specification = NULL,
1570 .verbs = binding_verbs,
1572 .init = sm_event_init,
struct _AudiomanagerRoutingSoundmanager AudiomanagerRoutingSoundmanager
#define DYNAMIC_SOURCE_ID
gboolean audiomanager_routinginterface_call_deregister_source_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_sourceID, guint16 *out_error, GCancellable *cancellable, GError **error)
#define SOUND_MANAGER_RETURN_INTERFACE
gboolean(* handle_async_connect)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_sourceID, guint16 arg_sinkID, gint arg_connectionFormat)
#define DEFAULT_SOURCE_CLASS_ID
#define DYNAMIC_DOMAIN_ID
void sm_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
#define DEFAULT_AVAILABLES
struct _AudiomanagerCommandinterface AudiomanagerCommandinterface
struct _AudiomanagerRoutinginterface AudiomanagerRoutinginterface
#define DEFAULT_INTERRUPT
char * get_response_audiomanager_massage_error(int am_error_code)
gboolean audiomanager_routinginterface_call_ack_disconnect_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_ack_connect_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_set_volume_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_volume, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_register_source_sync(AudiomanagerRoutinginterface *proxy, GVariant *arg_sourceData, guint16 *out_sourceID, guint16 *out_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_set_sink_mute_state_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_muteState, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_ack_set_sink_volume_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, gint16 arg_volume, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_get_list_main_connections_sync(AudiomanagerCommandinterface *proxy, gint16 *out_result, GVariant **out_listConnections, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_get_list_main_sinks_sync(AudiomanagerCommandinterface *proxy, gint16 *out_result, GVariant **out_listMainSinks, GCancellable *cancellable, GError **error)
#define AUDIOMANAGER_ROUTING_SOUNDMANAGER_GET_IFACE(o)
gboolean(* handle_async_abort)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle)
REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id)
#define ROUTING_EVENT_NUM
gboolean(* handle_async_disconnect)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_connectionID)
AudiomanagerRoutinginterface * audiomanager_routinginterface_proxy_new_for_bus_sync(GBusType bus_type, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, GCancellable *cancellable, GError **error)
int sm_search_event_name_index(const char *value)
#define SOUND_MANAGER_BUS_NAME
AudiomanagerRoutingSoundmanager * audiomanager_routing_soundmanager_skeleton_new(void)
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
char * get_source_state_key(int am_source_state)
#define SOUND_MANAGER_PATH
gboolean audiomanager_commandinterface_call_connect_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sourceID, guint16 arg_sinkID, gint16 *out_result, guint16 *out_mainConnectionID, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_volume_step_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_volumeStep, gint16 *out_result, GCancellable *cancellable, GError **error)
const struct afb_binding_v2 afbBindingV2
REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id)
void sm_add_object_to_json_object(struct json_object *j_obj, int count,...)
GVariant * create_domain_data(struct domain_data *data)
gboolean audiomanager_routinginterface_call_ack_set_source_state_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_error, GCancellable *cancellable, GError **error)
#define DEFAULT_CONNECTION_FORMAT
gboolean(* handle_async_set_source_state)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_sourceID, gint arg_sourceState)
GVariant * create_source_data(guint16 sourceID, guint16 domainID, const char *appname, guint16 sourceClassID, gint32 sourceState, gint16 volume, gboolean visible, struct availability_s availables, guint16 interrupt, struct sound_property_s soundPropertyList, gint32 connectionFormatList, struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting, struct notification_config_s NConfCommand)
#define EVENT_SUBSCRIBE_ERROR_CODE
AudiomanagerCommandinterface * audiomanager_commandinterface_proxy_new_for_bus_sync(GBusType bus_type, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_disconnect_sync(AudiomanagerCommandinterface *proxy, guint16 arg_mainConnectionID, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_register_domain_sync(AudiomanagerRoutinginterface *proxy, GVariant *arg_domaindata, const gchar *arg_returnBusname, const gchar *arg_returnPath, const gchar *arg_returnInterface, guint16 *out_domainid, guint16 *out_error, GCancellable *cancellable, GError **error)
gboolean(* handle_async_set_sink_volume)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_sinkID, gint16 arg_volume, gint16 arg_ramp, guint16 arg_time)
#define DEFAULT_SOURCE_STATE
#define COMMAND_EVENT_NUM
int sm_search_routing_event_name_index(const char *value)