#define LOG_TAG "CAPI_MEDIA_VIDEO_UTIL"
-#define UTIL_SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
-#define UTIL_STRING_VALID(str) \
+#define UTIL_SAFE_FREE(src) \
+ do { \
+ if (src) { \
+ free(src); \
+ src = NULL; \
+ } \
+ } while (0)
+
+#define UTIL_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? true : false)
#define VIDEO_UTIL_MINIMUM_WIDTH 128
#define VIDEO_UTIL_MINIMUM_HEIGHT 96
-#define VIDEO_UTIL_MINIMUM_DURATION 1000 /*1 sec*/
+#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
MMHandleType transcode_h = 0;
ret = mm_transcode_create(&transcode_h);
- if(ret != MM_ERROR_NONE)
- {
- if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE)
- {
+ if (ret != MM_ERROR_NONE) {
+ if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
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)
- {
+ } 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
- {
+ } else {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
}
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_TRANSCODE_INVALID_VALUE)
- {
+ if (ret != MM_ERROR_NONE) {
+ if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
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)
- {
+ } 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
- {
+ } else {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
ret = VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
}
- if(ret == MM_ERROR_NONE)
- {
+ if (ret == MM_ERROR_NONE)
handle->transcode_h = transcode_h;
- }
else
- {
__video_util_destroy_transcode_handle(handle);
- }
return ret;
}
-//when should make new trandcode handle? input_filepath or file_format or video_codec or audio_codec is modified
+/* when should make new trandcode handle? input_filepath or file_format or video_codec or audio_codec is modified */
static int __video_util_destroy_transcode_handle(video_util_s *handle)
{
int ret = VIDEO_UTIL_ERROR_NONE;
- if(handle->transcode_h)
- {
+ if (handle->transcode_h) {
ret = mm_transcode_destroy(handle->transcode_h);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
video_util_error("INVALID_OPERATION (0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
return ret;
}
-int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy)
+int __video_util_check_transcode_is_busy(video_util_s *handle, bool *is_busy)
{
int ret = VIDEO_UTIL_ERROR_NONE;
- if(handle->transcode_h)
- {
+ if (handle->transcode_h) {
ret = mm_transcode_is_busy(handle->transcode_h, is_busy);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
- }
- else
- {
+ } else {
*is_busy = false;
}
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 ))
- {
+ if ((video_codec < 0) || (video_codec > VIDEO_UTIL_VIDEO_CODEC_NONE)) {
video_util_error("invalid video_codec [%d]", video_codec);
return false;
}
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 ))
- {
+ if ((audio_codec < 0) || (audio_codec > VIDEO_UTIL_AUDIO_CODEC_NONE)) {
video_util_error("invalid audio_codec [%d]", audio_codec);
return false;
}
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 ))
- {
+ if ((file_format < 0) || (file_format >= VIDEO_UTIL_FILE_FORMAT_MAX)) {
video_util_error("invalid file_format [%d]", file_format);
return false;
}
static bool __video_util_check_resolution(int width, int height)
{
- if(((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0))
- {
+ if (((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0)) {
video_util_error("invalid width [%d]", width);
return false;
}
- if(((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0))
- {
+ if (((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0)) {
video_util_error("invalid height [%d]", height);
return false;
}
static bool __video_util_check_duration(int duration)
{
- if(((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0))
- {
+ if (((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0)) {
video_util_error("invalid duration [%d]", duration);
return false;
}
static bool __video_util_check_fps(int fps)
{
- if((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS))
- {
+ if ((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS)) {
video_util_error("invalid fps [%d]", fps);
return false;
}
static video_util_error_e __video_util_error_convert(int error)
{
- if(error == MM_ERROR_NONE)
- {
+ if (error == MM_ERROR_NONE) {
video_util_debug("Error None");
return VIDEO_UTIL_ERROR_NONE;
- }
- else if(error == MM_ERROR_TRANSCODE_INVALID_VALUE)
- {
+ } else if (error == MM_ERROR_TRANSCODE_INVALID_VALUE) {
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)
- {
+ } 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
- {
+ return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ } else {
video_util_error("INVALID_OPERATION(0x%08x)", error);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
{
video_util_cb_s *_util_cb = (video_util_cb_s *)user_data;
- if((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL))
- {
+ if ((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL))
_util_cb->transcode_progress_cb(current_position, duration, _util_cb->user_data);
- }
return;
}
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_completed_cb != NULL))
- {
+ if ((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL)) {
error_value = __video_util_error_convert(error);
_util_cb->transcode_completed_cb(error_value, _util_cb->user_data);
}
{
video_util_type_cb_s *codec_cb = (video_util_type_cb_s *)user_data;
- if(codec_cb != NULL)
- {
- if (codec_cb->supported_type_cb) {
+ if (codec_cb != NULL) {
+ if (codec_cb->supported_type_cb)
codec_cb->supported_type_cb(codec_type, codec_cb->user_data);
- }
}
return true;
{
int ret = VIDEO_UTIL_ERROR_NONE;
- video_util_type_cb_s *codec_cb = (video_util_type_cb_s*)calloc(1, sizeof(video_util_type_cb_s));
+ video_util_type_cb_s *codec_cb = (video_util_type_cb_s *)calloc(1, sizeof(video_util_type_cb_s));
codec_cb->user_data = user_data;
codec_cb->supported_type_cb = (video_util_supported_type_cb)callback;
- if(type == VIDEO_UTIL_TYPE_FORMAT)
- {
+ if (type == VIDEO_UTIL_TYPE_FORMAT)
ret = mm_transcode_get_supported_container_format((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
- }
- else if(type == VIDEO_UTIL_TYPE_VIDEO_ENC)
- {
+ else if (type == VIDEO_UTIL_TYPE_VIDEO_ENC)
ret = mm_transcode_get_supported_video_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
- }
- else if(type == VIDEO_UTIL_TYPE_AUDIO_ENC)
- {
+ else if (type == VIDEO_UTIL_TYPE_AUDIO_ENC)
ret = mm_transcode_get_supported_audio_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
- }
- else
- {
+ else {
video_util_error("Invalid type (%d)", type);
ret = VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- if(handle == NULL)
- {
+ if (handle == NULL) {
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)
- {
+ video_util_s *_handle = (video_util_s *)calloc(1, sizeof(video_util_s));
+ if (_handle == NULL) {
video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY);
return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle == NULL)
- {
+ _handle = (video_util_s *)handle;
+ if (_handle == NULL) {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if((_handle != NULL) && (UTIL_STRING_VALID(file_path)))
- {
+ _handle = (video_util_s *)handle;
+ if ((_handle != NULL) && (UTIL_STRING_VALID(file_path))) {
video_util_secure_info("file_path [%s]\n", file_path);
- if(_handle->input_path != NULL)
- {
+ if (_handle->input_path != NULL) {
ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
- if(is_busy)
- {
+ if (is_busy) {
video_util_error("BUSY!! Transcoding is already running.\n");
return VIDEO_UTIL_ERROR_BUSY;
- }
- else
- {
+ } else {
ret = __video_util_destroy_transcode_handle(_handle);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
UTIL_SAFE_FREE(_handle->input_path);
}
_handle->input_path = strdup(file_path);
- if(_handle->input_path == NULL)
- {
+ if (_handle->input_path == NULL) {
video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY);
return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
}
- }
- else
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle != NULL)
- {
- _handle->accurate_mode= accurate_mode;
- }
- else
- {
+ _handle = (video_util_s *)handle;
+ if (_handle != NULL) {
+ _handle->accurate_mode = accurate_mode;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if((_handle != NULL) && (__video_util_check_video_codec(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);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
- if(is_busy)
- {
+ if (is_busy) {
video_util_error("BUSY!! Transcoding is already running.\n");
return VIDEO_UTIL_ERROR_BUSY;
- }
- else
- {
+ } else {
ret = __video_util_destroy_transcode_handle(_handle);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
}
- _handle->video_codec= codec;
- }
- else
- {
+ _handle->video_codec = codec;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if((_handle != NULL) && (__video_util_check_audio_codec(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);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
- if(is_busy)
- {
+ if (is_busy) {
video_util_error("BUSY!! Transcoding is already running.\n");
return VIDEO_UTIL_ERROR_BUSY;
- }
- else
- {
+ } else {
ret = __video_util_destroy_transcode_handle(_handle);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
}
- _handle->audio_codec= codec;
- }
- else
- {
+ _handle->audio_codec = codec;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if((_handle != NULL) && (__video_util_check_file_format(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);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
- if(is_busy)
- {
+ if (is_busy) {
video_util_error("BUSY!! Transcoding is already running.\n");
return VIDEO_UTIL_ERROR_BUSY;
- }
- else
- {
+ } else {
ret = __video_util_destroy_transcode_handle(_handle);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
}
- _handle->file_format= format;
- }
- else
- {
+ _handle->file_format = format;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if((_handle != NULL) && (__video_util_check_resolution(width, height)))
- {
- _handle->width= width;
- _handle->height= height;
- }
- else
- {
+ _handle = (video_util_s *)handle;
+ if ((_handle != NULL) && (__video_util_check_resolution(width, height))) {
+ _handle->width = width;
+ _handle->height = height;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle && __video_util_check_fps(fps))
- {
- _handle->fps= fps;
- }
- else
- {
+ _handle = (video_util_s *)handle;
+ if (_handle && __video_util_check_fps(fps)) {
+ _handle->fps = fps;
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return ret;
}
-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 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 = NULL;
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
+ _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)
- {
- if(!_handle->transcode_h)
- {
+ if (_handle && (__video_util_check_duration(duration)) && (UTIL_STRING_VALID(_handle->input_path)) && (UTIL_STRING_VALID(out_path)) && completed_cb) {
+ if (!_handle->transcode_h) {
ret = __video_util_create_transcode_handle(_handle);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE)
return ret;
- }
- if(!_handle->transcode_h)
- {
+ if (!_handle->transcode_h) {
video_util_error("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
- }
- else
- {
+ } else {
ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
return ret;
- if(is_busy)
- {
+ if (is_busy) {
video_util_error("BUSY!! Transcoding is already running.\n");
return VIDEO_UTIL_ERROR_BUSY;
}
}
- 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_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);
- _handle->_util_cb = (video_util_cb_s*)calloc(1, sizeof(video_util_cb_s));
- if(!_handle->_util_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->transcode_completed_cb = completed_cb;
_handle->_util_cb->transcode_progress_cb = progress_cb;
- if(_handle->accurate_mode)
+ 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 *)_handle->_util_cb);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
UTIL_SAFE_FREE(_handle->_util_cb);
- if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE)
- {
+ if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
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)
- {
+ } 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
- {
+ } else {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
}
- }
- else
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle && (_handle->transcode_h))
- {
+ _handle = (video_util_s *)handle;
+ if (_handle && (_handle->transcode_h)) {
ret = mm_transcode_cancel(_handle->transcode_h);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
- }
- else
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle && current_position && duration)
- {
- if(_handle->transcode_h)
- {
- ret = mm_transcode_get_attrs(_handle->transcode_h, (mm_containerformat_e *)&value, (mm_videoencoder_e *)&value, (mm_audioencoder_e *)&value,
- current_position, duration, (unsigned int *)&value, (unsigned int *)&value);
- if(ret != MM_ERROR_NONE)
- {
+ _handle = (video_util_s *)handle;
+ if (_handle && current_position && duration) {
+ if (_handle->transcode_h) {
+ ret = mm_transcode_get_attrs(_handle->transcode_h, (mm_containerformat_e *)&value, (mm_videoencoder_e *)&value, (mm_audioencoder_e *)&value, current_position, duration, (unsigned int *)&value, (unsigned int *)&value);
+ if (ret != MM_ERROR_NONE) {
video_util_error("INVALID_OPERATION(0x%08x)", ret);
return VIDEO_UTIL_ERROR_INVALID_OPERATION;
}
- }
- else
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
- }
- else
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle && callback)
- {
+ _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
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
}
- _handle = (video_util_s*)handle;
- if(_handle && callback)
- {
+ _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
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
}
- _handle = (video_util_s*)handle;
- if(_handle && callback)
- {
+ _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
- {
+ } else {
video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
}
#include <glib.h>
#include <video_util.h>
-//#define CANCEL_TEST
+/* #define CANCEL_TEST */
-typedef struct
-{
+typedef struct {
video_util_h video_h;
int idx;
int start_time;
int duration;
-}test_util_s;
+} test_util_s;
GMainLoop *g_loop = NULL;
int g_make_video_cnt = 5;
int start_position = 0;
test_util_s *_util_s = (test_util_s *)user_data;
- printf("transcode_completed_cb============= [%2d][%d]\n", _util_s->idx, error);
+ g_print("transcode_completed_cb============= [%2d][%d]\n", _util_s->idx, error);
- if(_util_s->idx == (g_make_video_cnt-1))
- {
- if(g_loop)
+ if (_util_s->idx == (g_make_video_cnt - 1)) {
+ if (g_loop)
g_main_loop_quit(g_loop);
return;
}
#ifdef CANCEL_TEST
int ret = VIDEO_UTIL_ERROR_NONE;
- if(_util_s->idx == 3)
- {
- printf("Try cancel============= [%2d]]\n", _util_s->idx);
+ if (_util_s->idx == 3) {
+ g_print("Try cancel============= [%2d]]\n", _util_s->idx);
ret = video_util_cancel_transcoding(_util_s->video_h);
- if(ret != VIDEO_UTIL_ERROR_NONE)
- {
- printf("[%d]error video_util_cancel_transcoding [%d]\n", __LINE__, ret);
- if(g_loop)
+ if (ret != VIDEO_UTIL_ERROR_NONE) {
+ g_print("[%d]error video_util_cancel_transcoding [%d]\n", __LINE__, ret);
+ if (g_loop)
g_main_loop_quit(g_loop);
return;
}
{
test_util_s *_util_s = (test_util_s *)user_data;
- printf("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, current_position, duration);
+ g_print("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, current_position, duration);
#if 0
unsigned long pos = 0;
unsigned long dur = 0;
video_util_get_progress_transcoding(_util_s->video_h, &pos, &dur);
- printf("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, pos, dur);
+ g_print("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, pos, dur);
#endif
return;
}
bool test_transcode_spec_cb(int value, void *user_data)
{
- if(user_data != NULL)
- printf("[%s]-----------", (char*)user_data);
- printf("[%d] \n", value);
+ if (user_data != NULL)
+ g_print("[%s]-----------", (char*)user_data);
+
+ g_print("[%d] \n", value);
return true;
}
{
int ret = 0;
ret = video_util_foreach_supported_file_format(handle, (video_util_supported_file_format_cb)test_transcode_spec_cb, "format_check");
- printf("video_util_foreach_supported_file_format [%d]\n", ret);
+ g_print("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("video_util_foreach_supported_video_codec [%d]\n", ret);
+ g_print("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("video_util_foreach_supported_audio_codec [%d]\n", ret);
+ g_print("video_util_foreach_supported_audio_codec [%d]\n", ret);
return true;
}
memset(test_output_file_path, 0x00, sizeof(test_output_file_path));
snprintf(test_output_file_path, sizeof(test_output_file_path), "/opt/usr/media/Videos/transcode_test_%d.mp4", util_s->idx);
- printf("g_start_time[%d] duration[%d] [%s]\n", util_s->start_time, util_s->duration, test_output_file_path);
+ g_print("g_start_time[%d] duration[%d] [%s]\n", util_s->start_time, util_s->duration, test_output_file_path);
ret = video_util_start_transcoding(util_s->video_h, util_s->start_time, util_s->duration, test_output_file_path, test_transcode_progress_cb, test_transcode_completed_cb, util_s);
- if(ret != VIDEO_UTIL_ERROR_NONE)
- {
- printf("[%d]error video_util_start_transcoding [%d]\n", __LINE__, ret);
- if(g_loop)
+ if (ret != VIDEO_UTIL_ERROR_NONE) {
+ g_print("[%d]error video_util_start_transcoding [%d]\n", __LINE__, ret);
+ if (g_loop)
g_main_loop_quit(g_loop);
+
return ret;
}
test_util_s *_util_s = NULL;
int cnt = argc -1;
- if(cnt < 1)
- {
- printf("type file path plz. [%d]\n", cnt);
+ if (cnt < 1) {
+ g_print("type file path plz. [%d]\n", cnt);
return 0;
}
ret = video_util_create(&video_h);
- if(ret != VIDEO_UTIL_ERROR_NONE)
- {
- printf("[%d]error video_util_create [%d]\n", __LINE__, ret);
- }
+ if (ret != VIDEO_UTIL_ERROR_NONE)
+ g_print("[%d]error video_util_create [%d]\n", __LINE__, ret);
#if 0
supported_spec_check(video_h);
ret = video_util_set_resolution(video_h, 176, 144);
ret = video_util_set_fps(video_h, 10);
- if(ret != VIDEO_UTIL_ERROR_NONE)
- {
- printf("[%d]error video_util_set condition [%d]\n", __LINE__, ret);
+ if (ret != VIDEO_UTIL_ERROR_NONE) {
+ g_print("[%d]error video_util_set condition [%d]\n", __LINE__, ret);
return 0;
}
- _util_s = (test_util_s*)calloc(1,sizeof(test_util_s));
- if(_util_s == NULL)
- {
- printf("[%d]error calloc\n", __LINE__);
+ _util_s = (test_util_s *)calloc(1, sizeof(test_util_s));
+ if (_util_s == NULL) {
+ g_print("[%d]error calloc\n", __LINE__);
return 0;
}
_util_s->duration = g_duration;
ret = test_transcode_do(_util_s);
- if(ret != VIDEO_UTIL_ERROR_NONE)
+ if (ret != VIDEO_UTIL_ERROR_NONE)
goto Exit;
g_loop = g_main_loop_new(NULL, FALSE);
g_main_loop_unref(g_loop);
Exit:
- ret = video_util_destroy(video_h); //destory handle in cb
- if(ret != VIDEO_UTIL_ERROR_NONE)
- {
- printf("[%d]error video_util_destroy [%d]\n", __LINE__, ret);
- }
+ /* destory handle in cb */
+ ret = video_util_destroy(video_h);
+ if (ret != VIDEO_UTIL_ERROR_NONE)
+ g_print("[%d]error video_util_destroy [%d]\n", __LINE__, ret);
else
- {
- printf("[%d]Success video_util_destroy [%d]\n", __LINE__, ret);
- }
+ g_print("[%d]Success video_util_destroy [%d]\n", __LINE__, ret);
- if(_util_s != NULL)
+ if (_util_s != NULL)
free(_util_s);
return 0;