finer granularity of amname generation + audio manager registration filtering
[profile/ivi/pulseaudio-module-murphy-ivi.git] / murphy / node.h
1 /*
2  * module-murphy-ivi -- PulseAudio module for providing audio routing support
3  * Copyright (c) 2012, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU Lesser General Public License,
7  * version 2.1, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
17  * MA 02110-1301 USA.
18  *
19  */
20 #ifndef foomirnodefoo
21 #define foomirnodefoo
22
23 #include <sys/types.h>
24
25 #include "userdata.h"
26 #include "list.h"
27 #include "multiplex.h"
28 #include "loopback.h"
29 #include "volume.h"
30
31 #define AM_ID_INVALID   65535
32
33 enum mir_direction {
34     mir_direction_unknown,
35     mir_input,
36     mir_output
37 };
38
39 enum mir_implement {
40     mir_implementation_unknown = 0,
41     mir_device,
42     mir_stream
43 };
44
45 enum mir_location {
46     mir_location_unknown = 0,
47     mir_internal,
48     mir_external
49 };
50
51 enum mir_node_type {
52     mir_node_type_unknown = 0,
53
54     /* application classes */
55     mir_application_class_begin,
56     mir_radio = mir_application_class_begin,
57     mir_player,
58     mir_navigator,
59     mir_game,
60     mir_browser,
61     mir_camera,
62     mir_phone,                  /**< telephony voice */
63     mir_alert,                  /**< ringtone, alarm */
64     mir_event,                  /**< notifications */
65     mir_system,                 /**< always audible system notifications, events */
66     mir_application_class_end,
67
68     /* device types */
69     mir_device_class_begin = 128,
70     mir_null = mir_device_class_begin,
71     mir_speakers,
72     mir_front_speakers,
73     mir_rear_speakers,
74     mir_microphone,
75     mir_jack,
76     mir_hdmi,
77     mir_spdif,
78     mir_wired_headset,
79     mir_wired_headphone,
80     mir_usb_headset,
81     mir_usb_headphone,
82     mir_bluetooth_sco,
83     mir_bluetooth_a2dp,
84     mir_bluetooth_carkit,
85     mir_bluetooth_source,
86     mir_bluetooth_sink,
87     mir_gateway_sink,
88     mir_gateway_source,
89     mir_device_class_end,
90
91     /* extensions */
92     mir_user_defined_start = 256
93 };
94
95 enum mir_privacy {
96     mir_privacy_unknown = 0,
97     mir_public,
98     mir_private
99 };
100
101 struct pa_nodeset_resdef {
102     uint32_t           priority;
103     struct {
104         uint32_t rset;
105         uint32_t audio;
106     }                  flags;
107 };
108
109 struct pa_nodeset_map {
110     const char        *name;
111     mir_node_type      type;
112     const char        *role;
113     pa_nodeset_resdef *resdef;
114 }; 
115
116 struct pa_node_card {
117     uint32_t  index;
118     char     *profile;
119 };
120
121
122 /**
123  * @brief routing endpoint
124  *
125  * @details node is a routing endpoint in the GenIVI audio model.
126  *          In pulseaudio terminology a routing endpoint is one of
127  *          the following
128  * @li      node is a pulseaudio sink or source. Such node is a
129  *          combination of pulseudio card/profile + sink/port
130  * @li      node is a pulseaudio stream. Such node in pulseaudio
131  *          is either a sink_input or a source_output
132  */
133 struct mir_node {
134     uint32_t       index;     /**< index into nodeset->idxset */
135     char          *key;       /**< hash key for discover lookups */
136     mir_direction  direction; /**< mir_input | mir_output */
137     mir_implement  implement; /**< mir_device | mir_stream */
138     uint32_t       channels;  /**< number of channels (eg. 1=mono, 2=stereo) */
139     mir_location   location;  /**< mir_internal | mir_external */
140     mir_privacy    privacy;   /**< mir_public | mir_private */
141     mir_node_type  type;      /**< mir_speakers | mir_headset | ...  */
142     char          *zone;      /**< zone where the node belong */
143     bool           visible;   /**< internal or can appear on UI  */
144     bool           available; /**< eg. is the headset connected?  */
145     bool           ignore;    /**< do not consider it while routing  */
146     bool           localrset; /**< locally generated resource set */
147     char          *amname;    /**< audiomanager name */
148     char          *amdescr;   /**< UI description */
149     uint16_t       amid;      /**< handle to audiomanager, if any */
150     char          *paname;    /**< sink|source|sink_input|source_output name */
151     uint32_t       paidx;     /**< sink|source|sink_input|source_output index*/
152     pa_node_card   pacard;    /**< pulse card related data, if any  */
153     char          *paport;    /**< sink or source port if applies */
154     pa_muxnode    *mux;       /**< for multiplexable input streams only */
155     pa_loopnode   *loop;      /**< for looped back sources only */
156     mir_dlist      rtentries; /**< in device nodes: listhead of nodchain */
157     mir_dlist      rtprilist; /**< in stream nodes: priority link (head is in
158                                                                    pa_router)*/
159     mir_dlist      constrains;/**< listhead of constrains */
160     mir_vlim       vlim;      /**< volume limit */
161     char          *rsetid;    /**< resource set id, if any */
162     uint32_t       stamp;
163     scripting_node *scripting;/** scripting data, if any */
164 };
165
166
167 pa_nodeset *pa_nodeset_init(struct userdata *);
168 void pa_nodeset_done(struct userdata *);
169
170 int pa_nodeset_add_class(struct userdata *u, mir_node_type , const char *);
171 void pa_nodeset_delete_class(struct userdata *, mir_node_type);
172 const char *pa_nodeset_get_class(struct userdata *, mir_node_type);
173
174 int pa_nodeset_add_role(struct userdata *, const char *, mir_node_type,
175                         pa_nodeset_resdef *);
176 void pa_nodeset_delete_role(struct userdata *, const char *);
177 pa_nodeset_map *pa_nodeset_get_map_by_role(struct userdata *, const char *);
178
179 int pa_nodeset_add_binary(struct userdata *, const char *, mir_node_type,
180                           const char *, pa_nodeset_resdef *);
181 void pa_nodeset_delete_binary(struct userdata *, const char *);
182 pa_nodeset_map *pa_nodeset_get_map_by_binary(struct userdata *, const char *);
183
184 int pa_nodeset_print_maps(struct userdata *, char *, int);
185
186 mir_node *pa_nodeset_iterate_nodes(struct userdata *, uint32_t *);
187
188
189 mir_node *mir_node_create(struct userdata *, mir_node *);
190 void mir_node_destroy(struct userdata *, mir_node *);
191
192 mir_node *mir_node_find_by_index(struct userdata *, uint32_t);
193
194
195 int mir_node_print(mir_node *, char *, int);
196
197 const char *mir_direction_str(mir_direction);
198 const char *mir_implement_str(mir_implement);
199 const char *mir_location_str(mir_location);
200 const char *mir_node_type_str(mir_node_type);
201 const char *mir_privacy_str(mir_privacy);
202
203 #endif
204
205
206 /*
207  * Local Variables:
208  * c-basic-offset: 4
209  * indent-tabs-mode: nil
210  * End:
211  *
212  */