2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__
18 #define __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__
26 * @file sound_manager_internal.h
27 * @brief This file contains the Sound Manager Internal API.
31 * @addtogroup CAPI_MEDIA_SOUND_MANAGER_MODULE
35 #define SOUND_TYPE_NUM SOUND_TYPE_VOICE + 1
39 * @brief Virtual sound stream handle.
42 typedef struct virtual_sound_stream_s* virtual_sound_stream_h;
46 * @brief Enumeration for Native API.
50 NATIVE_API_SOUND_MANAGER, /**< Sound-manager Native API */
51 NATIVE_API_PLAYER, /**< Player Native API */
52 NATIVE_API_WAV_PLAYER, /**< Wav-player Native API */
53 NATIVE_API_TONE_PLAYER, /**< Tone-player Native API */
54 NATIVE_API_AUDIO_IO, /**< Audio-io Native API */
55 NATIVE_API_RECORDER, /**< Recorder Native API */
60 * @brief Enumeration for sound stream type for internal.
64 SOUND_STREAM_TYPE_RINGTONE_CALL = 100, /**< Sound stream type for ringtone for call */
65 SOUND_STREAM_TYPE_RINGBACKTONE_CALL, /**< Sound stream type for ringback tone for call */
66 SOUND_STREAM_TYPE_VOICE_CALL, /**< Sound stream type for voice-call */
67 SOUND_STREAM_TYPE_VIDEO_CALL, /**< Sound stream type for video-call */
68 SOUND_STREAM_TYPE_RADIO, /**< Sound stream type for radio */
69 SOUND_STREAM_TYPE_LOOPBACK, /**< Sound stream type for loopback */
70 SOUND_STREAM_TYPE_LOOPBACK_MIRRORING, /**< Sound stream type for loopback-mirroring */
71 SOUND_STREAM_TYPE_SOLO, /**< Sound stream type for solo */
72 SOUND_STREAM_TYPE_VOICE_RECOGNITION_SERVICE, /**< Sound stream type for voice recognition by service (Since 4.0) */
73 SOUND_STREAM_TYPE_MEDIA_COMPRESSED, /**< Sound stream type for compressed media (Since 4.0) */
74 } sound_stream_type_internal_e;
78 * @brief Enumeration for sound filters.
82 SOUND_FILTER_LOW_PASS = 0,
83 SOUND_FILTER_HIGH_PASS,
85 SOUND_FILTER_SOUNDALIVE,
90 * @brief Enumeration for filter preset.
94 SOUND_FILTER_PRESET_LOW_PASS_NONE = 0, /**< Filter preset for SOUND_FILTER_LOW_PASS none */
95 SOUND_FILTER_PRESET_LOW_PASS_UNDER_240HZ, /**< Filter preset for SOUND_FILTER_LOW_PASS under 240hz */
96 SOUND_FILTER_PRESET_LOW_PASS_UNDER_480HZ, /**< Filter preset for SOUND_FILTER_LOW_PASS under 480hz */
97 SOUND_FILTER_PRESET_HIGH_PASS_NONE, /**< Filter preset for SOUND_FILTER_HIGH_PASS none */
98 SOUND_FILTER_PRESET_HIGH_PASS_OVER_240HZ, /**< Filter preset for SOUND_FILTER_HIGH_PASS over 240hz */
99 SOUND_FILTER_PRESET_HIGH_PASS_OVER_480HZ, /**< Filter preset for SOUND_FILTER_HIGH_PASS over 480hz */
100 SOUND_FILTER_PRESET_DELAY_NONE, /**< Filter preset for SOUND_FILTER_DELAY none */
101 SOUND_FILTER_PRESET_DELAY_1SEC, /**< Filter preset for SOUND_FILTER_DELAY 1 second */
102 SOUND_FILTER_PRESET_DELAY_2SEC, /**< Filter preset for SOUND_FILTER_DELAY 2 seconds */
103 SOUND_FILTER_PRESET_SOUNDALIVE_NORMAL, /**< Filter preset for SOUND_FILTER_SOUNDALIVE normal */
104 SOUND_FILTER_PRESET_SOUNDALIVE_TUBE, /**< Filter preset for SOUND_FILTER_SOUNDALIVE tube */
105 SOUND_FILTER_PRESET_SOUNDALIVE_VIRT71, /**< Filter preset for SOUND_FILTER_SOUNDALIVE virtual7.1 */
106 SOUND_FILTER_PRESET_SOUNDALIVE_STUDIO, /**< Filter preset for SOUND_FILTER_SOUNDALIVE studio */
107 SOUND_FILTER_PRESET_SOUNDALIVE_CLUB, /**< Filter preset for SOUND_FILTER_SOUNDALIVE club */
108 SOUND_FILTER_PRESET_SOUNDALIVE_CONCERT_HALL, /**< Filter preset for SOUND_FILTER_SOUNDALIVE concert hall */
109 } sound_filter_preset_e;
113 * @brief Creates a handle for stream information.
116 * @remarks Do not call this API within sound_stream_focus_state_changed_cb() and sound_stream_focus_state_watch_cb(),\n
117 * otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.\n
118 * To apply the stream policy according to this stream information, this handle should be passed to other APIs\n
119 * related to playback or recording.(e.g. player, wav-player, audio-io, etc.)
121 * @param[in] stream_type The type of stream for internal usage
122 * @param[in] callback The focus state change callback function
123 * @param[in] user_data The user data to be passed to the callback function
124 * @param[out] stream_info The handle of stream information
125 * @return @c 0 on success,
126 * otherwise a negative error value
127 * @retval #SOUND_MANAGER_ERROR_NONE Success
128 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
129 * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
130 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
131 * @see sound_manager_destroy_stream_information()
132 * @see sound_manager_add_device_for_stream_routing()
133 * @see sound_manager_remove_device_for_stream_routing()
134 * @see sound_manager_remove_all_devices_for_stream_routing()
135 * @see sound_manager_apply_stream_routing()
136 * @see sound_manager_acquire_focus()
137 * @see sound_manager_destroy_focus()
138 * @see sound_manager_get_focus_state()
140 int sound_manager_create_stream_information_internal(sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info);
144 * @brief Sets the stream routing option.
147 * @remarks If the stream has not been made yet, this setting will be applied when the stream starts to play.
149 * @param[in] stream_info The handle of stream information
150 * @param[in] name The name of option
151 * @param[in] value The value of option
152 * @return @c 0 on success,
153 * otherwise a negative error value
154 * @retval #SOUND_MANAGER_ERROR_NONE Success
155 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
156 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
157 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
158 * @pre Call sound_manager_create_stream_information() before calling this function.
159 * @see sound_manager_create_stream_information()
160 * @see sound_manager_create_stream_information_internal()
161 * @see sound_manager_destroy_stream_information()
163 int sound_manager_set_stream_routing_option(sound_stream_info_h stream_info, const char *name, int value);
167 * @brief Queries if this stream information handle is available for the API.
169 * @param[in] stream_info The handle of stream information
170 * @param[in] api_name The native API name
171 * @param[out] is_available If @c true the api_name is available, @c false the api_name is not available for this strema_info
172 * @return @c 0 on success,
173 * otherwise a negative error value
174 * @retval #SOUND_MANAGER_ERROR_NONE Success
175 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
176 * @see sound_manager_create_stream_information()
177 * @see sound_manager_destroy_stream_information()
179 int sound_manager_is_available_stream_information(sound_stream_info_h stream_info, native_api_e api_name, bool *is_available);
183 * @brief Gets stream type from the stream information handle.
185 * @param[in] stream_info The handle of stream information
186 * @param[out] type The stream type
187 * @return @c 0 on success,
188 * otherwise a negative error value
189 * @retval #SOUND_MANAGER_ERROR_NONE Success
190 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
191 * @see sound_manager_create_stream_information()
192 * @see sound_manager_destroy_stream_information()
194 int sound_manager_get_type_from_stream_information(sound_stream_info_h stream_info, char **type);
198 * @brief Gets the index of the stream information handle.
200 * @param[in] stream_info The handle of stream information
201 * @param[out] index The unique index
203 * @return @c 0 on success,
204 * otherwise a negative error value
205 * @retval #SOUND_MANAGER_ERROR_NONE Success
206 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
207 * @see sound_manager_create_stream_information()
208 * @see sound_manager_destroy_stream_information()
210 int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_info, int *index);
214 * @brief Adds the device id to the stream information for the stream routing.
217 * @remarks Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
218 * to get the device id.\n
219 * #SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the @a stream_info.\n
220 * The available types of the @a stream_info for this function are #SOUND_STREAM_TYPE_VOIP and #SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY.
222 * @param[in] stream_info The handle of stream information
223 * @param[in] device_id The device id
224 * @return @c 0 on success,
225 * otherwise a negative error value
226 * @retval #SOUND_MANAGER_ERROR_NONE Success
227 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
228 * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
229 * @pre Call sound_manager_create_stream_information() before calling this function.
230 * @post You can apply this setting by calling sound_manager_apply_stream_routing().
231 * @see sound_manager_create_stream_information()
232 * @see sound_manager_destroy_stream_information()
233 * @see sound_manager_remove_device_id_for_stream_routing()
234 * @see sound_manager_remove_all_devices_for_stream_routing()
235 * @see sound_manager_apply_stream_routing()
237 int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
241 * @brief Removes the device id to the stream information for the stream routing.
244 * @remarks Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
245 * to get the device id.\n
247 * @param[in] stream_info The handle of stream information
248 * @param[in] device The device id
249 * @return @c 0 on success,
250 * otherwise a negative error value
251 * @retval #SOUND_MANAGER_ERROR_NONE Success
252 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
253 * @pre Call sound_manager_create_stream_information() and sound_manager_add_device_for_stream_routing() before calling this function.
254 * @post You can apply this setting by calling sound_manager_apply_stream_routing().
255 * @see sound_manager_create_stream_information()
256 * @see sound_manager_destroy_stream_information()
257 * @see sound_manager_add_device_id_for_stream_routing()
258 * @see sound_manager_remove_all_devices_for_stream_routing()
259 * @see sound_manager_apply_stream_routing()
261 int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
265 * @brief Gets the state of the device by id.
267 * @param[in] device_id The device id
268 * @param[out] state The state of the device
269 * @return @c 0 on success,
270 * otherwise a negative error value
271 * @retval #SOUND_MANAGER_ERROR_NONE Success
272 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
273 * @see sound_manager_get_device_list()
274 * @see sound_manager_get_next_device()
275 * @see sound_manager_get_prev_device()
276 * @see sound_manager_get_device_id()
277 * @see sound_manager_free_device_list()
279 int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
283 * @brief Gets the internal stream information handle for VoIP session.
286 * @remarks If VoIP session is not set in this process, it'll return #SOUND_MANAGER_ERROR_NO_DATA.
288 * @param[out] stream_info The handle of stream information
290 * @return @c 0 on success,
291 * otherwise a negative error value
292 * @retval #SOUND_MANAGER_ERROR_NONE Success
293 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
294 * @retval #SOUND_MANAGER_ERROR_NO_DATA No data
295 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
296 * @see sound_manager_set_session_type()
297 * @see sound_manager_set_voip_session_mode()
299 int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info);
303 * @brief Disable session backward compatibility.
306 * @remarks Multimedia framework support backward compatibility of legacy sound session. \n
307 * If a process does not want legacy sound session behavior in each multimedia framework, \n
308 * this function can be used explicitly not to support that.
310 * @return @c 0 on success,
311 * otherwise a negative error value
312 * @retval #SOUND_MANAGER_ERROR_NONE Success
313 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
314 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
316 int sound_manager_disable_session_backward_compatibility(void);
320 * @brief Creates a virtual stream handle.
322 * @param[in] stream_info The handle of stream information
323 * @param[out] virtual_stream The handle of virtual stream
324 * @return @c 0 on success,
325 * otherwise a negative error value
326 * @retval #SOUND_MANAGER_ERROR_NONE Success
327 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
328 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
329 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
330 * @see sound_manager_create_stream_information()
331 * @see sound_manager_destroy_stream_information()
332 * @see sound_manager_destroy_virtual_stream()
333 * @see sound_manager_start_virtual_stream()
334 * @see sound_manager_stop_virtual_stream()
336 int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream);
340 * @brief Destroys the virtual stream handle.
342 * @param[in] virtual_stream The handle of virtual stream
343 * @return @c 0 on success,
344 * otherwise a negative error value
345 * @retval #SOUND_MANAGER_ERROR_NONE Success
346 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
347 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
348 * @see sound_manager_create_virtual_stream()
349 * @see sound_manager_start_virtual_stream()
350 * @see sound_manager_stop_virtual_stream()
352 int sound_manager_destroy_virtual_stream(virtual_sound_stream_h virtual_stream);
356 * @brief Starts the virtual stream.
358 * @param[in] virtual_stream The handle of virtual stream
359 * @return @c 0 on success,
360 * otherwise a negative error value
361 * @retval #SOUND_MANAGER_ERROR_NONE Success
362 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
363 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
364 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
365 * @see sound_manager_create_virtual_stream()
366 * @see sound_manager_destroy_virtual_stream()
367 * @see sound_manager_stop_virtual_stream()
369 int sound_manager_start_virtual_stream(virtual_sound_stream_h virtual_stream);
373 * @brief Stops the virtual stream.
375 * @param[in] virtual_stream The handle of virtual stream
376 * @return @c 0 on success,
377 * otherwise a negative error value
378 * @retval #SOUND_MANAGER_ERROR_NONE Success
379 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
380 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
381 * @see sound_manager_create_virtual_stream()
382 * @see sound_manager_destroy_virtual_stream()
383 * @see sound_manager_start_virtual_stream()
385 int sound_manager_stop_virtual_stream(virtual_sound_stream_h virtual_stream);
389 * @brief Set sound filter and apply to audio streams given selected stream type.
391 * @param[in] stream_type stream type to apply
392 * @param[in] filter sound filter to apply
393 * @return @c 0 on success,
394 * otherwise a negative error value
395 * @retval #SOUND_MANAGER_ERROR_NONE Success
396 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
397 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
398 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
399 * @see sound_manager_unset_filter()
401 int sound_manager_set_filter(sound_stream_type_e stream_type, sound_filter_e filter);
405 * @brief Unset sound filter and remove from audio streams given selected stream type.
407 * @param[in] stream_type stream type to remove
408 * @return @c 0 on success,
409 * otherwise a negative error value
410 * @retval #SOUND_MANAGER_ERROR_NONE Success
411 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
412 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
413 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
414 * @see sound_manager_set_filter()
416 int sound_manager_unset_filter(sound_stream_type_e stream_type);
420 * @brief Apply preset configuration to the filter according to selected stream type.
422 * @param[in] stream_type given stream type
423 * @param[in] filter given sound filter
424 * @param[in] preset filter preset to apply
425 * @return @c 0 on success,
426 * otherwise a negative error value
427 * @retval #SOUND_MANAGER_ERROR_NONE Success
428 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
429 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
430 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
431 * @see sound_manager_set_filter()
433 int sound_manager_set_filter_preset(sound_stream_type_e stream_type, sound_filter_e filter, sound_filter_preset_e preset);
437 * @brief Gets the vendor id of the device.
440 * @remarks It works only with USB audio device. Otherwise, #SOUND_MANAGER_ERROR_NOT_SUPPORTED will be returned.\n
442 * @param[in] device The device item
443 * @param[out] vendor_id The vendor id of the device
444 * @return @c 0 on success,
445 * otherwise a negative error value
446 * @retval #SOUND_MANAGER_ERROR_NONE Success
447 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
448 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
449 * @see sound_manager_get_device_list()
450 * @see sound_manager_get_next_device()
451 * @see sound_manager_get_prev_device()
452 * @see sound_manager_get_device_type()
453 * @see sound_manager_get_device_io_direction()
454 * @see sound_manager_get_device_name()
455 * @see sound_manager_get_device_state()
456 * @see sound_manager_get_device_id()
457 * @see sound_manager_get_device_product_id()
458 * @see sound_manager_free_device_list()
460 int sound_manager_get_device_vendor_id(sound_device_h device, int *vendor_id);
464 * @brief Gets the product id of the device.
467 * @remarks It works only with USB audio device. Otherwise, #SOUND_MANAGER_ERROR_NOT_SUPPORTED will be returned.\n
469 * @param[in] device The device item
470 * @param[out] product_id The product id of the device
471 * @return @c 0 on success,
472 * otherwise a negative error value
473 * @retval #SOUND_MANAGER_ERROR_NONE Success
474 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
475 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
476 * @see sound_manager_get_device_list()
477 * @see sound_manager_get_next_device()
478 * @see sound_manager_get_prev_device()
479 * @see sound_manager_get_device_type()
480 * @see sound_manager_get_device_io_direction()
481 * @see sound_manager_get_device_name()
482 * @see sound_manager_get_device_state()
483 * @see sound_manager_get_device_id()
484 * @see sound_manager_get_device_vendor_id()
485 * @see sound_manager_free_device_list()
487 int sound_manager_get_device_product_id(sound_device_h device, int *product_id);
497 #endif /* __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__ */