3 #include <pulsecore/pulsecore-config.h>
5 #include <pulsecore/card.h>
6 #include <pulsecore/device-port.h>
7 #include <pulsecore/core-util.h>
13 void pa_classify_node_by_card(mir_node *node,
15 pa_card_profile *prof,
24 bus = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_BUS);
25 form = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_FORM_FACTOR);
28 if (!strcasecmp(form, "internal")) {
29 node->location = mir_external;
30 if (port && !strcasecmp(bus, "pci")) {
31 pa_classify_guess_device_node_type_and_name(node, port->name,
35 else if (!strcasecmp(form, "speaker") || !strcasecmp(form, "car")) {
36 if (node->direction == mir_output) {
37 node->location = mir_internal;
38 node->type = mir_speakers;
41 else if (!strcasecmp(form, "handset")) {
42 node->location = mir_external;
43 node->type = mir_phone;
44 node->privacy = mir_private;
46 else if (!strcasecmp(form, "headset")) {
47 node->location = mir_external;
49 if (!strcasecmp(bus,"usb")) {
50 node->type = mir_usb_headset;
52 else if (!strcasecmp(bus,"bluetooth")) {
53 if (prof && !strcmp(prof->name, "a2dp"))
54 node->type = mir_bluetooth_a2dp;
56 node->type = mir_bluetooth_sco;
59 node->type = mir_wired_headset;
63 else if (!strcasecmp(form, "headphone")) {
64 if (node->direction == mir_output) {
65 node->location = mir_external;
67 if (!strcasecmp(bus,"usb"))
68 node->type = mir_usb_headphone;
69 else if (strcasecmp(bus,"bluetooth"))
70 node->type = mir_wired_headphone;
74 else if (!strcasecmp(form, "microphone")) {
75 if (node->direction == mir_input) {
76 node->location = mir_external;
77 node->type = mir_microphone;
82 if (port && !strcasecmp(bus, "pci")) {
83 pa_classify_guess_device_node_type_and_name(node, port->name,
88 if (!node->amname[0]) {
89 if (node->type != mir_node_type_unknown)
90 node->amname = (char *)mir_node_type_str(node->type);
91 else if (port && port->description)
92 node->amname = port->description;
93 else if (port && port->name)
94 node->amname = port->name;
96 node->amname = node->paname;
100 if (node->direction == mir_input)
101 node->privacy = mir_privacy_unknown;
103 switch (node->type) {
107 case mir_front_speakers:
108 case mir_rear_speakers:
109 node->privacy = mir_public;
114 case mir_wired_headset:
115 case mir_wired_headphone:
116 case mir_usb_headset:
117 case mir_usb_headphone:
118 case mir_bluetooth_sco:
119 case mir_bluetooth_a2dp:
120 node->privacy = mir_private;
128 node->privacy = mir_privacy_unknown;
135 /* data->direction must be set */
136 void pa_classify_guess_device_node_type_and_name(mir_node *node,
144 if (node->direction == mir_output && strcasestr(name, "headphone")) {
145 node->type = mir_wired_headphone;
146 node->amname = (char *)desc;
148 else if (strcasestr(name, "headset")) {
149 node->type = mir_wired_headset;
150 node->amname = (char *)desc;
152 else if (strcasestr(name, "line")) {
153 node->type = mir_jack;
154 node->amname = (char *)desc;
156 else if (strcasestr(name, "spdif")) {
157 node->type = mir_spdif;
158 node->amname = (char *)desc;
160 else if (strcasestr(name, "hdmi")) {
161 node->type = mir_hdmi;
162 node->amname = (char *)desc;
164 else if (node->direction == mir_input && strcasestr(name, "microphone")) {
165 node->type = mir_microphone;
166 node->amname = (char *)desc;
168 else if (node->direction == mir_output && strcasestr(name,"analog-output"))
169 node->type = mir_speakers;
170 else if (node->direction == mir_input && strcasestr(name, "analog-input"))
171 node->type = mir_jack;
173 node->type = mir_node_type_unknown;
178 mir_node_type pa_classify_guess_stream_node_type(pa_proplist *pl)
185 static map_t role_map[] = {
186 {"video" , mir_player },
187 {"music" , mir_player },
188 {"game" , mir_game },
189 {"event" , mir_event },
190 {"phone" , mir_player },
191 {"animation", mir_browser},
192 {"test" , mir_player },
193 {NULL, mir_node_type_unknown}
196 static map_t bin_map[] = {
197 {"rhytmbox" , mir_player },
198 {"firefox" , mir_browser},
199 {"chrome" , mir_browser},
200 {"sound-juicer", mir_player },
201 {NULL, mir_node_type_unknown}
205 mir_node_type rtype, btype;
212 rtype = btype = mir_node_type_unknown;
214 role = pa_proplist_gets(pl, PA_PROP_MEDIA_ROLE);
215 bin = pa_proplist_gets(pl, PA_PROP_APPLICATION_PROCESS_BINARY);
218 for (m = role_map; m->id; m++) {
219 if (pa_streq(role, m->id))
225 if (rtype != mir_node_type_unknown && rtype != mir_player)
229 for (m = bin_map; m->id; m++) {
230 if (pa_streq(bin, m->id))
236 if (btype == mir_node_type_unknown)
243 pa_bool_t pa_classify_multiplex_stream(mir_node *node)
245 static pa_bool_t multiplex[mir_application_class_end] = {
246 [ mir_player ] = TRUE,
248 [ mir_browser ] = TRUE,
257 if (node->implement == mir_stream && node->direction == mir_input) {
260 if (class > mir_application_class_begin &&
261 class < mir_application_class_end)
263 return multiplex[class];