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 Gets the maximum master volume level.
115 * @param[out] max_level The maximum volume level
116 * @return @c 0 on success,
117 * otherwise a negative error value
118 * @retval #SOUND_MANAGER_ERROR_NONE Success
119 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
120 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
121 * @see sound_manager_set_master_volume()
122 * @see sound_manager_get_master_volume()
124 int sound_manager_get_max_master_volume(int *max_level);
128 * @brief Sets the master volume level.
130 * @param[in] level The volume level to be set
131 * @return @c 0 on success,
132 * otherwise a negative error value
133 * @retval #SOUND_MANAGER_ERROR_NONE Success
134 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
135 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
136 * @see sound_manager_get_max_master_volume()
137 * @see sound_manager_get_master_volume()
139 int sound_manager_set_master_volume(int level);
143 * @brief Gets the master volume level.
145 * @param[out] level The current master volume level
146 * @return @c 0 on success,
147 * otherwise a negative error value
148 * @retval #SOUND_MANAGER_ERROR_NONE Success
149 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
150 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
151 * @see sound_manager_get_max_master_volume()
152 * @see sound_manager_set_master_volume()
154 int sound_manager_get_master_volume(int *level);
158 * @brief Creates a handle for stream information.
161 * @remarks Do not call this API within sound_stream_focus_state_changed_cb() and sound_stream_focus_state_watch_cb(),\n
162 * otherwise SOUND_MANAGER_ERROR_INVALID_OPERATION will be returned.\n
163 * To apply the stream policy according to this stream information, this handle should be passed to other APIs\n
164 * related to playback or recording.(e.g. player, wav-player, audio-io, etc.)
166 * @param[in] stream_type The type of stream for internal usage
167 * @param[in] callback The focus state change callback function
168 * @param[in] user_data The user data to be passed to the callback function
169 * @param[out] stream_info The handle of stream information
170 * @return @c 0 on success,
171 * otherwise a negative error value
172 * @retval #SOUND_MANAGER_ERROR_NONE Success
173 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
174 * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
175 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
176 * @see sound_manager_destroy_stream_information()
177 * @see sound_manager_add_device_for_stream_routing()
178 * @see sound_manager_remove_device_for_stream_routing()
179 * @see sound_manager_apply_stream_routing()
180 * @see sound_manager_acquire_focus()
181 * @see sound_manager_destroy_focus()
182 * @see sound_manager_get_focus_state()
184 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);
188 * @brief Sets the stream routing option.
191 * @remarks If the stream has not been made yet, this setting will be applied when the stream starts to play.
193 * @param[in] stream_info The handle of stream information
194 * @param[in] name The name of option
195 * @param[in] value The value of option
196 * @return @c 0 on success,
197 * otherwise a negative error value
198 * @retval #SOUND_MANAGER_ERROR_NONE Success
199 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
200 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
201 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
202 * @pre Call sound_manager_create_stream_information() before calling this function.
203 * @see sound_manager_create_stream_information()
204 * @see sound_manager_create_stream_information_internal()
205 * @see sound_manager_destroy_stream_information()
207 int sound_manager_set_stream_routing_option(sound_stream_info_h stream_info, const char *name, int value);
211 * @brief Queries if this stream information handle is available for the API.
213 * @param[in] stream_info The handle of stream information
214 * @param[in] api_name The native API name
215 * @param[out] is_available If @c true the api_name is available, @c false the api_name is not available for this strema_info
216 * @return @c 0 on success,
217 * otherwise a negative error value
218 * @retval #SOUND_MANAGER_ERROR_NONE Success
219 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
220 * @see sound_manager_create_stream_information()
221 * @see sound_manager_destroy_stream_information()
223 int sound_manager_is_available_stream_information(sound_stream_info_h stream_info, native_api_e api_name, bool *is_available);
227 * @brief Gets stream type from the stream information handle.
229 * @param[in] stream_info The handle of stream information
230 * @param[out] type The stream type
231 * @return @c 0 on success,
232 * otherwise a negative error value
233 * @retval #SOUND_MANAGER_ERROR_NONE Success
234 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
235 * @see sound_manager_create_stream_information()
236 * @see sound_manager_destroy_stream_information()
238 int sound_manager_get_type_from_stream_information(sound_stream_info_h stream_info, char **type);
242 * @brief Gets the index of the stream information handle.
244 * @param[in] stream_info The handle of stream information
245 * @param[out] index The unique index
247 * @return @c 0 on success,
248 * otherwise a negative error value
249 * @retval #SOUND_MANAGER_ERROR_NONE Success
250 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
251 * @see sound_manager_create_stream_information()
252 * @see sound_manager_destroy_stream_information()
254 int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_info, int *index);
258 * @brief Adds the device id to the stream information for the stream routing.
261 * @remarks Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
262 * to get the device id.\n
263 * #SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the @a stream_info.\n
264 * The available types of the @a stream_info for this function are #SOUND_STREAM_TYPE_VOIP and #SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY.
266 * @param[in] stream_info The handle of stream information
267 * @param[in] device_id The device id
268 * @return @c 0 on success,
269 * otherwise a negative error value
270 * @retval #SOUND_MANAGER_ERROR_NONE Success
271 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
272 * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
273 * @pre Call sound_manager_create_stream_information() before calling this function.
274 * @post You can apply this setting by calling sound_manager_apply_stream_routing().
275 * @see sound_manager_create_stream_information()
276 * @see sound_manager_destroy_stream_information()
277 * @see sound_manager_remove_device_id_for_stream_routing()
278 * @see sound_manager_apply_stream_routing()
280 int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
284 * @brief Removes the device id to the stream information for the stream routing.
287 * @remarks Use sound_manager_get_device_list(), sound_manager_get_next_device() and sound_manager_get_device_id()\n
288 * to get the device id.\n
290 * @param[in] stream_info The handle of stream information
291 * @param[in] device The device id
292 * @return @c 0 on success,
293 * otherwise a negative error value
294 * @retval #SOUND_MANAGER_ERROR_NONE Success
295 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
296 * @pre Call sound_manager_create_stream_information() and sound_manager_add_device_for_stream_routing() before calling this function.
297 * @post You can apply this setting by calling sound_manager_apply_stream_routing().
298 * @see sound_manager_create_stream_information()
299 * @see sound_manager_destroy_stream_information()
300 * @see sound_manager_add_device_id_for_stream_routing()
301 * @see sound_manager_apply_stream_routing()
303 int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id);
307 * @brief Gets the state of the device by id.
309 * @param[in] device_id The device id
310 * @param[out] state The state of the device
311 * @return @c 0 on success,
312 * otherwise a negative error value
313 * @retval #SOUND_MANAGER_ERROR_NONE Success
314 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
315 * @see sound_manager_get_device_list()
316 * @see sound_manager_get_next_device()
317 * @see sound_manager_get_prev_device()
318 * @see sound_manager_get_device_id()
319 * @see sound_manager_free_device_list()
321 int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
325 * @brief Gets the internal stream information handle for VoIP session.
328 * @remarks If VoIP session is not set in this process, it'll return #SOUND_MANAGER_ERROR_NO_DATA.
330 * @param[out] stream_info The handle of stream information
332 * @return @c 0 on success,
333 * otherwise a negative error value
334 * @retval #SOUND_MANAGER_ERROR_NONE Success
335 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
336 * @retval #SOUND_MANAGER_ERROR_NO_DATA No data
337 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
338 * @see sound_manager_set_session_type()
339 * @see sound_manager_set_voip_session_mode()
341 int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info);
345 * @brief Disable session backward compatibility.
348 * @remarks Multimedia framework support backward compatibility of legacy sound session. \n
349 * If a process does not want legacy sound session behavior in each multimedia framework, \n
350 * this function can be used explicitly not to support that.
352 * @return @c 0 on success,
353 * otherwise a negative error value
354 * @retval #SOUND_MANAGER_ERROR_NONE Success
355 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
356 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
358 int sound_manager_disable_session_backward_compatibility(void);
362 * @brief Creates a virtual stream handle.
364 * @param[in] stream_info The handle of stream information
365 * @param[out] virtual_stream The handle of virtual stream
366 * @return @c 0 on success,
367 * otherwise a negative error value
368 * @retval #SOUND_MANAGER_ERROR_NONE Success
369 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
370 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
371 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
372 * @see sound_manager_create_stream_information()
373 * @see sound_manager_destroy_stream_information()
374 * @see sound_manager_destroy_virtual_stream()
375 * @see sound_manager_start_virtual_stream()
376 * @see sound_manager_stop_virtual_stream()
378 int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream);
382 * @brief Destroys the virtual stream handle.
384 * @param[in] virtual_stream The handle of virtual stream
385 * @return @c 0 on success,
386 * otherwise a negative error value
387 * @retval #SOUND_MANAGER_ERROR_NONE Success
388 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
389 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
390 * @see sound_manager_create_virtual_stream()
391 * @see sound_manager_start_virtual_stream()
392 * @see sound_manager_stop_virtual_stream()
394 int sound_manager_destroy_virtual_stream(virtual_sound_stream_h virtual_stream);
398 * @brief Starts the virtual stream.
400 * @param[in] virtual_stream The handle of virtual stream
401 * @return @c 0 on success,
402 * otherwise a negative error value
403 * @retval #SOUND_MANAGER_ERROR_NONE Success
404 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
405 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
406 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
407 * @see sound_manager_create_virtual_stream()
408 * @see sound_manager_destroy_virtual_stream()
409 * @see sound_manager_stop_virtual_stream()
411 int sound_manager_start_virtual_stream(virtual_sound_stream_h virtual_stream);
415 * @brief Stops the virtual stream.
417 * @param[in] virtual_stream The handle of virtual stream
418 * @return @c 0 on success,
419 * otherwise a negative error value
420 * @retval #SOUND_MANAGER_ERROR_NONE Success
421 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
422 * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
423 * @see sound_manager_create_virtual_stream()
424 * @see sound_manager_destroy_virtual_stream()
425 * @see sound_manager_start_virtual_stream()
427 int sound_manager_stop_virtual_stream(virtual_sound_stream_h virtual_stream);
431 * @brief Set sound filter and apply to audio streams given selected stream type.
433 * @param[in] stream_type stream type to apply
434 * @param[in] filter sound filter to apply
435 * @return @c 0 on success,
436 * otherwise a negative error value
437 * @retval #SOUND_MANAGER_ERROR_NONE Success
438 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
439 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
440 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
441 * @see sound_manager_unset_filter()
443 int sound_manager_set_filter(sound_stream_type_e stream_type, sound_filter_e filter);
447 * @brief Unset sound filter and remove from audio streams given selected stream type.
449 * @param[in] stream_type stream type to remove
450 * @return @c 0 on success,
451 * otherwise a negative error value
452 * @retval #SOUND_MANAGER_ERROR_NONE Success
453 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
454 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
455 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
456 * @see sound_manager_set_filter()
458 int sound_manager_unset_filter(sound_stream_type_e stream_type);
462 * @brief Apply preset configuration to the filter according to selected stream type.
464 * @param[in] stream_type given stream type
465 * @param[in] filter given sound filter
466 * @param[in] preset filter preset to apply
467 * @return @c 0 on success,
468 * otherwise a negative error value
469 * @retval #SOUND_MANAGER_ERROR_NONE Success
470 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
471 * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
472 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
473 * @see sound_manager_set_filter()
475 int sound_manager_set_filter_preset(sound_stream_type_e stream_type, sound_filter_e filter, sound_filter_preset_e preset);
479 * @brief Gets the vendor id of the device.
482 * @remarks It works only with USB audio device. Otherwise, #SOUND_MANAGER_ERROR_NOT_SUPPORTED will be returned.\n
484 * @param[in] device The device item
485 * @param[out] vendor_id The vendor id of the device
486 * @return @c 0 on success,
487 * otherwise a negative error value
488 * @retval #SOUND_MANAGER_ERROR_NONE Success
489 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
490 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
491 * @see sound_manager_get_device_list()
492 * @see sound_manager_get_next_device()
493 * @see sound_manager_get_prev_device()
494 * @see sound_manager_get_device_type()
495 * @see sound_manager_get_device_io_direction()
496 * @see sound_manager_get_device_name()
497 * @see sound_manager_get_device_state()
498 * @see sound_manager_get_device_id()
499 * @see sound_manager_get_device_product_id()
500 * @see sound_manager_free_device_list()
502 int sound_manager_get_device_vendor_id(sound_device_h device, int *vendor_id);
506 * @brief Gets the product id of the device.
509 * @remarks It works only with USB audio device. Otherwise, #SOUND_MANAGER_ERROR_NOT_SUPPORTED will be returned.\n
511 * @param[in] device The device item
512 * @param[out] product_id The product id of the device
513 * @return @c 0 on success,
514 * otherwise a negative error value
515 * @retval #SOUND_MANAGER_ERROR_NONE Success
516 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
517 * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
518 * @see sound_manager_get_device_list()
519 * @see sound_manager_get_next_device()
520 * @see sound_manager_get_prev_device()
521 * @see sound_manager_get_device_type()
522 * @see sound_manager_get_device_io_direction()
523 * @see sound_manager_get_device_name()
524 * @see sound_manager_get_device_state()
525 * @see sound_manager_get_device_id()
526 * @see sound_manager_get_device_vendor_id()
527 * @see sound_manager_free_device_list()
529 int sound_manager_get_device_product_id(sound_device_h device, int *product_id);
539 #endif /* __TIZEN_MEDIA_SOUND_MANAGER_INTERNAL_H__ */