From 1363f808f98eccfe113624cfcf3291fd601fbac2 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Wed, 1 Nov 2017 14:20:44 +0900 Subject: Update document Update ApplicationGuide Change-Id: I8a9c675adeb8997debaa553f0e45f736a2719010 Signed-off-by: Kazumasa Mitsunari --- doc/api-ref/html/soundmanager_8c_source.html | 93 +++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 14 deletions(-) (limited to 'doc/api-ref/html/soundmanager_8c_source.html') diff --git a/doc/api-ref/html/soundmanager_8c_source.html b/doc/api-ref/html/soundmanager_8c_source.html index 30d2f9b..691326b 100644 --- a/doc/api-ref/html/soundmanager_8c_source.html +++ b/doc/api-ref/html/soundmanager_8c_source.html @@ -5,7 +5,7 @@ -Sound Manager: SoundManagerBinding/soundmanager_binging/soundmanager.c Source File +Sound Manager: R:/SoundManagerBinding/src/soundmanager.c Source File @@ -83,24 +83,89 @@ $(document).ready(function(){initNavTree('soundmanager_8c_source.html','');});
soundmanager.c
-Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define _GNU_SOURCE
18 #include <stdio.h>
19 #include <string.h>
20 #include <stdlib.h>
21 #include <stdint.h>
22 #include <unistd.h>
23 #include <json-c/json.h>
24 //#include <search.h>
25 #include <pthread.h>
26 #include <afb/afb-binding.h>
27 #include "sm-helper.h"
28 #include <glib.h>
29 #include "dbus/audio_manager_interface.h"
30 
31 #define AM_NAME "org.genivi.audiomanager"
32 #define AM_CMD_PATH "/org/genivi/audiomanager/commandinterface"
33 #define AM_ROUTE_PATH "/org/genivi/audiomanager/routinginterface"
34 #define SOUND_MANAGER_NAME "org.soundmanager.genivi.routingsend"
35 #define SOUND_MANAGER_PATH "org/soundmanager/genivi/routingsend"
36 
37 #define COMMAND_EVENT_NUM 10
38 #define ROUTING_EVENT_NUM 10
39 #define MAX_LEN_STR 100
40 
41 const static struct afb_binding_interface *afbitf;
42 static AudiomanagerCommandinterface *am_cmd_bus;
43 static AudiomanagerRoutinginterface *am_route_bus;
44 static OrgSoundmanagerGeniviRoutingsend *sm_adapter;
45 static OrgSoundmanagerGeniviRoutingsendIface* sm_itf;
46 
47 static GMainLoop *loop = NULL;
48 /* To Do hash table is better */
49 struct event{
50  char* name;
51  struct afb_event* event;
52  };
53 static struct event command_event_list[COMMAND_EVENT_NUM];
54 static struct event routing_event_list[ROUTING_EVENT_NUM];
55 
56 static struct afb_event ev_new_connection;
57 static struct afb_event ev_removed_main_connection;
58 static struct afb_event ev_volume_changed;
59 static struct afb_event ev_sink_mute_state_changed;
60 static struct afb_event ev_main_connection_state_changed;
61 
62 /* Routing interface event */
63 static struct afb_event ev_set_routing_ready;
64 static struct afb_event ev_set_routing_rundown;
65 static struct afb_event ev_async_connect;
66 static struct afb_event ev_async_set_source_state;
67 
68 static const char _sourceid[] = "sourceID";
69 static const char _sinkid[] = "sinkID" ;
70 static const char _main_connection_id[] = "mainConnectionID";
71 static const char _delay[] = "delay";
72 static const char _connectionState[] = "connectionState";
73 static const char _connectionID[] = "connectionID";
74 static const char _volume[] = "volume";
75 static const char _volumeStep[] = "volumeStep";
76 static const char _muteState[] = "muteState";
77 
78 static const char _handle[] = "handle";
79 static const char _appname[] = "appname";
80 static const char _ramp[] = "ramp";
81 static const char _time[] = "time";
82 static const char _sourceState[] = "sourceState";
83 static const char _sourceClassID[] = "sourceClassID";
84 static const char _error[] = "error";
85 static const char _sinkData[] = "sinkData";
86 static const char _sourceData[] = "sourceData";
87 static const char _interruptState[] = "interruptState";
88 static const char _availability[] = "availability";
89 static const char _domainID[] = "domainID";
90 static const char _listvolumes[] = "listvolumes";
91 static const char _payload[] = "payload";
92 static const char _connectionFormat[] = "connectionFormat";
93 /*
94 ********** Method of Sound Manager (API) **********
95 */
96 
97 /* call "connect" function of Audio Manager*/
98 static void connect (struct afb_req request)
99 {
100  DEBUG(afbitf,"call connect");
101  guint16 source_id, sink_id;
102  guint16 main_connectionID = 0;
103  gint16 ret;
104  REQ_ERROR req_err1, req_err2;
105  GError *err = NULL;
106  /* ToDo select appname or sourceID(sinkID) */
107 
108  req_err1 = getid_uint16(request, _sourceid, &source_id);
109  req_err2 = getid_uint16(request, _sinkid, &sink_id);
110 
111  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
112  {
113  DEBUG(afbitf, "getid_uint16 source ret = %d,sink ret = %d", source_id, sink_id);
114  NOTICE(afbitf,"wrong request");
115  afb_req_fail(request,"wrong-request",NULL);
116  return;
117  }
118 
119  audiomanager_commandinterface_call_connect_sync(
120  am_cmd_bus,
121  source_id,
122  sink_id,
123  &ret,
124  &main_connectionID,
125  NULL, &err);
126 
127  if(err != NULL)
128  {
129  afb_req_fail(request, "failed", "Unable to call connect");
130  return;
131  }
132 
133  /* ToDo Remember appname(key) and tie to sourceID(value) */
134 
135  /*create response json object*/
136  struct json_object *res = json_object_new_object();
137  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
138  "error", ret,
139  _main_connection_id, main_connectionID);
140  char *info;
141  get_response_audiomanager_massage_error(ret,&info);
142  afb_req_success(request, res, info);
143 }
144 
145 /* call "disconnect" function of Audio Manager*/
146 static void disconnect (struct afb_req request)
147 {
148  DEBUG(afbitf,"call disconnect");
149 
150  guint16 id;
151  gint16 ret;
152  REQ_ERROR req_err;
153  GError *err = NULL;
154 
155  req_err = getid_uint16(request, _main_connection_id, &id);
156  DEBUG(afbitf, "requested %s = %d", _main_connection_id, id);
157 
158  if(req_err != REQ_OK)
159  {
160  afb_req_fail(request,"wrong-request",afb_req_value (request, _main_connection_id));
161  return;
162  }
163  audiomanager_commandinterface_call_disconnect_sync(
164  am_cmd_bus,
165  id,
166  &ret,
167  NULL, &err);
168  DEBUG(afbitf, "ret = %d", ret);
169 
170  if(err != NULL)
171  {
172  afb_req_fail(request, "failed", "Unable to call getListMainConnections");
173  return;
174  }
175 
176  struct json_object* res_obj = json_object_new_object();
177  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
178  "error", ret);
179  char *info;
180  get_response_audiomanager_massage_error(ret,&info);
181 
182  afb_req_success(request, res_obj, info); /* return error num as status */
183 }
184 
185 static void setVolume (struct afb_req request)
186 {
187  DEBUG(afbitf,"call setVolume");
188 
189  guint16 sink_id, vol;
190  gint16 ret;
191  REQ_ERROR req_err1, req_err2;
192  GError *err = NULL;
193 
194  req_err1 = getid_uint16(request, _sinkid, &sink_id);
195  req_err2 = getid_int16(request, _volume, &vol);
196  DEBUG(afbitf, "requested %s = %d, %s = %d",_sinkid, sink_id, _volume, vol);
197  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
198  {
199  afb_req_fail(request,"wrong-request", NULL);
200  return;
201  }
202 
203  audiomanager_commandinterface_call_set_volume_sync(
204  am_cmd_bus,
205  sink_id,
206  vol,
207  &ret,
208  NULL, &err);
209  DEBUG(afbitf, "ret = %d", ret);
210 
211  if(err != NULL)
212  {
213  afb_req_fail(request, "failed", "Unable to call setVolume");
214  return;
215  }
216 
217  struct json_object* res_obj = json_object_new_object();
218  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
219  "error", ret);
220  char *info;
221  get_response_audiomanager_massage_error(ret,&info);
222 
223  afb_req_success(request, res_obj, info); /* return error num as status */
224 }
225 
226 static void volumeStep (struct afb_req request)
227 {
228  DEBUG(afbitf,"call volumeStep");
229 
230  guint16 sink_id, vol;
231  gint16 ret;
232  REQ_ERROR req_err1, req_err2;
233  GError *err = NULL;
234 
235  req_err1 = getid_uint16(request, _sinkid, &sink_id);
236  req_err2 = getid_int16(request, _volumeStep, &vol);
237  DEBUG(afbitf, "requested %s = %d, %s = %d",_sinkid, sink_id, _volumeStep, vol);
238  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
239  {
240  afb_req_fail(request,"wrong-request", NULL);
241  return;
242  }
243 
244  audiomanager_commandinterface_call_volume_step_sync(
245  am_cmd_bus,
246  sink_id,
247  vol,
248  &ret,
249  NULL, &err);
250  DEBUG(afbitf, "ret = %d", ret);
251 
252  if(err != NULL)
253  {
254  afb_req_fail(request, "failed", "Unable to call volumeStep");
255  return;
256  }
257 
258  struct json_object* res_obj = json_object_new_object();
259  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
260  "error", ret);
261  char *info;
262  get_response_audiomanager_massage_error(ret,&info);
263 
264  afb_req_success(request, res_obj, info); /* return error num as status */
265 }
266 
267 /* 1 means mute, 2 means unmute */
268 static void setSinkMuteState(struct afb_req request)
269 {
270  DEBUG(afbitf,"call setSinkMuteStete");
271 
272  guint16 sink_id, mute;
273  gint16 ret;
274  REQ_ERROR req_err1, req_err2;
275  GError *err = NULL;
276 
277  req_err1 = getid_uint16(request, _sinkid, &sink_id);
278  req_err2 = getid_int16(request, _muteState, &mute);
279  DEBUG(afbitf, "requested %s = %d, %s = %d",_sinkid, sink_id, _muteState, mute);
280  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
281  {
282  afb_req_fail(request,"wrong-request", NULL);
283  return;
284  }
285 
286  audiomanager_commandinterface_call_set_sink_mute_state_sync(
287  am_cmd_bus,
288  sink_id,
289  mute,
290  &ret,
291  NULL, &err);
292  DEBUG(afbitf, "ret = %d", ret);
293 
294  if(err != NULL)
295  {
296  afb_req_fail(request, "failed", "Unable to call setSinkMuteStete");
297  return;
298  }
299 
300  struct json_object* res_obj = json_object_new_object();
301  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
302  "error", ret);
303  char *info;
304  get_response_audiomanager_massage_error(ret,&info);
305 
306  afb_req_success(request, res_obj, info); /* return error num as status */
307 }
308 
309 /* call "getListMainConnections" function of Audio Manager */
310 static void getListMainConnections(struct afb_req request)
311 {
312  DEBUG(afbitf,"call getListMainConnections");
313  guint16 ret;
314  GVariant* mainConnectionList;
315  GError *err = NULL;
316 
317  audiomanager_commandinterface_call_get_list_main_connections_sync(
318  am_cmd_bus,
319  &ret,
320  &mainConnectionList,
321  NULL,
322  &err
323  );
324  DEBUG(afbitf,"ret = %d, mainConnectionList pointer = %p", ret, &mainConnectionList);
325 
326  if(err != NULL)
327  {
328  afb_req_fail(request, "failed", "Unable to call getListMainConnections");
329  return;
330  }
331 
332  /* create response */
333  struct json_object *array_res = json_object_new_array();
334  gsize size = g_variant_n_children(mainConnectionList);
335  DEBUG(afbitf, "mainConnectionList size is %u",(uint16_t)size);
336  struct json_object *verb_obj = json_object_new_object();
337  sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
338  json_object_array_add(array_res, verb_obj);
339  if(size <= 0)
340  {
341  NOTICE(afbitf, "mainConnectionList size is 0");
342  }
343  else{
344  for(int i = 0; i < size; ++i)
345  {
346  guint16 mcid, srcid, sinkid;
347  gint16 delay, constate;
348  g_variant_get_child(
349  mainConnectionList,i,"(qqqnn)",
350  &mcid, &srcid, &sinkid, &delay, &constate
351  );
352 
353  struct json_object* res_obj = json_object_new_object();
354  sm_add_object_to_json_object_func(res_obj,__FUNCTION__,10,
355  _main_connection_id, mcid,
356  _sourceid, srcid,
357  _sinkid, sinkid,
358  _delay, delay,
359  _connectionState, constate
360  );
361  json_object_array_add(array_res,res_obj);
362  }
363  }
364  DEBUG(afbitf,"json object :%s:",json_object_to_json_string(array_res));
365  afb_req_success(request, array_res, "Success to get main connection list");
366 }
367 
368 /*
369 *
370 ****** Routing Interface method(API) ***********
371 *
372 */
373 static void ackConnect(struct afb_req request)
374 {
375  /* This function will be deprecated */
376  DEBUG(afbitf,"call %s", __FUNCTION__);
377  guint16 handle, connection_id, error;
378  REQ_ERROR req_err1, req_err2 , req_err3;
379  GError *err = NULL;
380 
381  req_err1 = getid_uint16(request, _handle, &handle);
382  req_err2 = getid_uint16(request, _connectionID, &connection_id);
383  req_err3 = getid_uint16(request, _error, &error);
384 
385  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
386  {
387  afb_req_fail(request,"wrong-request", NULL);
388  return;
389  }
390  if(connection_id == 0)
391  {
392  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
393  return;
394  }
395 
396 
397  audiomanager_routinginterface_call_ack_connect_sync(
398  am_route_bus,
399  handle,
400  connection_id,
401  error,
402  NULL, &err);
403 
404  if(err != NULL)
405  {
406  afb_req_fail(request, "failed", "Unable to call ackConnect");
407  return;
408  }
409  afb_req_success(request, NULL, NULL);
410 }
411 static void ackDisconnect(struct afb_req request)
412 {
413  /* This function will be deprecated */
414  DEBUG(afbitf,"call %s", __FUNCTION__);
415  guint16 handle, connection_id, error;
416  REQ_ERROR req_err1, req_err2 , req_err3;
417  GError *err = NULL;
418 
419  req_err1 = getid_uint16(request, _handle, &handle);
420  req_err2 = getid_uint16(request, _connectionID, &connection_id);
421  req_err3 = getid_uint16(request, _error, &error);
422 
423  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
424  {
425  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
426  return;
427  }
428  if(connection_id == 0)
429  {
430  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
431  return;
432  }
433 
434  audiomanager_routinginterface_call_ack_disconnect_sync(
435  am_route_bus,
436  handle,
437  connection_id,
438  error,
439  NULL, &err);
440 
441  if(err != NULL)
442  {
443  afb_req_fail(request, "failed", "Unable to call ackDisconnect");
444  return;
445  }
446  afb_req_success(request, NULL, NULL);
447 }
448 static void ackSetSourceState(struct afb_req request)
449 {
450  /* This function will be deprecated */
451  /* This function will be deprecated */
452  DEBUG(afbitf,"call %s", __FUNCTION__);
453  guint16 handle, error;
454  REQ_ERROR req_err1, req_err2;
455  GError *err = NULL;
456 
457  req_err1 = getid_uint16(request, _handle, &handle);
458  req_err2 = getid_uint16(request, _error, &error);
459 
460  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
461  {
462  NOTICE(afbitf,"wrong request");
463  afb_req_fail(request,"wrong-request", NULL);
464  return;
465  }
466 
467  audiomanager_routinginterface_call_ack_set_source_state_sync(
468  am_route_bus,
469  handle,
470  error,
471  NULL, &err);
472 
473  if(err != NULL)
474  {
475  afb_req_fail(request, "failed", "Unable to call ackDisconnect");
476  return;
477  }
478  afb_req_success(request, NULL, NULL);
479 }
480 static void registerSink(struct afb_req request)
481 {
482  /* This function will be deprecated because application will not register function*/
483 }
484 static void deregisterSink(struct afb_req request)
485 {
486  /* This function will be deprecated because application will not register function*/
487 }
488 
489 /* This function will be modified to abstract argument */
490 static void registerSource(struct afb_req request)
491 {
492  DEBUG(afbitf,"call %s", __FUNCTION__);
493  GError *err = NULL;
494 
495  guint16 source_id; /* q 0 is for dynamic id*/
496  guint16 domain_id; /* q */
497  guint16 source_class_id; /* q */
498  gint32 source_state = 1; /* i SS_ON */
499  gint16 volume; /* n */
500 
501  if(REQ_OK != getid_uint16(request, _sourceid, &source_id)){
502  source_id = 0; /* if 0, dynamic source id will be attached */
503  }
504  if( REQ_OK != getid_uint16(request, _domainID, &domain_id)){
505  afb_req_fail(request,"wrong-request", "domainID should be more than 0");
506  return;
507  }
508  if(domain_id == 0)
509  {
510  afb_req_fail(request,"wrong-request", "domainID should be more than 0");
511  return;
512  }
513  const gchar* name = afb_req_value(request, _appname); /* s */
514  if(!name)
515  {
516  char* info = "Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
517  afb_req_fail(request, NULL, info);
518  return;
519  }
520  if(REQ_OK != getid_uint16(request, _sourceClassID, &source_class_id)){
521  source_class_id = 0; /* BASE */
522  }
523  if(REQ_OK != getid_uint16(request, _sourceState, &source_state)){
524  source_state = 0;
525  }
526  if(REQ_OK != getid_int16(request, _volume, &volume)){
527  volume = 3000;
528  }
529  gboolean visible = TRUE; /* b */
530  struct availability_s available; /* (ii) */
531  available.availability = 1; /* A_UNKNOWN */
532  available.avalilable_reason = 0; /* AR_UNKNOWN */
533  guint16 interrupt = 1; /* q IS_OFF */
534 
535  struct sound_property_s sound_property_list; /* a(in) */
536  sound_property_list.type = 0;
537  sound_property_list.value = 0; /* in reality, this is array of struct */
538 
539  gint32 connection_format_list = 0; /* ai */
540  struct main_sound_property_s main_property_list; /* a(in) */
541  main_property_list.type = 0;
542  main_property_list.value = 0;
543 
544  struct notification_config_s nconf_routing;
545  struct notification_config_s nconf_command; /* a(iin)a(iin) */
546  nconf_routing.type = 0;
547  nconf_routing.status = 0;
548  nconf_routing.parameter = 0;
549 
550  nconf_command.type = 0;
551  nconf_command.status = 0;
552  nconf_command.parameter = 0;
553 
554  /* acuire data */
555  guint16 acquire_source_id;
556  guint16 error;
557 
558  GVariant* sourceData = create_source_data (source_id, domain_id, name, source_class_id,
559  source_state, volume, visible, available, interrupt,
560  sound_property_list, connection_format_list, main_property_list,
561  nconf_routing, nconf_command, afbitf);
562 
563  GVariant* input = g_variant_ref_sink(sourceData);
564  audiomanager_routinginterface_call_register_source_sync(
565  am_route_bus,
566  input,
567  &acquire_source_id,
568  &error,
569  NULL, &err);
570  g_variant_unref(input);
571 
572  if(err != NULL)
573  {
574  afb_req_fail(request, "failed", "Unable to call registerSource");
575  return;
576  }
577 
578  /*create response json object*/
579  struct json_object *res = json_object_new_object();
580  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
581  _error, error,
582  _sourceid, acquire_source_id);
583  char *info;
584  get_response_audiomanager_massage_error(error,&info);
585  afb_req_success(request, res, info);
586 }
587 
588 static void deregisterSource(struct afb_req request)
589 {
590  guint16 source_id;
591  guint16 error;
592 
593  GError *err = NULL;
594 
595  if(REQ_OK != getid_uint16(request, _sourceid, &source_id)){
596  afb_req_fail(request, "wrong-request", NULL);
597  }
598  audiomanager_routinginterface_call_deregister_source_sync(
599  am_route_bus,
600  source_id,
601  &error,
602  NULL, &err
603  );
604  if(err != NULL)
605  {
606  afb_req_fail(request, "failed", "Unable to call deregisterSource");
607  return;
608  }
609  /*create response json object*/
610  struct json_object *res = json_object_new_object();
611  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
612  _error, error);
613  char *info;
614  get_response_audiomanager_massage_error(error,&info);
615  afb_req_success(request, res, info);
616 
617 }
618 
619 static void confirmRoutingReady(struct afb_req request)
620 {
621  /* This function will be deprecated because application will not register function*/
622 }
623 static void confirmRoutingRundown(struct afb_req request)
624 {
625  /* This function will be deprecated because application will not register function*/
626 }
627 static void ackSetVolumes(struct afb_req request)
628 {
629  /* This function will be deprecated */
630 }
631 static void ackSinkNotificationConfiguration(struct afb_req request)
632 {
633  /* This function will be deprecated */
634 }
635 static void ackSourceNotificationConfiguration(struct afb_req request)
636 {
637  /* This function will be deprecated */
638 }
639 
640 
641 static void subscribe(struct afb_req request)
642 {
643  const char *value = afb_req_value(request, "event");
644  char *info;
645  DEBUG(afbitf, "value is %s", value);
646  if(value) {
647  int index = sm_search_event_name_index(value);
648  if(index < 0)
649  {
650  index = sm_search_routing_event_name_index(value);
651  if(index < 0)
652  {
653  ERROR(afbitf, "dedicated event doesn't exist");
654  }
655  else
656  {
657  afb_req_subscribe(request, *routing_event_list[index].event);
658  }
659  }
660  else
661  {
662  afb_req_subscribe(request, *command_event_list[index].event);
663  }
664  }
665  else{
666  ERROR(afbitf, "Please input event name");
667  }
668  afb_req_success(request, NULL, NULL);
669 }
670 
671 static void unsubscribe(struct afb_req request)
672 {
673  const char *value = afb_req_value(request, "event");
674  char *info;
675  DEBUG(afbitf, "value is %s", value);
676  if(value) {
677  int index = sm_search_event_name_index(value);
678  if(index < 0)
679  {
680  index = sm_search_routing_event_name_index(value);
681  if(index < 0)
682  {
683  ERROR(afbitf, "dedicated event doesn't exist");
684  }
685  else
686  {
687  afb_req_unsubscribe(request, *routing_event_list[index].event);
688  }
689  }
690  else
691  {
692  afb_req_unsubscribe(request, *command_event_list[index].event);
693  }
694  }
695  else{
696  ERROR(afbitf, "Please input event name");
697  }
698  afb_req_success(request, NULL, NULL);
699 }
700 
701 /*
702 ********** Callback Function invoked by Audio Manager **********
703 */
704 
705 static void on_new_main_connection(AudiomanagerCommandinterface* interface,
706  GVariant* mainConnection)
707 {
708  DEBUG(afbitf,"%s is called",__FUNCTION__);
709 
710  guint16 mcid, srcid, sinkid;
711  gint16 delay, constate;
712  g_variant_get(
713  mainConnection,"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
714 
715  struct json_object* res_obj = json_object_new_object();
716  sm_add_object_to_json_object(res_obj,10,
717  _main_connection_id, mcid,
718  _sourceid, srcid,
719  _sinkid, sinkid,
720  _delay, delay,
721  _connectionState, constate
722  );
723  DEBUG(afbitf,"json object :%s:",json_object_to_json_string(res_obj));
724 
725  afb_event_push(ev_new_connection, res_obj);
726 }
727 
728 static void on_removed_main_connection(
729  AudiomanagerCommandinterface* interface, guint16 mainConnectionID)
730 {
731  DEBUG(afbitf,"%s is called",__FUNCTION__);
732 
733  struct json_object* res_obj = json_object_new_object();
734  sm_add_object_to_json_object(res_obj, 2,
735  _main_connection_id, mainConnectionID);
736  afb_event_push(ev_removed_main_connection, res_obj);
737 }
738 
739 static void on_main_connection_state_changed(
740  AudiomanagerCommandinterface* interface, guint16 connectionID, gint16 connectionState)
741 {
742  DEBUG(afbitf,"%s is called",__FUNCTION__);
743 
744  struct json_object* res_obj = json_object_new_object();
745  sm_add_object_to_json_object(res_obj, 4,
746  _connectionID, connectionID,
747  _connectionState, connectionState);
748  afb_event_push(ev_main_connection_state_changed, res_obj);
749 }
750 
751 static void on_volume_changed(
752  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 volume)
753 {
754  DEBUG(afbitf,"%s is called",__FUNCTION__);
755  struct json_object* res_obj = json_object_new_object();
756  sm_add_object_to_json_object(res_obj, 4,
757  _sinkid, sinkID,
758  _volume, volume);
759  afb_event_push(ev_volume_changed, res_obj);
760 }
761 
762 static void on_sink_mute_state_changed(
763  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 mute)
764 {
765  DEBUG(afbitf,"%s is called",__FUNCTION__);
766  struct json_object* res_obj = json_object_new_object();
767  sm_add_object_to_json_object(res_obj, 4,
768  _sinkid, sinkID,
769  _muteState, mute);
770  afb_event_push(ev_sink_mute_state_changed, res_obj);
771 }
772 
773 /*
774 ********** Callback Function invoked by Audio Manager Routing Interface**********
775 */
776 static void on_set_routing_ready(
777  AudiomanagerRoutinginterface* interface)
778 {
779  DEBUG(afbitf,"%s is called",__FUNCTION__);
780  afb_event_push(ev_set_routing_ready, NULL);
781 }
782 
783 static void on_set_routing_rundown(
784  AudiomanagerRoutinginterface* interface)
785 {
786  DEBUG(afbitf,"%s is called",__FUNCTION__);
787  afb_event_push(ev_set_routing_ready, NULL);
788 }
789 
790 
791 
792 /*
793 ********** Callback Function invoked by Sound Manager Adapter Interface**********
794 *
795 * For now, there may be no need to send events to applications from these invocation.
796 * Sound Manager just sends ack to Audio Manager in charge of applications.
797 * If event is needed, make events in initialize function in this source, and
798 * write afb_event_push in the invocations.
799 * Events should be pushed in this source.(I teseted to push events in other code, but can't)
800 *
801 */
802 
803 
804 static gboolean on_async_abort(
805  OrgSoundmanagerGeniviRoutingsend *object,
806  GDBusMethodInvocation *invocation,
807  guint16 arg_handle)
808 {
809  DEBUG(afbitf, "%s called", __FUNCTION__);
810  /* Nothing To Do. If it is better to implement something, I will implement */
811  return TRUE;
812 }
813 
814 static gboolean on_async_connect(
815  OrgSoundmanagerGeniviRoutingsend *object,
816  GDBusMethodInvocation *invocation,
817  guint16 arg_handle,
818  guint16 arg_connectionID,
819  guint16 arg_sourceID,
820  guint16 arg_sinkID,
821  gint arg_connectionFormat)
822 {
823  DEBUG(afbitf, "%s called", __FUNCTION__);
824  GError* err;
825  struct json_object* res_obj = json_object_new_object();
826  sm_add_object_to_json_object(res_obj, 10,
827  _handle, arg_handle,
828  _connectionID, arg_connectionID,
829  _sourceid, arg_sourceID,
830  _sinkid, arg_sinkID,
831  _connectionFormat, arg_connectionFormat);
832  afb_event_push(ev_async_connect, res_obj);
833  audiomanager_routinginterface_call_ack_connect_sync(
834  am_route_bus,
835  arg_handle,
836  arg_connectionID,
837  NULL,
838  NULL, &err);
839  if(err != NULL)
840  {
841  ERROR(afbitf, "Can't create sound manager adapter");
842  return FALSE;
843  }
844  return TRUE;
845 }
846 
847 static gboolean on_async_disconnect(
848  OrgSoundmanagerGeniviRoutingsend *object,
849  GDBusMethodInvocation *invocation,
850  guint16 arg_handle,
851  guint16 arg_connectionID)
852 {
853  DEBUG(afbitf, "%s called", __FUNCTION__);
854  GError* err;
855  audiomanager_routinginterface_call_ack_disconnect_sync(
856  am_route_bus,
857  arg_handle,
858  arg_connectionID,
859  NULL,
860  NULL, &err);
861  if(err != NULL)
862  {
863  ERROR(afbitf, "Can't create sound manager adapter");
864  return FALSE;
865  }
866  return TRUE;
867 }
868 
869 static gboolean on_async_set_sink_volume(
870  OrgSoundmanagerGeniviRoutingsend *object,
871  GDBusMethodInvocation *invocation,
872  guint16 arg_handle,
873  guint16 arg_sinkID,
874  gint16 arg_volume,
875  gint16 arg_ramp,
876  guint16 arg_time)
877 {
878  DEBUG(afbitf, "%s called", __FUNCTION__);
879  /* Nothing To Do. If it is better to implement something, I will implement */
880  return TRUE;
881 }
882 
883 static gboolean on_async_set_source_state(
884  OrgSoundmanagerGeniviRoutingsend *object,
885  GDBusMethodInvocation *invocation,
886  guint16 arg_handle,
887  guint16 arg_sourceID,
888  gint arg_sourceState)
889 {
890  DEBUG(afbitf, "%s called", __FUNCTION__);
891  GError* err;
892  struct json_object* res_obj = json_object_new_object();
893  sm_add_object_to_json_object(res_obj, 6,
894  _handle, arg_handle,
895  _sourceid, arg_sourceID,
896  _sourceState, arg_sourceState);
897  afb_event_push(ev_async_set_source_state, res_obj);
898  /* Applications should return ackSetSourceState, then Sound Manager doen't return ackSetSourceState */
899  /*audiomanager_routinginterface_call_ack_set_source_state_sync(
900  am_route_bus,
901  arg_handle,
902  NULL,
903  NULL, &err);*/
904  if(err != NULL)
905  {
906  ERROR(afbitf, "Can't create sound manager adapter");
907  return FALSE;
908  }
909  return TRUE;
910 }
911 
912 static gboolean init_sound_manager_adapter(GDBusServer *server, GDBusConnection *conn, gpointer data)
913 {
914  DEBUG(afbitf, "%s called", __FUNCTION__);
915  sm_adapter = org_soundmanager_genivi_routingsend_skeleton_new();
916  sm_itf = ORG_SOUNDMANAGER_GENIVI_ROUTINGSEND_GET_IFACE(sm_adapter);
917  /* initialize sound manager adapter */
918  sm_itf->handle_async_abort = on_async_abort;
919  sm_itf->handle_async_connect = on_async_connect;
920  sm_itf->handle_async_disconnect = on_async_disconnect;
921  sm_itf->handle_async_set_sink_volume = on_async_set_sink_volume;
922  sm_itf->handle_async_set_source_state = on_async_set_source_state;
923  gboolean ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), conn, SOUND_MANAGER_PATH, NULL);
924  if(!ret)
925  {
926  ERROR(afbitf, "Can't create sound manager adapter");
927  return FALSE;
928  }
929  return TRUE;
930 }
931 
932 /*
933  * array of the verbs exported to afb-daemon
934  */
935 static const struct afb_verb_desc_v1 binding_verbs[]= {
936 /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */
937 { .name = "connect", .session = AFB_SESSION_NONE, .callback = connect, .info = "Connect source id and sink id" },
938 { .name = "disconnect", .session = AFB_SESSION_NONE, .callback = disconnect, .info = "Disconnect source id and sink id" },
939 { .name = "setVolume", .session = AFB_SESSION_NONE, .callback = setVolume, .info = "Set volume value" }, /* it is better to show the range*/
940 { .name = "volumeStep", .session = AFB_SESSION_NONE, .callback = volumeStep, .info = "Set volume step range" },
941 { .name = "setSinkMuteState", .session = AFB_SESSION_NONE, .callback = setSinkMuteState, .info = "Set Mute state: 1 means mute, 2 means umute. Others are invalid" },
942 { .name = "getListMainConnections", .session = AFB_SESSION_NONE, .callback = getListMainConnections, .info = "Get MainConnection List" },
943 /* Routing Interface */
944 { .name = "registerSource", .session = AFB_SESSION_NONE, .callback = registerSource, .info = "Register Application" },
945 { .name = "deregisterSource", .session = AFB_SESSION_NONE, .callback = deregisterSource, .info = "Deregister Application" },
946 { .name = "ackConnect", .session = AFB_SESSION_NONE, .callback = ackConnect, .info = "Acknowledge of asyncConnect" },
947 { .name = "ackDisconnect", .session = AFB_SESSION_NONE, .callback = ackDisconnect, .info = "Acknowledge of asyncConnect" },
948 { .name = "ackSetSourceState", .session = AFB_SESSION_NONE, .callback = ackSetSourceState, .info = "Acknowledge of asyncSetSourceState" },
949 { .name = "subscribe", .session = AFB_SESSION_NONE, .callback = subscribe, .info = "Subscribe event" },
950 { .name = "unsubscribe", .session = AFB_SESSION_NONE, .callback = unsubscribe, .info = "Unsubscribe event" },
951 { .name = NULL } /* marker for end of the array */
952 };
953 
954 static const struct afb_binding binding_description =
955 {
956  .type = AFB_BINDING_VERSION_1,
957  .v1 = {
958  .info = "Sound Manager" ,
959  .prefix = "soundmanager" ,
960  .verbs = binding_verbs
961  }
962 };
963 
964 static void *dbus_event_loop_run(void *args)
965 {
966  loop = g_main_loop_new(NULL, FALSE);
967  g_main_loop_run(loop);
968 }
969 
970 static void free_dbus()
971 {
972  ERROR(afbitf, "free dbus");
973  if(am_cmd_bus)
974  {
975  free(am_cmd_bus);
976  }
977  if(am_route_bus)
978  {
979  free(am_route_bus);
980  }
981 }
982 
983 static int init()
984 {
985  int ret;
986  INFO(afbitf,"Initialize Dbus object");
987  /* Initialize Dbus interface */
988  if(am_cmd_bus || am_route_bus)
989  {
990  ERROR(afbitf, "Dbus object to Audio Manager is already created");
991  goto out;
992  }
993  am_cmd_bus = audiomanager_commandinterface_proxy_new_for_bus_sync(
994  G_BUS_TYPE_SYSTEM,
995  G_DBUS_PROXY_FLAGS_NONE,
996  AM_NAME,
997  AM_CMD_PATH,
998  NULL,
999  NULL
1000  );
1001  am_route_bus = audiomanager_routinginterface_proxy_new_for_bus_sync(
1002  G_BUS_TYPE_SYSTEM,
1003  G_DBUS_PROXY_FLAGS_NONE,
1004  AM_NAME,
1005  AM_ROUTE_PATH,
1006  NULL,
1007  NULL
1008  );
1009 
1010  if(!am_cmd_bus || !am_route_bus)
1011  {
1012  goto out;
1013  }
1014 
1015  INFO(afbitf, "Finish Initialize");
1016  return 0;
1017 out:
1018  ERROR(afbitf,"Failed to initialize");
1019  free_dbus();
1020  return -1;
1021 }
1022 
1023 static int sm_event_init()
1024 {
1025  INFO(afbitf,"Initialize event receive setting");
1026  int ret;
1027  /* Initialize make event */
1028  size_t size = sizeof cmd_evlist / sizeof *cmd_evlist;
1029 
1030  /*create event*/
1031  /*ToDo Hash table is better. And event should be created in the loop
1032  I would like to change */
1033  ev_volume_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[0]);
1034  ev_new_connection = afb_daemon_make_event(afbitf->daemon, cmd_evlist[1]);
1035  ev_removed_main_connection = afb_daemon_make_event(afbitf->daemon, cmd_evlist[2]);
1036  ev_sink_mute_state_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[3]);
1037  ev_main_connection_state_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[4]);
1038  command_event_list[0].name = cmd_evlist[0];
1039  command_event_list[0].event = &ev_volume_changed;
1040  command_event_list[1].name = cmd_evlist[1];
1041  command_event_list[1].event = &ev_new_connection;
1042  command_event_list[2].name = cmd_evlist[2];
1043  command_event_list[2].event = &ev_removed_main_connection;
1044  command_event_list[3].name = cmd_evlist[3];
1045  command_event_list[3].event = &ev_sink_mute_state_changed;
1046  command_event_list[4].name = cmd_evlist[4];
1047  command_event_list[4].event = &ev_main_connection_state_changed;
1048 
1049  /* create routing event */
1050  ev_set_routing_ready = afb_daemon_make_event(afbitf->daemon, route_evlist[0]);
1051  ev_set_routing_rundown = afb_daemon_make_event(afbitf->daemon, route_evlist[1]);
1052  ev_async_connect = afb_daemon_make_event(afbitf->daemon, route_evlist[2]);
1053  ev_async_set_source_state = afb_daemon_make_event(afbitf->daemon, route_evlist[3]);
1054  routing_event_list[0].name = route_evlist[0];
1055  routing_event_list[0].event = &ev_set_routing_ready;
1056  routing_event_list[1].name = route_evlist[1];
1057  routing_event_list[1].event = &ev_set_routing_rundown;
1058  routing_event_list[2].name = route_evlist[1];
1059  routing_event_list[2].event = &ev_async_connect;
1060  routing_event_list[3].name = route_evlist[1];
1061  routing_event_list[3].event = &ev_async_set_source_state;
1062  /*for(size_t i = 0; i < size; ++i)
1063  {
1064  struct afb_event afbev = afb_daemon_make_event(afbitf->daemon, cmd_evlist[i]));
1065  size_t afbev_size = sizeof afbev;
1066  size_t key_size = sizeof cmd_evlist[i];
1067 
1068  struct event ev = {cmd_evlist[i],afbev};
1069  command_event_list[i] = malloc(key_size + afbev_size);
1070  command_event_list[i] = ev;
1071  search_result = hsearch(entry, FIND);
1072  if(search_result)
1073  DEBUG(afbitf, "event name is %s", search_result->key);
1074  }*/
1075 
1076  /* Initialize dbus event thread */
1077  if(!am_cmd_bus || !am_route_bus)
1078  {
1079  goto ev_init_out;
1080  }
1081  pthread_t thread_id;
1082  ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
1083  if(ret != 0)
1084  {
1085  goto ev_init_out;
1086  }
1087  /* initialize signal from audio manager command interface */
1088  g_signal_connect(am_cmd_bus,
1089  "volume_changed",
1090  G_CALLBACK(on_volume_changed),
1091  NULL);
1092  g_signal_connect(am_cmd_bus,
1093  "new_main_connection",
1094  G_CALLBACK(on_new_main_connection),
1095  NULL);
1096  g_signal_connect(am_cmd_bus,
1097  "removed_main_connection",
1098  G_CALLBACK(on_removed_main_connection),
1099  NULL);
1100  g_signal_connect(am_cmd_bus,
1101  "sink_mute_state_changed",
1102  G_CALLBACK(on_sink_mute_state_changed),
1103  NULL);
1104  g_signal_connect(am_cmd_bus,
1105  "main_connection_state_changed",
1106  G_CALLBACK(on_main_connection_state_changed),
1107  NULL);
1108  g_signal_connect(am_route_bus,
1109  "set_routing_ready",
1110  G_CALLBACK(on_set_routing_ready),
1111  NULL);
1112  g_signal_connect(am_route_bus,
1113  "set_routing_rundown",
1114  G_CALLBACK(on_set_routing_rundown),
1115  NULL);
1116 
1117  /* Get soundmanager adapter bus */
1118  g_bus_own_name(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
1119  NULL, init_sound_manager_adapter, NULL, NULL, NULL);
1120 
1121  INFO(afbitf,"Finish Initialize event receive setting");
1122  return 0;
1123 
1124 ev_init_out:
1125  if(loop != NULL)
1126  {
1127  g_main_loop_unref(loop);
1128  }
1129  free_dbus();
1130  ERROR(afbitf, "DBus connection is not created");
1131  return -1;
1132 }
1133 
1134 /*
1135  * activation function for registering the binding called by afb-daemon
1136  */
1137 const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf)
1138 {
1139  afbitf = itf; // records the interface for accessing afb-daemon
1140 
1141  int ret = init(); // Set Dbus communication with audio mangaer
1142  return (ret == 0) ? &binding_description : NULL;
1143 }
1144 
1145 int afbBindingV1ServiceInit(struct afb_service service)
1146 {
1147  DEBUG(afbitf, "Initializing Audio Manager Notification \n");
1148  int ret = sm_event_init();
1149  return ret;
1150 }
struct afb_event * event
Definition: soundmanager.c:51
-
#define AM_CMD_PATH
Definition: soundmanager.c:32
-
#define AM_NAME
Definition: soundmanager.c:31
-
#define AM_ROUTE_PATH
Definition: soundmanager.c:33
- -
const struct afb_binding * afbBindingV1Register(const struct afb_binding_interface *itf)
-
int afbBindingV1ServiceInit(struct afb_service service)
-
#define ROUTING_EVENT_NUM
Definition: soundmanager.c:38
-
#define SOUND_MANAGER_PATH
Definition: soundmanager.c:35
-
#define SOUND_MANAGER_NAME
Definition: soundmanager.c:34
-
#define COMMAND_EVENT_NUM
Definition: soundmanager.c:37
-
char * name
Definition: soundmanager.c:50
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define _GNU_SOURCE
18 #define AFB_BINDING_VERSION 2
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <stdint.h>
23 #include <unistd.h>
24 #include <json-c/json.h>
25 #include <glib.h>
26 #include <pthread.h>
27 #include <afb/afb-binding.h>
28 #include "sm-error.h"
29 #include "sm-helper.h"
31 
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"
39 
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
53 
54 #define EVENT_SUBSCRIBE_ERROR_CODE 100
55 
56 const static struct afb_binding_interface *afbitf;
57 static AudiomanagerCommandinterface *am_cmd_bus;
58 static AudiomanagerRoutinginterface *am_route_bus;
59 static AudiomanagerRoutingSoundmanager *sm_adapter;
61 static GDBusConnection* system_conn = NULL;
62 
63 static GMainLoop *loop = NULL;
64 static guint16 SOUNDMANAGER_DOMAIN_ID;
65 /* To Do hash table is better */
66 struct event{
67  char* name;
68  struct afb_event* event;
69  };
70 static struct event command_event_list[COMMAND_EVENT_NUM];
71 static struct event routing_event_list[ROUTING_EVENT_NUM];
72 
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;
78 
79 /* Routing interface event */
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;
85 
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";
97 
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";
114 /*
115 ********** Method of Sound Manager (API) **********
116 */
117 
147 static void connect (struct afb_req request)
148 {
149  AFB_DEBUG("call %s", __FUNCTION__);
150  guint16 source_id = 0, sink_id = 0;
151  guint16 main_connectionID = 0;
152  gint16 ret = -1;
153  REQ_ERROR req_err1 = REQ_FAIL;
154  REQ_ERROR req_err2 = REQ_FAIL;
155  GError *err = NULL;
156 
157  req_err1 = get_value_uint16(request, _source_id, &source_id);
158  /* ToDo: Hardware abstraction for application user is needed.
159  select appname(speaker) or sourceID(sinkID). If appname is desired, it changes to sourceID(sinkID) */
160 
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")))){
165  sink_id = DEFAULT_SINK;
166  req_err2 = REQ_OK;
167  }
168  else{
169  req_err2 = get_value_uint16(request, _sink_id, &sink_id);
170  }
171  }
172 
173  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
174  {
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);
178  return;
179  }
180 
182  am_cmd_bus,
183  source_id,
184  sink_id,
185  &ret,
186  &main_connectionID,
187  NULL, &err);
188 
189  if(err != NULL)
190  {
191  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
192  return;
193  }
194 
195  /* ToDo Remember appname(key) and tie to sourceID(value) */
196 
197  /*create response json object*/
198  struct json_object *res = json_object_new_object();
199  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
200  "error", ret,
201  _main_connection_id, main_connectionID);
202  char *info = get_response_audiomanager_massage_error(ret);
203  afb_req_success(request, res, info);
204 }
205 
222 static void disconnect (struct afb_req request)
223 {
224  AFB_DEBUG("call %s", __FUNCTION__);
225 
226  guint16 id;
227  gint16 ret;
228  REQ_ERROR req_err;
229  GError *err = NULL;
230 
231  req_err = get_value_uint16(request, _main_connection_id, &id);
232  AFB_DEBUG( "requested %s = %d", _main_connection_id, id);
233 
234  if(req_err != REQ_OK)
235  {
236  afb_req_fail(request,"wrong-request",afb_req_value (request, _main_connection_id));
237  return;
238  }
240  am_cmd_bus,
241  id,
242  &ret,
243  NULL, &err);
244  AFB_DEBUG( "ret = %d", ret);
245 
246  if(err != NULL)
247  {
248  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
249  return;
250  }
251 
252  struct json_object* res_obj = json_object_new_object();
253  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
254  _error, ret);
255  char *info = get_response_audiomanager_massage_error(ret);
256 
257  afb_req_success(request, res_obj, info); /* return error num as status */
258 }
259 
275 static void setVolume (struct afb_req request)
276 {
277  AFB_DEBUG("call %s", __FUNCTION__);
278 
279  guint16 sink_id, vol;
280  gint16 ret;
281  REQ_ERROR req_err1, req_err2;
282  GError *err = NULL;
283 
284  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
285  req_err2 = get_value_int16(request, _volume, &vol);
286  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _volume, vol);
287  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
288  {
289  afb_req_fail(request,"wrong-request", NULL);
290  return;
291  }
292 
294  am_cmd_bus,
295  sink_id,
296  vol,
297  &ret,
298  NULL, &err);
299  AFB_DEBUG( "ret = %d", ret);
300 
301  if(err != NULL)
302  {
303  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
304  return;
305  }
306 
307  struct json_object* res_obj = json_object_new_object();
308  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
309  "error", ret);
310  char *info = get_response_audiomanager_massage_error(ret);
311 
312  afb_req_success(request, res_obj, info); /* return error num as status */
313 }
314 
331 static void volumeStep (struct afb_req request)
332 {
333  AFB_DEBUG("call %s", __FUNCTION__);
334 
335  guint16 sink_id, vol;
336  gint16 ret;
337  REQ_ERROR req_err1, req_err2;
338  GError *err = NULL;
339 
340  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
341  req_err2 = get_value_int16(request, _volume_step, &vol);
342  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _volume_step, vol);
343  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
344  {
345  afb_req_fail(request,"wrong-request", NULL);
346  return;
347  }
348 
350  am_cmd_bus,
351  sink_id,
352  vol,
353  &ret,
354  NULL, &err);
355  AFB_DEBUG( "ret = %d", ret);
356 
357  if(err != NULL)
358  {
359  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
360  return;
361  }
362 
363  struct json_object* res_obj = json_object_new_object();
364  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
365  "error", ret);
366  char *info = get_response_audiomanager_massage_error(ret);
367 
368  afb_req_success(request, res_obj, info); /* return error num as status */
369 }
370 
387 static void setSinkMuteState(struct afb_req request)
388 {
389  AFB_DEBUG("call %s", __FUNCTION__);
390 
391  guint16 sink_id, mute;
392  gint16 ret;
393  REQ_ERROR req_err1, req_err2;
394  GError *err = NULL;
395 
396  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
397  req_err2 = get_value_int16(request, _mute_state, &mute);
398  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _mute_state, mute);
399  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
400  {
401  afb_req_fail(request,"wrong-request", NULL);
402  return;
403  }
404 
406  am_cmd_bus,
407  sink_id,
408  mute,
409  &ret,
410  NULL, &err);
411  AFB_DEBUG( "ret = %d", ret);
412 
413  if(err != NULL)
414  {
415  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
416  return;
417  }
418 
419  struct json_object* res_obj = json_object_new_object();
420  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
421  "error", ret);
422  char *info = get_response_audiomanager_massage_error(ret);
423 
424  afb_req_success(request, res_obj, info); /* return error num as status */
425 }
426 
443 static void getListMainConnections(struct afb_req request)
444 {
445  AFB_DEBUG("call getListMainConnections");
446  guint16 ret;
447  GVariant* mainConnectionList;
448  GError *err = NULL;
449 
451  am_cmd_bus,
452  &ret,
453  &mainConnectionList,
454  NULL,
455  &err
456  );
457 
458  if(err != NULL)
459  {
460  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
461  return;
462  }
463 
464  /* create response */
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();
469  sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
470  json_object_array_add(array_res, verb_obj);
471  if(size <= 0)
472  {
473  AFB_NOTICE( "mainConnectionList size is 0");
474  }
475  else{
476  for(int i = 0; i < size; ++i)
477  {
478  guint16 mcid, srcid, sinkid;
479  gint16 delay, constate;
480  g_variant_get_child(
481  mainConnectionList,i,"(qqqnn)",
482  &mcid, &srcid, &sinkid, &delay, &constate
483  );
484 
485  struct json_object* res_obj = json_object_new_object();
486  sm_add_object_to_json_object(res_obj,10,
487  _main_connection_id, mcid,
488  _source_id, srcid,
489  _sink_id, sinkid,
490  _delay, delay,
491  _connection_state, constate
492  );
493  json_object_array_add(array_res,res_obj);
494  }
495  }
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");
498 }
499 
516 static void getListMainSinks(struct afb_req request)
517 {
518  AFB_DEBUG("call %s", __FUNCTION__);
519  guint16 ret;
520  GVariant* mainSinkList;
521  GError *err = NULL;
522 
524  am_cmd_bus,
525  &ret,
526  &mainSinkList,
527  NULL,
528  &err
529  );
530 
531  if(err != NULL)
532  {
533  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
534  return;
535  }
536 
537  /* create response */
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();
542  sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
543  json_object_array_add(array_res, verb_obj);
544  if(size <= 0)
545  {
546  AFB_NOTICE("%s size is 0", __FUNCTION__);
547  }
548  else{
549  /*for(int i = 0; i < size; ++i)
550  {
551  guint16 sinkid, sinkclassid;
552  gchar* sinkname;
553  GVariant* available = g_variant_new("(nn)", -1, -1);
554  gint16 volume, mutestate;
555  g_variant_get_child(
556  mainSinkList,i,"(qs(nn)nnq)",
557  &sinkid, sinkname, &volume, &mutestate, &sinkclassid);
558  struct json_object* res_obj = json_object_new_object();
559  sm_add_object_to_json_object(res_obj,2,_sink_id, sinkid);
560  json_object_object_add(res_obj, _sink_name, json_object_new_string(sinkname));
561  sm_add_object_to_json_object(res_obj,6,
562  _volume, volume,
563  _mute_state, mutestate,
564  _sink_class_id, sinkclassid);
565  json_object_array_add(array_res,res_obj);
566  }*/
567  }
568  AFB_DEBUG("json object :%s:",json_object_to_json_string(array_res));
569  //afb_req_success(request, array_res, "Success to get main sink list");
570  afb_req_success(request, array_res, "This is not implemented yet");
571 }
572 /*
573 *
574 ****** Routing Interface method(API) ***********
575 *
576 */
577 
597 static void ackConnect(struct afb_req request)
598 {
599  /* This function will be deprecated */
600  AFB_DEBUG("call %s", __FUNCTION__);
601  guint16 handle, connection_id, error;
602  guint16 ret = 0;
603  REQ_ERROR req_err1, req_err2 , req_err3;
604  GError *err = NULL;
605 
606  req_err1 = get_value_uint16(request, _handle, &handle);
607  req_err2 = get_value_uint16(request, _connection_id, &connection_id);
608  req_err3 = get_value_uint16(request, _error, &error);
609 
610  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
611  {
612  afb_req_fail(request,"wrong-request", NULL);
613  return;
614  }
615  if(connection_id == 0)
616  {
617  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
618  return;
619  }
620 
622  am_route_bus,
623  handle,
624  connection_id,
625  error,
626  NULL, &err);
627 
628  if(err != NULL)
629  {
630  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
631  return;
632  }
633  /*create response json object*/
634  struct json_object *res = json_object_new_object();
635  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
636  _error, ret);
637  char *info = get_response_audiomanager_massage_error(ret);
638  afb_req_success(request, res, info);
639 }
640 
659 static void ackDisconnect(struct afb_req request)
660 {
661  /* This function will be deprecated */
662  AFB_DEBUG("call %s", __FUNCTION__);
663  guint16 handle, connection_id, error;
664  guint16 ret = 0;
665  REQ_ERROR req_err1, req_err2 , req_err3;
666  GError *err = NULL;
667 
668  req_err1 = get_value_uint16(request, _handle, &handle);
669  req_err2 = get_value_uint16(request, _connection_id, &connection_id);
670  req_err3 = get_value_uint16(request, _error, &error);
671 
672  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
673  {
674  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
675  return;
676  }
677  if(connection_id == 0)
678  {
679  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
680  return;
681  }
682 
684  am_route_bus,
685  handle,
686  connection_id,
687  error,
688  NULL, &err);
689 
690  if(err != NULL)
691  {
692  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
693  return;
694  }
695  /*create response json object*/
696  struct json_object *res = json_object_new_object();
697  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
698  _error, ret);
699  char *info = get_response_audiomanager_massage_error(ret);
700  afb_req_success(request, res, info);
701 }
702 
720 static void ackSetSourceState(struct afb_req request)
721 {
722  AFB_DEBUG("call %s", __FUNCTION__);
723  guint16 handle, error;
724  guint16 ret = 0;
725  REQ_ERROR req_err1, req_err2;
726  GError *err = NULL;
727 
728  req_err1 = get_value_uint16(request, _handle, &handle);
729  req_err2 = get_value_uint16(request, _error, &error);
730 
731  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
732  {
733  AFB_DEBUG("wrong request");
734  afb_req_fail(request,"wrong-request", NULL);
735  return;
736  }
737 
739  am_route_bus,
740  handle,
741  error,
742  NULL, &err);
743 
744  if(err != NULL)
745  {
746  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
747  return;
748  }
749  /*create response json object*/
750  struct json_object *res = json_object_new_object();
751  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
752  _error, ret);
753  char *info = get_response_audiomanager_massage_error(ret);
754  afb_req_success(request, res, info);
755 }
756 
776 static void registerSource(struct afb_req request)
777 {
778  AFB_DEBUG("call %s", __FUNCTION__);
779  GError *err = NULL;
780 
781 
782  guint16 source_id; /* q 0 is for dynamic id*/
783  guint16 domain_id; /* q */
784  guint16 source_class_id; /* q */
785  gint32 source_state; /* i */
786  gint16 volume; /* n */
787 
788  if(REQ_OK != get_value_uint16(request, _source_id, &source_id)){
789  source_id = DYNAMIC_SOURCE_ID; /* if 0, dynamic source id will be applied */
790  }
791  REQ_ERROR req_err = get_value_uint16(request, _domain_id, &domain_id);
792  if( req_err != REQ_OK){
793  if(req_err == REQ_FAIL)
794  {
795  domain_id = SOUNDMANAGER_DOMAIN_ID; /* default in AGL */
796  }
797  else{
798  afb_req_fail(request,"wrong-request", "Please input domainID as uint16, otherwise no value is OK");
799  return;
800  }
801  }
802  if(domain_id == 0)
803  {
804  afb_req_fail(request,"wrong-request", "domainID should be more than 0");
805  return;
806  }
807  const gchar* name = afb_req_value(request, _appname); /* s */
808  if(!name)
809  {
810  char* info = "Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
811  afb_req_fail(request, NULL, info);
812  return;
813  }
814  if(REQ_OK != get_value_uint16(request, _source_class_id, &source_class_id)){
815  source_class_id = DEFAULT_SOURCE_CLASS_ID; /* BASE */
816  }
817  if(REQ_OK != get_value_int32(request, _source_state, &source_state)){
818  source_state = DEFAULT_SOURCE_STATE; /* SS_OFF */
819  }
820  if(REQ_OK != get_value_int16(request, _volume, &volume)){
821  volume = DEFAULT_VOLUME;
822  }
823  gboolean visible = TRUE; /* b */
824  struct availability_s available; /* (ii) */
825  available.availability = DEFAULT_AVAILABLES; /* A_UNKNOWN */
826  available.avalilable_reason = 0; /* AR_UNKNOWN */
827 
828  guint16 interrupt;
829  if(REQ_OK != get_value_int16(request, _interrupt, &interrupt)){
830  interrupt = DEFAULT_INTERRUPT; /* q IS_OFF */
831  }
832  struct sound_property_s sound_property_list; /* a(in) */
833  sound_property_list.type = 0;
834  sound_property_list.value = 0; /* in reality, this is array of struct */
835 
836  gint32 connection_format_list = DEFAULT_CONNECTION_FORMAT; /* ai */
837  struct main_sound_property_s main_property_list; /* a(in) */
838  main_property_list.type = 0;
839  main_property_list.value = 0;
840 
841  struct notification_config_s nconf_routing;
842  struct notification_config_s nconf_command; /* a(iin)a(iin) */
843  nconf_routing.type = 0;
844  nconf_routing.status = 0;
845  nconf_routing.parameter = 0;
846 
847  nconf_command.type = 0;
848  nconf_command.status = 0;
849  nconf_command.parameter = 0;
850 
851  /* acquire data */
852  guint16 acquire_source_id;
853  guint16 ret;
854 
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);
859 
860  GVariant* input = g_variant_ref_sink(sourceData);
862  am_route_bus,
863  input,
864  &acquire_source_id,
865  &ret,
866  NULL, &err);
867  g_variant_unref(input);
868 
869  if(err != NULL)
870  {
871  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
872  return;
873  }
874 
875  /*create response json object*/
876  struct json_object *res = json_object_new_object();
877  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
878  _error, ret,
879  _source_id, acquire_source_id);
880  char *info = get_response_audiomanager_massage_error(ret);
881  afb_req_success(request, res, info);
882 }
883 
897 static void deregisterSource(struct afb_req request)
898 {
899  guint16 source_id;
900  guint16 ret;
901 
902  GError *err = NULL;
903 
904  if(REQ_OK != get_value_uint16(request, _source_id, &source_id)){
905  afb_req_fail(request, "wrong-request", NULL);
906  }
908  am_route_bus,
909  source_id,
910  &ret,
911  NULL, &err
912  );
913  if(err != NULL)
914  {
915  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
916  return;
917  }
918  /*create response json object*/
919  struct json_object *res = json_object_new_object();
920  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
921  _error, ret);
922  char *info = get_response_audiomanager_massage_error(ret);
923  afb_req_success(request, res, info);
924 
925 }
926 
939 static void subscribe(struct afb_req request)
940 {
941  const char *value = afb_req_value(request, "event");
942  AFB_DEBUG( "value is %s", value);
943  int ret = 0;
944  if(value) {
945  int index = sm_search_event_name_index(value);
946  if(index < 0)
947  {
948  index = sm_search_routing_event_name_index(value);
949  if(index < 0)
950  {
951  AFB_NOTICE( "dedicated event doesn't exist");
953  }
954  else
955  {
956  afb_req_subscribe(request, *routing_event_list[index].event);
957  }
958  }
959  else
960  {
961  afb_req_subscribe(request, *command_event_list[index].event);
962  }
963  }
964  else{
965  AFB_NOTICE( "Please input event name");
967  }
968  /*create response json object*/
969  struct json_object *res = json_object_new_object();
970  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
971  _error, ret);
972  char *info = get_response_audiomanager_massage_error(ret);
973  afb_req_success(request, res, info);
974 }
975 
988 static void unsubscribe(struct afb_req request)
989 {
990  const char *value = afb_req_value(request, "event");
991  AFB_DEBUG( "value is %s", value);
992  int ret = 0;
993  if(value) {
994  int index = sm_search_event_name_index(value);
995  if(index < 0)
996  {
997  index = sm_search_routing_event_name_index(value);
998  if(index < 0)
999  {
1000  AFB_NOTICE( "dedicated event doesn't exist");
1002  }
1003  else
1004  {
1005  afb_req_unsubscribe(request, *routing_event_list[index].event);
1006  }
1007  }
1008  else
1009  {
1010  afb_req_unsubscribe(request, *command_event_list[index].event);
1011  }
1012  }
1013  else{
1014  AFB_NOTICE( "Please input event name");
1016  }
1017  /*create response json object*/
1018  struct json_object *res = json_object_new_object();
1019  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
1020  _error, ret);
1021  char *info = get_response_audiomanager_massage_error(ret);
1022  afb_req_success(request, res, info);
1023 }
1024 
1025 /*
1026 ********** Callback Function invoked by Audio Manager **********
1027 */
1028 
1029 static void on_new_main_connection(AudiomanagerCommandinterface* interface,
1030  GVariant* mainConnection)
1031 {
1032  AFB_DEBUG("%s is called",__FUNCTION__);
1033 
1034  guint16 mcid, srcid, sinkid;
1035  gint16 delay, constate;
1036  g_variant_get(
1037  mainConnection,"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
1038 
1039  struct json_object* res_obj = json_object_new_object();
1040  sm_add_object_to_json_object(res_obj,10,
1041  _main_connection_id, mcid,
1042  _source_id, srcid,
1043  _sink_id, sinkid,
1044  _delay, delay,
1045  _connection_state, constate
1046  );
1047  AFB_DEBUG("json object :%s:",json_object_to_json_string(res_obj));
1048 
1049  afb_event_push(ev_new_connection, res_obj);
1050 }
1051 
1052 static void on_removed_main_connection(
1053  AudiomanagerCommandinterface* interface, guint16 mainConnectionID)
1054 {
1055  AFB_DEBUG("%s is called",__FUNCTION__);
1056 
1057  struct json_object* res_obj = json_object_new_object();
1058  sm_add_object_to_json_object(res_obj, 2,
1059  _main_connection_id, mainConnectionID);
1060  afb_event_push(ev_removed_main_connection, res_obj);
1061 }
1062 
1063 static void on_main_connection_state_changed(
1064  AudiomanagerCommandinterface* interface, guint16 connectionID, gint16 connectionState)
1065 {
1066  AFB_DEBUG("%s is called",__FUNCTION__);
1067 
1068  struct json_object* res_obj = json_object_new_object();
1069  sm_add_object_to_json_object(res_obj, 4,
1070  _connection_id, connectionID,
1071  _connection_state, connectionState);
1072  afb_event_push(ev_main_connection_state_changed, res_obj);
1073 }
1074 
1075 static void on_volume_changed(
1076  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 volume)
1077 {
1078  AFB_DEBUG("%s is called",__FUNCTION__);
1079  struct json_object* res_obj = json_object_new_object();
1080  sm_add_object_to_json_object(res_obj, 4,
1081  _sink_id, sinkID,
1082  _volume, volume);
1083  afb_event_push(ev_volume_changed, res_obj);
1084 }
1085 
1086 static void on_sink_mute_state_changed(
1087  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 mute)
1088 {
1089  AFB_DEBUG("%s is called",__FUNCTION__);
1090  struct json_object* res_obj = json_object_new_object();
1091  sm_add_object_to_json_object(res_obj, 4,
1092  _sink_id, sinkID,
1093  _mute_state, mute);
1094  afb_event_push(ev_sink_mute_state_changed, res_obj);
1095 }
1096 
1097 /*
1098 ********** Callback Function invoked by Audio Manager Routing Interface**********
1099 */
1100 static void on_set_routing_ready(
1101  AudiomanagerRoutinginterface* interface)
1102 {
1103  AFB_DEBUG("%s is called",__FUNCTION__);
1104  afb_event_push(ev_set_routing_ready, NULL);
1105 }
1106 
1107 static void on_set_routing_rundown(
1108  AudiomanagerRoutinginterface* interface)
1109 {
1110  AFB_DEBUG("%s is called",__FUNCTION__);
1111  afb_event_push(ev_set_routing_ready, NULL);
1112 }
1113 
1114 
1115 
1116 /*
1117 ********** Callback Function invoked by Sound Manager Adapter Interface**********
1118 *
1119 * For now, there may be no need to send events to applications from these invocation.
1120 * Sound Manager just sends ack to Audio Manager in charge of applications.
1121 *
1122 */
1123 static gboolean on_async_abort(
1125  GDBusMethodInvocation *invocation,
1126  guint16 arg_handle)
1127 {
1128  AFB_DEBUG( "%s called", __FUNCTION__);
1129  /* Nothing To Do. If it is better to implement something, I will implement */
1130  return TRUE;
1131 }
1132 
1133 static gboolean on_async_connect(
1135  GDBusMethodInvocation *invocation,
1136  guint16 arg_handle,
1137  guint16 arg_connectionID,
1138  guint16 arg_sourceID,
1139  guint16 arg_sinkID,
1140  gint arg_connectionFormat)
1141 {
1142  AFB_DEBUG( "%s called", __FUNCTION__);
1143 
1144  struct json_object* ev_obj = json_object_new_object();
1145  sm_add_object_to_json_object(ev_obj, 10,
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);
1152 
1153  /* GError must be initialized here because it is same as grobal errno,
1154  so if afb_event_push is failed due to something, number will be changed */
1155  GError* err = NULL;
1157  am_route_bus,
1158  arg_handle,
1159  arg_connectionID,
1160  0,
1161  NULL, &err);
1162  if(err != NULL)
1163  {
1164  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1165  return FALSE;
1166  }
1167  return TRUE;
1168 }
1169 
1170 static gboolean on_async_disconnect(
1172  GDBusMethodInvocation *invocation,
1173  guint16 arg_handle,
1174  guint16 arg_connectionID)
1175 {
1176  AFB_DEBUG( "%s called", __FUNCTION__);
1177  struct json_object* ev_obj = json_object_new_object();
1178  sm_add_object_to_json_object(ev_obj, 4,
1179  _handle, arg_handle,
1180  _connection_id, arg_connectionID);
1181  afb_event_push(ev_async_disconnect, ev_obj);
1182  GError* err = NULL;
1184  am_route_bus,
1185  arg_handle,
1186  arg_connectionID,
1187  0,
1188  NULL, &err);
1189  if(err != NULL)
1190  {
1191  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1192  return FALSE;
1193  }
1194  return TRUE;
1195 }
1196 
1197 static gboolean on_async_set_sink_volume(
1199  GDBusMethodInvocation *invocation,
1200  guint16 arg_handle,
1201  guint16 arg_sinkID,
1202  gint16 arg_volume,
1203  gint16 arg_ramp,
1204  guint16 arg_time)
1205 {
1206  AFB_DEBUG( "%s called", __FUNCTION__);
1207  GError* err = NULL;
1209  am_route_bus,
1210  arg_handle,
1211  arg_volume,
1212  0, NULL, &err);
1213  if(err != NULL);{
1214  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1215  return FALSE;
1216  }
1217  return TRUE;
1218 }
1219 
1237 static gboolean on_async_set_source_state(
1239  GDBusMethodInvocation *invocation,
1240  guint16 arg_handle,
1241  guint16 arg_sourceID,
1242  gint arg_sourceState)
1243 {
1244  AFB_DEBUG( "%s called", __FUNCTION__);
1245  struct json_object* ev_obj = json_object_new_object();
1246  char* ss_key = get_source_state_key(arg_sourceState);
1247  sm_add_object_to_json_object(ev_obj, 4,
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);
1252  /* Applications must return ackSetSourceState to look sourceID, then Sound Manager doen't return ackSetSourceState */
1253  /*audiomanager_routinginterface_call_ack_set_source_state_sync(
1254  am_route_bus,
1255  arg_handle,
1256  NULL,
1257  NULL, &err);*/
1258 }
1259 
1260 
1261 /*
1262  * array of the verbs exported to afb-daemon
1263  */
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}, /* it is better to show the range*/
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},
1293 { .verb = NULL } /* marker for end of the array */};
1294 
1295 static void *dbus_event_loop_run(void *args)
1296 {
1297  loop = g_main_loop_new(NULL, FALSE);
1298  g_main_loop_run(loop);
1299 }
1300 
1301 /*
1302 *
1303 ********** Internal Function used by Sound Manager **********
1304 *
1305 */
1306 
1307 static int registerDomain()
1308 {
1309  /* Default Setting of Sound Manager Domain */
1310  struct domain_data ddata = {
1312  .name = "SoundManager",
1313  .busname = SOUND_MANAGER_BUS_NAME,
1314  .nodename = "soundmanager",
1315  .early = FALSE,
1316  .complete = TRUE,
1317  .state = DS_CONTROLLED
1318  };
1319  GVariant* domainData = create_domain_data(&ddata);
1320  gchar* retBusName = SOUND_MANAGER_BUS_NAME;
1321  gchar* retPath = SOUND_MANAGER_PATH;
1322  gchar* retInterface = SOUND_MANAGER_RETURN_INTERFACE;
1323  guint16 domain_id;
1324  GError *err = NULL;
1325  guint16 error;
1326 
1328  am_route_bus,
1329  domainData,
1330  retBusName,
1331  retPath,
1332  retInterface,
1333  &domain_id, &error,
1334  NULL, &err);
1335  if(err != NULL){
1336  AFB_ERROR( "Failed to call %s", __FUNCTION__);
1337  return -1;
1338  }
1339  if(error != 0)
1340  {
1341  AFB_ERROR( "Failed to register domain");
1342  return error;
1343  }
1344  SOUNDMANAGER_DOMAIN_ID = domain_id;
1345  AFB_NOTICE( "Complete registered domain id:%d",SOUNDMANAGER_DOMAIN_ID);
1346  return 0;
1347 }
1348 
1349 static int preinit()
1350 {
1351  int ret;
1352  AFB_INFO("Initialize Dbus object");
1353  /* Initialize Dbus interface */
1354  if(am_cmd_bus || am_route_bus)
1355  {
1356  AFB_ERROR( "Dbus object to Audio Manager is already created");
1357  goto out;
1358  }
1360  G_BUS_TYPE_SYSTEM,
1361  G_DBUS_PROXY_FLAGS_NONE,
1362  AM_NAME,
1363  AM_CMD_PATH,
1364  NULL,
1365  NULL
1366  );
1368  G_BUS_TYPE_SYSTEM,
1369  G_DBUS_PROXY_FLAGS_NONE,
1370  AM_NAME,
1371  AM_ROUTE_PATH,
1372  NULL,
1373  NULL
1374  );
1375 
1376  if(!am_cmd_bus || !am_route_bus)
1377  {
1378  goto out;
1379  }
1380 
1381  AFB_NOTICE( "Finish Initialize");
1382  return 0;
1383 out:
1384  AFB_ERROR("Failed to initialize");
1385  return -1;
1386 }
1387 
1388 static int create_adapter()
1389 {
1390  GError *error = NULL;
1391  gboolean ret;
1392  GVariant *value;
1393  system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
1394  if (error)
1395  {
1396  g_error_free(error);
1397  return -1;
1398  }
1400  sm_itf = AUDIOMANAGER_ROUTING_SOUNDMANAGER_GET_IFACE(sm_adapter);
1401 
1402  /* initialize sound manager adapter */
1403  sm_itf->handle_async_abort = on_async_abort;
1404  sm_itf->handle_async_connect = on_async_connect;
1405  sm_itf->handle_async_disconnect = on_async_disconnect;
1406  sm_itf->handle_async_set_sink_volume = on_async_set_sink_volume;
1407  sm_itf->handle_async_set_source_state = on_async_set_source_state;
1408 
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);
1415  if (FALSE == ret)
1416  {
1417  AFB_ERROR( "failed to export");
1418  g_error_free(error);
1419  g_object_unref(system_conn);
1420 
1421  return -1;
1422  }
1423 
1424  return 0;
1425 }
1426 
1427 
1428 static void on_name_lost(GDBusServer *server, GDBusConnection *conn, gpointer data)
1429 {
1430  AFB_WARNING("%s called", __FUNCTION__);
1431 }
1432 
1433 
1434 static int sm_event_init()
1435 {
1436  AFB_NOTICE("Initialize event receive setting");
1437  printf("Initialize event receive setting");
1438  int ret;
1439  /* Initialize make event */
1440  size_t size = sizeof cmd_evlist / sizeof *cmd_evlist;
1441 
1442  /*create event*/
1443  /*ToDo Hash table is better. And event should be created in the loop
1444  I would like to change */
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;
1460 
1461  /* create routing event */
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]);
1467 
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;
1478  /*for(size_t i = 0; i < size; ++i)
1479  {
1480  struct afb_event afbev = afb_daemon_make_event(afbitf->daemon, cmd_evlist[i]));
1481  size_t afbev_size = sizeof afbev;
1482  size_t key_size = sizeof cmd_evlist[i];
1483 
1484  struct event ev = {cmd_evlist[i],afbev};
1485  command_event_list[i] = malloc(key_size + afbev_size);
1486  command_event_list[i] = ev;
1487  search_result = hsearch(entry, FIND);
1488  if(search_result)
1489  AFB_NOTICE( "event name is %s", search_result->key);
1490  }*/
1491 
1492  /* Initialize dbus event thread */
1493  if(!am_cmd_bus || !am_route_bus)
1494  {
1495  goto ev_init_out;
1496  }
1497  pthread_t thread_id;
1498  ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
1499  if(ret != 0)
1500  {
1501  goto ev_init_out;
1502  }
1503  /* initialize signal from audio manager command interface */
1504  g_signal_connect(am_cmd_bus,
1505  "volume_changed",
1506  G_CALLBACK(on_volume_changed),
1507  NULL);
1508  g_signal_connect(am_cmd_bus,
1509  "new_main_connection",
1510  G_CALLBACK(on_new_main_connection),
1511  NULL);
1512  g_signal_connect(am_cmd_bus,
1513  "removed_main_connection",
1514  G_CALLBACK(on_removed_main_connection),
1515  NULL);
1516  g_signal_connect(am_cmd_bus,
1517  "sink_mute_state_changed",
1518  G_CALLBACK(on_sink_mute_state_changed),
1519  NULL);
1520  g_signal_connect(am_cmd_bus,
1521  "main_connection_state_changed",
1522  G_CALLBACK(on_main_connection_state_changed),
1523  NULL);
1524  g_signal_connect(am_route_bus,
1525  "set_routing_ready",
1526  G_CALLBACK(on_set_routing_ready),
1527  NULL);
1528  g_signal_connect(am_route_bus,
1529  "set_routing_rundown",
1530  G_CALLBACK(on_set_routing_rundown),
1531  NULL);
1532 
1533  /* Get soundmanager adapter bus */
1534  ret = g_bus_own_name(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
1535  NULL,NULL, NULL, NULL, NULL);
1536  AFB_DEBUG( "g_bus_own_name ret: %d", ret);
1537  ret = create_adapter();
1538  if(ret != 0)
1539  {
1540  goto ev_init_out;
1541  }
1542  ret = registerDomain();
1543 
1544  if(ret != 0)
1545  {
1546  AFB_ERROR("registerDomain error: %s",get_response_audiomanager_massage_error(ret));
1547  goto ev_init_out;
1548  }
1549 
1550  AFB_INFO("Finish Initialize event receive setting");
1551  return 0;
1552 
1553 ev_init_out:
1554  if(loop != NULL)
1555  {
1556  g_main_loop_unref(loop);
1557  }
1558  AFB_WARNING( "DBus connection is not created");
1559  return -1;
1560 }
1561 
1562 static void onevent(const char *event, struct json_object *object)
1563 {
1564  AFB_NOTICE("on_event %s", event);
1565 }
1566 
1567 const struct afb_binding_v2 afbBindingV2 = {
1568  .api = "soundmanager",
1569  .specification = NULL,
1570  .verbs = binding_verbs,
1571  .preinit = preinit,
1572  .init = sm_event_init,
1573  .onevent = onevent
1574 };
struct _AudiomanagerRoutingSoundmanager AudiomanagerRoutingSoundmanager
+
struct afb_event * event
Definition: soundmanager.c:68
+
#define DYNAMIC_SOURCE_ID
Definition: soundmanager.c:46
+ +
#define AM_CMD_PATH
Definition: soundmanager.c:33
+ +
#define AM_NAME
Definition: soundmanager.c:32
+
gint32 availability
Definition: sm-helper.h:56
+
gboolean audiomanager_routinginterface_call_deregister_source_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_sourceID, guint16 *out_error, GCancellable *cancellable, GError **error)
+
#define DEFAULT_VOLUME
Definition: soundmanager.c:47
+
#define AM_ROUTE_PATH
Definition: soundmanager.c:34
+
#define SOUND_MANAGER_RETURN_INTERFACE
Definition: soundmanager.c:36
+
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
Definition: soundmanager.c:43
+
#define DYNAMIC_DOMAIN_ID
Definition: soundmanager.c:44
+
void sm_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: sm-helper.c:110
+
#define DEFAULT_AVAILABLES
Definition: soundmanager.c:48
+
struct _AudiomanagerCommandinterface AudiomanagerCommandinterface
+ + +
struct _AudiomanagerRoutinginterface AudiomanagerRoutinginterface
+
#define DEFAULT_INTERRUPT
Definition: soundmanager.c:50
+
char * get_response_audiomanager_massage_error(int am_error_code)
Definition: sm-error.h:4
+
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)
Definition: sm-helper.c:48
+ +
guint16 domainID
Definition: sm-helper.h:70
+
#define ROUTING_EVENT_NUM
Definition: soundmanager.c:41
+
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)
Definition: sm-helper.c:127
+
#define SOUND_MANAGER_BUS_NAME
Definition: soundmanager.c:37
+
AudiomanagerRoutingSoundmanager * audiomanager_routing_soundmanager_skeleton_new(void)
+
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
Definition: sm-helper.c:24
+
char * get_source_state_key(int am_source_state)
Definition: sm-error.h:38
+
#define SOUND_MANAGER_PATH
Definition: soundmanager.c:38
+ +
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)
+
#define DS_CONTROLLED
Definition: soundmanager.c:52
+ +
guint16 type
Definition: sm-helper.h:52
+
const struct afb_binding_v2 afbBindingV2
+
REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id)
Definition: sm-helper.c:72
+
void sm_add_object_to_json_object(struct json_object *j_obj, int count,...)
Definition: sm-helper.c:96
+ +
GVariant * create_domain_data(struct domain_data *data)
Definition: sm-helper.c:218
+
gboolean audiomanager_routinginterface_call_ack_set_source_state_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_error, GCancellable *cancellable, GError **error)
+
#define DEFAULT_SINK
Definition: soundmanager.c:42
+ +
#define DEFAULT_CONNECTION_FORMAT
Definition: soundmanager.c:49
+
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)
Definition: sm-helper.c:159
+
#define EVENT_SUBSCRIBE_ERROR_CODE
Definition: soundmanager.c:54
+
REQ_ERROR
Definition: sm-helper.h:26
+
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
Definition: soundmanager.c:51
+
#define COMMAND_EVENT_NUM
Definition: soundmanager.c:40
+
char * name
Definition: soundmanager.c:67
+
int sm_search_routing_event_name_index(const char *value)
Definition: sm-helper.c:143