From: YoungHun Kim Date: Mon, 2 Feb 2015 04:52:59 +0000 (+0900) Subject: update doxygen X-Git-Tag: accepted/tizen/common/20150209.121943^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fapi%2Fvideo-util.git;a=commitdiff_plain;h=77c3be7087c3344c0523a0a6ace4f09a4669cff8 update doxygen Change-Id: I83f177a033a323ab6f6a7797ca3b1b792a6f60a3 Signed-off-by: YoungHun Kim --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d68d25..e92ec1a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ SET(service "media") SET(submodule "video-util") # for package file -SET(dependents "dlog mm-transcode capi-base-common") -SET(pc_dependents "capi-base-common") +SET(dependents "dlog mm-transcode capi-base-common capi-system-info") +SET(pc_dependents "capi-base-common capi-system-info") SET(fw_name "${project_prefix}-${service}-${submodule}") diff --git a/LICENSE.APLv2.0 b/LICENSE.APLv2.0 index 5554685..29f81d8 100755 --- a/LICENSE.APLv2.0 +++ b/LICENSE.APLv2.0 @@ -199,6 +199,3 @@ 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. - - - diff --git a/include/video_util.h b/include/video_util.h index 7363e27..7190d81 100755 --- a/include/video_util.h +++ b/include/video_util.h @@ -27,19 +27,35 @@ extern "C" { #endif /* __cplusplus */ /** + * @file video_util.h + */ + +/** * @addtogroup CAPI_MEDIA_VIDEO_UTIL_MODULE * @{ */ /** * @brief Creates a handle to video util. + * @since_tizen 2.3 + * * @details This function creates a handle to video util. - * @remarks The @a video util handle must be released with video_util_destroy() by you. + * + * @remarks You must release the @a video util handle using video_util_destroy().\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[out] handle A handle to video util - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_destroy() * */ @@ -47,14 +63,25 @@ int video_util_create(video_util_h *handle); /** * @brief Destroys a handle to video util. + * @since_tizen 2.3 + * * @details The function frees all resources related to the video util handle. The video util - * handle no longer can be used to perform any operation. A new video util handle - * has to be created before the next usage. + * handle no longer can be used to perform any operation. A new video util handle + * has to be created before the next usage. + * + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n * * @param[in] handle The handle to video util - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * */ @@ -62,13 +89,26 @@ int video_util_destroy(video_util_h handle); /** * @brief Sets the video util's file path. - * @details This function sets the @a source path to transcode. + * @since_tizen 2.3 + * + * @details This function sets the source @a path to transcode. + * + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util * @param[in] path The source file path - * @return return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * * @see video_util_create() * @see video_util_destroy() */ @@ -76,90 +116,154 @@ int video_util_set_file_path(video_util_h handle, const char *path); /** * @brief Sets the video util's accurate mode. - * @remarks If you do not set, the default value is @c false. + * @since_tizen 2.3 + * + * @remarks If you do not set this, the default value is @c false.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util - * @param [in] mode @c true, user can get an accurated frame for given the duration in video_util_start_transcoding()\n - * @c false, user can only get the nearest i-frame - * @return return 0 on success, otherwise a negative error value. + * @param[in] mode Set @c true if the user can get an accurated frame for given the duration in video_util_start_transcoding(), + * otherwise set @c false if user can only get the nearest i-frame + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() */ int video_util_set_accurate_mode(video_util_h handle, bool mode); - /** - * @brief Sets the video codec for encoding video stream. + * @brief Sets the video codec for encoding video stream. + * @since_tizen 2.3 + * * @remarks You can get available list of video codec by using video_util_foreach_supported_video_codec().\n - * If you do not set, the default codec is #VIDEO_UTIL_VIDEO_CODEC_MPEG4. + * If you do not set this, the default codec is #VIDEO_UTIL_VIDEO_CODEC_MPEG4.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util * @param[in] codec The video codec - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() - * @see video_util_get_video_codec() * @see video_util_foreach_supported_video_codec() */ int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec); /** - * @brief Sets the audio codec for encoding audio stream. + * @brief Sets the audio codec for encoding audio stream. + * @since_tizen 2.3 + * * @remarks You can get available list of audio codec by using video_util_foreach_supported_audio_codec().\n - * If you do not set, the default codec is #VIDEO_UTIL_AUDIO_CODEC_AAC. + * If you do not set this, the default codec is #VIDEO_UTIL_AUDIO_CODEC_AAC.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util * @param[in] codec The audio codec - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() - * @see video_util_get_audio_codec() * @see video_util_foreach_supported_audio_codec() */ int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec); /** - * @brief Sets the file format for transcoding media stream. - * @remarks You can get available list of media format by using video_util_foreach_supported_file_format().\n - * If you do not set, the default file format is #VIDEO_UTIL_FILE_FORMAT_3GP. + * @brief Sets the file format for transcoding media stream. + * @since_tizen 2.3 + * + * @remarks You can get available list of media formats by using video_util_foreach_supported_file_format().\n + * If you do not set this, the default file format is #VIDEO_UTIL_FILE_FORMAT_3GP.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util * @param[in] format The media file format - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() - * @see video_util_get_file_format() * @see video_util_foreach_supported_file_format() */ int video_util_set_file_format(video_util_h handle, video_util_file_format_e format); /** * @brief Sets the resolution(width and height). - * @remarks If you do not set, the default resolution is original size. + * @since_tizen 2.3 + * + * @remarks If you do not set, the default resolution is original size.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util - * @param[in] width The media's width, if the width is 0, it set original size.(minimum value is 128) - * @param[in] height The media's height, if the height is 0, it set original size.(minimum value is 96) - * @return 0 on success, otherwise a negative error value. + * @param[in] width The media's width \n + * If the width is 0, it set original size.(minimum value is 128) + * @param[in] height The media's height \n + * If the height is 0, it set original size.(minimum value is 96) + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() - * @see video_util_get_resolution() */ int video_util_set_resolution(video_util_h handle, int width, int height); /** * @brief Sets the frame rate. - * @remarks If fps is set 0, the default is original fps from source. + * @since_tizen 2.3 + * + * @remarks If fps is set @c 0, the default is original fps from source.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util + * * @param[in] fps The frame rate(minimum value is 5, maximum value is 30) - * @return 0 on success, otherwise a negative error value. - * @retval #VIDEO_UTIL_EROR_NONE Successful - * @retval #VIDEO_UTIL_EROR_INVALID_PARAMETER Invalid parameter + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #VIDEO_UTIL_ERROR_NONE Successful + * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() */ @@ -167,22 +271,34 @@ int video_util_set_fps(video_util_h handle, int fps); /** * @brief Transcodes the video for given video util handle. + * @since_tizen 2.3 + * * @details This function starts the transcoding from start time and for given duration.\n -#video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.\n -#video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished corresponding callback. - * @remarks If there is already exists same file in file system, then old file will be overwritten. + * #video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.\n + * #video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished. + * + * @remarks If there already exists same file in file system, then old file will be overwritten.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util * @param[in] start The start position to transcode - * @param[in] duration The duration is in seconds.\n - If duration is 0, transcoding happens until end of the video. + * @param[in] duration The duration in seconds \n + * if duration is @c 0, transcoding happens until end of the video. * @param[out] out_path The file path to save - * @param[in] progress_cb The callback function to invoke - * @param[in] completed_cb The callback function to invoke + * @param[in] progress_cb The callback function to be invoked + * @param[in] completed_cb The callback function to be invoked * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() * @see video_util_transcoding_progress_cb() @@ -193,14 +309,27 @@ int video_util_set_fps(video_util_h handle, int fps); int video_util_start_transcoding(video_util_h handle, unsigned long start, unsigned long duration, const char *out_path, video_util_transcoding_progress_cb progress_cb, video_util_transcoding_completed_cb completed_cb,void *user_data); /** - * @brief Cancels to transcode the video for given video util handle. - * @details This function cancels the transcoding for given video util handle.\n - * @remarks If this function is invoked during transcoding, the data transcoded is discard. + * @brief Cancels transcoding the video for given video util handle. + * @since_tizen 2.3 + + * + * @details This function cancels the transcoding for given video util handle.\n. + * + * @remarks If this function is invoked during transcoding, the data transcoded is discard.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * * @param[in] handle The handle to video util - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * * @see video_util_create() * @see video_util_destroy() * @see video_util_start_transcoding() @@ -209,63 +338,105 @@ int video_util_cancel_transcoding(video_util_h handle); /** * @brief Retreives the current position and duration of the video transcoding. + * @since_tizen 2.3 + + * + * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n + * * @param[in] handle The handle to video util - * @param[out] current_position The transcoded current position + * @param[out] current_position Current position of transcoding * @param[out] duration The duration is in seconds.\n - If duration is 0, transcoding happens until end of the video. - * @return 0 on success, otherwise a negative error value. + If duration is 0, transcoding happens until end of the video + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter - * @pre video_util_start_transcoding() + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * + * @pre video_util_start_transcoding(). + * * @see video_util_create() * @see video_util_destroy() */ int video_util_get_progress_transcoding(video_util_h handle, unsigned long *current_position, unsigned long *duration); /** - * @brief Retrieves all supported media format by invoking a specific callback for each supported media format. - * @remarks The callback invocation depends on the codec. + * @brief Retrieves all supported media formats by invoking a specific callback for each supported media format. + * @since_tizen 2.3 + * + * @remarks The callback invocation depends on the codec.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n + * * @param[in] handle The handle to video util * @param[in] callback The callback function to invoke * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter - * @post video_util_supported_file_format_cb() will be invoked - * @see video_util_get_file_format() + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * @post video_util_supported_file_format_cb() will be invoked. + * * @see video_util_set_file_format() * @see video_util_supported_file_format_cb() */ int video_util_foreach_supported_file_format(video_util_h handle, video_util_supported_file_format_cb callback, void *user_data); /** - * @brief Retrieves all supported video encoder by invoking a specific callback for each supported video encoder. - * @remarks The callback invocation depends on the file format. + * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder. + * @since_tizen 2.3 + * + * @remarks The callback invocation depends on the file format.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n + * * @param[in] handle The handle to video util - * @param[in] callback The callback function to invoke + * @param[in] callback The callback function to be invoked * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter - * @post video_util_supported_video_encoder_cb() will be invoked - * @see video_util_get_video_codec() + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * @post video_util_supported_video_encoder_cb() will be invoked. * @see video_util_set_video_codec() * @see video_util_supported_video_encoder_cb() */ int video_util_foreach_supported_video_codec(video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data); /** - * @brief Retrieves all supported audio encoder by invoking a specific callback for each supported audio encoder. - * @remarks The callback invocation depends on the file format. + * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder. + * @since_tizen 2.3 + * + * @remarks The callback invocation depends on the file format.\n + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n + * * @param[in] handle The handle to video util - * @param[in] callback The callback function to invoke + * @param[in] callback The callback function to be invoked * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * + * @return @c 0 on success, + * otherwise a negative error value + * * @retval #VIDEO_UTIL_ERROR_NONE Successful * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter - * @post video_util_supported_audio_encoder_cb() will be invoked - * @see video_util_get_audio_codec() - * @see video_util_set_audio_codec() + * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format + * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported + * @post video_util_supported_audio_encoder_cb() will be invoked. * @see video_util_supported_audio_encoder_cb() */ int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data); diff --git a/include/video_util_private.h b/include/video_util_private.h index 9dc5c29..34910a9 100755 --- a/include/video_util_private.h +++ b/include/video_util_private.h @@ -19,23 +19,41 @@ #define __TIZEN_VIDEO_UTIL_PRIVATE_H__ #include -#include #include +#include +#include -typedef bool (*video_util_supported_type_cb)(int type, void *user_data); +#ifdef LOG_TAG +#undef LOG_TAG +#endif -typedef struct -{ - char *input_path; - bool accurate_mode; - video_util_video_codec_e video_codec; - video_util_audio_codec_e audio_codec; - video_util_file_format_e file_format; - int width; - int height; - int fps; - MMHandleType transcode_h; -}video_util_s; +#define LOG_TAG "CAPI_MEDIA_VIDEO_UTIL" + +#define video_util_debug(fmt, arg...) do { \ + LOGD(""fmt"", ##arg); \ + } while (0) + +#define video_util_info(fmt, arg...) do { \ + LOGI(""fmt"", ##arg); \ + } while (0) + +#define video_util_error(fmt, arg...) do { \ + LOGE(""fmt"", ##arg); \ + } while (0) + +#define video_util_debug_fenter() do { \ + LOGD(""); \ + } while (0) + +#define video_util_debug_fleave() do { \ + LOGD(""); \ + } while (0) + +#define video_util_secure_info(fmt, arg...) do { \ + SECURE_LOGI(""fmt"", ##arg); \ + } while (0) + +typedef bool (*video_util_supported_type_cb)(int type, void *user_data); typedef struct { @@ -50,6 +68,21 @@ typedef struct video_util_supported_type_cb supported_type_cb; }video_util_type_cb_s; +typedef struct +{ + char *input_path; + bool accurate_mode; + video_util_video_codec_e video_codec; + video_util_audio_codec_e audio_codec; + video_util_file_format_e file_format; + int width; + int height; + int fps; + unsigned long bps; + MMHandleType transcode_h; + video_util_cb_s *_util_cb; +}video_util_s; + typedef enum { VIDEO_UTIL_TYPE_FORMAT = 0, diff --git a/include/video_util_type.h b/include/video_util_type.h index 0e71ce4..b9af21c 100755 --- a/include/video_util_type.h +++ b/include/video_util_type.h @@ -28,8 +28,11 @@ extern "C" { #define DEPRECATED_API __attribute__ ((deprecated)) #endif - -#define VIDEO_UTIL_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x90 +#define VIDEO_UTIL_ERROR_CLASS TIZEN_ERROR_VIDEO_UTIL +#define TRANSCODER_FEATURE_PATH "http://tizen.org/feature/multimedia.transcoder" +/** + * @file video_util_type.h + */ /** * @addtogroup CAPI_MEDIA_VIDEO_UTIL_MODULE @@ -38,68 +41,80 @@ extern "C" { /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief The enumerations of video util error + * @brief Enumeration for errors of a video util. + * @since_tizen 2.3 */ typedef enum { - VIDEO_UTIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - VIDEO_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - VIDEO_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - VIDEO_UTIL_ERROR_INVALID_OPERATION = VIDEO_UTIL_ERROR_CLASS | 0x01, /**< Invalid operation */ - VIDEO_UTIL_ERROR_BUSY = VIDEO_UTIL_ERROR_CLASS | 0x02, /**< Transcoding is already running */ + VIDEO_UTIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + VIDEO_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + VIDEO_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + VIDEO_UTIL_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + VIDEO_UTIL_ERROR_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */ + VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT = TIZEN_ERROR_VIDEO_UTIL | 0x01, /**< Not supported format */ + VIDEO_UTIL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + VIDEO_UTIL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported */ } video_util_error_e; /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief The enumerations of video codec + * @brief Enumeration for video codec. + * @since_tizen 2.3 */ typedef enum { VIDEO_UTIL_VIDEO_CODEC_MPEG4 = 0, /**< MPEG4 */ VIDEO_UTIL_VIDEO_CODEC_H263, /**< H.263 */ VIDEO_UTIL_VIDEO_CODEC_H264, /**< H.264 */ - VIDEO_UTIL_VIDEO_CODEC_NONE /**< no transcoding for video */ + VIDEO_UTIL_VIDEO_CODEC_NONE /**< No transcoding for video */ }video_util_video_codec_e; /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief The enumerations of audio codec + * @brief Enumeration for audio codec. + * @since_tizen 2.3 */ typedef enum { VIDEO_UTIL_AUDIO_CODEC_AAC = 0, /**< AAC */ - VIDEO_UTIL_AUDIO_CODEC_AMRNB, /**< AMRNB */ - VIDEO_UTIL_AUDIO_CODEC_NONE /**< no transcoding for audio */ + VIDEO_UTIL_AUDIO_CODEC_AMRNB, /**< AMRNB */ + VIDEO_UTIL_AUDIO_CODEC_NONE /**< No transcoding for audio */ }video_util_audio_codec_e; /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief The enumerations of media format + * @brief Enumeration for formats of a media. + * @since_tizen 2.3 */ typedef enum { VIDEO_UTIL_FILE_FORMAT_3GP = 0, /**< 3GP */ - VIDEO_UTIL_FILE_FORMAT_MP4, /**< MP4 */ - VIDEO_UTIL_FILE_FORMAT_MAX /**< MAX */ + VIDEO_UTIL_FILE_FORMAT_MP4, /**< MP4 */ + VIDEO_UTIL_FILE_FORMAT_MAX /**< MAX */ }video_util_file_format_e; /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief The handle to video util + * @brief Video util handle. + * @since_tizen 2.3 */ typedef struct video_util_s *video_util_h; /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE - * @brief Called during the video transcoding regularly. - The interval of callback invocation depends on the framework. + * @brief Called regularly during the video transcoding. + * @since_tizen 2.3 + * + * @details The interval of callback invocation depends on the framework. * * @param[in] current_position The current position in milliseconds * @param[in] duration The duration in seconds * @param[in] user_data The user data passed from the callback registration function + * * @pre This callback function is invoked if you register this callback using video_util_set_progress_transcoding_cb(). + * * @see video_util_start_transcoding() */ typedef void (*video_util_transcoding_progress_cb)(unsigned long current_position, unsigned long duration, void *user_data); @@ -107,37 +122,53 @@ typedef void (*video_util_transcoding_progress_cb)(unsigned long current_positio /** * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE * @brief Called when transcoding is finished just before storing in the file. + * @since_tizen 2.3 * * @param[in] error_code The error code of video util * @param[in] user_data The user data passed from the callback registration function + * * @pre video_util_start_transcoding() will invoke this function. */ typedef void (*video_util_transcoding_completed_cb)(video_util_error_e error_code, void *user_data); /** - * @brief Gets called iteratively to notify you of supported file formats. + * @brief Called iteratively to notify you about the supported file formats. + * @since_tizen 2.3 + * * @param[in] format The format of media 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 @c false to break out of the loop + * + * @return @c true to continue with the next iteration of the loop, + * otherwise @c false to break out of the loop + * * @pre video_util_foreach_supported_file_format() will invoke this callback. */ typedef bool (*video_util_supported_file_format_cb)(video_util_file_format_e format, void *user_data); /** - * @brief Gets called iteratively to notify you of supported video codec. + * @brief Called iteratively to notify you of supported video codec. + * @since_tizen 2.3 + * * @param[in] format The codec of video * @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 @c false to break out of the loop + * + * @return @c true to continue with the next iteration of the loop, + * otherwise @c false to break out of the loop + * * @pre video_util_foreach_supported_video_codec() will invoke this callback. */ typedef bool (*video_util_supported_video_encoder_cb)(video_util_video_codec_e codec, void *user_data); - /** - * @brief Gets called iteratively to notify you of supported audio codec. + * @brief Called iteratively to notify you about the supported audio codec. + * @since_tizen 2.3 + * * @param[in] format The codec of audio * @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 @c false to break out of the loop + * + * @return @c true to continue with the next iteration of the loop, + * otherwise @c false to break out of the loop + * * @pre video_util_foreach_supported_audio_codec() will invoke this callback. */ typedef bool (*video_util_supported_audio_encoder_cb)(video_util_audio_codec_e codec, void *user_data); @@ -145,8 +176,6 @@ typedef bool (*video_util_supported_audio_encoder_cb)(video_util_audio_codec_e c __attribute__ ((deprecated)) typedef bool (*video_util_progress_transcoding_cb)(video_util_error_e error, unsigned long current_position, unsigned long duration, void *user_data); - - /** * @} */ diff --git a/packaging/capi-media-video-util.spec b/packaging/capi-media-video-util.spec index c855aa1..86e2fac 100755 --- a/packaging/capi-media-video-util.spec +++ b/packaging/capi-media-video-util.spec @@ -1,7 +1,7 @@ Name: capi-media-video-util Summary: A Video Utility library in Tizen Native API -Version: 0.1.6 -Release: 2 +Version: 0.1.7 +Release: 5 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz @@ -10,6 +10,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-common) BuildRequires: pkgconfig(mm-transcode) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-system-info) BuildRequires: cmake BuildRequires: gettext-devel diff --git a/src/video_util.c b/src/video_util.c index 94acc84..81394d7 100755 --- a/src/video_util.c +++ b/src/video_util.c @@ -38,6 +38,7 @@ #define VIDEO_UTIL_MINIMUM_DURATION 1000 /*1 sec*/ #define VIDEO_UTIL_MINIMUM_FPS 5 #define VIDEO_UTIL_MAXIMUM_FPS 30 +#define VIDEO_UTIL_MAXIMUM_BPS 4294967295UL static int __video_util_create_transcode_handle(video_util_s *handle); static int __video_util_destroy_transcode_handle(video_util_s *handle); @@ -62,14 +63,18 @@ static int __video_util_create_transcode_handle(video_util_s *handle) ret = mm_transcode_create(&transcode_h); if(ret != MM_ERROR_NONE) { - if(ret == MM_ERROR_INVALID_ARGUMENT) + if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) + { + video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } @@ -77,19 +82,30 @@ static int __video_util_create_transcode_handle(video_util_s *handle) ret = mm_transcode_prepare(transcode_h, handle->input_path, handle->file_format, handle->video_codec, handle->audio_codec); if(ret != MM_ERROR_NONE) { - if(ret == MM_ERROR_INVALID_ARGUMENT) + if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + ret = VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) + { + video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); - return VIDEO_UTIL_ERROR_INVALID_OPERATION; + video_util_error("INVALID_OPERATION(0x%08x)", ret); + ret = VIDEO_UTIL_ERROR_INVALID_OPERATION; } } - handle->transcode_h = transcode_h; + if(ret == MM_ERROR_NONE) + { + handle->transcode_h = transcode_h; + } + else + { + __video_util_destroy_transcode_handle(handle); + } return ret; } @@ -102,10 +118,9 @@ static int __video_util_destroy_transcode_handle(video_util_s *handle) if(handle->transcode_h) { ret = mm_transcode_destroy(handle->transcode_h); - LOGI("mm_transcode_destroy [%d]\n", ret); if(ret != MM_ERROR_NONE) { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION (0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } @@ -124,7 +139,7 @@ int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy) ret = mm_transcode_is_busy(handle->transcode_h, is_busy); if(ret != MM_ERROR_NONE) { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } @@ -140,7 +155,7 @@ static bool __video_util_check_video_codec(video_util_video_codec_e video_codec) { if((video_codec < 0) || (video_codec > VIDEO_UTIL_VIDEO_CODEC_NONE )) { - LOGE("invalid video_codec [%d]", video_codec); + video_util_error("invalid video_codec [%d]", video_codec); return false; } @@ -151,7 +166,7 @@ static bool __video_util_check_audio_codec(video_util_audio_codec_e audio_codec) { if((audio_codec < 0) || (audio_codec > VIDEO_UTIL_AUDIO_CODEC_NONE )) { - LOGE("invalid audio_codec [%d]", audio_codec); + video_util_error("invalid audio_codec [%d]", audio_codec); return false; } @@ -162,7 +177,7 @@ static bool __video_util_check_file_format(video_util_file_format_e file_format) { if((file_format < 0) || (file_format >= VIDEO_UTIL_FILE_FORMAT_MAX )) { - LOGE("invalid file_format [%d]", file_format); + video_util_error("invalid file_format [%d]", file_format); return false; } @@ -173,13 +188,13 @@ static bool __video_util_check_resolution(int width, int height) { if(((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0)) { - LOGE("invalid width [%d]", width); + video_util_error("invalid width [%d]", width); return false; } if(((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0)) { - LOGE("invalid height [%d]", height); + video_util_error("invalid height [%d]", height); return false; } @@ -190,7 +205,7 @@ static bool __video_util_check_duration(int duration) { if(((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0)) { - LOGE("invalid duration [%d]", duration); + video_util_error("invalid duration [%d]", duration); return false; } @@ -201,7 +216,7 @@ static bool __video_util_check_fps(int fps) { if((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS)) { - LOGE("invalid fps [%d]", fps); + video_util_error("invalid fps [%d]", fps); return false; } @@ -210,27 +225,29 @@ static bool __video_util_check_fps(int fps) static video_util_error_e __video_util_error_convert(int error) { - LOGI("error [%d]\n", error); - if(error == MM_ERROR_NONE) { + video_util_debug("Error None"); return VIDEO_UTIL_ERROR_NONE; } - else if(error == MM_ERROR_INVALID_ARGUMENT) + else if(error == MM_ERROR_TRANSCODE_INVALID_VALUE) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } else if(error == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) + { + video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", error); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } static void __video_util_transcode_progress_cb(unsigned long current_position, unsigned long duration, void *user_data) { - int error_value = VIDEO_UTIL_ERROR_NONE; video_util_cb_s *_util_cb = (video_util_cb_s *)user_data; if((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL)) @@ -293,8 +310,8 @@ static int __video_util_foreach_supported_type(video_util_type_e type, video_uti } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + video_util_error("Invalid type (%d)", type); + ret = VIDEO_UTIL_ERROR_INVALID_PARAMETER; } UTIL_SAFE_FREE(codec_cb); @@ -306,18 +323,27 @@ int video_util_create(video_util_h *handle) { int ret = VIDEO_UTIL_ERROR_NONE; - LOGI("enter \n"); + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } if(handle == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } video_util_s *_handle = (video_util_s*)calloc(1,sizeof(video_util_s)); if(_handle == NULL) { - LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY); return VIDEO_UTIL_ERROR_OUT_OF_MEMORY; } @@ -330,46 +356,65 @@ int video_util_create(video_util_h *handle) _handle->height = 0; _handle->fps = 0; _handle->transcode_h = 0; + _handle->_util_cb = NULL; *handle = (video_util_h)_handle; - LOGI("leave \n"); - return ret; } int video_util_destroy(video_util_h handle) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - LOGI("enter \n"); + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } - if(!_handle) + _handle = (video_util_s*)handle; + if(_handle == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } ret = __video_util_destroy_transcode_handle(_handle); + UTIL_SAFE_FREE(_handle->_util_cb); + video_util_debug("FREE(_handle->_util_cb)"); UTIL_SAFE_FREE(_handle->input_path); UTIL_SAFE_FREE(_handle); - LOGI("leave \n"); - return ret; } int video_util_set_file_path(video_util_h handle, const char *file_path) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; bool is_busy = false; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if((_handle != NULL) && (UTIL_STRING_VALID(file_path))) { - LOGI("file_path [%s]\n", file_path); + video_util_secure_info("file_path [%s]\n", file_path); if(_handle->input_path != NULL) { @@ -379,7 +424,7 @@ int video_util_set_file_path(video_util_h handle, const char *file_path) if(is_busy) { - LOGE("BUSY!! Transcoding is already running.\n"); + video_util_error("BUSY!! Transcoding is already running.\n"); return VIDEO_UTIL_ERROR_BUSY; } else @@ -395,81 +440,42 @@ int video_util_set_file_path(video_util_h handle, const char *file_path) _handle->input_path = strdup(file_path); if(_handle->input_path == NULL) { - LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY); return VIDEO_UTIL_ERROR_OUT_OF_MEMORY; } } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } return ret; } -int video_util_get_file_path(video_util_h handle, char **file_path) +int video_util_set_accurate_mode(video_util_h handle, bool accurate_mode) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && file_path) - { - if(UTIL_STRING_VALID(_handle->input_path)) - { - *file_path = strdup(_handle->input_path); - if(*file_path == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_OUT_OF_MEMORY; - } - } - else - { - *file_path = NULL; + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; } - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; } - return ret; -} - -int video_util_set_accurate_mode(video_util_h handle, bool accurate_mode) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - LOGI("accurate_mode [%d]\n", accurate_mode); - + _handle = (video_util_s*)handle; if(_handle != NULL) { _handle->accurate_mode= accurate_mode; } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -int video_util_get_accurate_mode(video_util_h handle, bool *accurate_mode) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && accurate_mode) - { - *accurate_mode = _handle->accurate_mode; - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -479,11 +485,20 @@ int video_util_get_accurate_mode(video_util_h handle, bool *accurate_mode) int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; bool is_busy = false; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } - LOGI("video_codec [%d]\n", codec); - + _handle = (video_util_s*)handle; if((_handle != NULL) && (__video_util_check_video_codec(codec))) { ret = __video_util_check_transcode_is_busy(_handle, &is_busy); @@ -492,7 +507,7 @@ int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e cod if(is_busy) { - LOGE("BUSY!! Transcoding is already running.\n"); + video_util_error("BUSY!! Transcoding is already running.\n"); return VIDEO_UTIL_ERROR_BUSY; } else @@ -506,25 +521,7 @@ int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e cod } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -int video_util_get_video_codec(video_util_h handle, video_util_video_codec_e *codec) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && codec) - { - *codec = _handle->video_codec; - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -534,11 +531,20 @@ int video_util_get_video_codec(video_util_h handle, video_util_video_codec_e *co int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; bool is_busy = false; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } - LOGI("audio_codec [%d]\n", codec); - + _handle = (video_util_s*)handle; if((_handle != NULL) && (__video_util_check_audio_codec(codec))) { ret = __video_util_check_transcode_is_busy(_handle, &is_busy); @@ -547,7 +553,7 @@ int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e cod if(is_busy) { - LOGE("BUSY!! Transcoding is already running.\n"); + video_util_error("BUSY!! Transcoding is already running.\n"); return VIDEO_UTIL_ERROR_BUSY; } else @@ -561,25 +567,7 @@ int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e cod } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -int video_util_get_audio_codec(video_util_h handle, video_util_audio_codec_e *codec) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && codec) - { - *codec = _handle->audio_codec; - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -589,11 +577,20 @@ int video_util_get_audio_codec(video_util_h handle, video_util_audio_codec_e *co int video_util_set_file_format(video_util_h handle, video_util_file_format_e format) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; bool is_busy = false; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } - LOGI("file_format [%d]\n", format); - + _handle = (video_util_s*)handle; if((_handle != NULL) && (__video_util_check_file_format(format))) { ret = __video_util_check_transcode_is_busy(_handle, &is_busy); @@ -602,7 +599,7 @@ int video_util_set_file_format(video_util_h handle, video_util_file_format_e for if(is_busy) { - LOGE("BUSY!! Transcoding is already running.\n"); + video_util_error("BUSY!! Transcoding is already running.\n"); return VIDEO_UTIL_ERROR_BUSY; } else @@ -616,25 +613,7 @@ int video_util_set_file_format(video_util_h handle, video_util_file_format_e for } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -int video_util_get_file_format(video_util_h handle, video_util_file_format_e *format) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && format) - { - *format = _handle->file_format; - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -644,10 +623,19 @@ int video_util_get_file_format(video_util_h handle, video_util_file_format_e *fo int video_util_set_resolution(video_util_h handle, int width, int height) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - LOGI("width [%d] height [%d]\n", width, height); + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if((_handle != NULL) && (__video_util_check_resolution(width, height))) { _handle->width= width; @@ -655,26 +643,7 @@ int video_util_set_resolution(video_util_h handle, int width, int height) } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); - return VIDEO_UTIL_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -int video_util_get_resolution(video_util_h handle, int *width, int *height) -{ - int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - - if(_handle && width && height) - { - *width = _handle->width; - *height = _handle->height; - } - else - { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -684,15 +653,26 @@ int video_util_get_resolution(video_util_h handle, int *width, int *height) int video_util_set_fps(video_util_h handle, int fps) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if(_handle && __video_util_check_fps(fps)) { _handle->fps= fps; } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -702,11 +682,22 @@ int video_util_set_fps(video_util_h handle, int fps) int video_util_start_transcoding(video_util_h handle, unsigned long start, unsigned long duration, const char *out_path, video_util_transcoding_progress_cb progress_cb, video_util_transcoding_completed_cb completed_cb,void *user_data) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; mm_seek_mode_e accurate_mode = MM_SEEK_NUM; bool is_busy = false; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } - LOGI("start [%d] duration [%d]\n", start, duration); + _handle = (video_util_s*)handle; + video_util_debug("start [%d] duration [%d]\n", start, duration); if(_handle && (__video_util_check_duration(duration)) && (UTIL_STRING_VALID(_handle->input_path)) && (UTIL_STRING_VALID(out_path)) && completed_cb) { @@ -720,7 +711,7 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig if(!_handle->transcode_h) { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } @@ -732,43 +723,53 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig if(is_busy) { - LOGE("BUSY!! Transcoding is already running.\n"); + video_util_error("BUSY!! Transcoding is already running.\n"); return VIDEO_UTIL_ERROR_BUSY; } } - LOGI("width [%d] height [%d] fps [%d]v_codec [%d] a_codec [%d] file_format [%d] accurate [%d]\n", + video_util_debug("width [%d] height [%d] fps [%d]v_codec [%d] a_codec [%d] file_format [%d] accurate [%d]\n", _handle->width, _handle->height, _handle->fps, _handle->video_codec, _handle->audio_codec, _handle->file_format, _handle->accurate_mode); - video_util_cb_s *_util_cb = (video_util_cb_s*)calloc(1, sizeof(video_util_cb_s)); - _util_cb->user_data = user_data; - _util_cb->transcode_completed_cb = completed_cb; - _util_cb->transcode_progress_cb = progress_cb; + _handle->_util_cb = (video_util_cb_s*)calloc(1, sizeof(video_util_cb_s)); + if(!_handle->_util_cb) { + video_util_error("Error _util_cb"); + return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } + _handle->_util_cb->user_data = user_data; + _handle->_util_cb->transcode_completed_cb = completed_cb; + _handle->_util_cb->transcode_progress_cb = progress_cb; if(_handle->accurate_mode) accurate_mode = MM_SEEK_ACCURATE; else accurate_mode = MM_SEEK_INACCURATE; - ret = mm_transcode(_handle->transcode_h, _handle->width, _handle->height, _handle->fps, start, duration, accurate_mode, out_path, (mm_transcode_progress_callback)__video_util_transcode_progress_cb, (mm_transcode_completed_callback)__video_util_transcode_completed_cb, (void *)_util_cb); + ret = mm_transcode(_handle->transcode_h, _handle->width, _handle->height, _handle->fps, start, duration, accurate_mode, out_path, (mm_transcode_progress_callback)__video_util_transcode_progress_cb, (mm_transcode_completed_callback)__video_util_transcode_completed_cb, (void *)_handle->_util_cb); if(ret != MM_ERROR_NONE) { - if(ret == MM_ERROR_INVALID_ARGUMENT) + UTIL_SAFE_FREE(_handle->_util_cb); + + if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE) { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; + } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) + { + video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -778,32 +779,57 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig int video_util_cancel_transcoding(video_util_h handle) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if(_handle && (_handle->transcode_h)) { ret = mm_transcode_cancel(_handle->transcode_h); if(ret != MM_ERROR_NONE) { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } + UTIL_SAFE_FREE(_handle->_util_cb); + video_util_debug("FREE(_handle->_util_cb)"); + return ret; } int video_util_get_progress_transcoding(video_util_h handle, unsigned long *current_position, unsigned long *duration) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; int value = 0; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if(_handle && current_position && duration) { if(_handle->transcode_h) @@ -812,19 +838,19 @@ int video_util_get_progress_transcoding(video_util_h handle, unsigned long *curr current_position, duration, (unsigned int *)&value, (unsigned int *)&value); if(ret != MM_ERROR_NONE) { - LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION); + video_util_error("INVALID_OPERATION(0x%08x)", ret); return VIDEO_UTIL_ERROR_INVALID_OPERATION; } } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -834,15 +860,26 @@ int video_util_get_progress_transcoding(video_util_h handle, unsigned long *curr int video_util_foreach_supported_file_format(video_util_h handle, video_util_supported_file_format_cb callback, void *user_data) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if(_handle && callback) { ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_FORMAT, (video_util_supported_type_cb)callback, user_data); } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -852,15 +889,22 @@ int video_util_foreach_supported_file_format(video_util_h handle, video_util_sup int video_util_foreach_supported_video_codec(video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; - + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } + _handle = (video_util_s*)handle; if(_handle && callback) { ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_VIDEO_ENC, (video_util_supported_type_cb)callback, user_data); } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } @@ -870,15 +914,26 @@ int video_util_foreach_supported_video_codec(video_util_h handle, video_util_sup int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data) { int ret = VIDEO_UTIL_ERROR_NONE; - video_util_s *_handle = (video_util_s*)handle; + video_util_s *_handle = NULL; + bool transcoder_supported = false; + if (0 == system_info_get_platform_bool(TRANSCODER_FEATURE_PATH, &transcoder_supported)) { + if (false == transcoder_supported) { + video_util_error("VIDEO_UTIL_ERROR_NOT_SUPPORTED(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + } else { + video_util_error("Error - System Info of Platform(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED); + return VIDEO_UTIL_ERROR_NOT_SUPPORTED; + } + _handle = (video_util_s*)handle; if(_handle && callback) { ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_AUDIO_ENC, (video_util_supported_type_cb)callback, user_data); } else { - LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); + video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER); return VIDEO_UTIL_ERROR_INVALID_PARAMETER; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cf3dadd..9754ccc 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ SET(fw_test "${fw_name}-test") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog capi-base-common mm-transcode) +pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog capi-base-common capi-system-info mm-transcode) FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") MESSAGE(${flag}) diff --git a/test/video_util_test.c b/test/video_util_test.c index 9b4f984..921d0a3 100755 --- a/test/video_util_test.c +++ b/test/video_util_test.c @@ -47,7 +47,8 @@ void test_transcode_completed_cb(video_util_error_e error, void *user_data) if(_util_s->idx == (g_make_video_cnt-1)) { - g_main_loop_quit(g_loop); + if(g_loop) + g_main_loop_quit(g_loop); return; } @@ -67,7 +68,8 @@ void test_transcode_completed_cb(video_util_error_e error, void *user_data) if(ret != VIDEO_UTIL_ERROR_NONE) { printf("[%d]error video_util_cancel_transcoding [%d]\n", __LINE__, ret); - g_main_loop_quit(g_loop); + if(g_loop) + g_main_loop_quit(g_loop); return; } @@ -107,18 +109,18 @@ bool supported_spec_check(video_util_h handle) { int ret = 0; ret = video_util_foreach_supported_file_format(handle, (video_util_supported_file_format_cb)test_transcode_spec_cb, "format_check"); - printf("[%d] video_util_foreach_supported_file_format [%d]\n", __LINE__, ret); + printf("video_util_foreach_supported_file_format [%d]\n", ret); ret = video_util_foreach_supported_video_codec(handle, (video_util_supported_video_encoder_cb)test_transcode_spec_cb, "video_codec_check"); - printf("[%d] video_util_foreach_supported_video_codec [%d]\n", __LINE__, ret); + printf("video_util_foreach_supported_video_codec [%d]\n", ret); ret = video_util_foreach_supported_audio_codec(handle, (video_util_supported_audio_encoder_cb)test_transcode_spec_cb, "audio_codec_check"); - printf("[%d] video_util_foreach_supported_audio_codec [%d]\n", __LINE__, ret); + printf("video_util_foreach_supported_audio_codec [%d]\n", ret); return true; } static int test_transcode_do(test_util_s *util_s) { - int ret = 0; + int ret = VIDEO_UTIL_ERROR_NONE; char test_output_file_path[128] = {0, }; memset(test_output_file_path, 0x00, sizeof(test_output_file_path)); @@ -130,7 +132,8 @@ static int test_transcode_do(test_util_s *util_s) if(ret != VIDEO_UTIL_ERROR_NONE) { printf("[%d]error video_util_start_transcoding [%d]\n", __LINE__, ret); - g_main_loop_quit(g_loop); + if(g_loop) + g_main_loop_quit(g_loop); return ret; } @@ -186,13 +189,16 @@ int main(int argc, char *argv[]) _util_s->start_time = 0; _util_s->duration = g_duration; - test_transcode_do(_util_s); + ret = test_transcode_do(_util_s); + if(ret != VIDEO_UTIL_ERROR_NONE) + goto Exit; g_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(g_loop); g_main_loop_unref(g_loop); +Exit: ret = video_util_destroy(video_h); //destory handle in cb if(ret != VIDEO_UTIL_ERROR_NONE) {