2 This file is part of PulseAudio.
4 Copyright 2015-2016 Sangchul Lee <sc11.lee@samsung.com>
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 #ifndef foostreammanagerfoo
23 #define foostreammanagerfoo
25 #include <pulsecore/core.h>
27 #define IS_AUTO_ROUTE_TYPE_SERIES(route_type_enum) \
28 ((route_type_enum == STREAM_ROUTE_TYPE_AUTO) || (route_type_enum == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) || \
29 (route_type_enum == STREAM_ROUTE_TYPE_AUTO_ALL))
31 #define IS_MANUAL_ROUTE_TYPE_SERIES(route_type_enum) \
32 ((route_type_enum == STREAM_ROUTE_TYPE_MANUAL) || (route_type_enum == STREAM_ROUTE_TYPE_MANUAL_EXT))
34 #define IS_ROUTE_TYPE_FOR_EXTERNAL_DEV(route_type_str, route_type) \
35 (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_MANUAL_EXT))
37 #define IS_ROUTE_TYPE_FOR_AUTO(route_type_str, route_type) \
38 (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO))
40 #define IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type) \
41 (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))
43 #define IS_ROLE_COMMUNICATION(stream_role) \
44 (stream_role && (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \
45 pa_streq(stream_role, STREAM_ROLE_VOIP) || pa_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL)))
47 #define IS_ROLE_RINGTONE(stream_role) \
48 (pa_streq(stream_role, STREAM_ROLE_RINGTONE_CALL) || pa_streq(stream_role, STREAM_ROLE_RINGTONE_VOIP))
50 #define IS_ROLE_AVAILABLE_BT_SCO_OPEN(stream_role) \
51 (stream_role && (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \
52 pa_streq(stream_role, STREAM_ROLE_VOIP) || pa_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL) || \
53 pa_streq(stream_role, STREAM_ROLE_VOICE_RECOGNITION)))
55 #define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) \
57 pa_assert(x_stream_role); \
58 if (pa_safe_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
59 x_device_role = DEVICE_ROLE_CALL_VOICE; \
60 else if (pa_safe_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
61 x_device_role = DEVICE_ROLE_CALL_VIDEO; \
62 else if (pa_safe_streq(x_stream_role, STREAM_ROLE_VOIP)) \
63 x_device_role = DEVICE_ROLE_VOIP; \
65 x_device_role = DEVICE_ROLE_NORMAL; \
68 #define GET_STREAM_NEW_PROPLIST(stream, type) \
69 (type == STREAM_SINK_INPUT ? ((pa_sink_input_new_data*)stream)->proplist : ((pa_source_output_new_data*)stream)->proplist)
71 #define GET_STREAM_PROPLIST(stream, type) \
72 (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->proplist : ((pa_source_output*)stream)->proplist)
74 #define STREAM_ROLE_MEDIA "media"
75 #define STREAM_ROLE_RINGTONE_CALL "ringtone-call"
76 #define STREAM_ROLE_RINGBACKTONE_CALL "ringbacktone-call"
77 #define STREAM_ROLE_RINGTONE_VOIP "ringtone-voip"
78 #define STREAM_ROLE_CALL_VOICE "call-voice"
79 #define STREAM_ROLE_CALL_VIDEO "call-video"
80 #define STREAM_ROLE_VOIP "voip"
81 #define STREAM_ROLE_LOOPBACK "loopback"
82 #define STREAM_ROLE_LOOPBACK_MIRRORING "loopback-mirroring"
83 #define STREAM_ROLE_RADIO "radio"
84 #define STREAM_ROLE_SOLO "solo"
85 #define STREAM_ROLE_VOICE_RECOGNITION "voice-recognition"
86 #define STREAM_ROLE_VOICE_INFORMATION "voice-information"
88 #define SINK_NAME_COMBINED "sink_combined"
89 #define SINK_NAME_NULL "sink_null"
90 #define SOURCE_NAME_NULL "source_null"
92 typedef struct _stream_manager pa_stream_manager;
94 typedef enum _stream_type {
99 typedef enum stream_route_type {
100 STREAM_ROUTE_TYPE_AUTO, /* A stream is routed automatically to a particular device which has the highest priority. */
101 STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED,/* A stream is routed automatically to a particular device which has the latest connection time. */
102 STREAM_ROUTE_TYPE_AUTO_ALL, /* A stream is routed automatically to several devices simultaneously. */
103 STREAM_ROUTE_TYPE_MANUAL, /* A stream is routed manually to the device(s) selected by user. */
104 STREAM_ROUTE_TYPE_MANUAL_EXT, /* A stream is routed manually only to the external device(s) selected by user. */
105 STREAM_ROUTE_TYPE_DEFAULT = STREAM_ROUTE_TYPE_AUTO, /* default (auto based on priority) */
106 } stream_route_type_t;
108 typedef struct _hook_call_data_for_select {
110 const char *stream_role;
111 const char *device_role;
112 const char *occupying_role;
113 stream_type_t stream_type;
114 stream_route_type_t route_type;
115 pa_sink **proper_sink;
116 pa_source **proper_source;
117 pa_sample_spec sample_spec;
118 pa_idxset *idx_avail_devices;
119 pa_idxset *idx_manual_devices;
120 bool origins_from_new_data;
121 } pa_stream_manager_hook_data_for_select;
123 typedef struct _hook_call_data_for_route {
125 const char *stream_role;
126 const char *device_role;
127 stream_type_t stream_type;
128 stream_route_type_t route_type;
129 pa_sink **proper_sink;
130 pa_source **proper_source;
131 pa_sample_spec sample_spec;
132 pa_idxset *idx_avail_devices;
133 pa_idxset *idx_manual_devices;
134 pa_idxset *idx_streams;
135 bool origins_from_new_data;
136 } pa_stream_manager_hook_data_for_route;
138 typedef struct _hook_call_data_for_update_info {
139 const char *stream_role;
142 } pa_stream_manager_hook_data_for_update_info;
144 int32_t pa_stream_manager_get_route_type(void *stream, stream_type_t stream_type, bool is_new_data, stream_route_type_t *stream_route_type);
145 bool pa_stream_manager_check_name_is_vstream(void *stream, stream_type_t type, bool is_new_data);
146 bool pa_stream_manager_check_filter_apply_stream(void *stream, stream_type_t stream_type);
148 pa_stream_manager* pa_stream_manager_init(pa_core *c);
149 void pa_stream_manager_done(pa_stream_manager* m);