Add sound manager initial source code
[staging/soundmanager.git] / soundmanager_binging / sm-helper.h
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 #ifndef AM_HELPER_H
18 #define AM_HELPER_H
19 #define _GNU_SOURCE
20 #include <afb/afb-binding.h>
21 #include <stdint.h>
22 #include <glib.h>
23 #include <errno.h>
24
25 typedef enum REQ_ERROR
26 {
27   REQ_FAIL = -1,
28   REQ_OK=0,
29   NOT_NUMBER,
30   OUT_RANGE
31 }REQ_ERROR;
32
33 static const char* cmd_evlist[] = {
34     "volumeChanged",
35     "newMainConnection",
36     "removedMainConnection",
37     "sinkMuteStateChanged",
38     "mainConnectionStateChanged"
39 };
40
41 static const char* route_evlist[] = {
42     /* Routing event*/
43     "setRoutingReady",
44     "setRoutingRundown",
45     "asyncConnect",
46     "asyncSetSourceState",
47     "asyncDisconnect"
48 };
49
50 struct sound_property_s{
51     guint16 type;
52     gint16 value;
53 };
54 struct availability_s{
55     gint32 availability;
56     gint32 avalilable_reason;
57 };
58 struct notification_config_s{
59     gint32 type;
60     gint32 status;
61     gint16 parameter;
62 };
63 struct main_sound_property_s{
64     gint32 type;    /* am_CustomMainSoundPropertyType_t */
65     gint16 value;
66 };
67
68 struct domain_data{
69     guint16      domainID;
70     gchar*      name;
71     gchar*      busname;
72     gchar*      nodename;
73     gboolean    early;
74     gboolean    complete;
75     gint16      state;
76 };
77
78 REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id);
79 REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id);
80 REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id);
81 void sm_add_object_to_json_object(struct json_object* j_obj, int count, ...);
82 void sm_add_object_to_json_object_func(struct json_object* j_obj, const char* verb_name, int count, ...);
83 int sm_search_event_name_index(const char* value);
84 int sm_search_routing_event_name_index(const char* value);
85 GVariant* create_source_data(guint16 sourceID, guint16 domainID, const char* appname, guint16 sourceClassID,
86     gint32  sourceState, gint16 volume, gboolean visible, struct availability_s availables, 
87     guint16 interrupt,  struct sound_property_s soundPropertyList, gint32 connectionFormatList, 
88     struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting, 
89     struct notification_config_s NConfCommand, struct afb_binding_interface* afbitf);
90 GVariant* create_domain_data(struct domain_data*, struct afb_binding_interface* afbitf);
91
92
93 #endif /*AM_HELPER_H*/