pump up version number and update changelog
[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 struct pa_nodeset_resdef {
34     uint32_t           priority;
35     struct {
36         uint32_t rset;
37         uint32_t audio;
38     }                  flags;
39 };
40
41 struct pa_nodeset_map {
42     const char        *name;
43     mir_node_type      type;
44     const char        *role;
45     pa_nodeset_resdef *resdef;
46 }; 
47
48 struct pa_node_card {
49     uint32_t  index;
50     char     *profile;
51 };
52
53 struct pa_node_rset {
54     char     *id;               /**< resource set id, if any */
55     bool      grant;            /**< permission to play/render etc */
56 };
57
58 /**
59  * @brief routing endpoint
60  *
61  * @details node is a routing endpoint in the GenIVI audio model.
62  *          In pulseaudio terminology a routing endpoint is one of
63  *          the following
64  * @li      node is a pulseaudio sink or source. Such node is a
65  *          combination of pulseudio card/profile + sink/port
66  * @li      node is a pulseaudio stream. Such node in pulseaudio
67  *          is either a sink_input or a source_output
68  */
69 struct mir_node {
70     uint32_t       index;     /**< index into nodeset->idxset */
71     char          *key;       /**< hash key for discover lookups */
72     mir_direction  direction; /**< mir_input | mir_output */
73     mir_implement  implement; /**< mir_device | mir_stream */
74     uint32_t       channels;  /**< number of channels (eg. 1=mono, 2=stereo) */
75     mir_location   location;  /**< mir_internal | mir_external */
76     mir_privacy    privacy;   /**< mir_public | mir_private */
77     mir_node_type  type;      /**< mir_speakers | mir_headset | ...  */
78     char          *zone;      /**< zone where the node belong */
79     bool           visible;   /**< internal or can appear on UI  */
80     bool           available; /**< eg. is the headset connected?  */
81     bool           ignore;    /**< do not consider it while routing  */
82     bool           localrset; /**< locally generated resource set */
83     const char    *amname;    /**< audiomanager name */
84     const char    *amdescr;   /**< UI description */
85     uint16_t       amid;      /**< handle to audiomanager, if any */
86     const char    *paname;    /**< sink|source|sink_input|source_output name */
87     uint32_t       paidx;     /**< sink|source|sink_input|source_output index*/
88     pa_node_card   pacard;    /**< pulse card related data, if any  */
89     const char    *paport;    /**< sink or source port if applies */
90     pa_muxnode    *mux;       /**< for multiplexable input streams only */
91     pa_loopnode   *loop;      /**< for looped back sources only */
92     mir_dlist      rtentries; /**< in device nodes: listhead of nodchain */
93     mir_dlist      rtprilist; /**< in stream nodes: priority link (head is in
94                                                                    pa_router)*/
95     mir_dlist      constrains;/**< listhead of constrains */
96     mir_vlim       vlim;      /**< volume limit */
97     pa_node_rset   rset;      /**< resource set info if applies */
98     uint32_t       stamp;
99     scripting_node *scripting;/** scripting data, if any */
100 };
101
102
103 pa_nodeset *pa_nodeset_init(struct userdata *);
104 void pa_nodeset_done(struct userdata *);
105
106 int pa_nodeset_add_class(struct userdata *u, mir_node_type , const char *);
107 void pa_nodeset_delete_class(struct userdata *, mir_node_type);
108 const char *pa_nodeset_get_class(struct userdata *, mir_node_type);
109
110 int pa_nodeset_add_role(struct userdata *, const char *, mir_node_type,
111                         pa_nodeset_resdef *);
112 void pa_nodeset_delete_role(struct userdata *, const char *);
113 pa_nodeset_map *pa_nodeset_get_map_by_role(struct userdata *, const char *);
114
115 int pa_nodeset_add_binary(struct userdata *, const char *, mir_node_type,
116                           const char *, pa_nodeset_resdef *);
117 void pa_nodeset_delete_binary(struct userdata *, const char *);
118 pa_nodeset_map *pa_nodeset_get_map_by_binary(struct userdata *, const char *);
119
120 int pa_nodeset_print_maps(struct userdata *, char *, int);
121
122 mir_node *pa_nodeset_iterate_nodes(struct userdata *, uint32_t *);
123
124
125 mir_node *mir_node_create(struct userdata *, mir_node *);
126 void mir_node_destroy(struct userdata *, mir_node *);
127
128 mir_node *mir_node_find_by_index(struct userdata *, uint32_t);
129
130
131 int mir_node_print(mir_node *, char *, int);
132
133 const char *mir_direction_str(mir_direction);
134 const char *mir_implement_str(mir_implement);
135 const char *mir_location_str(mir_location);
136 const char *mir_node_type_str(mir_node_type);
137 const char *mir_privacy_str(mir_privacy);
138
139 #endif
140
141
142 /*
143  * Local Variables:
144  * c-basic-offset: 4
145  * indent-tabs-mode: nil
146  * End:
147  *
148  */