2 * Copyright (c) 2011 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_RADIO_H__
18 #define __TIZEN_MEDIA_RADIO_H__
28 * @brief This file contains the radio API.
29 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
33 * @addtogroup CAPI_MEDIA_RADIO_MODULE
38 * @brief Radio type handle.
39 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
41 typedef struct radio_s *radio_h;
44 * @brief Enumeration of radio state.
45 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
49 RADIO_STATE_READY, /**< Ready to play or scan */
50 RADIO_STATE_PLAYING, /**< Playing the audio from the tuner */
51 RADIO_STATE_SCANNING, /**< Scanning/Searching for the next station signal that starts from a given starting frequency */
55 * @brief Enumeration of error codes for the radio.
56 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
60 RADIO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
61 RADIO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
62 RADIO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
63 RADIO_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
64 RADIO_ERROR_INVALID_STATE = TIZEN_ERROR_RADIO | 0x01 , /**< Invalid state */
65 RADIO_ERROR_SOUND_POLICY = TIZEN_ERROR_RADIO | 0x02 , /**< Sound policy error */
66 RADIO_ERROR_NO_ANTENNA = TIZEN_ERROR_RADIO | 0x03 , /**< No Antenna error (Since 2.4) */
67 RADIO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
68 RADIO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
72 * @brief Enumeration of radio interrupted type.
73 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
77 RADIO_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */
78 RADIO_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application */
79 RADIO_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */
80 RADIO_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */
81 RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */
82 RADIO_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */
83 RADIO_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */
84 RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by a resumable media application */
85 RADIO_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */
86 } radio_interrupted_code_e;
89 * @brief Called when the scan information is updated.
90 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
91 * @param[in] frequency The tuned radio frequency [87500 ~ 108000] (kHz)
92 * @param[in] user_data The user data passed from the callback registration function
93 * @pre It will be invoked by radio_scan_start().
94 * @see radio_scan_start()
96 typedef void (*radio_scan_updated_cb)(int frequency, void *user_data);
99 * @brief Called when the radio scan is stopped.
100 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
101 * @param[in] user_data The user data passed from the callback registration function
102 * @pre It will be invoked when the scan is stopped by radio_scan_stop().
103 * @see radio_scan_stop()
105 typedef void (*radio_scan_stopped_cb)(void *user_data);
108 * @brief Called when the radio scan is completed.
109 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
110 * @param[in] user_data The user data passed from the callback registration function
111 * @pre It will be invoked when the scan is completed by registering this callback using radio_set_scan_completed_cb().
112 * @see radio_scan_start()
113 * @see radio_set_scan_completed_cb()
114 * @see radio_unset_scan_completed_cb()
116 typedef void (*radio_scan_completed_cb)(void *user_data);
119 * @brief Called when the radio seek is completed.
120 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
121 * @param[in] frequency The current frequency [87500 ~ 108000] (kHz)
122 * @param[in] user_data The user data passed from the callback registration function
123 * @pre It will be invoked when the radio seek is completed by registering this callback using radio_seek_up() or radio_seek_down().
124 * @see radio_seek_up()
125 * @see radio_seek_down()
127 typedef void (*radio_seek_completed_cb)(int frequency, void *user_data);
130 * @brief Called when the radio is interrupted.
131 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
132 * @param[in] error_code The interrupted error code
133 * @param[in] user_data The user data passed from the callback registration function
134 * @see radio_set_interrupted_cb()
135 * @see radio_unset_interrupted_cb()
137 typedef void (*radio_interrupted_cb)(radio_interrupted_code_e code, void *user_data);
140 * @brief Creates a radio handle.
141 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
142 * @remarks You must release @a radio using radio_destroy().
143 * @param[out] radio A new handle to radio
144 * @retval #RADIO_ERROR_NONE Successful
145 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
146 * @retval #RADIO_ERROR_OUT_OF_MEMORY Out of memory
147 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
148 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
149 * @see radio_destroy()
151 int radio_create(radio_h *radio);
154 * @brief Destroys the radio handle and releases all its resources.
155 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
156 * @remarks To completely shutdown the radio operation, call this function with a valid radio handle.
158 * @param[in] radio The handle to radio to be destroyed
159 * @return @c 0 on success,
160 * otherwise a negative error value
161 * @retval #RADIO_ERROR_NONE Successful
162 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
163 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
164 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
165 * @see radio_create()
167 int radio_destroy(radio_h radio);
170 * @brief Gets the radio's current state.
171 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
172 * @param[in] radio The handle to radio
173 * @param[out] state The current state of the radio
174 * @return @c 0 on success,
175 * otherwise a negative error value
176 * @retval #RADIO_ERROR_NONE Successful
177 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
178 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
180 int radio_get_state(radio_h radio, radio_state_e *state);
183 * @brief Starts playing the radio.
184 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
185 * @param[in] radio The handle to radio
186 * @return @c 0 on success,
187 * otherwise a negative error value
188 * @retval #RADIO_ERROR_NONE Successful
189 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
190 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
191 * @retval #RADIO_ERROR_SOUND_POLICY Sound policy error
192 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
193 * @retval #RADIO_ERROR_NO_ANTENNA No Antenna error
194 * @pre The radio state must be set to #RADIO_STATE_READY by calling radio_create().
195 * @post The radio state will be #RADIO_STATE_PLAYING.
198 int radio_start(radio_h radio);
201 * @brief Stops playing the radio.
202 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
203 * @param[in] radio The handle to radio
204 * @return @c 0 on success,
205 * otherwise a negative error value
206 * @retval #RADIO_ERROR_NONE Successful
207 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid state
208 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
209 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
210 * @pre The radio state must be set to #RADIO_STATE_PLAYING by calling radio_start().
211 * @post The radio state will be #RADIO_STATE_READY.
213 * @see radio_scan_start()
215 int radio_stop(radio_h radio);
218 * @brief Seeks up the effective frequency of the radio, asynchronously.
219 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
220 * @param[in] radio The handle to radio
221 * @param[in] callback The callback function to register
222 * @param[in] user_data The user data to be passed to the callback function
223 * @return @c 0 on success,
224 * otherwise a negative error value
225 * @retval #RADIO_ERROR_NONE Successful
226 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
227 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
228 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
229 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
230 * @pre The radio state must be set to #RADIO_STATE_PLAYING by calling radio_start().
231 * @post It invokes radio_seek_completed_cb() when the seek completes.
232 * @see radio_seek_down()
234 int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_data );
237 * @brief Seeks down the effective frequency of the radio, asynchronously.
238 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
239 * @param[in] radio The handle to radio
240 * @param[in] callback The callback function to register
241 * @param[in] user_data The user data to be passed to the callback function
242 * @return @c 0 on success,
243 * otherwise a negative error value
244 * @retval #RADIO_ERROR_NONE Successful
245 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
246 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
247 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
248 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
249 * @pre The radio state must be set to #RADIO_STATE_PLAYING by calling radio_start().
250 * @post It invokes radio_seek_completed_cb() when the seek completes.
251 * @see radio_seek_up()
253 int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_data );
256 * @brief Sets the radio frequency.
257 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
258 * @param[in] radio The handle to radio
259 * @param[in] frequency The frequency to set [87500 ~ 108000] (kHz)
260 * @return @c 0 on success,
261 * otherwise a negative error value
262 * @retval #RADIO_ERROR_NONE Successful
263 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
265 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
266 * @see radio_get_frequency()
268 int radio_set_frequency(radio_h radio, int frequency);
271 * @brief Gets the current frequency of the radio.
272 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
273 * @param[in] radio The handle to radio
274 * @param[out] frequency The current frequency [87500 ~ 108000] (kHz)
275 * @return @c 0 on success,
276 * otherwise a negative error value
277 * @retval #RADIO_ERROR_NONE Successful
278 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
279 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
280 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
281 * @see radio_set_frequency()
283 int radio_get_frequency(radio_h radio, int *frequency);
286 * @brief Gets the current signal strength of the radio.
287 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
288 * @param[in] radio The handle to radio
289 * @param[out] strength The current signal strength [-128 ~ 128] (dBm)
290 * @return @c 0 on success,
291 * otherwise a negative error value
292 * @retval #RADIO_ERROR_NONE Successful
293 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
294 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
295 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
297 int radio_get_signal_strength(radio_h radio, int *strength);
300 * @brief Starts scanning radio signals, asynchronously
301 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
302 * @param[in] radio The handle to radio
303 * @param[in] callback The callback function to register
304 * @param[in] user_data The user data to be passed to the callback function
305 * @return @c 0 on success,
306 * otherwise a negative error value
307 * @retval #RADIO_ERROR_NONE Successful
308 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
309 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
310 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
311 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
312 * @pre The radio state must be set to #RADIO_STATE_READY by calling radio_create() or radio_stop().
313 * @post The radio state will be #RADIO_STATE_SCANNING during a search. After the scan is completed, the radio state will be #RADIO_STATE_READY.
314 * @post It invokes radio_scan_updated_cb() when the scan information updates.
315 * @post It invokes radio_scan_completed_cb() when the scan completes, if you set a callback with radio_set_scan_completed_cb().
316 * @see radio_scan_stop()
317 * @see radio_set_scan_completed_cb()
318 * @see radio_scan_completed_cb()
320 int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data);
323 * @brief Stops scanning radio signals, asynchronously.
324 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
325 * @param[in] radio The handle to radio
326 * @param[in] callback The callback function to register
327 * @param[in] user_data The user data to be passed to the callback function
328 * @return @c 0 on success,
329 * otherwise a negative error value
330 * @retval #RADIO_ERROR_NONE Successful
331 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid state
332 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
333 * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
334 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
335 * @pre The radio state must be set to #RADIO_STATE_SCANNING by calling radio_scan_start().
336 * @post It invokes radio_scan_stopped_cb() when the scan stops.
337 * @post The radio state will be #RADIO_STATE_READY.
338 * @see radio_scan_start()
340 int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data);
343 * @brief Sets the radio's mute status.
344 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
345 * @details If the mute status is @c true, no sounds will be played. If @c false, sounds will be played. Until this function is called, by default the radio is not muted.
346 * @param[in] radio The handle to radio
347 * @param[in] muted The new mute status: (@c true = mute, @c false = not muted)
348 * @return @c 0 on success,
349 * otherwise a negative error value
350 * @retval #RADIO_ERROR_NONE Successful
351 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
352 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
353 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
354 * @see radio_is_muted()
356 int radio_set_mute(radio_h radio, bool muted);
359 * @brief Gets the radio's mute status.
360 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
361 * @details If the mute status is @c true, no sounds are played. If @c false, sounds are played.
362 * @param[in] radio The handle to radio
363 * @param[out] muted The current mute status: (@c true = mute, @c false = not muted)
364 * @return @c 0 on success,
365 * otherwise a negative error value
366 * @retval #RADIO_ERROR_NONE Successful
367 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
368 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
369 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
370 * @see radio_set_mute()
372 int radio_is_muted(radio_h radio, bool *muted);
375 * @brief Registers a callback function to be invoked when the scan finishes.
376 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
377 * @param[in] radio The handle to radio
378 * @param[in] callback The callback function to register
379 * @param[in] user_data The user data to be passed to the callback function
380 * @return @c 0 on success,
381 * otherwise a negative error value
382 * @retval #RADIO_ERROR_NONE Successful
383 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
384 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
385 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
386 * @post radio_scan_completed_cb() will be invoked.
387 * @see radio_unset_scan_completed_cb()
388 * @see radio_scan_completed_cb()
390 int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data);
393 * @brief Unregisters the callback function.
394 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
395 * @param[in] radio The handle to radio
396 * @return @c 0 on success,
397 * otherwise a negative error value
398 * @retval #RADIO_ERROR_NONE Successful
399 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
400 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
401 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
402 * @see radio_set_scan_completed_cb()
404 int radio_unset_scan_completed_cb(radio_h radio);
407 * @brief Registers a callback function to be invoked when the radio is interrupted.
408 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
409 * @param[in] radio The handle to radio
410 * @param[in] callback The callback function to register
411 * @param[in] user_data The user data to be passed to the callback function
412 * @return @c 0 on success,
413 * otherwise a negative error value
414 * @retval #RADIO_ERROR_NONE Successful
415 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
416 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
417 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
418 * @post radio_interrupted_cb() will be invoked.
419 * @see radio_unset_interrupted_cb()
420 * @see #radio_interrupted_code_e
421 * @see radio_interrupted_cb()
423 int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data);
426 * @brief Unregisters the callback function.
427 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
428 * @param[in] radio The handle to radio
429 * @return @c 0 on success,
430 * otherwise a negative error value
431 * @retval #RADIO_ERROR_NONE Successful
432 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
433 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
434 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
435 * @see radio_set_interrupted_cb()
437 int radio_unset_interrupted_cb(radio_h radio);
440 * @brief Gets the min, max frequency of the region.
441 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
442 * @param[in] radio The handle to radio
443 * @param[out] min_freq The min frequency [87500 ~ 108000] (kHz)
444 * @param[out] max_freq The max frequency [87500 ~ 108000] (kHz)
445 * @return @c 0 on success,
446 * otherwise a negative error value
447 * @retval #RADIO_ERROR_NONE Successful
448 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
449 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
450 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
452 int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq);
455 * @brief Gets channel spacing.
456 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
457 * @param[in] radio The handle to radio
458 * @param[out] channel_spacing The channel spacing value
459 * @return @c 0 on success,
460 * otherwise a negative error value
461 * @retval #RADIO_ERROR_NONE Successful
462 * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
463 * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
464 * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
466 int radio_get_channel_spacing(radio_h radio, int *channel_spacing);
477 #endif /* __TIZEN_MEDIA_RADIO_H__ */