From d72e678b8cb774a1d56a7c9a37c333b2a1639ecc Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Wed, 27 May 2015 15:18:03 +0900 Subject: Update latest code Change-Id: I20606833ed7f44f9f534e2272bf960816b49b7e7 Signed-off-by: Jeongmo Yang --- CMakeLists.txt | 8 +- include/recorder.h | 337 +++--- include/recorder_private.h | 18 +- packaging/capi-media-recorder.spec | 4 +- src/recorder.c | 2324 +++++++++++++++++++++++------------- 5 files changed, 1655 insertions(+), 1036 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2e9d41..ec1ae86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(Services +SET(Services "application" "base" "content" @@ -43,7 +43,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Wcast-align -Wcast-qual -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -92,10 +92,10 @@ IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean + DEPENDS clean COMMENT "distribution clean" COMMAND find - ARGS . + ARGS . -not -name config.cmake -and \( -name tester.c -or -name Testing -or diff --git a/include/recorder.h b/include/recorder.h index 2ba1392..857f1f6 100644 --- a/include/recorder.h +++ b/include/recorder.h @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and -* limitations under the License. +* limitations under the License. */ #ifndef __TIZEN_MULTIMEDIA_RECORDER_H__ @@ -29,7 +29,7 @@ extern "C" { /** * @file recorder.h * @brief This file contains the Recorder API. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ /** @@ -39,35 +39,35 @@ extern "C" { /** * @brief The Media recorder handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct recorder_s *recorder_h; /** * @brief Enumeration for error code of the media recorder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - RECORDER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - RECORDER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - RECORDER_ERROR_INVALID_STATE = RECORDER_ERROR_CLASS | 0x02, /**< Invalid state */ - RECORDER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY , /**< Out of memory */ - RECORDER_ERROR_DEVICE = RECORDER_ERROR_CLASS | 0x04, /**< Device error */ - RECORDER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Internal error */ - RECORDER_ERROR_SOUND_POLICY = RECORDER_ERROR_CLASS | 0x06, /**< Blocked by Audio Session Manager */ - RECORDER_ERROR_SECURITY_RESTRICTED = RECORDER_ERROR_CLASS | 0x07, /**< Restricted by security system policy */ - RECORDER_ERROR_SOUND_POLICY_BY_CALL = RECORDER_ERROR_CLASS | 0x08, /**< Blocked by Audio Session Manager - CALL */ + RECORDER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + RECORDER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + RECORDER_ERROR_INVALID_STATE = RECORDER_ERROR_CLASS | 0x02, /**< Invalid state */ + RECORDER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY , /**< Out of memory */ + RECORDER_ERROR_DEVICE = RECORDER_ERROR_CLASS | 0x04, /**< Device error */ + RECORDER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Internal error */ + RECORDER_ERROR_SOUND_POLICY = RECORDER_ERROR_CLASS | 0x06, /**< Blocked by Audio Session Manager */ + RECORDER_ERROR_SECURITY_RESTRICTED = RECORDER_ERROR_CLASS | 0x07, /**< Restricted by security system policy */ + RECORDER_ERROR_SOUND_POLICY_BY_CALL = RECORDER_ERROR_CLASS | 0x08, /**< Blocked by Audio Session Manager - CALL */ RECORDER_ERROR_SOUND_POLICY_BY_ALARM = RECORDER_ERROR_CLASS | 0x09, /**< Blocked by Audio Session Manager - ALARM */ - RECORDER_ERROR_ESD = RECORDER_ERROR_CLASS | 0x0a, /**< ESD situation */ - RECORDER_ERROR_OUT_OF_STORAGE = RECORDER_ERROR_CLASS | 0x0b, /**< Out of storage */ - RECORDER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< The access to the resources can not be granted */ + RECORDER_ERROR_ESD = RECORDER_ERROR_CLASS | 0x0a, /**< ESD situation */ + RECORDER_ERROR_OUT_OF_STORAGE = RECORDER_ERROR_CLASS | 0x0b, /**< Out of storage */ + RECORDER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< The access to the resources can not be granted */ RECORDER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< The feature is not supported */ } recorder_error_e; /** * @brief Enumeration for recorder states. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -80,7 +80,7 @@ typedef enum /** * @brief Enumeration for the recording limit. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -91,7 +91,7 @@ typedef enum /** * @brief Enumeration for the file container format. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -105,7 +105,7 @@ typedef enum /** * @brief Enumeration for the audio codec. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -118,7 +118,7 @@ typedef enum /** * @brief Enumeration for the video codec. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -130,7 +130,7 @@ typedef enum /** * @brief Enumeration for audio capture devices. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -140,7 +140,7 @@ typedef enum /** * @brief Enumeration for the recorder rotation type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -150,21 +150,9 @@ typedef enum RECORDER_ROTATION_270, /**< 270 degree rotation */ } recorder_rotation_e; -/** - * @brief Enumerations for the recorder flip type. - */ -typedef enum -{ - RECORDER_FLIP_NONE, /**< No Flip */ - RECORDER_FLIP_HORIZONTAL, /**< Horizontal flip */ - RECORDER_FLIP_VERTICAL, /**< Vertical flip */ - RECORDER_FLIP_BOTH /**< Horizontal and vertical flip */ -} recorder_flip_e; - - /** * @brief Enumeration for the recorder policy. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -187,7 +175,7 @@ typedef enum /** * @brief Called when limitation error occurs while recording. * @details The callback function is possible to receive three types of limits: time, size and no-space. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks After being called, recording data is discarded and not written in the recording file. Also the state of recorder is not changed. * @param[in] type The imitation type * @param[in] user_data The user data passed from the callback registration function @@ -200,7 +188,7 @@ typedef void (*recorder_recording_limit_reached_cb)(recorder_recording_limit_typ /** * @brief Called to indicate the recording status. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This callback function is repeatedly invoked during the #RECORDER_STATE_RECORDING state. * @param[in] elapsed_time The time of the recording (milliseconds) * @param[in] file_size The size of the recording file (KB) @@ -214,7 +202,7 @@ typedef void (*recorder_recording_status_cb)(unsigned long long elapsed_time, un /** * @brief Called when the record state is changed. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] previous The previous state of the recorder * @param[in] current The current state of the recorder * @param[in] by_policy @c true if the state is changed by policy, otherwise @c false if the state is not changed @@ -232,7 +220,7 @@ typedef void (*recorder_state_changed_cb)(recorder_state_e previous , recorder_s /** * @brief Called when the recorder is interrupted by a policy. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] policy The policy that is interrupting the recorder * @param[in] previous The previous state of the recorder * @param[in] current The current state of the recorder @@ -243,7 +231,7 @@ typedef void (*recorder_interrupted_cb)(recorder_policy_e policy, recorder_state /** * @brief Called when audio stream data was being delivered just before storing in the recorded file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks The callback function holds the same buffer that will be recorded. \n * So if the user changes the buffer, the result file will contain the buffer. * @remarks The callback is called via internal thread of Frameworks, therefore do not invoke UI API, recorder_unprepare(), recorder_commit() and recorder_cancel() in callback. @@ -259,7 +247,7 @@ typedef void (*recorder_audio_stream_cb)(void* stream, int size, audio_sample_ty /** * @brief Called once for each supported video resolution. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] width The video image width * @param[in] height The video image height * @param[in] user_data The user data passed from the foreach function @@ -271,7 +259,7 @@ typedef bool (*recorder_supported_video_resolution_cb)(int width, int height, vo /** * @brief Called when the error occurred. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This callback informs about the critical error situation. \n * When being invoked, user should release the resource and terminate the application. \n * This error code will be reported. @@ -298,7 +286,7 @@ typedef void (*recorder_error_cb)(recorder_error_e error, recorder_state_e curre /** * @brief Called iteratively to notify about the supported file formats. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] format The format of recording files * @param[in] user_data The user data passed from the foreach function * @return @c true to continue with the next iteration of the loop, \n otherwise @c false to break out of the loop @@ -309,7 +297,7 @@ typedef bool (*recorder_supported_file_format_cb)(recorder_file_format_e format, /** * @brief Called iteratively to notify about the supported audio encoders. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] codec The codec of audio encoder * @param[in] user_data The user data passed from the foreach function * @return @c true to continue with the next iteration of the loop, \n otherwise @c false to break out of the loop @@ -320,7 +308,7 @@ typedef bool (*recorder_supported_audio_encoder_cb)(recorder_audio_codec_e codec /** * @brief Called iteratively to notify about the supported video encoders. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] codec The codec of video encoder * @param[in] user_data The user data passed from the foreach function * @return @c true to continue with the next iteration of the loop, \n otherwise @c false to break out of the loop @@ -340,7 +328,7 @@ typedef bool (*recorder_supported_video_encoder_cb)(recorder_video_codec_e codec /** * @brief Creates a recorder handle to record a video. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks You must release @a recorder using recorder_destroy(). \n @@ -368,7 +356,7 @@ int recorder_create_videorecorder(camera_h camera, recorder_h *recorder); /** * @brief Creates a recorder handle to record an audio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks You must release @a recorder using recorder_destroy(). @@ -389,7 +377,7 @@ int recorder_create_audiorecorder(recorder_h *recorder); /** * @brief Destroys the recorder handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks The video recorder's camera handle is not released by this function. @@ -411,7 +399,7 @@ int recorder_destroy(recorder_h recorder); /** * @brief Prepares the media recorder for recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks Before calling the function, it is required to properly set audio encoder (recorder_set_audio_encoder()), @@ -439,7 +427,7 @@ int recorder_prepare(recorder_h recorder); /** * @brief Resets the media recorder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] recorder The handle to the media recorder @@ -461,7 +449,7 @@ int recorder_unprepare(recorder_h recorder); /** * @brief Starts the recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks If file path has been set to an existing file, this file is removed automatically and updated by new one. \n @@ -495,7 +483,7 @@ int recorder_start(recorder_h recorder); /** * @brief Pauses the recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks Recording can be resumed with recorder_start(). @@ -517,7 +505,7 @@ int recorder_pause(recorder_h recorder); /** * @brief Stops recording and saves the result. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks When you want to record audio or video file, you need to add privilege according to rules below additionally. \n @@ -543,7 +531,7 @@ int recorder_commit(recorder_h recorder); /** * @brief Cancels the recording. * @details The recording data is discarded and not written in the recording file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks When you want to record audio or video file, you need to add privilege according to rules below additionally. \n @@ -568,7 +556,7 @@ int recorder_cancel(recorder_h recorder); /** * @brief Gets the recorder's current state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] state The current state of the recorder * @return @c 0 on success, otherwise a negative error value @@ -581,7 +569,7 @@ int recorder_get_state(recorder_h recorder, recorder_state_e *state); /** * @brief Gets the peak audio input level that was sampled since the last call to this function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks @c 0 dB indicates maximum input level, @c -300 dB indicates minimum input level. * @param[in] recorder The handle to the media recorder * @param[out] dB The audio input level in dB @@ -598,7 +586,7 @@ int recorder_get_audio_level(recorder_h recorder, double *dB); /** * @brief Sets the file path to record. * @details This function sets file path which defines where newly recorded data should be stored. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks If the same file already exists in the file system, then old file will be overwritten. * @param[in] recorder The handle to the media recorder * @param[in] path The recording file path @@ -608,14 +596,14 @@ int recorder_get_audio_level(recorder_h recorder, double *dB); * @retval #RECORDER_ERROR_INVALID_STATE Invalid state * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @pre The recorder state must be #RECORDER_STATE_CREATED by recorder_create() or recorder_unprepare(). + * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY. * @see recorder_get_filename() */ int recorder_set_filename(recorder_h recorder, const char *path); /** * @brief Gets the file path to record. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You must release @a path using free(). * @param[in] recorder The handle to the media recorder * @param[out] path The recording file path @@ -630,7 +618,10 @@ int recorder_get_filename(recorder_h recorder, char **path); /** * @brief Sets the file format for recording media stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Since 2.3.1, it could be returned #RECORDER_ERROR_INVALID_OPERATION \n + * when it's audio recorder and its state is #RECORDER_STATE_READY \n + * because of checking codec compatibility with current encoder. * @param[in] recorder The handle to the media recorder * @param[in] format The media file format * @return @c 0 on success, otherwise a negative error value @@ -639,7 +630,9 @@ int recorder_get_filename(recorder_h recorder, char **path); * @retval #RECORDER_ERROR_INVALID_STATE Invalid state * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @pre The recorder state must be #RECORDER_STATE_CREATED. + * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation (Since 2.3.1) + * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY (for video recorder only).\n + * Since 2.3.1, this API also works for audio recorder when its state is #RECORDER_STATE_READY. * @see recorder_get_file_format() * @see recorder_foreach_supported_file_format() */ @@ -648,7 +641,7 @@ int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format) /** * @brief Gets the file format for recording media stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] format The media file format * @return @c 0 on success, otherwise a negative error value @@ -673,7 +666,7 @@ int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format /** * @brief Retrieves all supported file formats by invoking a specific callback for each supported file format. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The iteration callback * @param[in] user_data The user data to be passed to the callback function @@ -700,9 +693,12 @@ int recorder_foreach_supported_file_format(recorder_h recorder, recorder_support /** * @brief Sets the audio codec for encoding an audio stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You can get available audio encoders by using recorder_foreach_supported_audio_encoder(). \n - * If set to #RECORDER_AUDIO_CODEC_DISABLE, the audio track is not created in recording files. + * If set to #RECORDER_AUDIO_CODEC_DISABLE, the audio track is not created in recording files.\n + * Since 2.3.1, it could be returned #RECORDER_ERROR_INVALID_OPERATION \n + * when it's audio recorder and its state is #RECORDER_STATE_READY \n + * because of checking codec compatibility with current file format. * @param[in] recorder The handle to the media recorder * @param[in] codec The audio codec * @return @c 0 on success, otherwise a negative error value @@ -711,6 +707,7 @@ int recorder_foreach_supported_file_format(recorder_h recorder, recorder_support * @retval #RECORDER_ERROR_INVALID_STATE Invalid state * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported + * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation (Since 2.3.1) * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY. * @see recorder_get_audio_encoder() * @see recorder_foreach_supported_audio_encoder() @@ -719,7 +716,7 @@ int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec /** * @brief Gets the audio codec for encoding an audio stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] codec The audio codec * @return @c 0 on success, otherwise a negative error value @@ -743,7 +740,7 @@ int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *code /** * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The iteration callback * @param[in] user_data The user data to be passed to the callback function @@ -770,7 +767,7 @@ int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_suppo /** * @brief Sets the resolution of the video recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This function should be called before recording (recorder_start()). * @param[in] recorder The handle to the media recorder * @param[in] width The preview width @@ -790,11 +787,11 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height); /** * @brief Gets the resolution of the video recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] width The video width * @param[out] height The video height - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted @@ -804,9 +801,46 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height); */ int recorder_get_video_resolution(recorder_h recorder, int *width, int *height); +/** + * @} +*/ + +/** + * @addtogroup CAPI_MEDIA_RECORDER_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported video resolutions by invoking callback function once for each supported video resolution. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] recorder The handle to the media recorder + * @param[in] foreach_cb The callback function to be invoked + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #RECORDER_ERROR_NONE Successful + * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted + * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported + * @post This function invokes recorder_supported_video_resolution_cb() repeatedly to retrieve each supported video resolution. + * @see recorder_set_video_resolution() + * @see recorder_get_video_resolution() + * @see recorder_supported_video_resolution_cb() + */ +int recorder_foreach_supported_video_resolution(recorder_h recorder, + recorder_supported_video_resolution_cb foreach_cb, void *user_data); + +/** + * @} +*/ + +/** + * @addtogroup CAPI_MEDIA_RECORDER_MODULE + * @{ + */ + /** * @brief Sets the video codec for encoding video stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You can get available video encoders by using recorder_foreach_supported_video_encoder(). * @param[in] recorder The handle to the media recorder * @param[in] codec The video codec @@ -824,7 +858,7 @@ int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec /** * @brief Gets the video codec for encoding video stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] codec The video codec * @return @c 0 on success, otherwise a negative error value @@ -846,28 +880,9 @@ int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *code * @{ */ -/** - * @brief Retrieves all supported video resolutions by invoking callback function once for each supported video resolution. - * @since_tizen 2.3 - * @param[in] recorder The handle to the media recorder - * @param[in] foreach_cb The callback function to be invoked - * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, otherwise a negative error value - * @retval #RECORDER_ERROR_NONE Successful - * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted - * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @post This function invokes recorder_supported_video_resolution_cb() repeatedly to retrieve each supported video resolution. - * @see recorder_set_video_resolution() - * @see recorder_get_video_resolution() - * @see recorder_supported_video_resolution_cb() - */ -int recorder_foreach_supported_video_resolution(recorder_h recorder, - recorder_supported_video_resolution_cb foreach_cb, void *user_data); - /** * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The iteration callback * @param[in] user_data The user data to be passed to the callback function @@ -894,7 +909,7 @@ int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_suppo /** * @brief Registers the callback function that will be invoked when the recorder state changes. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The function pointer of user callback * @param[in] user_data The user data to be passed to the callback function @@ -911,7 +926,7 @@ int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful @@ -924,7 +939,7 @@ int recorder_unset_state_changed_cb(recorder_h recorder); /** * @brief Registers a callback function to be called when the media recorder is interrupted according to a policy. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -941,7 +956,7 @@ int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb cal /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful @@ -954,7 +969,7 @@ int recorder_unset_interrupted_cb(recorder_h recorder); /** * @brief Registers a callback function to be called when audio stream data is being delivered. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This callback function holds the same buffer that will be recorded. \n * Therefore if an user changes the buffer, the result file will have the buffer. \n * @remarks The callback is called via internal thread of Frameworks. Therefore do not invoke UI API, recorder_unprepare(), recorder_commit() and recorder_cancel() in callback.\n @@ -976,20 +991,20 @@ int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb c /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @see recorder_set_audio_stream_cb() + * @see recorder_set_audio_stream_cb() */ int recorder_unset_audio_stream_cb(recorder_h recorder); /** * @brief Registers a callback function to be invoked when the recording information changes. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] callback The function pointer of user callback * @param[in] user_data The user data to be passed to the callback function @@ -1006,7 +1021,7 @@ int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_sta /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful @@ -1019,7 +1034,7 @@ int recorder_unset_recording_status_cb(recorder_h recorder); /** * @brief Registers the callback function to be run when reached the recording limit. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to media recorder * @param[in] callback The function pointer of user callback * @param[in] user_data The user data to be passed to the callback function @@ -1038,7 +1053,7 @@ int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_record /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful @@ -1051,7 +1066,7 @@ int recorder_unset_recording_limit_reached_cb(recorder_h recorder); /** * @brief Registers a callback function to be called when an asynchronous operation error occurred. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This callback informs critical error situation.\n * When this callback is invoked, user should release the resource and terminate the application. \n * These error codes will occur. \n @@ -1075,7 +1090,7 @@ int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the recorder * @return @c on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful @@ -1099,7 +1114,7 @@ int recorder_unset_error_cb(recorder_h recorder); /** * @brief Sets the maximum size of a recording file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks After reaching the limitation, the recording data is discarded and not written in the recording file. * @param[in] recorder The handle to the media recorder * @param[in] kbyte The maximum size of the recording file(KB) \n @@ -1118,7 +1133,7 @@ int recorder_attr_set_size_limit(recorder_h recorder, int kbyte); /** * @brief Gets the maximum size of a recording file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] kbyte The maximum size of recording file (KB) \n * @c 0 means unlimited recording size. @@ -1134,7 +1149,7 @@ int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte); /** * @brief Sets the time limit of a recording file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks After reaching the limitation, the recording data is discarded and not written in the recording file. * @param[in] recorder The handle to the media recorder * @param[in] second The time limit of the recording file (in seconds) \n @@ -1154,7 +1169,7 @@ int recorder_attr_set_time_limit(recorder_h recorder, int second); /** * @brief Gets the time limit of a recording file. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] second The time limit of the recording file (in seconds) \n * @c 0 means unlimited recording time. @@ -1170,7 +1185,7 @@ int recorder_attr_get_time_limit(recorder_h recorder, int *second); /** * @brief Sets the audio device for recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] device The type of an audio device * @return @c 0 on success, otherwise a negative error value @@ -1179,14 +1194,15 @@ int recorder_attr_get_time_limit(recorder_h recorder, int *second); * @retval #RECORDER_ERROR_INVALID_STATE Invalid state * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @pre The recorder state must be #RECORDER_STATE_CREATED. + * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY (for video recorder only).\n + * Since 2.3.1, this API also works for audio recorder when its state is #RECORDER_STATE_READY. * @see recorder_attr_get_audio_device() */ int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device); /** * @brief Gets the audio device for recording. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] device The type of an audio device * @return @c 0 on success, otherwise a negative error value @@ -1200,7 +1216,7 @@ int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e /** * @brief Sets the sampling rate of an audio stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] samplerate The sample rate in Hertz * @return @c 0 on success, otherwise a negative error value @@ -1209,14 +1225,15 @@ int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e * @retval #RECORDER_ERROR_INVALID_STATE Invalid state * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @pre The recorder state must be #RECORDER_STATE_CREATED. + * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY (for video recorder only).\n + * Since 2.3.1, this API also works for audio recorder when its state is #RECORDER_STATE_READY. * @see recorder_attr_get_audio_samplerate() */ int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate); /** * @brief Gets the sampling rate of an audio stream. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] samplerate The sample rate in Hertz * @return @c 0 on success, otherwise a negative error value @@ -1230,7 +1247,7 @@ int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate); /** * @brief Sets the bitrate of an audio encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] bitrate The bitrate (for mms : 12200[bps], normal : 288000[bps]) * @return @c 0 on success, otherwise a negative error value @@ -1246,7 +1263,7 @@ int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate); /** * @brief Sets the bitrate of a video encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] bitrate The bitrate in bits per second * @return @c 0 on success, otherwise a negative error value @@ -1262,7 +1279,7 @@ int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate); /** * @brief Gets the bitrate of an audio encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] bitrate The bitrate in bits per second * @return @c 0 on success, otherwise a negative error value @@ -1276,7 +1293,7 @@ int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate); /** * @brief Gets the bitrate of a video encoder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] bitrate The bitrate in bits per second * @return @c 0 on success, otherwise a negative error value @@ -1290,7 +1307,7 @@ int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate); /** * @brief Sets the mute state of a recorder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[in] enable The mute state * @return @c 0 on success, otherwise a negative error value @@ -1304,7 +1321,7 @@ int recorder_attr_set_mute(recorder_h recorder, bool enable); /** * @brief Gets the mute state of a recorder. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. * @return @c true if the recorder is not recording any sound, @@ -1319,7 +1336,7 @@ bool recorder_attr_is_muted(recorder_h recorder); /** * @brief Sets the recording motion rate. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This attribute is valid only in a video recorder. \n * If the rate bigger than @c 0 and smaller than @c 1, video is recorded in a slow motion mode. \n * If the rate bigger than @c 1, video is recorded in a fast motion mode (time lapse recording). @@ -1340,7 +1357,7 @@ int recorder_attr_set_recording_motion_rate(recorder_h recorder , double rate); /** * @brief Gets the recording motion rate. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This attribute is valid only in a video recorder. \n * If the rate bigger than @c 0 and smaller than @c 1, video is recorded in a slow motion mode. \n * If the rate bigger than @c 1, video is recorded in a fast motion mode (time lapse recording). @@ -1358,12 +1375,9 @@ int recorder_attr_set_recording_motion_rate(recorder_h recorder , double rate); */ int recorder_attr_get_recording_motion_rate(recorder_h recorder , double *rate); -__attribute__ ((deprecated)) int recorder_attr_set_slow_motion_rate(recorder_h recorder , double rate); -__attribute__ ((deprecated)) int recorder_attr_get_slow_motion_rate(recorder_h recorder , double *rate); - /** * @brief Sets the number of the audio channel. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This attribute is applied only in RECORDER_STATE_CREATED state. \n * For mono recording, setting channel to @c 1. \n * For stereo recording, setting channel to @c 2. @@ -1374,14 +1388,15 @@ __attribute__ ((deprecated)) int recorder_attr_get_slow_motion_rate(recorder_h r * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted * @retval #RECORDER_ERROR_NOT_SUPPORTED The feature is not supported - * @pre The recorder state must be #RECORDER_STATE_CREATED. + * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY (for video recorder only).\n + * Since 2.3.1, this API also works for audio recorder when its state is #RECORDER_STATE_READY. * @see recorder_attr_get_audio_channel() */ int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count); /** * @brief Gets the number of the audio channel. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to the media recorder * @param[out] channel_count The number of the audio channel * @return @c 0 on success, otherwise a negative error value @@ -1393,67 +1408,13 @@ int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count); */ int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count); -/** - * @brief Sets the orientation of video recording data - * @remarks - * This attribute is valid only in video recorder.\n - * This attribute is applied in video encoding. - * @param[in] recorder The handle to media recorder - * @param[in] orientation The orientation of video recording data - * @return 0 on success, otherwise a negative error value. - * @retval #RECORDER_ERROR_NONE Successful - * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter - * @see recorder_attr_get_recording_orientation() - */ -__attribute__ ((deprecated)) int recorder_attr_set_recording_orientation(recorder_h recorder, recorder_rotation_e orientation); - -/** - * @brief Gets the orientation of video recording data - * @remarks - * This attribute is valid only in video recorder.\n - * @param[in] recorder The handle to media recorder - * @param[out] orientation The orientation of video recording data - * @return 0 on success, otherwise a negative error value. - * @retval #RECORDER_ERROR_NONE Successful - * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter - * @see recorder_attr_set_recording_orientation() - */ -__attribute__ ((deprecated)) int recorder_attr_get_recording_orientation(recorder_h recorder, recorder_rotation_e *orientation); - -/** - * @brief Sets the flip of video recording data - * @remarks - * This attribute is valid only in video recorder.\n - * This attribute is applied in video encoding. - * @param[in] recorder The handle to media recorder - * @param[in] flip The flip of video recording data - * @return 0 on success, otherwise a negative error value. - * @retval #RECORDER_ERROR_NONE Successful - * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter - * @see recorder_attr_get_recording_flip() - */ -__attribute__ ((deprecated)) int recorder_attr_set_recording_flip(recorder_h recorder, recorder_flip_e flip); - -/** - * @brief Gets the flip of video recording data - * @remarks - * This attribute is valid only in video recorder.\n - * This attribute is applied in video encoding. - * @param[in] recorder The handle to media recorder - * @param[out] flip The flip of video recording data - * @return 0 on success, otherwise a negative error value. - * @retval #RECORDER_ERROR_NONE Successful - * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter - * @see recorder_attr_set_recording_flip() - */ -__attribute__ ((deprecated)) int recorder_attr_get_recording_flip(recorder_h recorder, recorder_flip_e *flip); /** * @brief Sets the video orientation in a video metadata tag. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to a media recorder * @param[in] orientation The information of the video orientation - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted @@ -1464,10 +1425,10 @@ int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e /** * @brief Gets the video orientation in a video metadata tag. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] recorder The handle to a media recorder * @param[out] orientation The information of the video orientation -* @return @c 0 on success, otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #RECORDER_ERROR_NONE Successful * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RECORDER_ERROR_PERMISSION_DENIED The access to the resources can not be granted diff --git a/include/recorder_private.h b/include/recorder_private.h index 50ec96c..efcf0ed 100644 --- a/include/recorder_private.h +++ b/include/recorder_private.h @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and -* limitations under the License. +* limitations under the License. */ @@ -33,33 +33,39 @@ typedef union _mediaSource{ typedef enum { _RECORDER_EVENT_TYPE_STATE_CHANGE, - _RECORDER_EVENT_TYPE_RECORDING_LIMITED, + _RECORDER_EVENT_TYPE_RECORDING_LIMITED, _RECORDER_EVENT_TYPE_RECORDING_STATUS, _RECORDER_EVENT_TYPE_INTERRUPTED, - _RECORDER_EVENT_TYPE_INTERRUPT_COMPLETED, _RECORDER_EVENT_TYPE_AUDIO_STREAM, _RECORDER_EVENT_TYPE_ERROR, _RECORDER_EVENT_TYPE_NUM }_recorder_event_e; typedef enum { - _RECORDER_TYPE_AUDIO= 0, + _RECORDER_TYPE_AUDIO = 0, _RECORDER_TYPE_VIDEO }_recorder_type_e; +typedef enum { + _RECORDER_SOURCE_TYPE_UNKNOWN, + _RECORDER_SOURCE_TYPE_CAMERA, +}_recorder_source_type_e; + typedef struct _recorder_s{ MMHandleType mm_handle; mediasource mm_source; void* user_cb[_RECORDER_EVENT_TYPE_NUM]; void* user_data[_RECORDER_EVENT_TYPE_NUM]; unsigned int state; - _recorder_type_e type; + int camera_device_count; + _recorder_type_e type; + _recorder_source_type_e src_type; int origin_preview_format; int changed_preview_format; double last_max_input_level; } recorder_s; -static int __convert_recorder_error_code(const char *func, int code); +int __convert_recorder_error_code(const char *func, int code); #ifdef __cplusplus } #endif diff --git a/packaging/capi-media-recorder.spec b/packaging/capi-media-recorder.spec index 616a59f..f3e6be8 100644 --- a/packaging/capi-media-recorder.spec +++ b/packaging/capi-media-recorder.spec @@ -1,7 +1,7 @@ Name: capi-media-recorder Summary: A Recorder library in Tizen Native API -Version: 0.2.1 -Release: 1 +Version: 0.2.2 +Release: 0 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/recorder.c b/src/recorder.c index 9654fd0..7182596 100644 --- a/src/recorder.c +++ b/src/recorder.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,7 @@ /* - * camera_private function + * camera_private function */ int _camera_get_mm_handle(camera_h camera , MMHandleType *handle); int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data); @@ -56,349 +55,475 @@ static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *us static int __mm_recorder_msg_cb(int message, void *param, void *user_data); -static int __convert_error_code_camera_to_recorder(int code){ +static int __convert_error_code_camera_to_recorder(int code) +{ int new_code = code; - switch(code) - { - case CAMERA_ERROR_INVALID_STATE : - new_code = RECORDER_ERROR_INVALID_STATE; - break; - case CAMERA_ERROR_DEVICE: - new_code = RECORDER_ERROR_DEVICE; - break; - case CAMERA_ERROR_SOUND_POLICY: - new_code = RECORDER_ERROR_SOUND_POLICY; - break; - case CAMERA_ERROR_SECURITY_RESTRICTED: - new_code = RECORDER_ERROR_SECURITY_RESTRICTED; - break; - default: - break; + + switch (code) { + case CAMERA_ERROR_INVALID_STATE : + new_code = RECORDER_ERROR_INVALID_STATE; + break; + case CAMERA_ERROR_DEVICE: + new_code = RECORDER_ERROR_DEVICE; + break; + case CAMERA_ERROR_SOUND_POLICY: + new_code = RECORDER_ERROR_SOUND_POLICY; + break; + case CAMERA_ERROR_SECURITY_RESTRICTED: + new_code = RECORDER_ERROR_SECURITY_RESTRICTED; + break; + default: + break; } + return new_code; } -static int __convert_recorder_error_code(const char *func, int code){ + +int __convert_recorder_error_code(const char *func, int code) +{ int ret = RECORDER_ERROR_INVALID_OPERATION; const char *errorstr = NULL; - switch(code) - { - case RECORDER_ERROR_INVALID_PARAMETER: - ret = RECORDER_ERROR_INVALID_PARAMETER; - errorstr = "INVALID_PARAMETER"; - break; - case MM_ERROR_NONE: - ret = RECORDER_ERROR_NONE; - errorstr = "ERROR_NONE"; - break; - case MM_ERROR_CAMCORDER_INVALID_ARGUMENT : - case MM_ERROR_COMMON_INVALID_ATTRTYPE : - case MM_ERROR_COMMON_OUT_OF_ARRAY : - case MM_ERROR_COMMON_OUT_OF_RANGE : - case MM_ERROR_COMMON_ATTR_NOT_EXIST : - ret = RECORDER_ERROR_INVALID_PARAMETER; - errorstr = "INVALID_PARAMETER"; - break; - case MM_ERROR_COMMON_INVALID_PERMISSION : - ret = RECORDER_ERROR_PERMISSION_DENIED; - errorstr = "ERROR_PERMISSION_DENIED"; - break; - case MM_ERROR_CAMCORDER_NOT_INITIALIZED : - case MM_ERROR_CAMCORDER_INVALID_STATE : - ret = RECORDER_ERROR_INVALID_STATE; - errorstr = "INVALID_STATE"; - break; - - case MM_ERROR_CAMCORDER_DEVICE : - case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND : - case MM_ERROR_CAMCORDER_DEVICE_BUSY : - case MM_ERROR_CAMCORDER_DEVICE_OPEN : - case MM_ERROR_CAMCORDER_DEVICE_IO : - case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT : - case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG : - case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER : - ret = RECORDER_ERROR_DEVICE; - errorstr = "ERROR_DEVICE"; - break; - - case MM_ERROR_CAMCORDER_GST_CORE : - case MM_ERROR_CAMCORDER_GST_LIBRARY : - case MM_ERROR_CAMCORDER_GST_RESOURCE : - case MM_ERROR_CAMCORDER_GST_STREAM : - case MM_ERROR_CAMCORDER_GST_STATECHANGE : - case MM_ERROR_CAMCORDER_GST_NEGOTIATION : - case MM_ERROR_CAMCORDER_GST_LINK : - case MM_ERROR_CAMCORDER_GST_FLOW_ERROR : - case MM_ERROR_CAMCORDER_ENCODER : - case MM_ERROR_CAMCORDER_ENCODER_BUFFER : - case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE : - case MM_ERROR_CAMCORDER_ENCODER_WORKING : - case MM_ERROR_CAMCORDER_INTERNAL : - case MM_ERROR_CAMCORDER_NOT_SUPPORTED : - case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT : - case MM_ERROR_CAMCORDER_CMD_IS_RUNNING : - case MM_ERROR_CAMCORDER_DSP_FAIL : - case MM_ERROR_CAMCORDER_AUDIO_EMPTY : - case MM_ERROR_CAMCORDER_CREATE_CONFIGURE : - case MM_ERROR_CAMCORDER_FILE_SIZE_OVER : - case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF : - case MM_ERROR_CAMCORDER_INVALID_CONDITION : - ret = RECORDER_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - break; - case MM_ERROR_CAMCORDER_RESOURCE_CREATION : - case MM_ERROR_COMMON_OUT_OF_MEMORY: - ret = RECORDER_ERROR_OUT_OF_MEMORY; - errorstr = "OUT_OF_MEMORY"; - break; - - case MM_ERROR_POLICY_BLOCKED: - ret = RECORDER_ERROR_SOUND_POLICY; - errorstr = "ERROR_SOUND_POLICY"; - break; - - case MM_ERROR_POLICY_BLOCKED_BY_CALL: - ret = RECORDER_ERROR_SOUND_POLICY_BY_CALL; - errorstr = "ERROR_SOUND_POLICY_BY_CALL"; - break; - - case MM_ERROR_POLICY_BLOCKED_BY_ALARM: - ret = RECORDER_ERROR_SOUND_POLICY_BY_ALARM; - errorstr = "ERROR_SOUND_POLICY_BY_ALARM"; - break; - - case MM_ERROR_POLICY_RESTRICTED: - ret = RECORDER_ERROR_SECURITY_RESTRICTED; - errorstr = "ERROR_RESTRICTED"; - break; - - case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE: - ret = RECORDER_ERROR_ESD; - errorstr = "ERROR_ESD"; - break; - - case MM_ERROR_OUT_OF_STORAGE: - ret = RECORDER_ERROR_OUT_OF_STORAGE; - errorstr = "OUT_OF_STORAGE"; - break; - - default: - ret = RECORDER_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - + switch (code) { + case RECORDER_ERROR_INVALID_PARAMETER: + ret = RECORDER_ERROR_INVALID_PARAMETER; + errorstr = "INVALID_PARAMETER"; + break; + case MM_ERROR_NONE: + ret = RECORDER_ERROR_NONE; + errorstr = "ERROR_NONE"; + break; + case MM_ERROR_CAMCORDER_INVALID_ARGUMENT : + case MM_ERROR_COMMON_INVALID_ATTRTYPE : + ret = RECORDER_ERROR_INVALID_PARAMETER; + errorstr = "INVALID_PARAMETER"; + break; + case MM_ERROR_COMMON_INVALID_PERMISSION : + ret = RECORDER_ERROR_PERMISSION_DENIED; + errorstr = "ERROR_PERMISSION_DENIED"; + break; + case MM_ERROR_CAMCORDER_NOT_INITIALIZED : + case MM_ERROR_CAMCORDER_INVALID_STATE : + ret = RECORDER_ERROR_INVALID_STATE; + errorstr = "INVALID_STATE"; + break; + case MM_ERROR_CAMCORDER_DEVICE : + case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND : + case MM_ERROR_CAMCORDER_DEVICE_BUSY : + case MM_ERROR_CAMCORDER_DEVICE_OPEN : + case MM_ERROR_CAMCORDER_DEVICE_IO : + case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT : + case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG : + case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER : + ret = RECORDER_ERROR_DEVICE; + errorstr = "ERROR_DEVICE"; + break; + case MM_ERROR_CAMCORDER_GST_CORE : + case MM_ERROR_CAMCORDER_GST_LIBRARY : + case MM_ERROR_CAMCORDER_GST_RESOURCE : + case MM_ERROR_CAMCORDER_GST_STREAM : + case MM_ERROR_CAMCORDER_GST_STATECHANGE : + case MM_ERROR_CAMCORDER_GST_NEGOTIATION : + case MM_ERROR_CAMCORDER_GST_LINK : + case MM_ERROR_CAMCORDER_GST_FLOW_ERROR : + case MM_ERROR_CAMCORDER_ENCODER : + case MM_ERROR_CAMCORDER_ENCODER_BUFFER : + case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE : + case MM_ERROR_CAMCORDER_ENCODER_WORKING : + case MM_ERROR_CAMCORDER_INTERNAL : + case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT : + case MM_ERROR_CAMCORDER_CMD_IS_RUNNING : + case MM_ERROR_CAMCORDER_DSP_FAIL : + case MM_ERROR_CAMCORDER_AUDIO_EMPTY : + case MM_ERROR_CAMCORDER_CREATE_CONFIGURE : + case MM_ERROR_CAMCORDER_FILE_SIZE_OVER : + case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF : + case MM_ERROR_CAMCORDER_INVALID_CONDITION : + ret = RECORDER_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + break; + case MM_ERROR_CAMCORDER_RESOURCE_CREATION : + case MM_ERROR_COMMON_OUT_OF_MEMORY: + ret = RECORDER_ERROR_OUT_OF_MEMORY; + errorstr = "OUT_OF_MEMORY"; + break; + case MM_ERROR_POLICY_BLOCKED: + ret = RECORDER_ERROR_SOUND_POLICY; + errorstr = "ERROR_SOUND_POLICY"; + break; + case MM_ERROR_POLICY_BLOCKED_BY_CALL: + ret = RECORDER_ERROR_SOUND_POLICY_BY_CALL; + errorstr = "ERROR_SOUND_POLICY_BY_CALL"; + break; + case MM_ERROR_POLICY_BLOCKED_BY_ALARM: + ret = RECORDER_ERROR_SOUND_POLICY_BY_ALARM; + errorstr = "ERROR_SOUND_POLICY_BY_ALARM"; + break; + case MM_ERROR_POLICY_RESTRICTED: + ret = RECORDER_ERROR_SECURITY_RESTRICTED; + errorstr = "ERROR_RESTRICTED"; + break; + case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE: + ret = RECORDER_ERROR_ESD; + errorstr = "ERROR_ESD"; + break; + case MM_ERROR_OUT_OF_STORAGE: + ret = RECORDER_ERROR_OUT_OF_STORAGE; + errorstr = "OUT_OF_STORAGE"; + break; + case MM_ERROR_COMMON_OUT_OF_ARRAY: + case MM_ERROR_COMMON_OUT_OF_RANGE: + case MM_ERROR_COMMON_ATTR_NOT_EXIST: + case MM_ERROR_CAMCORDER_NOT_SUPPORTED: + ret = RECORDER_ERROR_NOT_SUPPORTED; + errorstr = "NOT_SUPPORTED"; + break; + default: + ret = RECORDER_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + break; } - LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code); - + LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, code); return ret; } -static recorder_state_e __recorder_state_convert(MMCamcorderStateType mm_state ) + +static recorder_state_e __recorder_state_convert(MMCamcorderStateType mm_state) { recorder_state_e state = RECORDER_STATE_NONE; - switch( mm_state ){ - case MM_CAMCORDER_STATE_NONE: - state = RECORDER_STATE_NONE; - break; - case MM_CAMCORDER_STATE_NULL: - state = RECORDER_STATE_CREATED; - break; - case MM_CAMCORDER_STATE_READY: - state = RECORDER_STATE_CREATED; - break; - case MM_CAMCORDER_STATE_PREPARE: - state = RECORDER_STATE_READY; - break; - case MM_CAMCORDER_STATE_CAPTURING: - state = RECORDER_STATE_READY; - break; - case MM_CAMCORDER_STATE_RECORDING: - state = RECORDER_STATE_RECORDING; - break; - case MM_CAMCORDER_STATE_PAUSED: - state = RECORDER_STATE_PAUSED; - break; - default: - state = RECORDER_STATE_NONE; - break; + switch (mm_state) { + case MM_CAMCORDER_STATE_NONE: + state = RECORDER_STATE_NONE; + break; + case MM_CAMCORDER_STATE_NULL: + state = RECORDER_STATE_CREATED; + break; + case MM_CAMCORDER_STATE_READY: + state = RECORDER_STATE_CREATED; + break; + case MM_CAMCORDER_STATE_PREPARE: + state = RECORDER_STATE_READY; + break; + case MM_CAMCORDER_STATE_CAPTURING: + state = RECORDER_STATE_READY; + break; + case MM_CAMCORDER_STATE_RECORDING: + state = RECORDER_STATE_RECORDING; + break; + case MM_CAMCORDER_STATE_PAUSED: + state = RECORDER_STATE_PAUSED; + break; + default: + state = RECORDER_STATE_NONE; + break; } return state; } -static int __mm_recorder_msg_cb(int message, void *param, void *user_data){ - recorder_s * handle = (recorder_s*)user_data; - MMMessageParamType *m = (MMMessageParamType*)param; - recorder_state_e previous_state; - - switch(message){ - case MM_MESSAGE_CAMCORDER_STATE_CHANGED: - case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM: - case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY: - previous_state = handle->state; - handle->state = __recorder_state_convert(m->state.current); - recorder_policy_e policy = RECORDER_POLICY_NONE; - if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) { - switch (m->state.code) { - case ASM_EVENT_SOURCE_CALL_START: - policy = RECORDER_POLICY_SOUND_BY_CALL; - LOGE("RECORDER_POLICY_SOUND_BY_CALL"); - break; - case ASM_EVENT_SOURCE_ALARM_START: - case ASM_EVENT_SOURCE_ALARM_END: - policy = RECORDER_POLICY_SOUND_BY_ALARM; - LOGE("RECORDER_POLICY_SOUND_BY_ALARM"); - break; - default: - policy = RECORDER_POLICY_SOUND; - LOGE("RECORDER_POLICY_SOUND"); - break; - } - } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) { - policy = RECORDER_POLICY_SECURITY; - LOGE("RECORDER_POLICY_SECURITY"); - } - - if( previous_state != handle->state && handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] ){ - ((recorder_state_changed_cb)handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy , handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE]); - } - // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state - if (policy != RECORDER_POLICY_NONE && - (m->state.current == MM_CAMCORDER_STATE_PAUSED || m->state.current == MM_CAMCORDER_STATE_NULL)) { - if (handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED]) { - ((recorder_interrupted_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED]); - } else { - LOGW("_RECORDER_EVENT_TYPE_INTERRUPTED cb is NULL"); - } - } +static int __mm_recorder_msg_cb(int message, void *param, void *user_data) +{ + recorder_s * handle = (recorder_s *)user_data; + MMMessageParamType *m = (MMMessageParamType *)param; + recorder_state_e previous_state; + recorder_recording_limit_type_e type; + int recorder_error = 0; + + switch (message) { + case MM_MESSAGE_READY_TO_RESUME: + LOGW("not supported message"); + break; + case MM_MESSAGE_CAMCORDER_STATE_CHANGED: + case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM: + case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY: + previous_state = handle->state; + handle->state = __recorder_state_convert(m->state.current); + recorder_policy_e policy = RECORDER_POLICY_NONE; + if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) { + switch (m->state.code) { + case ASM_EVENT_SOURCE_CALL_START: + case ASM_EVENT_SOURCE_CALL_END: + policy = RECORDER_POLICY_SOUND_BY_CALL; + LOGE("RECORDER_POLICY_SOUND_BY_CALL"); + break; + case ASM_EVENT_SOURCE_ALARM_START: + case ASM_EVENT_SOURCE_ALARM_END: + policy = RECORDER_POLICY_SOUND_BY_ALARM; + LOGE("RECORDER_POLICY_SOUND_BY_ALARM"); + break; + default: + policy = RECORDER_POLICY_SOUND; + LOGE("RECORDER_POLICY_SOUND"); break; - case MM_MESSAGE_CAMCORDER_MAX_SIZE: - case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE: - case MM_MESSAGE_CAMCORDER_TIME_LIMIT: - { - recorder_recording_limit_type_e type ; - if( MM_MESSAGE_CAMCORDER_MAX_SIZE == message ) - type = RECORDER_RECORDING_LIMIT_SIZE; - else if( MM_MESSAGE_CAMCORDER_NO_FREE_SPACE == message) - type = RECORDER_RECORDING_LIMIT_FREE_SPACE; - else - type = RECORDER_RECORDING_LIMIT_TIME; - if( handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] ){ - ((recorder_recording_limit_reached_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED])(type, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); - } - } - break; - case MM_MESSAGE_CAMCORDER_RECORDING_STATUS: - if( handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] ){ - ((recorder_recording_status_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS])( m->recording_status.elapsed, m->recording_status.filesize, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS]); } - break; - case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED: - case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED: - { - if( handle->type == _RECORDER_TYPE_AUDIO ){ - MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data; - if( report != NULL && report->recording_filename ){ - free(report->recording_filename ); - report->recording_filename = NULL; - } - if( report ){ - free(report); - report = NULL; - } + } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) { + policy = RECORDER_POLICY_SECURITY; + LOGE("RECORDER_POLICY_SECURITY"); + } + + if (previous_state != handle->state && handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE]) { + ((recorder_state_changed_cb)handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy, handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE]); + } + + /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */ + if (policy != RECORDER_POLICY_NONE && + (m->state.current == MM_CAMCORDER_STATE_PAUSED || m->state.current == MM_CAMCORDER_STATE_NULL)) { + if (handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED]) { + ((recorder_interrupted_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED]); + } else { + LOGW("_RECORDER_EVENT_TYPE_INTERRUPTED cb is NULL"); } - break; } - case MM_MESSAGE_CAMCORDER_ERROR: - { - int errorcode = m->code; - int recorder_error = 0; - switch( errorcode ){ - case MM_ERROR_CAMCORDER_DEVICE : - case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT : - case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG : - recorder_error = RECORDER_ERROR_DEVICE; - break; - case MM_ERROR_CAMCORDER_GST_CORE : - case MM_ERROR_CAMCORDER_GST_LIBRARY : - case MM_ERROR_CAMCORDER_GST_RESOURCE : - case MM_ERROR_CAMCORDER_GST_STREAM : - case MM_ERROR_CAMCORDER_GST_NEGOTIATION : - case MM_ERROR_CAMCORDER_GST_FLOW_ERROR : - case MM_ERROR_CAMCORDER_ENCODER : - case MM_ERROR_CAMCORDER_ENCODER_BUFFER : - case MM_ERROR_CAMCORDER_ENCODER_WORKING : - case MM_ERROR_CAMCORDER_MNOTE_CREATION : - case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY : - case MM_ERROR_CAMCORDER_INTERNAL : - case MM_ERROR_FILE_NOT_FOUND: - case MM_ERROR_FILE_READ: - recorder_error = RECORDER_ERROR_INVALID_OPERATION; - break; - case MM_ERROR_CAMCORDER_LOW_MEMORY : - case MM_ERROR_CAMCORDER_MNOTE_MALLOC : - recorder_error = RECORDER_ERROR_OUT_OF_MEMORY; - break; - case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE: - recorder_error = RECORDER_ERROR_ESD; - break; - case MM_ERROR_OUT_OF_STORAGE: - recorder_error = RECORDER_ERROR_OUT_OF_STORAGE; - break; - default: - recorder_error = RECORDER_ERROR_INVALID_OPERATION; - break; + break; + case MM_MESSAGE_CAMCORDER_MAX_SIZE: + case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE: + case MM_MESSAGE_CAMCORDER_TIME_LIMIT: + if (MM_MESSAGE_CAMCORDER_MAX_SIZE == message) { + type = RECORDER_RECORDING_LIMIT_SIZE; + } else if (MM_MESSAGE_CAMCORDER_NO_FREE_SPACE == message) { + type = RECORDER_RECORDING_LIMIT_FREE_SPACE; + } else { + type = RECORDER_RECORDING_LIMIT_TIME; + } + if (handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED]) { + ((recorder_recording_limit_reached_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED])(type, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); + } + break; + case MM_MESSAGE_CAMCORDER_RECORDING_STATUS: + if (handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS]) { + ((recorder_recording_status_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS])(m->recording_status.elapsed, m->recording_status.filesize, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS]); + } + break; + case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED: + case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED: + if (handle->type == _RECORDER_TYPE_AUDIO) { + MMCamRecordingReport *report = (MMCamRecordingReport *)m->data; + if (report != NULL && report->recording_filename) { + free(report->recording_filename); + report->recording_filename = NULL; + } + if (report) { + free(report); + report = NULL; } - if( recorder_error != 0 && handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] ) - ((recorder_error_cb)handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])(errorcode, handle->state , handle->user_data[_RECORDER_EVENT_TYPE_ERROR]); - break; } - case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME: - if( handle->last_max_input_level < m->rec_volume_dB ) - handle->last_max_input_level = m->rec_volume_dB; + break; + case MM_MESSAGE_CAMCORDER_ERROR: + switch (m->code) { + case MM_ERROR_CAMCORDER_DEVICE: + case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT: + case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG: + recorder_error = RECORDER_ERROR_DEVICE; + break; + case MM_ERROR_CAMCORDER_GST_CORE: + case MM_ERROR_CAMCORDER_GST_LIBRARY: + case MM_ERROR_CAMCORDER_GST_RESOURCE: + case MM_ERROR_CAMCORDER_GST_STREAM: + case MM_ERROR_CAMCORDER_GST_NEGOTIATION: + case MM_ERROR_CAMCORDER_GST_FLOW_ERROR: + case MM_ERROR_CAMCORDER_ENCODER: + case MM_ERROR_CAMCORDER_ENCODER_BUFFER: + case MM_ERROR_CAMCORDER_ENCODER_WORKING: + case MM_ERROR_CAMCORDER_MNOTE_CREATION: + case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY: + case MM_ERROR_CAMCORDER_INTERNAL: + case MM_ERROR_FILE_NOT_FOUND: + case MM_ERROR_FILE_READ: + recorder_error = RECORDER_ERROR_INVALID_OPERATION; + break; + case MM_ERROR_CAMCORDER_LOW_MEMORY: + case MM_ERROR_CAMCORDER_MNOTE_MALLOC: + recorder_error = RECORDER_ERROR_OUT_OF_MEMORY; + break; + case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE: + recorder_error = RECORDER_ERROR_ESD; + break; + case MM_ERROR_OUT_OF_STORAGE: + recorder_error = RECORDER_ERROR_OUT_OF_STORAGE; break; default: + recorder_error = RECORDER_ERROR_INVALID_OPERATION; break; + } + + if (recorder_error != 0 && handle->user_cb[_RECORDER_EVENT_TYPE_ERROR]) { + ((recorder_error_cb)handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])(recorder_error, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_ERROR]); + } + break; + case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME: + if (handle->last_max_input_level < m->rec_volume_dB) { + handle->last_max_input_level = m->rec_volume_dB; + } + break; + default: + break; } return 1; } -static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param){ - if( user_param == NULL || stream == NULL) + +static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param) +{ + if (user_param == NULL || stream == NULL) { return 0; + } - recorder_s * handle = (recorder_s*)user_param; + recorder_s *handle = (recorder_s *)user_param; audio_sample_type_e format = AUDIO_SAMPLE_TYPE_U8; - if( stream->format == MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE) + + if (stream->format == MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE) { format = AUDIO_SAMPLE_TYPE_S16_LE; + } if( handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] ){ - ((recorder_audio_stream_cb)(handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM]))(stream->data, - stream->length, - format, - stream->channel, - stream->timestamp, - handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM]); + ((recorder_audio_stream_cb)(handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM]))(stream->data, stream->length, format, + stream->channel, stream->timestamp, + handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM]); } + return 1; } -int recorder_create_videorecorder(camera_h camera, recorder_h* recorder) +static int _recorder_check_and_set_attribute(recorder_h recorder, const char *attribute_name, int set_value) +{ + bool reset_pipeline = false; + bool restore_set = false; + int ret = MM_ERROR_NONE; + int ret2 = MM_ERROR_NONE; + int current_value = -1; + int current_audio_disable = 0; + + recorder_s *handle = (recorder_s *)recorder; + MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + mm_camcorder_get_state(handle->mm_handle, &mmstate); + if (mmstate >= MM_CAMCORDER_STATE_RECORDING) { + LOGE("invalid state %d", mmstate); + return RECORDER_ERROR_INVALID_STATE; + } + + if (handle->type == _RECORDER_TYPE_AUDIO && mmstate == MM_CAMCORDER_STATE_PREPARE) { + mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_DISABLE, ¤t_audio_disable, + attribute_name, ¤t_value, + NULL); + + if (current_value != set_value) { + LOGD("try to reset pipeline"); + + ret = mm_camcorder_stop(handle->mm_handle); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_stop failed 0x%x", ret); + return __convert_recorder_error_code(attribute_name, ret); + } + + ret = mm_camcorder_unrealize(handle->mm_handle); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_unrealize failed 0x%x", ret); + mm_camcorder_start(handle->mm_handle); + return __convert_recorder_error_code(attribute_name, ret); + } + + reset_pipeline = true; + } + } + + if (!strcmp(attribute_name, MMCAM_AUDIO_ENCODER)) { + if (set_value == RECORDER_AUDIO_CODEC_DISABLE) { + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_DISABLE, true, + NULL); + } else { + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_DISABLE, false, + MMCAM_AUDIO_ENCODER, set_value, + NULL); + } + } else { + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + attribute_name, set_value, + NULL); + } + + if (ret != MM_ERROR_NONE) { + LOGE("set [%s] failed 0x%x", attribute_name, ret); + } + + if (reset_pipeline) { + ret2 = mm_camcorder_realize(handle->mm_handle); + if (ret2 == MM_ERROR_NONE) { + ret2 = mm_camcorder_start(handle->mm_handle); + if (ret2 == MM_ERROR_NONE) { + LOGW("restart pipeline done."); + } else { + LOGE("mm_camcorder_start failed 0x%x", ret2); + mm_camcorder_unrealize(handle->mm_handle); + } + } else { + LOGE("mm_camcorder_realize failed 0x%x", ret2); + } + + if (ret2 != MM_ERROR_NONE) { + restore_set = true; + /* determine return value */ + if (ret == MM_ERROR_NONE) { + ret = ret2; + } + } + } + + if (restore_set) { + ret2 = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_DISABLE, current_audio_disable, + attribute_name, current_value, + NULL); + LOGW("restore attribute set : 0x%x", ret2); + + ret2 = mm_camcorder_realize(handle->mm_handle); + LOGW("restore mm_camcorder_realize : 0x%x", ret2); + + ret2 = mm_camcorder_start(handle->mm_handle); + LOGW("restore mm_camcorder_realize : 0x%x", ret2); + if (ret2 != MM_ERROR_NONE) { + ret2 = mm_camcorder_unrealize(handle->mm_handle); + LOGW("restore mm_camcorder_unrealize : 0x%x", ret2); + } + } + + return __convert_recorder_error_code(attribute_name, ret); +} + + +int recorder_create_videorecorder(camera_h camera, recorder_h *recorder) { + int ret = MM_ERROR_NONE; int resource_fd = -1; - recorder_s * handle = NULL; + recorder_s *handle = NULL; int preview_format = MM_PIXEL_FORMAT_NV12; + int camera_device_count = 0; - if( camera == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + if (camera == NULL) { + LOGE("NULL pointer camera handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (recorder == NULL) { + LOGE("NULL pointer recorder handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } - //Check already used in another recorder - if( _camera_is_used(camera)){ + /* Check already used in another recorder */ + if (_camera_is_used(camera)) { LOGE("[%s] camera is using in another recorder.", __func__); return RECORDER_ERROR_INVALID_PARAMETER; } @@ -427,144 +552,219 @@ int recorder_create_videorecorder(camera_h camera, recorder_h* recorder) } memset(handle, 0 , sizeof(recorder_s)); + handle->src_type = _RECORDER_SOURCE_TYPE_CAMERA; handle->last_max_input_level = LOWSET_DECIBEL; handle->changed_preview_format = -1; handle->mm_source.camera = camera; - _camera_set_use(camera, true); _camera_get_mm_handle(camera, &handle->mm_handle); _camera_set_relay_mm_message_callback(camera, __mm_recorder_msg_cb , (void*)handle); handle->type = _RECORDER_TYPE_VIDEO; recorder_get_state((recorder_h)handle, (recorder_state_e*)&handle->state); - *recorder = (recorder_h)handle; - mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL); + mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_FORMAT, &preview_format, + NULL); handle->origin_preview_format = preview_format; - mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING, &preview_format, NULL); + mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING, &preview_format, + NULL); + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, + MMCAM_CAMERA_DEVICE_COUNT, &camera_device_count, + NULL); + if (ret != MM_ERROR_NONE) { + free(handle); + handle = NULL; + LOGE("get device count error"); + return __convert_recorder_error_code(__func__, ret); + } + if (camera_device_count == 0) { + free(handle); + handle = NULL; + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } else { + handle->camera_device_count = camera_device_count; + } - if( handle->state == RECORDER_STATE_CREATED ){ - int ret; - ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,MMCAM_CAMERA_FORMAT, preview_format,(void*)NULL); - if( ret ==0 ) + _camera_set_use(camera, true); + if (handle->state == RECORDER_STATE_CREATED) { + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_FORMAT, preview_format, + NULL); + if (ret == MM_ERROR_NONE) { handle->changed_preview_format = preview_format; + } } + *recorder = (recorder_h)handle; + return RECORDER_ERROR_NONE; } -int recorder_create_audiorecorder( recorder_h* recorder){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s * handle; +int recorder_create_audiorecorder(recorder_h *recorder) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = NULL; MMCamPreset info; - info.videodev_type= MM_VIDEO_DEVICE_NONE; + int camera_device_count = 0; - handle = (recorder_s*)malloc( sizeof(recorder_s) ); - if(handle==NULL){ - LOGE( "[%s] OUT_OF_MEMORY(0x%08x)", __func__, RECORDER_ERROR_OUT_OF_MEMORY); + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + info.videodev_type = MM_VIDEO_DEVICE_NONE; + + handle = (recorder_s *)malloc(sizeof(recorder_s)); + if (handle == NULL) { + LOGE("OUT_OF_MEMORY(0x%08x)", RECORDER_ERROR_OUT_OF_MEMORY); return RECORDER_ERROR_OUT_OF_MEMORY; } - memset(handle, 0 , sizeof(recorder_s)); + memset(handle, 0, sizeof(recorder_s)); + handle->last_max_input_level = LOWSET_DECIBEL; ret = mm_camcorder_create(&handle->mm_handle, &info); - if( ret != MM_ERROR_NONE){ + if (ret != MM_ERROR_NONE) { free(handle); - LOGE("[%s] mm_camcorder_create fail", __func__); + handle = NULL; + LOGE("mm_camcorder_create fail"); return __convert_recorder_error_code(__func__, ret); } + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, - MMCAM_MODE , MM_CAMCORDER_MODE_AUDIO, - (void*)NULL); + MMCAM_MODE, MM_CAMCORDER_MODE_AUDIO, + NULL); - if( ret != MM_ERROR_NONE){ + if (ret != MM_ERROR_NONE) { mm_camcorder_destroy(handle->mm_handle); free(handle); - LOGE("[%s] AUDIO mode setting fail", __func__); + handle = NULL; + LOGE("AUDIO mode setting fail"); return __convert_recorder_error_code(__func__, ret); } - - + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, + MMCAM_CAMERA_DEVICE_COUNT, &camera_device_count, NULL); + if (ret != MM_ERROR_NONE) { + mm_camcorder_destroy(handle->mm_handle); + free(handle); + handle = NULL; + LOGE("get device count error"); + return __convert_recorder_error_code(__func__, ret); + } else { + handle->camera_device_count = camera_device_count; + } handle->state = RECORDER_STATE_CREATED; - mm_camcorder_set_message_callback(handle->mm_handle, __mm_recorder_msg_cb, (void*)handle); handle->mm_source.camera = NULL; handle->type = _RECORDER_TYPE_AUDIO; + mm_camcorder_set_message_callback(handle->mm_handle, __mm_recorder_msg_cb, (void*)handle); + *recorder = (recorder_h)handle; return RECORDER_ERROR_NONE; - } -int recorder_get_state(recorder_h recorder, recorder_state_e * state){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( state == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); +int recorder_get_state(recorder_h recorder, recorder_state_e *state) +{ + int ret = MM_ERROR_NONE; + MMCamcorderStateType mmstate; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (state == NULL) { + LOGE("NULL pointer state"); + return RECORDER_ERROR_INVALID_PARAMETER; + } recorder_s *handle = (recorder_s*)recorder; - MMCamcorderStateType mmstate ; - recorder_state_e capi_state; - mm_camcorder_get_state(handle->mm_handle, &mmstate); - capi_state = __recorder_state_convert(mmstate); + ret = mm_camcorder_get_state(handle->mm_handle, &mmstate); + if (ret != MM_ERROR_NONE) { + return __convert_recorder_error_code(__func__, ret); + } + + *state = __recorder_state_convert(mmstate); - *state = capi_state; return RECORDER_ERROR_NONE; } -int recorder_destroy( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle; + +int recorder_destroy(recorder_h recorder) +{ + recorder_s *handle = NULL; int ret = MM_ERROR_NONE; + int preview_format; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } - handle = (recorder_s *) recorder; - if( handle->type == _RECORDER_TYPE_VIDEO ){ - //set to unsed + handle = (recorder_s *)recorder; + + if (handle->type == _RECORDER_TYPE_VIDEO) { + /* set to unsed */ _camera_set_use(handle->mm_source.camera, false); - int preview_format; - mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL); - // preview format was changed? - if( preview_format == handle->changed_preview_format ){ - mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, handle->origin_preview_format,(void*)NULL); + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_FORMAT, &preview_format, + NULL); + + /* preview format was changed? */ + if (ret == MM_ERROR_NONE && preview_format == handle->changed_preview_format) { + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_FORMAT, handle->origin_preview_format, + NULL); + } + + if (ret == MM_ERROR_NONE) { + _camera_set_relay_mm_message_callback(handle->mm_source.camera, NULL, NULL); } - _camera_set_relay_mm_message_callback(handle->mm_source.camera , NULL, NULL); - }else{ + } else { ret = mm_camcorder_destroy(handle->mm_handle); } - if(ret == MM_ERROR_NONE) + if (ret == MM_ERROR_NONE) { free(handle); + } return __convert_recorder_error_code(__func__, ret); - } -int recorder_prepare( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - if( handle->type == _RECORDER_TYPE_VIDEO ){ +int recorder_prepare(recorder_h recorder) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + MMCamcorderStateType mmstate; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (handle->type == _RECORDER_TYPE_VIDEO) { return __convert_error_code_camera_to_recorder(camera_start_preview(handle->mm_source.camera)); } - MMCamcorderStateType mmstate ; - mm_camcorder_get_state(handle->mm_handle, &mmstate); + ret = mm_camcorder_get_state(handle->mm_handle, &mmstate); - if( mmstate != MM_CAMCORDER_STATE_READY){ + if (ret == MM_ERROR_NONE && mmstate < MM_CAMCORDER_STATE_READY) { ret = mm_camcorder_realize(handle->mm_handle); - if( ret != MM_ERROR_NONE){ - LOGE("[%s] mm_camcorder_realize fail", __func__); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_realize fail"); return __convert_recorder_error_code(__func__, ret); } } ret = mm_camcorder_start(handle->mm_handle); - - if( ret != MM_ERROR_NONE){ - LOGE("[%s] mm_camcorder_start fail", __func__); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_start fail"); mm_camcorder_unrealize(handle->mm_handle); return __convert_recorder_error_code(__func__, ret); } @@ -572,56 +772,87 @@ int recorder_prepare( recorder_h recorder){ return RECORDER_ERROR_NONE; } -int recorder_unprepare( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - MMCamcorderStateType mmstate ; - mm_camcorder_get_state(handle->mm_handle, &mmstate); +int recorder_unprepare(recorder_h recorder) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + MMCamcorderStateType mmstate; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } - if( mmstate == MM_CAMCORDER_STATE_PREPARE){ + ret = mm_camcorder_get_state(handle->mm_handle, &mmstate); + if (ret == MM_ERROR_NONE && mmstate == MM_CAMCORDER_STATE_PREPARE) { ret = mm_camcorder_stop(handle->mm_handle); if( ret != MM_ERROR_NONE){ - LOGE("[%s] mm_camcorder_stop fail", __func__); - return __convert_recorder_error_code(__func__, ret); + LOGE("mm_camcorder_stop fail"); + } + } + + if (ret == MM_ERROR_NONE) { + ret = mm_camcorder_unrealize(handle->mm_handle); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_unrealize fail"); + mm_camcorder_start(handle->mm_handle); } } - ret = mm_camcorder_unrealize(handle->mm_handle); + return __convert_recorder_error_code(__func__, ret); } -int recorder_start( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - ret = mm_camcorder_record(handle->mm_handle); - return __convert_recorder_error_code(__func__, ret); + +int recorder_start(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return __convert_recorder_error_code(__func__, mm_camcorder_record(handle->mm_handle)); } -int recorder_pause( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - ret = mm_camcorder_pause(handle->mm_handle); - return __convert_recorder_error_code(__func__, ret); +int recorder_pause(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return __convert_recorder_error_code(__func__, mm_camcorder_pause(handle->mm_handle)); } -int recorder_commit( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - ret = mm_camcorder_commit(handle->mm_handle); - return __convert_recorder_error_code(__func__, ret); + +int recorder_commit(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return __convert_recorder_error_code(__func__, mm_camcorder_commit(handle->mm_handle)); } -int recorder_cancel( recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s *handle = (recorder_s*)recorder; - ret = mm_camcorder_cancel(handle->mm_handle); - return __convert_recorder_error_code(__func__, ret); + +int recorder_cancel(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return __convert_recorder_error_code(__func__, mm_camcorder_cancel(handle->mm_handle)); } @@ -631,11 +862,14 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height) recorder_s *handle = (recorder_s*)recorder; recorder_state_e state; - if (!handle || !width || !height) { - LOGE("NULL pointer %p %p %p", handle, width, height); - return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + if (handle == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; } - recorder_get_state(recorder, &state); if (state > RECORDER_STATE_READY) { LOGE("RECORDER_ERROR_INVALID_STATE (state:%d)", state); @@ -643,9 +877,9 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height) } ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, - MMCAM_VIDEO_WIDTH, width, - MMCAM_VIDEO_HEIGHT, height, - NULL); + MMCAM_VIDEO_WIDTH, width, + MMCAM_VIDEO_HEIGHT, height, + NULL); return __convert_recorder_error_code(__func__, ret); } @@ -656,15 +890,25 @@ int recorder_get_video_resolution(recorder_h recorder, int *width, int *height) int ret = MM_ERROR_NONE; recorder_s *handle = (recorder_s*)recorder; - if (!handle || !width || !height) { - LOGE("NULL pointer %p %p %p", handle, width, height); - return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + if (!handle) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + + if (!width || !height) { + LOGE("NULL pointer width = [%p], height = [%p]", width, height); + return RECORDER_ERROR_INVALID_PARAMETER; } ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, - MMCAM_VIDEO_WIDTH, width, - MMCAM_VIDEO_HEIGHT, height, - NULL); + MMCAM_VIDEO_WIDTH, width, + MMCAM_VIDEO_HEIGHT, height, + NULL); return __convert_recorder_error_code(__func__, ret); } @@ -679,13 +923,23 @@ int recorder_foreach_supported_video_resolution(recorder_h recorder, MMCamAttrsInfo video_width; MMCamAttrsInfo video_height; - if (!handle || !foreach_cb) { - LOGE("NULL pointer %p %p", handle, foreach_cb); + if (!handle) { + LOGE("NULL pointer handle"); return RECORDER_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_WIDTH , &video_width); - ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_HEIGHT , &video_height); + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + + if (!foreach_cb) { + LOGE("NULL pointer callback"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_WIDTH, &video_width); + ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_HEIGHT, &video_height); if (ret != MM_ERROR_NONE ) { return __convert_recorder_error_code(__func__, ret); @@ -701,43 +955,80 @@ int recorder_foreach_supported_video_resolution(recorder_h recorder, } -int recorder_get_audio_level(recorder_h recorder, double *level){ - if( recorder == NULL || level == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; - +int recorder_get_audio_level(recorder_h recorder, double *level) +{ + recorder_s *handle = (recorder_s *)recorder; recorder_state_e state; + + if (recorder == NULL || level == NULL) { + LOGE("NULL pointer %p %p", recorder, level); + return RECORDER_ERROR_INVALID_PARAMETER; + } + recorder_get_state(recorder, &state); - if( state < RECORDER_STATE_RECORDING ){ - LOGE("[%s]RECORDER_ERROR_INVALID_STATE(0x%08x) ",__func__, RECORDER_ERROR_INVALID_STATE); + if (state < RECORDER_STATE_RECORDING) { + LOGE("RECORDER_ERROR_INVALID_STATE(0x%08x)", RECORDER_ERROR_INVALID_STATE); return RECORDER_ERROR_INVALID_STATE; } - *level = handle->last_max_input_level ; + *level = handle->last_max_input_level; handle->last_max_input_level = LOWSET_DECIBEL; + return RECORDER_ERROR_NONE; } -int recorder_set_filename(recorder_h recorder, const char *filename){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_set_filename(recorder_h recorder, const char *filename) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , filename , strlen(filename), NULL); - return __convert_recorder_error_code(__func__, ret); + recorder_s *handle = (recorder_s *)recorder; + MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (filename == NULL) { + LOGE("filename is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + mm_camcorder_get_state(handle->mm_handle, &mmstate); + if (mmstate >= MM_CAMCORDER_STATE_RECORDING) { + LOGE("invalid state %d", mmstate); + return RECORDER_ERROR_INVALID_STATE; + } + + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_FILENAME, filename, strlen(filename), + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_get_filename(recorder_h recorder, char **filename){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; +int recorder_get_filename(recorder_h recorder, char **filename) +{ + int ret = MM_ERROR_NONE; char *record_filename = NULL; int record_filename_size; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , &record_filename, &record_filename_size, NULL); + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } - if( ret == MM_ERROR_NONE && record_filename) { + if (filename == NULL) { + LOGE("filename is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_FILENAME, &record_filename, &record_filename_size, + NULL); + if (ret == MM_ERROR_NONE && record_filename) { *filename = strdup(record_filename); } else { LOGE("internal return (0x%08x), get filename p:%p", ret, record_filename); @@ -750,81 +1041,101 @@ int recorder_get_filename(recorder_h recorder, char **filename){ int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format) { - int ret = MM_ERROR_NONE; - int format_table[6] = { MM_FILE_FORMAT_3GP, //RECORDER_FILE_FORMAT_3GP - MM_FILE_FORMAT_MP4, //RECORDER_FILE_FORMAT_MP4 - MM_FILE_FORMAT_AMR, //RECORDER_FILE_FORMAT_AMR - MM_FILE_FORMAT_AAC, //RECORDER_FILE_FORMAT_ADTS - MM_FILE_FORMAT_WAV, //RECORDER_FILE_FORMAT_WAV - MM_FILE_FORMAT_OGG //RECORDER_FILE_FORMAT_OGG + int format_table[6] = { MM_FILE_FORMAT_3GP, /* RECORDER_FILE_FORMAT_3GP */ + MM_FILE_FORMAT_MP4, /* RECORDER_FILE_FORMAT_MP4 */ + MM_FILE_FORMAT_AMR, /* RECORDER_FILE_FORMAT_AMR */ + MM_FILE_FORMAT_AAC, /* RECORDER_FILE_FORMAT_ADTS */ + MM_FILE_FORMAT_WAV, /* RECORDER_FILE_FORMAT_WAV */ + MM_FILE_FORMAT_OGG /* RECORDER_FILE_FORMAT_OGG */ }; - recorder_s *handle = (recorder_s *)recorder; - - if (handle == NULL) { - return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - } if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_OGG) { + LOGE("invalid format %d", format); return RECORDER_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, - MMCAM_FILE_FORMAT, format_table[format], - NULL); - - return __convert_recorder_error_code(__func__, ret); + return _recorder_check_and_set_attribute(recorder, MMCAM_FILE_FORMAT, format_table[format]); } -int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - g_return_val_if_fail(format != NULL, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; + recorder_s *handle = (recorder_s *)recorder; int mm_format; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILE_FORMAT , &mm_format, NULL); - if( ret == 0 ){ - switch( mm_format ){ - case MM_FILE_FORMAT_3GP: - *format = RECORDER_FILE_FORMAT_3GP; - break; - case MM_FILE_FORMAT_MP4 : - *format = RECORDER_FILE_FORMAT_MP4; - break; - case MM_FILE_FORMAT_AMR : - *format = RECORDER_FILE_FORMAT_AMR; - break; - case MM_FILE_FORMAT_AAC : - *format = RECORDER_FILE_FORMAT_ADTS; - break; - case MM_FILE_FORMAT_WAV: - *format = RECORDER_FILE_FORMAT_WAV; - break; - case MM_FILE_FORMAT_OGG: - *format = RECORDER_FILE_FORMAT_OGG; - break; - default : - ret = MM_ERROR_CAMCORDER_INTERNAL; - break; + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (format == NULL) { + LOGE("format is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_FILE_FORMAT, &mm_format, + NULL); + if (ret == MM_ERROR_NONE) { + switch (mm_format) { + case MM_FILE_FORMAT_3GP: + *format = RECORDER_FILE_FORMAT_3GP; + break; + case MM_FILE_FORMAT_MP4 : + *format = RECORDER_FILE_FORMAT_MP4; + break; + case MM_FILE_FORMAT_AMR : + *format = RECORDER_FILE_FORMAT_AMR; + break; + case MM_FILE_FORMAT_AAC : + *format = RECORDER_FILE_FORMAT_ADTS; + break; + case MM_FILE_FORMAT_WAV: + *format = RECORDER_FILE_FORMAT_WAV; + break; + case MM_FILE_FORMAT_OGG: + *format = RECORDER_FILE_FORMAT_OGG; + break; + default : + ret = MM_ERROR_CAMCORDER_INTERNAL; + break; } } + return __convert_recorder_error_code(__func__, ret); } -int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; - if( callback == NULL ) + +int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (callback == NULL) { + LOGE("NULL pointer callback"); return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback; handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data; return RECORDER_ERROR_NONE; } -int recorder_unset_state_changed_cb(recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + +int recorder_unset_state_changed_cb(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL; @@ -832,20 +1143,35 @@ int recorder_unset_state_changed_cb(recorder_h recorder){ return RECORDER_ERROR_NONE; } -int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; - if( callback == NULL ) + +int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); return RECORDER_ERROR_INVALID_PARAMETER; + } + if (callback == NULL) { + LOGE("NULL pointer callback"); + return RECORDER_ERROR_INVALID_PARAMETER; + } handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] = callback; handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data; return RECORDER_ERROR_NONE; } -int recorder_unset_interrupted_cb(recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + + +int recorder_unset_interrupted_cb(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL; @@ -853,518 +1179,844 @@ int recorder_unset_interrupted_cb(recorder_h recorder){ return RECORDER_ERROR_NONE; } -int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data){ - if( recorder == NULL || callback == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s *handle = (recorder_s*)recorder; - ret = mm_camcorder_set_audio_stream_callback( handle->mm_handle, __mm_audio_stream_cb, handle); - if( ret == 0 ){ + +int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (callback == NULL) { + LOGE("NULL pointer callback"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_set_audio_stream_callback(handle->mm_handle, __mm_audio_stream_cb, handle); + if (ret == MM_ERROR_NONE){ handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback; handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data; } + return __convert_recorder_error_code(__func__, ret); } -int recorder_unset_audio_stream_cb(recorder_h recorder){ - if( recorder == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s *handle = (recorder_s*)recorder; + +int recorder_unset_audio_stream_cb(recorder_h recorder) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL; - ret = mm_camcorder_set_audio_stream_callback( handle->mm_handle, NULL, NULL); + + ret = mm_camcorder_set_audio_stream_callback(handle->mm_handle, NULL, NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data){ - if( recorder == NULL || callback == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + +int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (callback == NULL) { + LOGE("NULL pointer callback"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] = callback; handle->user_data[_RECORDER_EVENT_TYPE_ERROR] = user_data; + return RECORDER_ERROR_NONE; } -int recorder_unset_error_cb(recorder_h recorder){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + +int recorder_unset_error_cb(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_ERROR] = NULL; + return RECORDER_ERROR_NONE; } -int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; - if( callback == NULL ) + +int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (callback == NULL) { + LOGE("NULL pointer callback"); return RECORDER_ERROR_INVALID_PARAMETER; - + } + handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback; handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data; return RECORDER_ERROR_NONE; } -int recorder_unset_recording_status_cb(recorder_h recorder){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + +int recorder_unset_recording_status_cb(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL; - + return RECORDER_ERROR_NONE; - } -int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; - if( callback == NULL ) + +int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); return RECORDER_ERROR_INVALID_PARAMETER; - + } + if (callback == NULL) { + LOGE("NULL pointer callback"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback; handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data; return RECORDER_ERROR_NONE; - } -int recorder_unset_recording_limit_reached_cb(recorder_h recorder){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s *handle = (recorder_s*)recorder; + +int recorder_unset_recording_limit_reached_cb(recorder_h recorder) +{ + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL; handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL; - return RECORDER_ERROR_NONE; + return RECORDER_ERROR_NONE; } -int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb , void *user_data){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; + +int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data) +{ + int i = 0; + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; MMCamAttrsInfo info; - ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILE_FORMAT , &info); - if( ret != MM_ERROR_NONE ) - return ret; - int i; - for( i=0 ; i < info.int_array.count ; i++) - { - - int format; - - switch( info.int_array.array[i] ){ - case MM_FILE_FORMAT_3GP: - format = RECORDER_FILE_FORMAT_3GP; - break; - case MM_FILE_FORMAT_MP4 : - format = RECORDER_FILE_FORMAT_MP4; - break; - case MM_FILE_FORMAT_AMR : - format = RECORDER_FILE_FORMAT_AMR; - break; - case MM_FILE_FORMAT_AAC: - format = RECORDER_FILE_FORMAT_ADTS; - break; - case MM_FILE_FORMAT_WAV: - format = RECORDER_FILE_FORMAT_WAV; - break; - default : - format = -1; - } + int format; - if ( format != -1 && !foreach_cb(format,user_data) ) - break; + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (foreach_cb == NULL) { + LOGE("NULL pointer foreach_cb"); + return RECORDER_ERROR_INVALID_PARAMETER; } - return RECORDER_ERROR_NONE; - -} + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILE_FORMAT, &info); + if (ret != MM_ERROR_NONE) { + LOGE("mm_camcorder_get_attribute_info failed 0x%x", ret); + return __convert_recorder_error_code(__func__, ret);; + } + for (i = 0 ; i < info.int_array.count ; i++) { + switch (info.int_array.array[i]) { + case MM_FILE_FORMAT_3GP: + format = RECORDER_FILE_FORMAT_3GP; + break; + case MM_FILE_FORMAT_MP4 : + format = RECORDER_FILE_FORMAT_MP4; + break; + case MM_FILE_FORMAT_AMR : + format = RECORDER_FILE_FORMAT_AMR; + break; + case MM_FILE_FORMAT_AAC: + format = RECORDER_FILE_FORMAT_ADTS; + break; + case MM_FILE_FORMAT_WAV: + format = RECORDER_FILE_FORMAT_WAV; + break; + default : + format = -1; + break; + } -int recorder_attr_set_size_limit(recorder_h recorder, int kbyte){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL); - return __convert_recorder_error_code(__func__, ret); -} + if (format != -1 && !foreach_cb(format,user_data)) { + break; + } + } -int recorder_attr_set_time_limit(recorder_h recorder, int second){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL); - return __convert_recorder_error_code(__func__, ret); + return RECORDER_ERROR_NONE; } -int recorder_attr_set_audio_device(recorder_h recorder , recorder_audio_device_e device){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL); - return __convert_recorder_error_code(__func__, ret); -} -int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); +int recorder_attr_set_size_limit(recorder_h recorder, int kbyte) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; - if( codec != RECORDER_AUDIO_CODEC_DISABLE && ( codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM) ) + if (recorder == NULL) { + LOGE("NULL pointer handle"); return RECORDER_ERROR_INVALID_PARAMETER; + } - int audio_table[4] = { MM_AUDIO_CODEC_AMR, //RECORDER_AUDIO_CODEC_AMR - MM_AUDIO_CODEC_AAC, //RECORDER_AUDIO_CODEC_AAC - MM_AUDIO_CODEC_VORBIS, //RECORDER_AUDIO_CODEC_VORBIS - MM_AUDIO_CODEC_WAVE //RECORDER_AUDIO_CODEC_PCM - }; - int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - if( codec == RECORDER_AUDIO_CODEC_DISABLE ) - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DISABLE , 1, NULL); - else - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , audio_table[codec], MMCAM_AUDIO_DISABLE, 0, NULL); + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_MAX_SIZE, kbyte, + NULL); return __convert_recorder_error_code(__func__, ret); } -int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - g_return_val_if_fail(codec != NULL, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_attr_set_time_limit(recorder_h recorder, int second) +{ int ret = MM_ERROR_NONE; - int mm_codec = 0; - int audio_disable = 0; + recorder_s *handle = (recorder_s *)recorder; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , &mm_codec , MMCAM_AUDIO_DISABLE, &audio_disable, NULL); - if( ret == 0 && audio_disable == 0 ){ - switch( mm_codec ){ - case MM_AUDIO_CODEC_AMR : - *codec = RECORDER_AUDIO_CODEC_AMR; - break; - case MM_AUDIO_CODEC_AAC : - *codec = RECORDER_AUDIO_CODEC_AAC; - break; - case MM_AUDIO_CODEC_VORBIS: - *codec = RECORDER_AUDIO_CODEC_VORBIS; - break; - case MM_AUDIO_CODEC_WAVE: - *codec = RECORDER_AUDIO_CODEC_PCM; - break; - default : - ret = MM_ERROR_CAMCORDER_INTERNAL; - break; - } - }else if( ret == 0 && audio_disable ){ - *codec = RECORDER_AUDIO_CODEC_DISABLE; + if (recorder == NULL) { + LOGE("NULL pointer handle"); + return RECORDER_ERROR_INVALID_PARAMETER; } + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_TIME_LIMIT, second, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret = MM_ERROR_NONE; - int video_table[4] = { MM_VIDEO_CODEC_H263, //RECORDER_VIDEO_CODEC_H263, /**< H263 codec */ - MM_VIDEO_CODEC_H264, //RECORDER_VIDEO_CODEC_H264, /**< H264 codec */ - MM_VIDEO_CODEC_MPEG4, //RECORDER_VIDEO_CODEC_MPEG4, /**< MPEG4 codec */ - MM_VIDEO_CODEC_THEORA //RECORDER_VIDEO_CODEC_THEORA - }; - if( codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA ) +int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device) +{ + if (device < RECORDER_AUDIO_DEVICE_MIC || device > RECORDER_AUDIO_DEVICE_MODEM) { + LOGE("invalid device %d", device); return RECORDER_ERROR_INVALID_PARAMETER; - recorder_s * handle = (recorder_s*)recorder; + } - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER , video_table[codec], NULL); - return __convert_recorder_error_code(__func__, ret); + return _recorder_check_and_set_attribute(recorder, MMCAM_AUDIO_DEVICE, device); } -int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( codec == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; +int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec) +{ + recorder_s *handle = (recorder_s *)recorder; + int audio_table[4] = { MM_AUDIO_CODEC_AMR, /* RECORDER_AUDIO_CODEC_AMR */ + MM_AUDIO_CODEC_AAC, /* RECORDER_AUDIO_CODEC_AAC */ + MM_AUDIO_CODEC_VORBIS, /* RECORDER_AUDIO_CODEC_VORBIS */ + MM_AUDIO_CODEC_WAVE /* RECORDER_AUDIO_CODEC_PCM */ + }; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (codec != RECORDER_AUDIO_CODEC_DISABLE && + (codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM)) { + LOGE("invalid parameter : codec %d", codec); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (handle->type == _RECORDER_TYPE_AUDIO && codec == RECORDER_AUDIO_CODEC_DISABLE) { + LOGE("AUDIO_CODEC_DISABLE is not supported in audio mode"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + + return _recorder_check_and_set_attribute(recorder, MMCAM_AUDIO_ENCODER, codec == RECORDER_AUDIO_CODEC_DISABLE ? RECORDER_AUDIO_CODEC_DISABLE : audio_table[codec]); +} + + +int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec) +{ + int ret = MM_ERROR_NONE; int mm_codec = 0; + int audio_disable = 0; + recorder_s *handle = (recorder_s *)recorder; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER , &mm_codec, NULL); - if( ret == 0 ){ - switch( mm_codec ){ - case MM_VIDEO_CODEC_H263 : - *codec = RECORDER_VIDEO_CODEC_H263; - break; - case MM_VIDEO_CODEC_H264 : - *codec = RECORDER_VIDEO_CODEC_H264; - break; - case MM_VIDEO_CODEC_MPEG4 : - *codec = RECORDER_VIDEO_CODEC_MPEG4; - break; - case MM_VIDEO_CODEC_THEORA: - *codec = RECORDER_VIDEO_CODEC_THEORA; - break; - default : - ret = MM_ERROR_CAMCORDER_INTERNAL; - break; + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (codec == NULL) { + LOGE("codec is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_ENCODER, &mm_codec, + MMCAM_AUDIO_DISABLE, &audio_disable, + NULL); + + if (ret == MM_ERROR_NONE && audio_disable == 0) { + switch (mm_codec) { + case MM_AUDIO_CODEC_AMR : + *codec = RECORDER_AUDIO_CODEC_AMR; + break; + case MM_AUDIO_CODEC_AAC : + *codec = RECORDER_AUDIO_CODEC_AAC; + break; + case MM_AUDIO_CODEC_VORBIS: + *codec = RECORDER_AUDIO_CODEC_VORBIS; + break; + case MM_AUDIO_CODEC_WAVE: + *codec = RECORDER_AUDIO_CODEC_PCM; + break; + default : + ret = MM_ERROR_CAMCORDER_INTERNAL; + break; } + } else if (ret == MM_ERROR_NONE && audio_disable) { + *codec = RECORDER_AUDIO_CODEC_DISABLE; } - + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL); + int video_table[4] = { MM_VIDEO_CODEC_H263, /* RECORDER_VIDEO_CODEC_H263 */ + MM_VIDEO_CODEC_H264, /* RECORDER_VIDEO_CODEC_H264 */ + MM_VIDEO_CODEC_MPEG4, /* RECORDER_VIDEO_CODEC_MPEG4 */ + MM_VIDEO_CODEC_THEORA /* RECORDER_VIDEO_CODEC_THEORA */ + }; + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + + if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) { + LOGE("invalid codec %d", codec); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_VIDEO_ENCODER, video_table[codec], + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL); + int mm_codec = 0; + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + if (codec == NULL) { + LOGE("codec is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_VIDEO_ENCODER, &mm_codec, + NULL); + if (ret == MM_ERROR_NONE) { + switch(mm_codec) { + case MM_VIDEO_CODEC_H263 : + *codec = RECORDER_VIDEO_CODEC_H263; + break; + case MM_VIDEO_CODEC_H264 : + *codec = RECORDER_VIDEO_CODEC_H264; + break; + case MM_VIDEO_CODEC_MPEG4 : + *codec = RECORDER_VIDEO_CODEC_MPEG4; + break; + case MM_VIDEO_CODEC_THEORA: + *codec = RECORDER_VIDEO_CODEC_THEORA; + break; + default : + ret = MM_ERROR_CAMCORDER_INTERNAL; + break; + } + } + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate) +{ + if (samplerate < 1) { + LOGE("invalid samplerate %d", samplerate); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return _recorder_check_and_set_attribute(recorder, MMCAM_AUDIO_SAMPLERATE, samplerate); +} + + +int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate) +{ + if (bitrate < 1) { + LOGE("invalid bitrate %d", bitrate); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + return _recorder_check_and_set_attribute(recorder, MMCAM_AUDIO_ENCODER_BITRATE, bitrate); +} + + +int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL); + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_VIDEO_ENCODER_BITRATE, bitrate, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL); + +int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_MAX_SIZE, kbyte, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_time_limit(recorder_h recorder, int *second){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL); + +int recorder_attr_get_time_limit(recorder_h recorder, int *second) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_TARGET_TIME_LIMIT, second, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_audio_device(recorder_h recorder , recorder_audio_device_e *device){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL); + +int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_DEVICE, device, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL); + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_SAMPLERATE, samplerate, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL); + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_ENCODER_BITRATE, bitrate, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate) +{ int ret = MM_ERROR_NONE; - recorder_s * handle = (recorder_s*)recorder; - ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL); + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_VIDEO_ENCODER_BITRATE, bitrate, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb , void *user_data){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; + +int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data) +{ + int i = 0; + int ret = MM_ERROR_NONE; + int codec; + recorder_s *handle = (recorder_s *)recorder; MMCamAttrsInfo info; - ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_AUDIO_ENCODER , &info); - if( ret != MM_ERROR_NONE ) + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (foreach_cb == NULL) { + LOGE("foreach_cb is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_AUDIO_ENCODER, &info); + if (ret != MM_ERROR_NONE) { return __convert_recorder_error_code(__func__, ret); - - int i; - for( i=0 ; i < info.int_array.count ; i++) - { - int codec; - - switch( info.int_array.array[i] ){ - case MM_AUDIO_CODEC_AMR: - codec = RECORDER_AUDIO_CODEC_AMR; - break; - case MM_AUDIO_CODEC_AAC : - codec = RECORDER_AUDIO_CODEC_AAC; - break; - case MM_AUDIO_CODEC_VORBIS: - codec = RECORDER_AUDIO_CODEC_VORBIS; - break; - case MM_AUDIO_CODEC_WAVE: - codec = RECORDER_AUDIO_CODEC_PCM; - break; - default : - codec = -1; - } - if( codec != -1 && !foreach_cb(codec,user_data) ) + } + + for (i = 0 ; i < info.int_array.count ; i++) { + switch (info.int_array.array[i]) { + case MM_AUDIO_CODEC_AMR: + codec = RECORDER_AUDIO_CODEC_AMR; + break; + case MM_AUDIO_CODEC_AAC : + codec = RECORDER_AUDIO_CODEC_AAC; + break; + case MM_AUDIO_CODEC_VORBIS: + codec = RECORDER_AUDIO_CODEC_VORBIS; + break; + case MM_AUDIO_CODEC_WAVE: + codec = RECORDER_AUDIO_CODEC_PCM; + break; + default : + codec = -1; break; + } + if (codec != -1 && !foreach_cb(codec,user_data)) { + break; + } } - return RECORDER_ERROR_NONE; + + return RECORDER_ERROR_NONE; } -int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb , void *user_data){ - - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - int ret; - recorder_s * handle = (recorder_s*)recorder; + + +int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data) +{ + int i = 0; + int ret = MM_ERROR_NONE; + int codec; + recorder_s *handle = (recorder_s *)recorder; MMCamAttrsInfo info; - ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_ENCODER , &info); - if( ret != MM_ERROR_NONE ) + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + if (foreach_cb == NULL) { + LOGE("foreach_cb is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_ENCODER, &info); + if (ret != MM_ERROR_NONE) { return __convert_recorder_error_code(__func__, ret); - - int i; - for( i=0 ; i < info.int_array.count ; i++) - { - int codec; - - switch( info.int_array.array[i] ){ - case MM_VIDEO_CODEC_H263 : - codec = RECORDER_VIDEO_CODEC_H263; - break; - case MM_VIDEO_CODEC_H264 : - codec = RECORDER_VIDEO_CODEC_H264; - break; - case MM_VIDEO_CODEC_MPEG4 : - codec = RECORDER_VIDEO_CODEC_MPEG4; - break; - case MM_VIDEO_CODEC_THEORA : - codec = RECORDER_VIDEO_CODEC_THEORA; - break; - default : - codec = -1; - } - - if ( codec != -1 && !foreach_cb(codec,user_data) ) + } + + for (i = 0 ; i < info.int_array.count ; i++) { + switch (info.int_array.array[i]){ + case MM_VIDEO_CODEC_H263 : + codec = RECORDER_VIDEO_CODEC_H263; break; + case MM_VIDEO_CODEC_H264 : + codec = RECORDER_VIDEO_CODEC_H264; + break; + case MM_VIDEO_CODEC_MPEG4 : + codec = RECORDER_VIDEO_CODEC_MPEG4; + break; + case MM_VIDEO_CODEC_THEORA : + codec = RECORDER_VIDEO_CODEC_THEORA; + break; + default : + codec = -1; + break; + } + + if (codec != -1 && !foreach_cb(codec,user_data)) { + break; + } } + return RECORDER_ERROR_NONE; - } -int recorder_attr_set_mute(recorder_h recorder, bool enable){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , enable ? 0.0 : 1.0 , NULL); +int recorder_attr_set_mute(recorder_h recorder, bool enable) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_VOLUME, enable ? 0.0 : 1.0, + NULL); + return __convert_recorder_error_code(__func__, ret); } -bool recorder_attr_is_muted(recorder_h recorder){ - if( recorder == NULL){ - __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + +bool recorder_attr_is_muted(recorder_h recorder) +{ + int ret = MM_ERROR_NONE; + double volume = 1.0; + recorder_s *handle = (recorder_s *)recorder; + + if (recorder == NULL) { + LOGE("handle is NULL"); return false; } - recorder_s * handle = (recorder_s*)recorder; - double volume = 1.0; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , &volume , NULL); + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_VOLUME, &volume, + NULL); set_last_result(__convert_recorder_error_code(__func__, ret)); - if( volume == 0.0 ) + + if (volume == 0.0) { return true; - else + } else { return false; + } } -int recorder_attr_set_recording_motion_rate(recorder_h recorder , double rate){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "camera-recording-motion-rate" , rate, NULL); + +int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_RECORDING_MOTION_RATE, rate, + NULL); + return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_recording_motion_rate(recorder_h recorder , double *rate){ - if( recorder == NULL || rate == NULL ) - return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "camera-recording-motion-rate" , rate , NULL); +int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + if (rate == NULL) { + LOGE("rate is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_CAMERA_RECORDING_MOTION_RATE, rate, + NULL); + return __convert_recorder_error_code(__func__, ret); } +int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count) +{ + if (channel_count < 1) { + LOGE("invalid channel %d", channel_count); + return RECORDER_ERROR_INVALID_PARAMETER; + } -int recorder_attr_set_slow_motion_rate(recorder_h recorder , double rate){ - return recorder_attr_set_recording_motion_rate(recorder, rate); + return _recorder_check_and_set_attribute(recorder, MMCAM_AUDIO_CHANNEL, channel_count); } -int recorder_attr_get_slow_motion_rate(recorder_h recorder , double *rate){ - return recorder_attr_get_recording_motion_rate(recorder, rate); -} +int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; -int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_CHANNEL, channel_count, NULL); - return __convert_recorder_error_code(__func__, ret); -} + if (recorder == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (channel_count == NULL) { + LOGE("channel_count is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } -int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count){ - if( recorder == NULL || channel_count == NULL ) - return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_AUDIO_CHANNEL, channel_count, + NULL); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_CHANNEL , channel_count, NULL); return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_set_recording_orientation(recorder_h recorder, recorder_rotation_e orientation){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "camcorder-rotation", orientation, NULL); - return __convert_recorder_error_code(__func__, ret); -} -int recorder_attr_get_recording_orientation(recorder_h recorder, recorder_rotation_e *orientation){ - if( recorder == NULL || orientation == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "camcorder-rotation" , orientation, NULL); - return __convert_recorder_error_code(__func__, ret); -} +int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; -int recorder_attr_set_recording_flip(recorder_h recorder, recorder_flip_e flip){ - if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "camcorder-flip", flip, NULL); - return __convert_recorder_error_code(__func__, ret); -} + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + if (orientation > RECORDER_ROTATION_270) { + LOGE("invalid orientation %d", orientation); + return RECORDER_ERROR_INVALID_PARAMETER; + } -int recorder_attr_get_recording_flip(recorder_h recorder, recorder_flip_e *flip){ - if( recorder == NULL || flip == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "camcorder-flip" , flip, NULL); - return __convert_recorder_error_code(__func__, ret); -} + ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, + MMCAM_RECORDER_TAG_ENABLE, true, + MMCAM_TAG_VIDEO_ORIENTATION, orientation, + NULL); -int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation){ - if( recorder == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - if((orientation < RECORDER_ROTATION_NONE) || ( orientation > RECORDER_ROTATION_270)) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_VIDEO_ORIENTATION , orientation, NULL); return __convert_recorder_error_code(__func__, ret); } -int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation){ - if( recorder == NULL || orientation == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER); - recorder_s * handle = (recorder_s*)recorder; - int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_VIDEO_ORIENTATION , orientation, NULL); + +int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation) +{ + int ret = MM_ERROR_NONE; + recorder_s *handle = (recorder_s *)recorder; + + if (handle == NULL) { + LOGE("handle is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + if (handle->camera_device_count == 0) { + LOGE("RECORDER_ERROR_NOT_SUPPORTED"); + return RECORDER_ERROR_NOT_SUPPORTED; + } + if (orientation == NULL) { + LOGE("orientation is NULL"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, + MMCAM_TAG_VIDEO_ORIENTATION, orientation, + NULL); + return __convert_recorder_error_code(__func__, ret); } -- cgit v1.2.3