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.
19 #ifndef __TIZEN_MULTIMEDIA_RECORDER_H__
20 #define __TIZEN_MULTIMEDIA_RECORDER_H__
29 #define RECORDER_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x10
34 * @brief This file contains the Recorder API.
38 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
43 * @brief The handle to media recorder
45 typedef struct recorder_s *recorder_h;
48 * @brief Enumerations of error code for the media recorder.
52 RECORDER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
53 RECORDER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
54 RECORDER_ERROR_INVALID_STATE = RECORDER_ERROR_CLASS | 0x02, /**< Invalid state */
55 RECORDER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY , /**< Out of memory */
56 RECORDER_ERROR_DEVICE = RECORDER_ERROR_CLASS | 0x04, /**< Device error */
57 RECORDER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Internal error */
58 RECORDER_ERROR_SOUND_POLICY = RECORDER_ERROR_CLASS | 0x06, /**< Blocked by Audio Session Manager */
59 RECORDER_ERROR_SECURITY_RESTRICTED = RECORDER_ERROR_CLASS | 0x07, /**< Restricted by security system policy */
63 * @brief Enumerations for camera states.
67 RECORDER_STATE_NONE, /**< Recorder is not created */
68 RECORDER_STATE_CREATED, /**< Recorder is created, but not prepared*/
69 RECORDER_STATE_READY, /**< Recorder is ready to record\n In case of video recorder, preview display will be shown */
70 RECORDER_STATE_RECORDING, /**< Recorder is recording media*/
71 RECORDER_STATE_PAUSED, /**< Recorder is paused while recording media*/
75 * @brief Enumerations of recording limitation.
79 RECORDER_RECORDING_LIMIT_TIME, /**< Time limit (second) of recording file */
80 RECORDER_RECORDING_LIMIT_SIZE, /**< Size limit (kilo bytes [KB]) of recording file */
81 RECORDER_RECORDING_LIMIT_FREE_SPACE, /**< No free space in storage */
82 } recorder_recording_limit_type_e;
85 * @brief Enumerations of file container format.
89 RECORDER_FILE_FORMAT_3GP, /**< 3GP file format */
90 RECORDER_FILE_FORMAT_MP4, /**< MP4 file format */
91 RECORDER_FILE_FORMAT_AMR, /**< AMR file format */
92 RECORDER_FILE_FORMAT_ADTS, /**< ADTS file format */
93 RECORDER_FILE_FORMAT_WAV, /**< WAV file format */
94 } recorder_file_format_e;
98 * @brief Enumerations of audio codec.
102 RECORDER_AUDIO_CODEC_DISABLE = -1, /**< Disable audio track */
103 RECORDER_AUDIO_CODEC_AMR = 0, /**< AMR codec */
104 RECORDER_AUDIO_CODEC_AAC, /**< AAC codec */
105 RECORDER_AUDIO_CODEC_VORBIS, /**< Vorbis codec */
106 RECORDER_AUDIO_CODEC_PCM /**< PCM codec */
107 } recorder_audio_codec_e;
110 * @brief Enumerations of video codec.
114 RECORDER_VIDEO_CODEC_H263, /**< H263 codec */
115 RECORDER_VIDEO_CODEC_H264, /**< H264 codec */
116 RECORDER_VIDEO_CODEC_MPEG4, /**< MPEG4 codec */
117 RECORDER_VIDEO_CODEC_THEORA /**< Theora codec */
118 } recorder_video_codec_e;
121 * @brief Enumerations of audio capture devices.
125 RECORDER_AUDIO_DEVICE_MIC, /**< Mic device */
126 RECORDER_AUDIO_DEVICE_MODEM, /**< Modem */
127 } recorder_audio_device_e;
130 * @brief Enumerations of the recorder rotation type.
134 RECORDER_ROTATION_NONE, /**< No rotation */
135 RECORDER_ROTATION_90, /**< 90 degree rotation */
136 RECORDER_ROTATION_180, /**< 180 degree rotation */
137 RECORDER_ROTATION_270, /**< 270 degree rotation */
138 } recorder_rotation_e;
141 * @brief Enumerations of the recorder policy.
145 RECORDER_POLICY_NONE = 0, /**< None */
146 RECORDER_POLICY_SOUND, /**< Sound policy */
147 RECORDER_POLICY_SECURITY /**< Security policy */
155 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
160 * @brief The callback function called when limitation error occurs while recording.
161 * @details The callback function is possible to receive three types of limits: time, size and no-space.
162 * @remarks After called it, recording data is discarded and not written in recording file. Also the state of recorder is not changed.
163 * @param[in] type The limitation type
164 * @param[in] user_data The user data passed from the callback registration function
165 * @pre It is required to register a callback using recorder_set_recording_limit_reached_cb()
166 * @see recorder_set_recording_status_cb()
167 * @see recorder_set_recording_limit_reached_cb()
168 * @see recorder_unset_recording_limit_reached_cb()
170 typedef void (*recorder_recording_limit_reached_cb)(recorder_recording_limit_type_e type, void *user_data);
174 * @brief Callback function to indicate recording status
175 * @remarks This callback function is repeatedly invoked during #RECORDER_STATE_RECORDING state
176 * @param[in] elapsed_time The time of recording (milliseconds)
177 * @param[in] file_size The size of recording file (KB)
178 * @param[in] user_data The user data passed from the callback registration function
179 * @pre recorder_start() will cause this callback if you register this callback using recorder_set_recording_status_cb()
180 * @see recorder_set_recording_status_cb()
181 * @see recorder_unset_recording_status_cb()
182 * @see recorder_start()
184 typedef void (*recorder_recording_status_cb)(int elapsed_time, int file_size, void *user_data);
188 * @brief Called when the record state has changed.
189 * @param[in] previous The previous state of recorder
190 * @param[in] current The current state of recorder
191 * @param[in] by_policy @c true if the state is changed by policy, otherwise @c false
192 * @param[in] user_data The user data passed from the callback registration function
193 * @pre This function is required to register a callback using recorder_set_state_changed_cb()
194 * @see recorder_set_state_changed_cb()
195 * @see recorder_prepare()
196 * @see recorder_unprepare()
197 * @see recorder_start()
198 * @see recorder_pause()
199 * @see recorder_commit()
200 * @see recorder_cancel()
202 typedef void (*recorder_state_changed_cb)(recorder_state_e previous , recorder_state_e current , bool by_policy, void *user_data);
205 * @brief Called when the recorder interrupted by policy
207 * @param[in] policy The policy that interrupting the recorder
208 * @param[in] previous The previous state of the recorder
209 * @param[in] current The current state of the recorder
210 * @param[in] user_data The user data passed from the callback registration function
211 * @see recorder_set_interrupted_cb()
213 typedef void (*recorder_interrupted_cb)(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *user_data);
216 * @brief Called when audio stream data was delivering just before storing in record file.
218 * The callback function holds the same buffer that will be recorded.\n
219 * So if an user change the buffer, the result file will has the buffer.\n
220 * The callback is called via internal thread of Frameworks. so don't be invoke UI API, recorder_unprepare(), recorder_commit() and recorder_cancel() in callback.
222 * @param[in] stream The audio stream data
223 * @param[in] size The size of stream data
224 * @param[in] format The audio format
225 * @param[in] channel The number of channel
226 * @param[in] timestamp The timestamp of stream buffer( in msec )
227 * @param[in] user_data The user data passed from the callback registration function
229 * @see recorder_set_audio_stream_cb()
231 typedef void (*recorder_audio_stream_cb)(void* stream, int size, audio_sample_type_e format, int channel, unsigned int timestamp, void *user_data);
234 * @brief Called when the error occurred.
237 * This callback inform critical error situation.\n
238 * When invoked this callback, user should release the resource and terminate application.\n
239 * These error code will be occurred\n
240 * #RECORDER_ERROR_DEVICE\n
241 * #RECORDER_ERROR_INVALID_OPERATION\n
242 * #RECORDER_ERROR_OUT_OF_MEMORY\n
244 * @param[in] error The error code
245 * @param[in] current_state The current state of the recorder
246 * @param[in] user_data The user data passed from the callback registration function
248 * @pre This callback function is invoked if you register this callback using recorder_set_error_cb().
249 * @see recorder_set_error_cb()
250 * @see recorder_unset_error_cb()
252 typedef void (*recorder_error_cb)(recorder_error_e error, recorder_state_e current_state, void *user_data);
260 * @addtogroup CAPI_MEDIA_RECORDER_CAPABILITY_MODULE
265 * @brief Gets called iteratively to notify you of supported file formats.
266 * @param[in] format The format of recording files
267 * @param[in] user_data The user data passed from the foreach function
268 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
269 * @pre recorder_foreach_supported_file_format() will invoke this callback.
270 * @see recorder_foreach_supported_file_format()
272 typedef bool (*recorder_supported_file_format_cb)(recorder_file_format_e format, void *user_data);
276 * @brief Gets called iteratively to notify you of supported audio encoders.
277 * @param[in] codec The codec of audio encoder.
278 * @param[in] user_data The user data passed from the foreach function
279 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
280 * @pre recorder_foreach_supported_audio_encoder() will invoke this callback.
281 * @see recorder_foreach_supported_audio_encoder()
283 typedef bool (*recorder_supported_audio_encoder_cb)(recorder_audio_codec_e codec, void *user_data);
287 * @brief Gets called iteratively to notify you of supported video encoders.
288 * @param[in] codec The codec of video encoder.
289 * @param[in] user_data The user data passed from the foreach function
290 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
291 * @pre recorder_foreach_supported_video_encoder() will invoke this callback.
292 * @see recorder_foreach_supported_video_encoder()
294 typedef bool (*recorder_supported_video_encoder_cb)(recorder_video_codec_e codec, void *user_data);
301 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
306 * @brief Creates a recorder handle to record a video.
307 * @param[in] camera The handle to camera
308 * @param[out] recorder A handle to recorder
309 * @remarks @a recorder must be released with recorder_destroy() by you.\n
310 * The @a camera handle can not be used for capturing images until @record is deleted by recorder_destroy().
311 * @return 0 on success, otherwise a negative error value.
312 * @retval #RECORDER_ERROR_NONE Successful
313 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
314 * @retval #RECORDER_ERROR_OUT_OF_MEMORY Out of memory
315 * @retval #RECORDER_ERROR_SOUND_POLICY Sound policy error
316 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
317 * @pre Camera handle's state must be #CAMERA_STATE_CREATED by camera_create() or camera_stop_preview().
318 * @post The recorder state will be #RECORDER_STATE_CREATED.
319 * @see camera_create()
320 * @see camera_stop_preview()
321 * @see recorder_destroy()
323 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder);
327 * @brief Creates a recorder handle to record an audio.
328 * @remarks @a recorder must be released with recorder_destroy() by you
329 * @param[out] recorder A handle to recorder
330 * @return 0 on success, otherwise a negative error value.
331 * @retval #RECORDER_ERROR_NONE Successful
332 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
333 * @retval #RECORDER_ERROR_OUT_OF_MEMORY Out of memory
334 * @retval #RECORDER_ERROR_SOUND_POLICY Sound policy error
335 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
336 * @post The recorder state will be #RECORDER_STATE_CREATED.
337 * @see recorder_destroy()
339 int recorder_create_audiorecorder(recorder_h *recorder);
343 * @brief Destroys the recorder handle
344 * @remarks Video recorder's camera handle is not release by this function.
345 * @param[in] recorder The handle to media recorder
346 * @return 0 on success, otherwise a negative error value.
347 * @retval #RECORDER_ERROR_NONE Successful
348 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
349 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
350 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
351 * @pre The recorder state should be #RECORDER_STATE_CREATED
352 * @post The recorder state will be #RECORDER_STATE_NONE.
353 * @see camera_destroy()
354 * @see recorder_create_videorecorder()
355 * @see recorder_create_audiorecorder()
357 int recorder_destroy(recorder_h recorder);
361 * @brief Prepares the media recorder for recording
362 * @remarks Before calling the function, it is required to set audio encoder (recorder_set_audio_encoder()),
363 * video encoder(recorder_set_video_encoder()), file format (recorder_set_file_format()) with proper value.
364 * @param[in] recorder The handle to media recorder
365 * @return 0 on success, otherwise a negative error value.
366 * @retval #RECORDER_ERROR_NONE Successful
367 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
368 * @retval #RECORDER_ERROR_SOUND_POLICY Sound policy error
369 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
370 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
371 * @pre The recorder state should be #RECORDER_STATE_CREATED by recorder_create_videorecorder(), recorder_create_audiorecorder() or recorder_unprepare().
372 * @post The recorder state will be #RECORDER_STATE_READY.
373 * @post If recorder handle is created by recorder_create_videorecorder(), it's camera state will be changed to #CAMERA_STATE_PREVIEW.
374 * @see recorder_create_videorecorder()
375 * @see recorder_create_audiorecorder()
376 * @see recorder_unprepare()
377 * @see recorder_set_audio_encoder()
378 * @see recorder_set_video_encoder()
379 * @see recorder_set_file_format()
381 int recorder_prepare(recorder_h recorder);
385 * @brief Reset the media recorder.
386 * @param[in] recorder The handle to media recorder
387 * @return 0 on success, otherwise a negative error value.
388 * @retval #RECORDER_ERROR_NONE Successful
389 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
390 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
391 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
392 * @pre The recorder state should be #RECORDER_STATE_READY by recorder_prepare(), recorder_cancel(),or recorder_commit().
393 * @post The recorder state will be #RECORDER_STATE_CREATED.
394 * @post If recorder handle is created by recorder_create_videorecorder(), it's camera state will be changed to #CAMERA_STATE_CREATED.
395 * @see recorder_prepare()
396 * @see recorder_cancel()
397 * @see recorder_commit()
399 int recorder_unprepare(recorder_h recorder);
403 * @brief Starts recording
404 * @remarks If file path has been set to existing file, this file is removed automatically and updated by new one.
405 * @param[in] recorder The handle to media recorder
406 * @return 0 on success, otherwise a negative error value.
407 * @retval #RECORDER_ERROR_NONE Successful
408 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
409 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
410 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
411 * @pre The recorder state must be #RECORDER_STATE_READY by recorder_prepare() or #RECORDER_STATE_PAUSED by recorder_pause()
412 * @post The recorder state will be #RECORDER_STATE_RECORDING.
413 * @see recorder_pause()
414 * @see recorder_commit()
415 * @see recorder_cancel()
416 * @see recorder_set_audio_encoder()
417 * @see recorder_set_filename()
418 * @see recorder_set_file_format()
419 * @see recorder_recording_status_cb()
421 int recorder_start(recorder_h recorder);
425 * @brief Pauses recording
426 * @remarks Recording can be resumed with recorder_start().
427 * @param[in] recorder The handle to media recorder
428 * @return 0 on success, otherwise a negative error value.
429 * @retval #RECORDER_ERROR_NONE Successful
430 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
431 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
432 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
433 * @pre The recorder state must be #RECORDER_STATE_RECORDING
434 * @post The recorder state will be #RECORDER_STATE_PAUSED.
435 * @see recorder_pause()
436 * @see recorder_commit()
437 * @see recorder_cancel()
439 int recorder_pause(recorder_h recorder);
443 * @brief Stops recording and saving the result
444 * @param [in] recorder The handle to media recorder
445 * @return 0 on success, otherwise a negative error value.
446 * @retval #RECORDER_ERROR_NONE Successful
447 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
448 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
449 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
450 * @pre The recorder state must be #RECORDER_STATE_RECORDING by recorder_start() or #RECORDER_STATE_PAUSED by recorder_pause()
451 * @post The recorder state will be #RECORDER_STATE_READY.
452 * @see recorder_pause()
453 * @see recorder_cancel()
454 * @see recorder_set_filename()
455 * @see recorder_start()
457 int recorder_commit(recorder_h recorder);
461 * @brief Cancels recording.
462 * @detail The recording data is discarded and not written in recording file.
463 * @param[in] recorder The handle to media recorder
464 * @return 0 on success, otherwise a negative error value
465 * @retval #RECORDER_ERROR_NONE Successful
466 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
467 * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
468 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
469 * @pre The recorder state must be #RECORDER_STATE_RECORDING by recorder_start() or #RECORDER_STATE_PAUSED by recorder_pause()
470 * @post The recorder state will be #RECORDER_STATE_READY.
471 * @see recorder_pause()
472 * @see recorder_commit()
473 * @see recorder_cancel()
474 * @see recorder_start()
476 int recorder_cancel(recorder_h recorder);
480 * @brief Gets the recorder's current state.
481 * @param[in] recorder The handle to the recorder.
482 * @param[out] state The current state of the recorder
483 * @return 0 on success, otherwise a negative error value.
484 * @retval #RECORDER_ERROR_NONE Successful
485 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
487 int recorder_get_state(recorder_h recorder, recorder_state_e *state);
490 * @brief Gets the peak audio input level that was sampled since the last call to this function.
491 * @remarks 0 dB indicates maximum input level, -300dB indicates minimum input level
492 * @param[in] recorder The handle to the recorder.
493 * @param[out] level The audio input level in dB
494 * @return 0 on success, otherwise a negative error value.
495 * @retval #RECORDER_ERROR_NONE Successful
496 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
497 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
498 * @pre The recorder state must be #RECORDER_STATE_RECORDING or #RECORDER_STATE_PAUSED
500 int recorder_get_audio_level(recorder_h recorder, double *dB);
503 * @brief Sets the file path to record
504 * @details This function sets file path which defines where newly recorder data should be stored.
505 * @remarks If there is already exists same file in file system, then old file will be overwritten.
506 * @param[in] recorder The handle to media recorder
507 * @param[in] path The recording file path
508 * @return 0 on success, otherwise a negative error value.
509 * @retval #RECORDER_ERROR_NONE Successful
510 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
511 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
512 * @pre The recorder state must be #RECORDER_STATE_CREATED by recorder_create() or recorder_unprepare()
513 * @see recorder_get_filename()
515 int recorder_set_filename(recorder_h recorder, const char *path);
519 * @brief Gets the file path to record
520 * @remarks @a path must be released with @c free() by you.
521 * @param[in] recorder The handle to media recorder
522 * @param[out] path The recording file path
523 * @return 0 on success, otherwise a negative error value.
524 * @retval #RECORDER_ERROR_NONE Successful
525 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
526 * @see recorder_set_filename()
528 int recorder_get_filename(recorder_h recorder, char **path);
532 * @brief Sets the file format for recording media stream
533 * @param[in] recorder The handle to media recorder
534 * @param[in] format The media file format
535 * @return 0 on success, otherwise a negative error value.
536 * @retval #RECORDER_ERROR_NONE Successful
537 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
538 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
539 * @pre The recorder state must be #RECORDER_STATE_CREATED
540 * @see recorder_get_file_format()
541 * @see recorder_foreach_supported_file_format()
543 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format);
547 * @brief Gets the file format for recording media stream
548 * @param [in] recorder The handle to media recorder
549 * @param [in] format The media file format
550 * @return 0 on success, otherwise a negative error value.
551 * @retval #RECORDER_ERROR_NONE Successful
552 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
553 * @see recorder_set_file_format()
554 * @see recorder_foreach_supported_file_format()
556 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format);
564 * @addtogroup CAPI_MEDIA_RECORDER_CAPABILITY_MODULE
569 * @brief Retrieves all supported file formats by invoking a specific callback for each supported file format
570 * @param[in] recorder The handle to media recorder
571 * @param[in] callback The iteration callback
572 * @param[in] user_data The user data to be passed to the callback function
573 * @return 0 on success, otherwise a negative error value.
574 * @retval #RECORDER_ERROR_NONE Successful
575 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
576 * @post recorder_supported_file_format_cb() will be invoked
577 * @see recorder_get_file_format()
578 * @see recorder_set_file_format()
579 * @see recorder_supported_file_format_cb()
581 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb callback, void *user_data);
588 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
593 * @brief Sets the audio codec for encoding audio stream
594 * @remarks You can get available audio encoders by using recorder_foreach_supported_audio_encoder().\n
595 * if set to RECORDER_AUDIO_CODEC_DISABLE, audio track is not created in recording files.
596 * @param[in] recorder The handle to media recorder
597 * @param[in] codec The audio codec
598 * @return 0 on success, otherwise a negative error value.
599 * @retval #RECORDER_ERROR_NONE Successful
600 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
601 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
602 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
603 * @see recorder_get_audio_encoder()
604 * @see recorder_foreach_supported_audio_encoder()
606 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec);
610 * @brief Gets the audio codec for encoding audio stream
611 * @param [in] recorder The handle to media recorder
612 * @param [out] codec The audio codec
613 * @return 0 on success, otherwise a negative error value.
614 * @retval #RECORDER_ERROR_NONE Successful
615 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
616 * @see recorder_set_audio_encoder()
617 * @see recorder_foreach_supported_audio_encoder()
619 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec);
626 * @addtogroup CAPI_MEDIA_RECORDER_CAPABILITY_MODULE
631 * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder.
632 * @param[in] recorder The handle to media recorder
633 * @param[in] callback The iteration callback
634 * @param[in] user_data The user data to be passed to the callback function
635 * @return 0 on success, otherwise a negative error value.
636 * @retval #RECORDER_ERROR_NONE Successful
637 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
638 * @post recorder_supported_audio_encoder_cb() will be invoked
639 * @see recorder_set_audio_encoder()
640 * @see recorder_get_audio_encoder()
641 * @see recorder_supported_audio_encoder_cb()
643 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb callback, void *user_data);
650 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
655 * @brief Sets the video codec for encoding video stream.
656 * @remarks You can get available video encoders by using recorder_foreach_supported_video_encoder().
657 * @param[in] recorder The handle to media recorder
658 * @param[in] codec The video codec
659 * @return 0 on success, otherwise a negative error value.
660 * @retval #RECORDER_ERROR_NONE Successful
661 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
662 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
663 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
664 * @see recorder_get_video_encoder()
665 * @see recorder_foreach_supported_video_encoder()
667 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec);
671 * @brief Gets the video codec for encoding video stream.
672 * @param[in] recorder The handle to media recorder
673 * @param[out] codec The video codec
674 * @return 0 on success, otherwise a negative error value.
675 * @retval #RECORDER_ERROR_NONE Successful
676 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
677 * @see recorder_set_video_encoder()
678 * @see recorder_foreach_supported_video_encoder()
680 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec);
687 * @addtogroup CAPI_MEDIA_RECORDER_CAPABILITY_MODULE
692 * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder.
693 * @param[in] recorder The handle to media recorder
694 * @param[in] callback The iteration callback
695 * @param[in] user_data The user data to be passed to the callback function
696 * @return 0 on success, otherwise a negative error value.
697 * @retval #RECORDER_ERROR_NONE Successful
698 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
699 * @post recorder_supported_video_encoder_cb() will be invoked
700 * @see recorder_set_video_encoder()
701 * @see recorder_get_video_encoder()
702 * @see recorder_supported_video_encoder_cb()
704 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb callback, void *user_data);
711 * @addtogroup CAPI_MEDIA_RECORDER_MODULE
716 * @brief Registers the callback function that will be invoked when the recorder state changes.
717 * @param[in] recorder The handle to the recorder.
718 * @param[in] callback The function pointer of user callback
719 * @param[in] user_data The user data to be passed to the callback function
720 * @return 0 on success, otherwise a negative error value.
721 * @retval #RECORDER_ERROR_NONE Successful
722 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
723 * @post recorder_state_changed_cb() will be invoked
724 * @see recorder_unset_state_changed_cb()
725 * @see recorder_state_changed_cb()
727 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data);
731 * @brief Unregisters the callback function.
732 * @param[in] recorder The handle to the recorder.
733 * @return 0 on success, otherwise a negative error value.
734 * @retval #RECORDER_ERROR_NONE Successful
735 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
736 * @see recorder_set_state_changed_cb()
738 int recorder_unset_state_changed_cb(recorder_h recorder);
741 * @brief Registers a callback function to be called when recorder interrupted by policy.
743 * @param[in] recorder The handle to the recorder
744 * @param[in] callback The callback function to register
745 * @param[in] user_data The user data to be passed to the callback function
747 * @return 0 on success, otherwise a negative error value.
748 * @retval #RECORDER_ERROR_NONE Successful
749 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
751 * @see recorder_unset_interrupted_cb()
752 * @see recorder_interrupted_cb()
754 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback,
758 * @brief Unregisters the callback function.
760 * @param[in] recorder The handle to the recorder
761 * @return 0 on success, otherwise a negative error value.
762 * @retval #RECORDER_ERROR_NONE Successful
763 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
765 * @see recorder_set_interrupted_cb()
767 int recorder_unset_interrupted_cb(recorder_h recorder);
770 * @brief Registers a callback function to be called when audio stream data was delivering
773 * This callback function holds the same buffer that will be recorded.\n
774 * So if an user change the buffer, the result file will has the buffer.\n
775 * The callback is called via internal thread of Frameworks. so don't be invoke UI API, recorder_unprepare(), recorder_commit() and recorder_cancel() in callback.\n
776 * This callback function to be called in RECORDER_STATE_RECORDING and RECORDER_STATE_PAUSE state.
778 * @param[in] recorder The handle to the recorder
779 * @param[in] callback The callback function to register
780 * @param[in] user_data The user data to be passed to the callback function
782 * @return 0 on success, otherwise a negative error value.
783 * @retval #RECORDER_ERROR_NONE Successful
784 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
785 * @pre The recorder state should be #RECORDER_STATE_READY or #RECORDER_STATE_CREATED.
787 * @see recorder_unset_audio_stream_cb()
788 * @see recorder_audio_stream_cb()
790 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data);
793 * @brief Unregisters the callback function.
795 * @param[in] recorder The handle to the recorder
796 * @return 0 on success, otherwise a negative error value.
797 * @retval #RECORDER_ERROR_NONE Successful
798 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
800 * @see recorder_set_audio_stream_cb()
802 int recorder_unset_audio_stream_cb(recorder_h recorder);
806 * @brief Registers a callback function to be invoked when the recording information changes.
807 * @param[in] recorder The handle to media recorder
808 * @param[in] callback The function pointer of user callback
809 * @param[in] user_data The user data to be passed to the callback function
810 * @return 0 on success, otherwise a negative error value.
811 * @retval #RECORDER_ERROR_NONE Successful
812 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
813 * @post recorder_recording_status_cb() will be invoked
814 * @see recorder_unset_recording_status_cb()
815 * @see recorder_recording_status_cb()
817 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data);
821 * @brief Unregisters the callback function.
822 * @param[in] recorder The handle to media recorder
823 * @return 0 on success, otherwise a negative error value.
824 * @retval #RECORDER_ERROR_NONE Successful
825 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
826 * @see recorder_set_recording_status_cb()
828 int recorder_unset_recording_status_cb(recorder_h recorder);
832 * @brief Registers the callback function to run when reached recording limit.
833 * @param[in] recorder The handle to media recorder
834 * @param[in] callback The function pointer of user callback
835 * @param[in] user_data The user data to be passed to the callback function
836 * @return 0 on success, otherwise a negative error value.
837 * @retval #RECORDER_ERROR_NONE Successful
838 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
839 * @post recorder_recording_limit_reached_cb() will be invoked
840 * @see recorder_unset_recording_limit_reached_cb()
841 * @see recorder_attr_set_size_limit()
842 * @see recorder_attr_set_time_limit()
843 * @see recorder_recording_limit_reached_cb()
845 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data);
849 * @brief Unregisters the callback function.
850 * @param[in] recorder The handle to media recorder
851 * @return 0 on success, otherwise a negative error value.
852 * @retval #RECORDER_ERROR_NONE Successful
853 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
854 * @see recorder_set_recording_limit_reached_cb()
856 int recorder_unset_recording_limit_reached_cb(recorder_h recorder);
860 * @brief Registers a callback function to be called when an asynchronous operation error occurred.
863 * This callback inform critical error situation.\n
864 * When invoked this callback, user should release the resource and terminate application.\n
865 * These error code will be occurred\n
866 * #RECORDER_ERROR_DEVICE\n
867 * #RECORDER_ERROR_INVALID_OPERATION\n
868 * #RECORDER_ERROR_OUT_OF_MEMORY\n
870 * @param[in] recorder The handle to the recorder
871 * @param[in] callback The callback function to register
872 * @param[in] user_data The user data to be passed to the callback function
873 * @return 0 on success, otherwise a negative error value.
874 * @retval #RECORDER_ERROR_NONE Successful
875 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
876 * @post This function will invoke recorder_error_cb() when an asynchronous operation error occur.
878 * @see recorder_unset_error_cb()
879 * @see recorder_error_cb()
881 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data);
885 * @brief Unregisters the callback function.
887 * @param[in] recorder The handle to the recorder
888 * @return 0 on success, otherwise a negative error value.
889 * @retval #RECORDER_ERROR_NONE Successful
890 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
892 * @see recorder_set_error_cb()
894 int recorder_unset_error_cb(recorder_h recorder);
902 * @addtogroup CAPI_MEDIA_RECORDER_ATTRIBUTES_MODULE
908 * @brief Sets maximum size of recording file.
909 * @remarks After reached limitation, recording data is discarded and not written in recording file.
910 * @param[in] recorder The handle to media recorder
911 * @param[in] kbyte The maximum size of recording file(KB)\n @c 0 means unlimited recording size.
912 * @return 0 on success, otherwise a negative error value.
913 * @retval #RECORDER_ERROR_NONE Successful
914 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
915 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
916 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
917 * @see recorder_attr_get_size_limit()
918 * @see recorder_attr_set_time_limit()
920 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte);
924 * @brief Gets the maximum size of recording file.
925 * @param[in] recorder The handle to media recorder
926 * @param[out] kbyte The maximum size of recording file (KB)\n @c 0 means unlimited recording size
927 * @return 0 on success, otherwise a negative error value.
928 * @retval #RECORDER_ERROR_NONE Successful
929 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
930 * @see recorder_attr_set_size_limit()
931 * @see recorder_attr_get_time_limit()
933 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte);
937 * @brief Sets time limit of recording file.
938 * @remarks After reached limitation, recording data is discarded and not written in recording file.
939 * @param[in] recorder The handle to media recorder
940 * @param[in] second The time limit of recording file (in seconds) \n @c 0 means unlimited recording size
941 * @return 0 on success, otherwise a negative error value.
942 * @retval #RECORDER_ERROR_NONE Successful
943 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
944 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
945 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
946 * @see recorder_attr_get_time_limit()
947 * @see recorder_attr_set_size_limit()
949 int recorder_attr_set_time_limit(recorder_h recorder, int second);
953 * @brief Gets the time limit of recording file
954 * @param[in] recorder The handle to media recorder
955 * @param[out] second The time limit of recording file (in seconds)\n @c 0 means unlimited recording time.
956 * @return 0 on success, otherwise a negative error value.
957 * @retval #RECORDER_ERROR_NONE Successful
958 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
959 * @see recorder_attr_set_time_limit()
960 * @see recorder_attr_get_size_limit()
962 int recorder_attr_get_time_limit(recorder_h recorder, int *second);
966 * @brief Sets audio device for recording.
967 * @param[in] recorder The handle to media recorder
968 * @param[in] device The type of audio device
969 * @return 0 on success, otherwise a negative error value.
970 * @retval #RECORDER_ERROR_NONE Successful
971 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
972 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
973 * @pre The recorder state must be #RECORDER_STATE_CREATED
974 * @see recorder_attr_get_audio_device()
976 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device);
980 * @brief Gets the audio device for recording.
981 * @param[in] recorder The handle to media recorder
982 * @param[out] device The type of audio device
983 * @return 0 on success, otherwise a negative error value.
984 * @retval #RECORDER_ERROR_NONE Successful
985 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
986 * @see recorder_attr_set_audio_device()
988 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device);
992 * @brief Sets sampling rate of audio stream.
993 * @param[in] recorder The handle to media recorder
994 * @param[in] samplerate The sample rate in Hertz
995 * @return 0 on success, otherwise a negative error value.
996 * @retval #RECORDER_ERROR_NONE Successful
997 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
998 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
999 * @pre The recorder state must be #RECORDER_STATE_CREATED
1000 * @see recorder_attr_get_audio_samplerate()
1002 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate);
1006 * @brief Gets the sampling rate of audio stream.
1007 * @param[in] recorder The handle to media recorder
1008 * @param[out] samplerate The sample rate in Hertz
1009 * @return 0 on success, otherwise a negative error value.
1010 * @retval #RECORDER_ERROR_NONE Successful
1011 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1012 * @see recorder_attr_set_audio_samplerate()
1014 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate);
1018 * @brief Sets the bitrate of audio encoder.
1019 * @param[in] recorder The handle to media recorder
1020 * @param[in] bitrate The bitrate (for mms : 12200[bps], normal : 288000[bps])
1021 * @return 0 on success, otherwise a negative error value.
1022 * @retval #RECORDER_ERROR_NONE Successful
1023 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1024 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
1025 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
1026 * @see recorder_attr_get_audio_encoder_bitrate()
1028 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate);
1032 * @brief Sets bitrate of video encoder.
1033 * @param[in] recorder The handle to media recorder
1034 * @param[in] bitrate The bitrate in bits per second
1035 * @return 0 on success, otherwise a negative error value.
1036 * @retval #RECORDER_ERROR_NONE Successful
1037 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1038 * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
1039 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
1040 * @see recorder_attr_get_video_encoder_bitrate()
1042 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate);
1046 * @brief Gets the bitrate of audio encoder.
1047 * @param[in] recorder The handle to media recorder
1048 * @param[out] bitrate The bitrate in bits per second
1049 * @return 0 on success, otherwise a negative error value.
1050 * @retval #RECORDER_ERROR_NONE Successful
1051 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1052 * @see recorder_attr_set_audio_encoder_bitrate()
1054 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate);
1058 * @brief Gets the bitrate of video encoder.
1059 * @param[in] recorder The handle to media recorder
1060 * @param[out] bitrate The bitrate in bits per second
1061 * @return 0 on success, otherwise a negative error value.
1062 * @retval #RECORDER_ERROR_NONE Successful
1063 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1064 * @see recorder_attr_set_audio_encoder_bitrate()
1066 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate);
1071 * @brief Sets the mute state of recorder
1072 * @param[in] recorder The handle to media recorder
1073 * @param[in] enable The mute state
1074 * @return 0 on success, otherwise a negative error value.
1075 * @retval #RECORDER_ERROR_NONE Successful
1076 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1077 * @see recorder_attr_is_muted()
1079 int recorder_attr_set_mute(recorder_h recorder, bool enable);
1082 * @brief Gets the mute state of recorder
1083 * @param[in] recorder The handle to media recorder
1084 * @return true if the recorder is not recording any sound,\nelse false
1085 * @see recorder_attr_set_mute()
1087 bool recorder_attr_is_muted(recorder_h recorder);
1090 * @brief Sets recording motion rate
1092 * This attribute is valid only in video recorder.\n
1093 * If the rate bigger than 0 and smaller than 1, video is recorded slow motion mode.\n
1094 * If the rate bigger than 1, video is recorded fast motion mode(time lapse recording).
1095 * Audio data is not recorded.\n
1096 * To reset slow motion recording, setting rate to 1.
1097 * @param[in] recorder The handle to media recorder
1098 * @param[in] rate The recording motion rate. it is computed with fps. (0<rate<1 for slow motion, 1<rate for fast motion(time lapse recording), 1 to reset )
1099 * @return 0 on success, otherwise a negative error value.
1100 * @retval #RECORDER_ERROR_NONE Successful
1101 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1102 * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
1103 * @see recorder_attr_get_recording_motion_rate()
1105 int recorder_attr_set_recording_motion_rate(recorder_h recorder , double rate);
1108 * @brief Gets the recording motion rate
1110 * This attribute is valid only in video recorder.\n
1111 * If the rate bigger than 0 and smaller than 1, video is recorded slow motion mode.\n
1112 * If the rate bigger than 1, video is recorded fast motion mode(time lapse recording).
1113 * Audio data is not recorded.\n
1114 * To reset slow motion recording, setting rate to 1.
1115 * @param[in] recorder The handle to media recorder
1116 * @param[out] rate The recording motion rate. it is computed with fps.
1117 * @return 0 on success, otherwise a negative error value.
1118 * @retval #RECORDER_ERROR_NONE Successful
1119 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1120 * @see recorder_attr_set_recording_motion_rate()
1122 int recorder_attr_get_recording_motion_rate(recorder_h recorder , double *rate);
1124 __attribute__ ((deprecated)) int recorder_attr_set_slow_motion_rate(recorder_h recorder , double rate);
1125 __attribute__ ((deprecated)) int recorder_attr_get_slow_motion_rate(recorder_h recorder , double *rate);
1128 * @brief Sets the numer of audio channel.
1129 * @remarks This attribute is applied only in RECORDER_STATE_CREATED state.\n
1130 * For mono recording, setting channel to 1.\n
1131 * For stereo recording, setting channel to 2.
1132 * @param[in] recorder The handle to media recorder
1133 * @param[in] channel_count The number of audio channel
1134 * @return 0 on success, otherwise a negative error value.
1135 * @retval #RECORDER_ERROR_NONE Successful
1136 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1137 * @pre The recorder state must be #RECORDER_STATE_CREATED
1138 * @see recorder_attr_get_audio_channel()
1140 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count);
1143 * @brief Gets the numer of audio channel.
1144 * @param[in] recorder The handle to media recorder
1145 * @param[out] channel_count The number of audio channel
1146 * @return 0 on success, otherwise a negative error value.
1147 * @retval #RECORDER_ERROR_NONE Successful
1148 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1149 * @see recorder_attr_set_audio_channel()
1151 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count);
1154 * @brief Sets the orientation of video recording data
1156 * This attribute is valid only in video recorder.\n
1157 * @param[in] recorder The handle to media recorder
1158 * @param[in] orientation The orientation of video recording data
1159 * @return 0 on success, otherwise a negative error value.
1160 * @retval #RECORDER_ERROR_NONE Successful
1161 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1162 * @see recorder_attr_get_recording_orientation()
1164 int recorder_attr_set_recording_orientation(recorder_h recorder, recorder_rotation_e orientation);
1167 * @brief Gets the orientation of video recording data
1169 * This attribute is valid only in video recorder.\n
1170 * @param[in] recorder The handle to media recorder
1171 * @param[out] orientation The orientation of video recording data
1172 * @return 0 on success, otherwise a negative error value.
1173 * @retval #RECORDER_ERROR_NONE Successful
1174 * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
1175 * @see recorder_attr_set_recording_orientation()
1177 int recorder_attr_get_recording_orientation(recorder_h recorder, recorder_rotation_e *orientation);
1187 #endif /* __TIZEN_MULTIMEDIA_RECORDER_H__ */