From b710713d0427bbe3158e3f900077e3d10ba018e5 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 16 Mar 2016 10:44:18 +0900 Subject: [PATCH 01/16] Check build warning Signed-off-by: SeokHoon Lee Change-Id: I2685f28a53e4bf796b290a34418dd9596d802aa3 --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder_ini.h | 72 ------------------------------------- src/mm_streamrecorder_attribute.c | 5 ++- src/mm_streamrecorder_ini.c | 30 +--------------- src/mm_streamrecorder_internal.c | 6 ++-- src/mm_streamrecorder_recorder.c | 3 +- test/mm_streamrecorder_testsuite.c | 26 ++++---------- 7 files changed, 19 insertions(+), 125 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index e30c202..2bb8a53 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.3 +Version: 0.0.4 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder_ini.h b/src/include/mm_streamrecorder_ini.h index 7fbaca5..a65453e 100644 --- a/src/include/mm_streamrecorder_ini.h +++ b/src/include/mm_streamrecorder_ini.h @@ -133,78 +133,6 @@ typedef struct __mm_streamrecorder_ini { #define DEFAULT_SUPPORTED_VIDEO_ENCODERS "" #define DEFAULT_SUPPORTED_FILE_FORMATS "" -#define MM_STREAMRECORDER_DEFAULT_INI \ -" \ -[general]\n\ -\n\ -retrialcount =10\n\ -\n\ -minimum frame =5\n\ -\n\ -reset pause time = 0 \n\ -\n\ -screen record =0 \n\ -\n\ -convert output buffer num =6\n\ -\n\ -[encodebin]\n\ -\n\ -encsink bin profile = 0 \n\ -\n\ -encsink source auto audio resample = 0\n\ -\n\ -encsink source auto audio colorsapce = 0 \n\ -\n\ -encsink source auto audio convert =1\n\ -\n\ -encsink source use video toggle = 1\n\ -\n\ -[pipeline]\n\ -\n\ -encsink bin source = xvimagesrc\n\ -\n\ -name of audio src \n\ -\n\ -h264 encoder = omx_h264enc\n\ -\n\ -h263 encoder = omx_h263enc\n\ -\n\ -mpeg4 encoder = omx_mpeg4enc\n\ -\n\ -name of audio encoder =savsenc_aac\n\ -\n\ -name of 3GP muxer =ffmux_3gp\n\ -\n\ -use parser= \n\ -\n\ -name of MP4 muxer =ffmux_mp4\n\ -\n\ -name of video converter\n\ -\n\ -name of sink = filesink \n\ -\n\ -[video param]\n\ -\n\ -video frame wait time = 200000\n\ -\n\ -[audio param]\n\ -\n\ -audio frame minimum space = 102400\n\ -\n\ -audio frame wait time = 20000\n\ -\n\ -supported width = ""\n\ -\n\ -supported height = ""\n\ -\n\ -supported audio encoders = ""\n\ -\n\ -supported video encoders = ""\n\ -\n\ -supported file formats = ""\n\ -\n\ -" - int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t * ini); diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index 40d7c91..61464d6 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -277,6 +277,9 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /*----------------------------------------------------------------------- | LOCAL FUNCTION PROTOTYPES: | -----------------------------------------------------------------------*/ +int _mmstreamrecorder_get_available_format(MMHandleType handle, int type, int ** format); + + /* STATIC INTERNAL FUNCTION */ static int __mmstreamrecorder_set_conf_to_valid_info(MMHandleType handle) { @@ -692,7 +695,7 @@ _mmstreamrecorder_get_available_format(MMHandleType handle, int type, int ** for int count = 0; int i = 0; int fmt = 0; - const char *name = NULL; + char *name = NULL; mmf_return_val_if_fail(hstreamrecorder, 0); diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 89c4dfa..7160ec1 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -30,9 +30,6 @@ static gboolean loaded = FALSE; /* global variables here */ -#ifdef MM_STREAMRECORDER_DEFAULT_INI -static gboolean __generate_default_ini(void); -#endif static void __get_element_list(mm_streamrecorder_ini_t* ini, gchar* str, int keyword_type); static void __mm_streamrecorder_ini_check_status(void); @@ -78,31 +75,6 @@ do { \ } \ } while (0) - -#ifdef MM_STREAMRECORDER_DEFAULT_INI -static -gboolean __generate_default_ini(void) -{ - FILE *fp = NULL; - const gchar *default_ini = MM_STREAMRECORDER_DEFAULT_INI; - - /* create new file */ - fp = fopen(MM_STREAMRECORDER_INI_DEFAULT_PATH, "wt"); - - if (!fp) - return FALSE; - - /* writing default ini file */ - if (strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp)) { - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} -#endif - int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) { dictionary *dict = NULL; @@ -160,7 +132,7 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) ini->video_frame_wait_time = iniparser_getint(dict, "video param:video frame wait time", DEFAULT_VIDEO_FRAME_WAIT_TIME); /*supported attribute*/ - MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", DEFAULT_SUPPORTED_WIDTH); + MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", DEFAULT_SUPPORTED_WIDTH); MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_height, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported height", DEFAULT_SUPPORTED_HEIGHT); __get_element_list(ini, iniparser_getstring(dict, "attribute:supported audio encoders", DEFAULT_SUPPORTED_AUDIO_ENCODERS), KEYWORD_AUDIO_ENCODERS); __get_element_list(ini, iniparser_getstring(dict, "attribute:supported video encoders", DEFAULT_SUPPORTED_VIDEO_ENCODERS), KEYWORD_VIDEO_ENCODERS); diff --git a/src/mm_streamrecorder_internal.c b/src/mm_streamrecorder_internal.c index 435f5d5..b9f6da6 100644 --- a/src/mm_streamrecorder_internal.c +++ b/src/mm_streamrecorder_internal.c @@ -46,10 +46,13 @@ /*--------------------------------------------------------------------------------------- | LOCAL FUNCTION PROTOTYPES: | ---------------------------------------------------------------------------------------*/ +void _mmstreamrecorder_set_state(MMHandleType handle, int state); + /*======================================================================================= | FUNCTION DEFINITIONS | =======================================================================================*/ + /*--------------------------------------------------------------------------------------- | GLOBAL FUNCTION DEFINITIONS: | ---------------------------------------------------------------------------------------*/ @@ -375,7 +378,6 @@ int _mmstreamrecorder_record(MMHandleType handle) return MM_ERROR_NONE; _ERR_STREAMRECORDER_CMD: - _ERR_STREAMRECORDER_CMD_PRECON: /* check internal error of gstreamer */ if (hstreamrecorder->sub_context->error_code != MM_ERROR_NONE) { ret = hstreamrecorder->sub_context->error_code; @@ -442,7 +444,7 @@ int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderSt ret = _mmstreamrecorder_push_videostream_buffer(handle, timestamp, stream_buffer->buffer, size); } else if (streamtype == MM_STREAM_TYPE_AUDIO) { gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, - buffer, size, 0, buffer, stream_buffer, _mmstreamrecorder_buffer_destroy)); + buffer, size, 0, size, stream_buffer, _mmstreamrecorder_buffer_destroy)); ret = _mmstreamrecorder_push_audiostream_buffer(handle, timestamp, stream_buffer->buffer, size); } else { gst_buffer_unmap(stream_buffer->buffer, &map); diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index 2d5c083..402118e 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -1271,8 +1271,9 @@ int _mmstreamrecorder_video_handle_eos(MMHandleType handle) sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); mmf_return_val_if_fail(sc, FALSE); mmf_return_val_if_fail(sc->info_video, FALSE); - if (sc->audio_enable == TRUE) + if (sc->audio_enable == TRUE) { mmf_return_val_if_fail(sc->info_audio, FALSE); + } mmf_return_val_if_fail(sc->info_file, FALSE); diff --git a/test/mm_streamrecorder_testsuite.c b/test/mm_streamrecorder_testsuite.c index 91403ca..5564ff6 100644 --- a/test/mm_streamrecorder_testsuite.c +++ b/test/mm_streamrecorder_testsuite.c @@ -686,16 +686,10 @@ static void setting_menu(gchar buf) int width_count = 0; int height_count = 0; int i = 0; - int count = 0; - int value = 0; - int* array = NULL; int *width_array = NULL; int *height_array = NULL; - char *err_attr_name = NULL; str_xypair_t input_pair; - char filename[100]; int err = MM_ERROR_NONE; - int x = 0, y = 0, width = 0, height = 0; if (hstreamrecorder->mode == MODE_VIDEO_CAPTURE) { switch (buf) { @@ -992,17 +986,11 @@ static gboolean init(int type) char *err_attr_name = NULL; int video_codec = MM_VIDEO_CODEC_INVALID; - int audio_codec = MM_AUDIO_CODEC_INVALID; int file_format = MM_FILE_FORMAT_INVALID; - int audio_enc = MM_AUDIO_CODEC_INVALID; - int channel = 0; int v_bitrate = 0; - int a_bitrate = 0; int video_width = 0; int video_height = 0; int video_fps = 0; - int audio_samplerate = 0; - int audio_src_format = 0; int video_src_format = 0; int rec_mode = 0; const char *filename = "/opt/usr/media/test.mp4"; @@ -1020,17 +1008,17 @@ static gboolean init(int type) *=================================================================================*/ if (type == MODE_VIDEO_CAPTURE) { video_codec = MM_VIDEO_CODEC_MPEG4; - /*audio_codec = MM_AUDIO_CODEC_AAC;*/ + /* audio_codec = MM_AUDIO_CODEC_AAC; */ file_format = MM_FILE_FORMAT_MP4; - /*audio_enc = MM_AUDIO_CODEC_PCM;*/ - /*channel = 1; - v_bitrate = 8000000; - /*a_bitrate = 64000;*/ + /* audio_enc = MM_AUDIO_CODEC_PCM; */ + /* channel = 1; */ + /* v_bitrate = 8000000; */ + /* a_bitrate = 64000; */ video_width = 640; video_height = 480; video_fps = 30; - /*audio_samplerate = 48000;*/ - /*audio_src_format = 2;*/ + /* audio_samplerate = 48000; */ + /* audio_src_format = 2; */ rec_mode = 0; video_src_format = MM_STREAMRECORDER_INPUT_FORMAT_NV12; mm_streamrecorder_set_attributes((MMHandleType)str_handle, &err_attr_name, -- 2.7.4 From 8d8b63818516c682fc07491d72aa27f8a1048efd Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 16 Mar 2016 16:08:27 +0900 Subject: [PATCH 02/16] migration /usr/etc directory to sysconfdir(/etc)/multimedia Signed-off-by: SeokHoon Lee Change-Id: Ibcb1fb2ab848a8baf086da081d99f2adbd4965dc --- packaging/libmm-streamrecorder.spec | 3 ++- src/include/mm_streamrecorder_ini.h | 2 +- src/include/mm_streamrecorder_util.h | 4 ---- src/mm_streamrecorder_ini.c | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 2bb8a53..cbbfafb 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.4 +Version: 0.0.5 Release: 0 Group: Multimedia/Other License: Apache-2.0 @@ -35,6 +35,7 @@ Media Stream Recorder development library %build #export CFLAGS+=" -DGST_EXT_TIME_ANALYSIS" export CFLAGS+=" -Wall -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable" +export CFLAGS+=" -DSYSCONFDIR=\\\"%{_sysconfdir}\\\"" ./autogen.sh %configure --disable-static make %{?jobs:-j%jobs} diff --git a/src/include/mm_streamrecorder_ini.h b/src/include/mm_streamrecorder_ini.h index a65453e..09fcfcd 100644 --- a/src/include/mm_streamrecorder_ini.h +++ b/src/include/mm_streamrecorder_ini.h @@ -31,7 +31,7 @@ extern "C" { #endif -#define MM_STREAMRECORDER_INI_DEFAULT_PATH "/usr/etc/mmfw_streamrecorder.ini" +#define MM_STREAMRECORDER_INI_DEFAULT_PATH SYSCONFDIR"/multimedia/mmfw_streamrecorder.ini" #define STREAMRECORDER_INI_MAX_STRLEN 256 #define STREAMRECORDER_INI_MAX_ELEMENT 10 diff --git a/src/include/mm_streamrecorder_util.h b/src/include/mm_streamrecorder_util.h index f0806eb..387badc 100644 --- a/src/include/mm_streamrecorder_util.h +++ b/src/include/mm_streamrecorder_util.h @@ -127,10 +127,6 @@ enum { }\ } -#if 0 -#define MM_STREAMRECORDER_INI_DEFAULT_PATH "/usr/etc/mmfw_transcode.ini" -#define STREAMRECORDER_INI_MAX_STRLEN 100 -#endif /*======================================================================================= | ENUM DEFINITIONS | ========================================================================================*/ diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 7160ec1..3a67847 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -316,10 +316,10 @@ void __mm_streamrecorder_ini_check_status(void) debug_fenter(); if (g_stat(MM_STREAMRECORDER_INI_DEFAULT_PATH, &ini_buff) < 0) { - _mmstreamrec_dbg_err("failed to get mmfw_wfd_sink ini status\n"); + _mmstreamrec_dbg_err("failed to get mmfw_streamrecorder.ini status\n"); } else { if (ini_buff.st_size < 5) { - _mmstreamrec_dbg_err("mmfw_wfd_sink.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size); + _mmstreamrec_dbg_err("mmfw_streamrecorder.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size); g_remove(MM_STREAMRECORDER_INI_DEFAULT_PATH); } } -- 2.7.4 From 931c3609d3b59bf8fc211e9cd7d1cb5034a9b8d8 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 5 Apr 2016 11:42:52 +0900 Subject: [PATCH 03/16] mm_streamrecorder_get_attribute_info move to streamrecorder from streamrecorder_attribute, because of warning in mediastreamrecorder package Signed-off-by: SeokHoon Lee Change-Id: I1c12339df727d68467b95f6c6a7f61611bee74cf --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder.h | 20 ++++++++++++++ src/include/mm_streamrecorder_attribute.h | 22 +--------------- src/mm_streamrecorder.c | 5 ++++ src/mm_streamrecorder_attribute.c | 43 ++++++++++++++----------------- src/mm_streamrecorder_ini.c | 16 ++++++------ 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index cbbfafb..1b9de95 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.5 +Version: 0.0.6 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder.h b/src/include/mm_streamrecorder.h index 6414668..a369d7b 100644 --- a/src/include/mm_streamrecorder.h +++ b/src/include/mm_streamrecorder.h @@ -613,6 +613,26 @@ int mm_streamrecorder_get_attributes(MMHandleType streamrecorder, char **err_att int mm_streamrecorder_set_attributes(MMHandleType streamrecorder, char **err_attr_name, const char *attribute_name, ...) G_GNUC_NULL_TERMINATED; /** + * mm_streamrecorder_get_attribute_info:\n + * Get detail information of the attribute. To manager attributes, an user may want to know the exact character of the attribute, + * such as type, flag, and validity. This is the function to provide such information. + * Depending on the 'validity_type', validity union would be different. To know about the type of union, please refer 'MMStreamRecorderAttrsInfo'. + * + * @param[in] streamrecorder Specifies the streamrecorder handle. + * @param[in] attribute_name attribute name that user want to get information. + * @param[out] info a structure that holds information related with the attribute. + * @return This function returns zero(MM_ERROR_NONE) on success, or negative value with error code.\n + * Please refer 'mm_error.h' to know the exact meaning of the error. + * @pre None + * @post None + * @remarks If the function succeeds, 'info' holds detail information about the attribute, such as type, + * flag, validity_type, validity_values, and default values. + * @see mm_streamrecorder_get_attributes, mm_streamrecorder_set_attributes + */ + +int mm_streamrecorder_get_attribute_info(MMHandleType streamrecorder, const char *attribute_name, MMStreamRecorderAttrsInfo *info); + +/** * mm_streamrecorder_get_state:\n * Get the current state of streamreccorder. * mm_streamrecorderr is working on the base of its state. An user should check the state of mm_streamrecorder before calling its functions. diff --git a/src/include/mm_streamrecorder_attribute.h b/src/include/mm_streamrecorder_attribute.h index 4438ae3..4f80184 100644 --- a/src/include/mm_streamrecorder_attribute.h +++ b/src/include/mm_streamrecorder_attribute.h @@ -90,7 +90,7 @@ typedef bool(*mmf_streamrecorder_commit_func_t) (MMHandleType handle, int attr_i ========================================================================================*/ typedef struct { MMStreamRecorderAttrsID attrid; - const char *name; + char *name; int value_type; int flags; union { @@ -226,26 +226,6 @@ bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, c */ bool _mmstreamrecorder_check_supported_attribute(MMHandleType handle, int attr_index); -/** - * mm_streamrecorder_get_attribute_info:\n - * Get detail information of the attribute. To manager attributes, an user may want to know the exact character of the attribute, - * such as type, flag, and validity. This is the function to provide such information. - * Depending on the 'validity_type', validity union would be different. To know about the type of union, please refer 'MMStreamRecorderAttrsInfo'. - * - * @param[in] streamrecorder Specifies the streamrecorder handle. - * @param[in] attribute_name attribute name that user want to get information. - * @param[out] info a structure that holds information related with the attribute. - * @return This function returns zero(MM_ERROR_NONE) on success, or negative value with error code.\n - * Please refer 'mm_error.h' to know the exact meaning of the error. - * @pre None - * @post None - * @remarks If the function succeeds, 'info' holds detail information about the attribute, such as type, - * flag, validity_type, validity_values, and default values. - * @see mm_streamrecorder_get_attributes, mm_streamrecorder_set_attributes - */ - -int mm_streamrecorder_get_attribute_info(MMHandleType streamrecorder, const char *attribute_name, MMStreamRecorderAttrsInfo *info); - bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value); #ifdef __cplusplus diff --git a/src/mm_streamrecorder.c b/src/mm_streamrecorder.c index 7e867fa..ec4c9b6 100644 --- a/src/mm_streamrecorder.c +++ b/src/mm_streamrecorder.c @@ -229,3 +229,8 @@ int mm_streamrecorder_set_attributes(MMHandleType streamrecorder, char **err_att return ret; } + +int mm_streamrecorder_get_attribute_info(MMHandleType streamrecorder, const char *attribute_name, MMStreamRecorderAttrsInfo * info) +{ + return _mmstreamrecorder_get_attribute_info(streamrecorder, attribute_name, info); +} diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index 61464d6..9d8fbe3 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -43,7 +43,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 0 */ { MM_STR_VIDEO_BUFFER_TYPE, /* ID */ - "videobuffer-type", /* Name */ + (char *)"videobuffer-type", /* Name */ MMF_VALUE_TYPE_INT, /* Type */ MM_ATTRS_FLAG_RW, /* Flag */ {(void *)MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO}, /* Default value */ @@ -54,7 +54,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { }, /* 1 */ {MM_STR_VIDEO_FORMAT, - "videosource-format", + (char *)"videosource-format", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_INPUT_FORMAT_NV12}, @@ -66,7 +66,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 2 */ { MM_STR_VIDEO_FRAMERATE, - "video-framerate", + (char *)"video-framerate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -78,7 +78,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 3 */ { MM_STR_VIDEO_ENCODER_BITRATE, - "video-bitrate", + (char *)"video-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -90,7 +90,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 4 */ { MM_STR_VIDEO_RESOLUTION_WIDTH, - "video-resolution-width", + (char *)"video-resolution-width", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -102,7 +102,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 5 */ { MM_STR_VIDEO_RESOLUTION_HEIGHT, - "video-resolution-height", + (char *)"video-resolution-height", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -114,7 +114,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 6 */ { MM_STR_AUDIO_FORMAT, - "audio-source-format", + (char *)"audio-source-format", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE}, @@ -126,7 +126,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 7 */ { MM_STR_AUDIO_ENCODER_BITRATE, - "audio-bitrate", + (char *)"audio-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)128000}, @@ -138,7 +138,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 8 */ { MM_STR_AUDIO_SAMPLERATE, - "audio-samplerate", + (char *)"audio-samplerate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -150,7 +150,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 9 */ { MM_STR_VIDEO_ENCODER, - "video-encoder", + (char *)"video-encoder", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -162,7 +162,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 10 */ { MM_STR_AUDIO_ENCODER, - "audio-encoder", + (char *)"audio-encoder", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -174,7 +174,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 11 */ { MM_STR_AUDIO_CHENNEL_COUNT, - "audio-channel-count", + (char *)"audio-channel-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)2}, @@ -186,7 +186,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 12 */ { MM_STR_FILE_FORMAT, - "file-format", + (char *)"file-format", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -198,7 +198,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 13 */ { MM_STR_TARGET_FILE_NAME, - "filename", + (char *)"filename", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, {NULL}, @@ -210,7 +210,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 14 */ { MM_STR_VIDEO_ENABLE, - "video-enable", + (char *)"video-enable", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)FALSE}, @@ -222,7 +222,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 15 */ { MM_STR_AUDIO_ENABLE, - "audio-enable", + (char *)"audio-enable", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)FALSE}, @@ -234,7 +234,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 16 */ { MM_STR_MODE, - "recorder-mode", + (char *)"recorder-mode", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_MODE_MEDIABUFFER}, @@ -246,7 +246,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /*17*/ { MM_STR_TARGET_MAX_SIZE, - "target-max-size", + (char *)"target-max-size", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -258,7 +258,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /*18*/ { MM_STR_TARGET_TIME_LIMIT, - "target-time-limit", + (char *)"target-time-limit", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, @@ -1149,8 +1149,3 @@ bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, c return TRUE; } - -int mm_streamrecorder_get_attribute_info(MMHandleType streamrecorder, const char *attribute_name, MMStreamRecorderAttrsInfo * info) -{ - return _mmstreamrecorder_get_attribute_info(streamrecorder, attribute_name, info); -} diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 3a67847..49571f3 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -132,11 +132,11 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) ini->video_frame_wait_time = iniparser_getint(dict, "video param:video frame wait time", DEFAULT_VIDEO_FRAME_WAIT_TIME); /*supported attribute*/ - MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", DEFAULT_SUPPORTED_WIDTH); - MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_height, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported height", DEFAULT_SUPPORTED_HEIGHT); - __get_element_list(ini, iniparser_getstring(dict, "attribute:supported audio encoders", DEFAULT_SUPPORTED_AUDIO_ENCODERS), KEYWORD_AUDIO_ENCODERS); - __get_element_list(ini, iniparser_getstring(dict, "attribute:supported video encoders", DEFAULT_SUPPORTED_VIDEO_ENCODERS), KEYWORD_VIDEO_ENCODERS); - __get_element_list(ini, iniparser_getstring(dict, "attribute:supported file formats", DEFAULT_SUPPORTED_FILE_FORMATS), KEYWORD_FILE_FORMATS); + MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", (char *)DEFAULT_SUPPORTED_WIDTH); + MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_height, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported height", (char *)DEFAULT_SUPPORTED_HEIGHT); + __get_element_list(ini, iniparser_getstring(dict, "attribute:supported audio encoders", (char*)DEFAULT_SUPPORTED_AUDIO_ENCODERS), KEYWORD_AUDIO_ENCODERS); + __get_element_list(ini, iniparser_getstring(dict, "attribute:supported video encoders", (char*)DEFAULT_SUPPORTED_VIDEO_ENCODERS), KEYWORD_VIDEO_ENCODERS); + __get_element_list(ini, iniparser_getstring(dict, "attribute:supported file formats", (char*)DEFAULT_SUPPORTED_FILE_FORMATS), KEYWORD_FILE_FORMATS); } else { /* if dict is not available just fill the structure with default value */ _mmstreamrec_dbg_err("failed to load ini. using hardcoded default\n"); @@ -176,9 +176,9 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) ini->video_frame_wait_time = DEFAULT_VIDEO_FRAME_WAIT_TIME; /*supported attributes*/ - __get_element_list(ini, DEFAULT_SUPPORTED_AUDIO_ENCODERS, KEYWORD_AUDIO_ENCODERS); - __get_element_list(ini, DEFAULT_SUPPORTED_VIDEO_ENCODERS, KEYWORD_VIDEO_ENCODERS); - __get_element_list(ini, DEFAULT_SUPPORTED_FILE_FORMATS, KEYWORD_FILE_FORMATS); + __get_element_list(ini, (char *)DEFAULT_SUPPORTED_AUDIO_ENCODERS, KEYWORD_AUDIO_ENCODERS); + __get_element_list(ini, (char *)DEFAULT_SUPPORTED_VIDEO_ENCODERS, KEYWORD_VIDEO_ENCODERS); + __get_element_list(ini, (char *)DEFAULT_SUPPORTED_FILE_FORMATS, KEYWORD_FILE_FORMATS); } /* free dict as we got our own structure */ -- 2.7.4 From b63fdfd2d20ce66c514990203453fbca98c9e0e5 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Fri, 20 May 2016 11:15:44 +0900 Subject: [PATCH 04/16] fix memory leak - add caps_unref in buffer push function - delete unused caps and srcpad Signed-off-by: SeokHoon Lee Change-Id: Ieccbeedfe1d46d963df4ae408a3bce88c8b7805a --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_recorder.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 1b9de95..2583090 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.6 +Version: 0.0.7 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index 402118e..bfd8046 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -1843,7 +1843,7 @@ int _mmstreamrecorder_push_videostream_buffer(MMHandleType handle, unsigned long { mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); _MMStreamRecorderSubContext *sc = NULL; - GstPad *srcpad = NULL; + /* GstPad *srcpad = NULL; */ GstCaps *srccaps = NULL; char *err_name = NULL; int video_fps = 0; @@ -1871,12 +1871,16 @@ int _mmstreamrecorder_push_videostream_buffer(MMHandleType handle, unsigned long if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst) { /*_mmstreamrec_dbg_log("Buffer Push start , time stamp %ld",timestamp);*/ - srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, "src"); - srccaps = gst_pad_get_current_caps(srcpad); + /* srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, "src"); */ + /* srccaps = gst_pad_get_current_caps(srcpad); */ srccaps = gst_set_videosrcpad_caps(video_src, video_width, video_height, video_fps, 1); - gst_app_src_set_caps((GstAppSrc *) sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, srccaps); - /*_mmstreamrec_dbg_err("newbuf streamrecorder(%p) ",newbuf);*/ + if (srccaps) { + gst_app_src_set_caps((GstAppSrc *) sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, srccaps); + gst_caps_unref(srccaps); + srccaps = NULL; + } + /*_mmstreamrec_dbg_err("newbuf streamrecorder(%p) ",newbuf);*/ ret = gst_app_src_push_buffer((GstAppSrc *) sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, buffer); if (ret) { _mmstreamrec_dbg_err("video gst_app_src_push_buffer %d", ret); -- 2.7.4 From 413f24de7c84e622d7a68d1257ff92457b953c24 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Mon, 13 Jun 2016 19:58:23 +0900 Subject: [PATCH 05/16] fix buffer overflow in case of length of str equal to 255 Signed-off-by: SeokHoon Lee Change-Id: I192051c1eb739cf0bd7b4294c79a15ba9520e303 --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_ini.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 2583090..2f59972 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.7 +Version: 0.0.8 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 49571f3..240e0ae 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -43,7 +43,7 @@ do { \ if (str) { \ length = strlen(str); \ if ((length > 1) && (length < STREAMRECORDER_INI_MAX_STRLEN)) \ - strncpy(x_item, str, length+1); \ + strncpy(x_item, str, STREAMRECORDER_INI_MAX_STRLEN-1); \ else \ strncpy(x_item, x_default, STREAMRECORDER_INI_MAX_STRLEN-1); \ } else { \ -- 2.7.4 From 90c47f2683a6421dc9a6ed14931fbc757eb50dd9 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 29 Nov 2016 12:24:12 +0900 Subject: [PATCH 06/16] Delete unreached code and unused function. Load default value without ini file. Fix failure for setting attribute on 64bit environment [Version] 0.0.9 [Profile] Common [Issue Type] Code refactoring [Dependency module] N/A[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20161128.2] Signed-off-by: SeokHoon Lee Change-Id: I549d25086300286c776b5e965bc7da1bc8240ba7 --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder_recorder.h | 47 --- src/mm_streamrecorder_attribute.c | 11 +- src/mm_streamrecorder_gstdispatch.c | 7 - src/mm_streamrecorder_ini.c | 27 +- src/mm_streamrecorder_internal.c | 2 +- src/mm_streamrecorder_recorder.c | 514 ------------------------------- 7 files changed, 31 insertions(+), 579 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 2f59972..9a6cd9f 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.8 +Version: 0.0.9 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder_recorder.h b/src/include/mm_streamrecorder_recorder.h index f4f74db..20a27b0 100644 --- a/src/include/mm_streamrecorder_recorder.h +++ b/src/include/mm_streamrecorder_recorder.h @@ -140,53 +140,6 @@ int _mmstreamrecorder_destroy_recorder_pipeline(MMHandleType handle); // COMMAND int _mmstreamrecorder_video_command(MMHandleType handle, int command); -/** - * This function creates audio pipeline for audio recording. - * - * @param[in] handle Handle of streamrecorder. - * @return This function returns MM_ERROR_NONE on success, or others on failure. - * @remarks - * @see _mmstreamrecorder_destroy_audio_pipeline() - * - */ -int _mmstreamrecorder_create_audio_pipeline(MMHandleType handle); - -/** - * This function destroy audio pipeline. - * - * @param[in] handle Handle of streamrecorder. - * @return void - * @remarks - * @see _mmstreamrecorder_destroy_pipeline() - * - */ -void _mmstreamrecorder_destroy_audio_pipeline(MMHandleType handle); - -/** - * This function runs command for audio recording. - * - * @param[in] handle Handle of streamrecorder. - * @param[in] command audio recording command. - * @return This function returns MM_ERROR_NONE on success, or others on failure. - * @remarks - * @see - * - */ -int _mmstreamrecorder_audio_command(MMHandleType handle, int command); - -/** - * This function handles EOS(end of stream) when audio recording is finished. - * - * @param[in] handle Handle of streamrecorder. - * @return This function returns TRUE on success, or FALSE on failure. - * @remarks - * @see - * - */ -int _mmstreamrecorder_audio_handle_eos(MMHandleType handle); - -int _mmstreamrecorder_create_audiop_with_encodebin(MMHandleType handle); - int _mmstreamrecorder_push_videostream_buffer(MMHandleType handle, unsigned long timestamp, GstBuffer *buffer, int size); int _mmstreamrecorder_push_audiostream_buffer(MMHandleType handle, unsigned long timestamp, GstBuffer *buffer, int size); diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index 9d8fbe3..ce9a771 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -846,9 +846,13 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, { MMHandleType attrs = 0; int ret = MM_ERROR_NONE; + va_list var_args_copy; mmf_return_val_if_fail(handle, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT); + /* copy var_args to keep original var_args */ + va_copy(var_args_copy, var_args); + attrs = MMF_STREAMRECORDER_ATTRS(handle); if (!attrs) { _mmstreamrec_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name); @@ -859,8 +863,11 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, _mmstreamrec_dbg_err("__mmstreamrecorder_check_valid_pair handle 0x%x, attr name [%s] , ret = %d", handle, attribute_name, ret); - if (ret == MM_ERROR_NONE) - ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args); + if (ret == MM_ERROR_NONE) { + /* In 64bit environment, unexpected result is returned if var_args is used again. */ + ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args_copy); + } + va_end(var_args_copy); _mmstreamrec_dbg_err("mm_attrs_set_valist handle 0x%x, attr name [%s] , ret = %d", handle, attribute_name, ret); return ret; diff --git a/src/mm_streamrecorder_gstdispatch.c b/src/mm_streamrecorder_gstdispatch.c index e53c821..d572501 100644 --- a/src/mm_streamrecorder_gstdispatch.c +++ b/src/mm_streamrecorder_gstdispatch.c @@ -752,17 +752,10 @@ gboolean _mmstreamrecorder_pipeline_cb_message(GstBus *bus, GstMessage *message, sc = MMF_STREAMRECORDER_SUBCONTEXT(hstreamrecorder); mmf_return_val_if_fail(sc, TRUE); - /*if (hstreamrecorder->type != MM_STREAMRECORDER_MODE_AUDIO) { */ mmf_return_val_if_fail(sc->info_video, TRUE); if (sc->info_video->b_commiting) { _mmstreamrecorder_video_handle_eos((MMHandleType) hstreamrecorder); } - /*} else { - mmf_return_val_if_fail(sc->info_audio, TRUE); - if (sc->info_audio->b_commiting) { - _mmstreamrecorder_audio_handle_eos((MMHandleType)hstreamrecorder); - } - } */ sc->bget_eos = TRUE; diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 240e0ae..d5125e4 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -86,12 +86,6 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) /* first, try to load existing ini file */ dict = iniparser_load(MM_STREAMRECORDER_INI_DEFAULT_PATH); - /* if no file exists. create one with set of default values */ - if (!dict) { - _mmstreamrec_dbg_err("No ini file found. \n"); - return MM_ERROR_FILE_NOT_FOUND; - } - /* get ini values */ memset(ini, 0, sizeof(mm_streamrecorder_ini_t)); @@ -176,13 +170,16 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) ini->video_frame_wait_time = DEFAULT_VIDEO_FRAME_WAIT_TIME; /*supported attributes*/ + __get_element_list(ini, (char *)DEFAULT_SUPPORTED_HEIGHT, KEYWORD_VIDEO_HEIGHT); + __get_element_list(ini, (char *)DEFAULT_SUPPORTED_WIDTH, KEYWORD_VIDEO_WIDTH); __get_element_list(ini, (char *)DEFAULT_SUPPORTED_AUDIO_ENCODERS, KEYWORD_AUDIO_ENCODERS); __get_element_list(ini, (char *)DEFAULT_SUPPORTED_VIDEO_ENCODERS, KEYWORD_VIDEO_ENCODERS); __get_element_list(ini, (char *)DEFAULT_SUPPORTED_FILE_FORMATS, KEYWORD_FILE_FORMATS); } /* free dict as we got our own structure */ - iniparser_freedict(dict); + if(dict) + iniparser_freedict(dict); /* dump structure */ _mmstreamrec_dbg_log("[Stream Recorder initial setting][Start]"); @@ -262,6 +259,22 @@ void __get_element_list(mm_streamrecorder_ini_t* ini, gchar* str, int keyword /* copy list */ switch (keyword_type) { + case KEYWORD_VIDEO_HEIGHT: + { + for (walk = list; *walk; walk++) { + ini->supported_video_height[i] = atoi(*walk); + i++; + } + break; + } + case KEYWORD_VIDEO_WIDTH: + { + for (walk = list; *walk; walk++) { + ini->supported_video_width[i] = atoi(*walk); + i++; + } + break; + } case KEYWORD_AUDIO_ENCODERS: { for (walk = list; *walk; walk++) { diff --git a/src/mm_streamrecorder_internal.c b/src/mm_streamrecorder_internal.c index b9f6da6..5293609 100644 --- a/src/mm_streamrecorder_internal.c +++ b/src/mm_streamrecorder_internal.c @@ -648,7 +648,7 @@ int _mmstreamrecorder_alloc_subcontext(MMHandleType handle) goto ALLOC_SUBCONTEXT_FAILED; } - _mmstreamrecorder_alloc_subcontext_audioinfo((MMHandleType) hstreamrecorder); + ret = _mmstreamrecorder_alloc_subcontext_audioinfo((MMHandleType) hstreamrecorder); if (ret != MM_ERROR_NONE) { _mmstreamrec_dbg_err("Failed to allocate subcontext audioinfo"); goto ALLOC_SUBCONTEXT_FAILED; diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index bfd8046..d59cea5 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -1325,520 +1325,6 @@ int _mmstreamrecorder_video_handle_eos(MMHandleType handle) return TRUE; } -/* AUDIO */ - -int _mmstreamrecorder_create_audio_pipeline(MMHandleType handle) -{ - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - - mmf_return_val_if_fail(hstreamrecorder, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_val_if_fail(sc, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - - return _mmstreamrecorder_create_audiop_with_encodebin(handle); -} - -/** - * This function destroy audio pipeline. - * - * @param[in] handle Handle of streamrecorder. - * @return void - * @remarks - * @see _mmstreamrecorder_destroy_audio_pipeline() - * - */ -void _mmstreamrecorder_destroy_audio_pipeline(MMHandleType handle) -{ - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - _MMStreamRecorderAudioInfo *info = NULL; - mmf_return_if_fail(hstreamrecorder); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_if_fail(sc && sc->info_audio); - - info = sc->info_audio; - - _mmstreamrec_dbg_log("start"); - - if (sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst) { - _mmstreamrec_dbg_warn("release audio pipeline"); - - _mmstreamrecorder_gst_set_state(handle, sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst, GST_STATE_NULL); - - _mmstreamrecorder_remove_all_handlers((MMHandleType) hstreamrecorder, _MMSTREAMRECORDER_HANDLER_CATEGORY_ALL); - - if (info->bMuxing) { - GstPad *reqpad = NULL; - /* FIXME: - Release request pad - The ref_count of mux is always # of streams in here, i don't know why it happens. - So, i unref the mux manually - */ - reqpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "audio"); - gst_element_release_request_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, reqpad); - gst_object_unref(reqpad); - - if (GST_IS_ELEMENT(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst) && GST_OBJECT_REFCOUNT(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst) > 1) { - gst_object_unref(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst); - } - } - gst_object_unref(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst); - } - - _mmstreamrec_dbg_log("done"); - - return; -} - -int _mmstreamrecorder_create_audiop_with_encodebin(MMHandleType handle) -{ - int err = MM_ERROR_NONE; - char *aenc_name = NULL; - char *mux_name = NULL; - char *err_name = NULL; - int rec_mode = 0; - - GstBus *bus = NULL; - GstPad *srcpad = NULL; - GstPad *sinkpad = NULL; - GList *element_list = NULL; - - _MMStreamRecorderAudioInfo *info = NULL; - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - /* type_element *aenc_elem = NULL; */ - /* type_element *mux_elem = NULL; */ - - mmf_return_val_if_fail(hstreamrecorder, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_val_if_fail(sc, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - mmf_return_val_if_fail(sc->info_audio, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - - info = (_MMStreamRecorderAudioInfo *) sc->info_audio; - - _mmstreamrec_dbg_log(""); - - err = mm_streamrecorder_get_attributes(handle, &err_name, MMSTR_RECORDER_MODE, &rec_mode, NULL); - - if (!mux_name || !strcmp(mux_name, "wavenc")) { - /* IF MUX in not chosen then record in raw file */ - _mmstreamrec_dbg_log("Record without muxing."); - info->bMuxing = FALSE; - } else { - _mmstreamrec_dbg_log("Record with mux."); - info->bMuxing = TRUE; - } - - /* Create GStreamer pipeline */ - _MMSTREAMRECORDER_PIPELINE_MAKE(sc, sc->encode_element, _MMSTREAMRECORDER_ENCODE_MAIN_PIPE, "recorder_pipeline", err); - - err = _mmstreamrecorder_create_audiosrc_bin(handle); - if (err != MM_ERROR_NONE) - return err; - - if (info->bMuxing) { - /* Muxing. can use encodebin. */ - err = _mmstreamrecorder_create_encodesink_bin((MMHandleType) hstreamrecorder, MM_STREAMRECORDER_ENCBIN_PROFILE_AUDIO); - if (err != MM_ERROR_NONE) - return err; - - } else { - /* without muxing. can't use encodebin. */ - - _MMSTREAMRECORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMSTREAMRECORDER_ENCSINK_AQUE, "queue", NULL, element_list, err); - - if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) { - if (strcmp(hstreamrecorder->ini.name_of_encsink_bin_audio_encoder, "wavenc") != 0) { - _MMSTREAMRECORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMSTREAMRECORDER_ENCSINK_CONV, "audioconvert", NULL, element_list, err); - } - } - - _MMSTREAMRECORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMSTREAMRECORDER_ENCSINK_AENC, aenc_name, NULL, element_list, err); - - _MMSTREAMRECORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMSTREAMRECORDER_ENCSINK_SINK, hstreamrecorder->ini.name_of_encsink_sink, NULL, element_list, err); - } - - /* Add and link elements */ - if (info->bMuxing) { - /* IF MUX is indicated create MUX */ - gst_bin_add_many(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_BIN].gst, NULL); - - srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, "src"); - sinkpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_BIN].gst, "audio_sink0"); - _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error); - } else { - /* IF MUX in not chosen then record in raw amr file */ - if (!strcmp(aenc_name, "wavenc")) { - gst_bin_add_many(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL); - - if (!_MM_GST_ELEMENT_LINK_MANY(sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL)) { - err = MM_ERROR_STREAMRECORDER_GST_LINK; - goto pipeline_creation_error; - } - } else { - if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) { - gst_bin_add_many(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_CONV].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL); - - if (!_MM_GST_ELEMENT_LINK_MANY(sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_CONV].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL)) { - err = MM_ERROR_STREAMRECORDER_GST_LINK; - goto pipeline_creation_error; - } - } else { - gst_bin_add_many(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL); - - if (!_MM_GST_ELEMENT_LINK_MANY(sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, NULL)) { - err = MM_ERROR_STREAMRECORDER_GST_LINK; - goto pipeline_creation_error; - } - } - } - } - - if (info->bMuxing) { - MMSTREAMRECORDER_SIGNAL_CONNECT(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, _MMSTREAMRECORDER_HANDLER_AUDIOREC, "pad-added", __mmstreamrecorder_audiorec_pad_added_cb, hstreamrecorder); - } else { - srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, "src"); - MMSTREAMRECORDER_ADD_BUFFER_PROBE(srcpad, _MMSTREAMRECORDER_HANDLER_AUDIOREC, __mmstreamrecorder_audio_dataprobe_record, hstreamrecorder); - gst_object_unref(srcpad); - srcpad = NULL; - } - - bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst)); - - /* register message callback */ - hstreamrecorder->pipeline_cb_event_id = gst_bus_add_watch(bus, (GstBusFunc) _mmstreamrecorder_pipeline_cb_message, hstreamrecorder); - - /* set sync callback */ - gst_bus_set_sync_handler(bus, gst_bus_sync_signal_handler, hstreamrecorder, NULL); - - gst_object_unref(bus); - bus = NULL; - - if (element_list) { - g_list_free(element_list); - element_list = NULL; - } - - return MM_ERROR_NONE; - - pipeline_creation_error: - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCODE_MAIN_PIPE); - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_AUDIOSRC_BIN); - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCSINK_AQUE); - if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) { - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCSINK_CONV); - } - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCSINK_AENC); - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCSINK_SINK); - _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCSINK_BIN); - - if (element_list) { - g_list_free(element_list); - element_list = NULL; - } - - return err; -} - -int _mmstreamrecorder_audio_command(MMHandleType handle, int command) -{ - int cmd = command; - int ret = MM_ERROR_NONE; - int err = 0; - guint64 free_space = 0; - guint64 cal_space = 0; - char *dir_name = NULL; - char *err_attr_name = NULL; - guint count = 0; - int size = 0; - - GstElement *pipeline = NULL; - GstElement *audioSrc = NULL; - - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - _MMStreamRecorderAudioInfo *info = NULL; - _MMStreamRecorderFileInfo *finfo = NULL; - - mmf_return_val_if_fail(hstreamrecorder, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_val_if_fail(sc, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - mmf_return_val_if_fail(sc->info_audio, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - mmf_return_val_if_fail(sc->info_file, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - pipeline = sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst; - info = sc->info_audio; - finfo = sc->info_file; - - _mmstreamrec_dbg_log(""); - - pipeline = sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst; - audioSrc = sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_SRC].gst; - switch (cmd) { - case _MM_STREAMRECORDER_CMD_RECORD: - /* check status for resume case */ - { - guint imax_size = 0; - guint imax_time = 0; - char *temp_filename = NULL; - - if (sc->pipeline_time) - gst_element_set_start_time((GstElement *) GST_PIPELINE(pipeline), sc->pipeline_time); - - sc->pipeline_time = hstreamrecorder->ini.reset_pause_time; - - ret = mm_streamrecorder_get_attributes(handle, &err_attr_name, MMSTR_TARGET_MAX_SIZE, &imax_size, MMSTR_TARGET_TIME_LIMIT, &imax_time, MMSTR_FILE_FORMAT, &(finfo->fileformat), MMSTR_FILENAME, &temp_filename, &size, NULL); - if (ret != MM_ERROR_NONE) { - _mmstreamrec_dbg_warn("failed to get attribute. (%s:%x)", err_attr_name, ret); - SAFE_FREE(err_attr_name); - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - } - - finfo->filename = g_strdup(temp_filename); - if (!finfo->filename) { - _mmstreamrec_dbg_err("STRDUP was failed"); - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - } - - _mmstreamrec_dbg_log("Record start : set file name using attribute - %s\n ", finfo->filename); - - MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, "location", finfo->filename); - - sc->ferror_send = FALSE; - sc->ferror_count = 0; - sc->bget_eos = FALSE; - info->filesize = 0; - - /* set max size */ - if (imax_size <= 0) - info->max_size = 0; /* do not check */ - else - info->max_size = ((guint64) imax_size) << 10; /* to byte */ - - /* set max time */ - if (imax_time <= 0) - info->max_time = 0; /* do not check */ - else - info->max_time = ((guint64) imax_time) * 1000; /* to millisecond */ - - /* TODO : check free space before recording start, need to more discussion */ - dir_name = g_path_get_dirname(finfo->filename); - err = _mmstreamrecorder_get_freespace(dir_name, &free_space); - - _mmstreamrec_dbg_warn("current space for recording - %s : [%" G_GUINT64_FORMAT "]", dir_name, free_space); - - if (dir_name) { - g_free(dir_name); - dir_name = NULL; - } - cal_space = (guint64)(hstreamrecorder->ini.audio_frame_minimum_space); - cal_space = cal_space + (5 * 1024); - if ((err == -1) || free_space <= cal_space) { - _mmstreamrec_dbg_err("No more space for recording"); - return MM_MESSAGE_STREAMRECORDER_NO_FREE_SPACE; - } - } - - ret = _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING); - if (ret != MM_ERROR_NONE) - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - - break; - - case _MM_STREAMRECORDER_CMD_PAUSE: - { - GstClock *l_clock = NULL; - - if (info->b_commiting) { - _mmstreamrec_dbg_warn("now on commiting previous file!!(cmd : %d)", cmd); - return MM_ERROR_STREAMRECORDER_CMD_IS_RUNNING; - } - - for (count = 0; count <= hstreamrecorder->ini.retrial_count; count++) { - if (info->filesize > 0) { - break; - } else if (count == hstreamrecorder->ini.retrial_count) { - _mmstreamrec_dbg_err("Pause fail, wait 200 ms, but file size is %lld", info->filesize); - return MM_ERROR_STREAMRECORDER_INVALID_CONDITION; - } else { - _mmstreamrec_dbg_warn("Wait for enough audio frame, retry count[%d], file size is %lld", count, info->filesize); - } - usleep(hstreamrecorder->ini.audio_frame_wait_time); - } - - ret = _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_PAUSED); - if (ret != MM_ERROR_NONE) - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - - /* FIXME: consider delay. */ - l_clock = gst_pipeline_get_clock(GST_PIPELINE(pipeline)); - sc->pipeline_time = gst_clock_get_time(l_clock) - gst_element_get_base_time(GST_ELEMENT(pipeline)); - break; - } - - case _MM_STREAMRECORDER_CMD_CANCEL: - if (info->b_commiting) { - _mmstreamrec_dbg_warn("now on commiting previous file!!(cmd : %d)", cmd); - return MM_ERROR_STREAMRECORDER_CMD_IS_RUNNING; - } - - ret = _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_READY); - if (ret != MM_ERROR_NONE) - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - - if (info->bMuxing) { - MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", FALSE); - } else { - MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", FALSE); - } - - _mmstreamrecorder_gst_set_state(handle, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SINK].gst, GST_STATE_NULL); - - sc->pipeline_time = 0; - sc->pause_time = 0; - sc->isMaxsizePausing = FALSE; - sc->isMaxtimePausing = FALSE; - - if (finfo->filename) { - _mmstreamrec_dbg_log("file delete(%s)", finfo->filename); - unlink(finfo->filename); - g_free(finfo->filename); - finfo->filename = NULL; - } - break; - - case _MM_STREAMRECORDER_CMD_COMMIT: - { - - _mmstreamrec_dbg_log("_MM_STREAMRECORDER_CMD_COMMIT"); - - if (info->b_commiting) { - _mmstreamrec_dbg_warn("now on commiting previous file!!(cmd : %d)", cmd); - return MM_ERROR_STREAMRECORDER_CMD_IS_RUNNING; - } else { - _mmstreamrec_dbg_log("_MM_STREAMRECORDER_CMD_COMMIT : start"); - info->b_commiting = TRUE; - } - - for (count = 0; count <= hstreamrecorder->ini.retrial_count; count++) { - if (info->filesize > 0) { - break; - } else if (count == hstreamrecorder->ini.retrial_count) { - _mmstreamrec_dbg_err("Commit fail, waited 200 ms, but file size is %lld", info->filesize); - info->b_commiting = FALSE; - return MM_ERROR_STREAMRECORDER_INVALID_CONDITION; - } else { - _mmstreamrec_dbg_warn("Waiting for enough audio frame, re-count[%d], file size is %lld", count, info->filesize); - } - usleep(hstreamrecorder->ini.audio_frame_wait_time); - } - - if (audioSrc) { - GstPad *pad = gst_element_get_static_pad(audioSrc, "src"); - ret = gst_element_send_event(audioSrc, gst_event_new_eos()); - gst_object_unref(pad); - pad = NULL; - /* for pause -> commit case */ - /*if (_mmstreamrecorder_get_state((MMHandleType)hstreamrecorder) == MM_STREAMRECORDER_STATE_PAUSED) { - ret = _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING); - if (ret != MM_ERROR_NONE) { - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - } - } */ - } - - /* wait until finishing EOS */ - _mmstreamrec_dbg_log("Start to wait EOS"); - if ((ret = _mmstreamrecorder_get_eos_message(handle)) != MM_ERROR_NONE) - goto _ERR_STREAMRECORDER_AUDIO_COMMAND; - - break; - } - default: - ret = MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT; - break; - } - - _ERR_STREAMRECORDER_AUDIO_COMMAND: - return ret; -} - -int _mmstreamrecorder_audio_handle_eos(MMHandleType handle) -{ - int err = MM_ERROR_NONE; - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - _MMStreamRecorderAudioInfo *info = NULL; - _MMStreamRecorderFileInfo *finfo = NULL; - GstElement *pipeline = NULL; - _MMStreamRecorderMsgItem msg; - MMStreamRecordingReport *report; - - mmf_return_val_if_fail(hstreamrecorder, FALSE); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_val_if_fail(sc, FALSE); - mmf_return_val_if_fail(sc->info_audio, FALSE); - mmf_return_val_if_fail(sc->info_file, FALSE); - - _mmstreamrec_dbg_err(""); - - info = sc->info_audio; - finfo = sc->info_file; - - pipeline = sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst; - - err = _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_READY); - - if (err != MM_ERROR_NONE) - _mmstreamrec_dbg_warn("Failed:_MM_STREAMRECORDER_CMD_COMMIT:GST_STATE_READY. err[%x]", err); - - /* Send recording report message to application */ - msg.id = MM_MESSAGE_STREAMRECORDER_AUDIO_CAPTURED; - report = (MMStreamRecordingReport *) g_malloc(sizeof(MMStreamRecordingReport)); - if (!report) { - _mmstreamrec_dbg_err("Recording report fail(%s). Out of memory.", finfo->filename); - return FALSE; - } - - /* START TAG HERE */ - /* MM_AUDIO_CODEC_AAC + MM_FILE_FORMAT_MP4 */ - if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) - _mmstreamrecorder_audio_add_metadata_info_m4a(handle); - /* END TAG HERE */ - - report->recording_filename = g_strdup(finfo->filename); - msg.param.data = report; - - _mmstreamrecorder_send_message(handle, &msg); - - if (info->bMuxing) { - MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", FALSE); - } else { - MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", FALSE); - } - - _mmstreamrecorder_gst_set_state(handle, pipeline, GST_STATE_NULL); - - sc->pipeline_time = 0; - sc->pause_time = 0; - sc->isMaxsizePausing = FALSE; - sc->isMaxtimePausing = FALSE; - - g_free(finfo->filename); - finfo->filename = NULL; - - _mmstreamrec_dbg_err("_MM_STREAMRECORDER_CMD_COMMIT : end"); - - info->b_commiting = FALSE; - - return TRUE; -} - int _mmstreamrecorder_push_videostream_buffer(MMHandleType handle, unsigned long timestamp, GstBuffer *buffer, int size) { mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); -- 2.7.4 From 93f608822339c2de6833345e78b4e84c21934d7e Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Thu, 1 Dec 2016 16:42:42 +0900 Subject: [PATCH 07/16] Change mm_attr structure [Version] 0.0.10 [Profile] Common [Issue Type] Change mm_attr structure [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20161129.2] Signed-off-by: SeokHoon Lee Change-Id: Ie4a2ebd6f8a76c17a60112e15c13f483ba285980 --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder_attribute.h | 13 ++- src/mm_streamrecorder_attribute.c | 154 ++++++++++++++++-------------- src/mm_streamrecorder_gstdispatch.c | 2 +- 4 files changed, 97 insertions(+), 74 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 9a6cd9f..f850b96 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.9 +Version: 0.0.10 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder_attribute.h b/src/include/mm_streamrecorder_attribute.h index 4f80184..9879e7c 100644 --- a/src/include/mm_streamrecorder_attribute.h +++ b/src/include/mm_streamrecorder_attribute.h @@ -100,8 +100,17 @@ typedef struct { double value_double; } default_value; /* default value */ MMStreamRecorderAttrsValidType validity_type; - int validity_value1; /* can be int min, int *array, double *array, or cast to double min. */ - int validity_value2; /* can be int max, int count, int count, or cast to double max. */ + union { + int *int_array; + int int_min; + double *double_array; + double double_min; + } validity_value_1; + union { + int int_max; + double double_max; + int count; + } validity_value_2; mmf_streamrecorder_commit_func_t attr_commit; } mm_streamrecorder_attr_construct_info; diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index ce9a771..6db79d1 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -48,8 +48,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, /* Flag */ {(void *)MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO}, /* Default value */ MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */ - MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO, /* Validity val1 (min, *array,...) */ - MM_STREAMRECORDER_VIDEO_TYPE_NORMAL_BUFFER, /* Validity val2 (max, count, ...) */ + {.int_min = MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO}, /* Validity val1 (min, *array,...) */ + {.int_max = MM_STREAMRECORDER_VIDEO_TYPE_NORMAL_BUFFER}, /* Validity val2 (max, count, ...) */ NULL, /* Runtime setting function of the attribute */ }, /* 1 */ @@ -59,8 +59,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_INPUT_FORMAT_NV12}, MM_ATTRS_VALID_TYPE_INT_RANGE, - MM_STREAMRECORDER_INPUT_FORMAT_INVALID, - MM_STREAMRECORDER_INPUT_FORMAT_NUM, + {.int_min = MM_STREAMRECORDER_INPUT_FORMAT_INVALID}, + {.int_max = MM_STREAMRECORDER_INPUT_FORMAT_NUM}, NULL, }, /* 2 */ @@ -71,8 +71,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, NULL, }, /* 3 */ @@ -83,8 +83,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, NULL, /*_mmstreamrecorder_commit_video_bitrate, */ }, /* 4 */ @@ -95,8 +95,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, - 0, - 0, + {.int_array = NULL}, + {.count = 0}, NULL, }, /* 5 */ @@ -107,8 +107,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, - 0, - 0, + {.int_array = NULL}, + {.count = 0}, NULL, }, /* 6 */ @@ -118,9 +118,9 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE}, - MMF_VALUE_TYPE_INT, - MM_STREAMRECORDER_AUDIO_FORMAT_PCM_U8, - MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE, + MM_ATTRS_VALID_TYPE_INT_RANGE, + {.int_min = MM_STREAMRECORDER_AUDIO_FORMAT_PCM_U8}, + {.int_max = MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE}, _mmstreamrecorder_commit_audio_bitformat, }, /* 7 */ @@ -131,8 +131,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)128000}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, _mmstreamrecorder_commit_audio_bitrate, }, /* 8 */ @@ -143,8 +143,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, _mmstreamrecorder_commit_audio_samplingrate, }, /* 9 */ @@ -155,8 +155,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, - 0, - 0, + {.int_array = NULL}, + {.count = 0}, _mmstreamrecorder_commit_video_encoder, }, /* 10 */ @@ -167,8 +167,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, - 0, - 0, + {.int_array = NULL}, + {.count = 0}, _mmstreamrecorder_commit_audio_encoder, }, /* 11 */ @@ -179,8 +179,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)2}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, _mmstreamrecorder_commit_audio_channel, }, /* 12 */ @@ -191,8 +191,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, - 0, - 0, + {.int_array = NULL}, + {.count = 0}, NULL, }, /* 13 */ @@ -203,8 +203,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {NULL}, MM_ATTRS_VALID_TYPE_NONE, - 0, - 0, + {0}, + {0}, NULL, }, /* 14 */ @@ -215,8 +215,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)FALSE}, MM_ATTRS_VALID_TYPE_NONE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {0}, + {_MMSTREAMRECORDER_MAX_INT}, _mmstreamrecorder_commit_video_enable, }, /* 15 */ @@ -227,8 +227,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)FALSE}, MM_ATTRS_VALID_TYPE_NONE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {0}, + {_MMSTREAMRECORDER_MAX_INT}, _mmstreamrecorder_commit_audio_enable, }, /* 16 */ @@ -239,8 +239,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_MODE_MEDIABUFFER}, MM_ATTRS_VALID_TYPE_NONE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {0}, + {_MMSTREAMRECORDER_MAX_INT}, NULL, }, /*17*/ @@ -251,8 +251,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, NULL, }, /*18*/ @@ -263,8 +263,8 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, - 0, - _MMSTREAMRECORDER_MAX_INT, + {.int_min = 0}, + {.int_max = _MMSTREAMRECORDER_MAX_INT}, NULL, }, @@ -288,28 +288,28 @@ static int __mmstreamrecorder_set_conf_to_valid_info(MMHandleType handle) /* Video width */ total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_WIDTH, &format); - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value1 = (int)format; - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value2 = (int)total_count; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array = format; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_2.count = total_count; /* Video height */ total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_HEIGHT, &format); - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value1 = (int)format; - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value2 = (int)total_count; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array = format; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_2.count = total_count; /* Audio encoder */ total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_AUDIO_ENCODERS, &format); - stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value1 = (int)format; - stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value2 = (int)total_count; + stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array = format; + stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_2.count = total_count; /*Video encoder*/ total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_ENCODERS, &format); - stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value1 = (int)format; - stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value2 = (int)total_count; + stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array = format; + stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_2.count = total_count; /* File Format */ total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_FILE_FORMATS, &format); - stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value1 = (int)format; - stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value2 = (int)total_count; + stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array = format; + stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_2.count = total_count; return MM_ERROR_NONE; } @@ -320,39 +320,39 @@ static int __mmstreamrecorder_release_conf_valid_info(MMHandleType handle) _mmstreamrec_dbg_log("START"); - allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value1); + allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array); if (allocated_memory) { free(allocated_memory); - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value1 = (int)NULL; - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value2 = (int)0; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array = NULL; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_2.count = 0; } - allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value1); + allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array); if (allocated_memory) { free(allocated_memory); - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value1 = (int)NULL; - stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value2 = (int)0; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array = NULL; + stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_2.count = 0; } - allocated_memory = (int *)(stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value1); + allocated_memory = (int *)(stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array); if (allocated_memory) { free(allocated_memory); - stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value1 = (int)NULL; - stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value2 = (int)0; + stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array = NULL; + stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_2.count = 0; } - allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value1); + allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array); if (allocated_memory) { free(allocated_memory); - stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value1 = (int)NULL; - stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value2 = (int)0; + stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array = NULL; + stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_2.count = 0; } - allocated_memory = (int *)(stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value1); + allocated_memory = (int *)(stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array); if (allocated_memory) { free(allocated_memory); - stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value1 = (int)NULL; - stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value2 = (int)0; + stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array = NULL; + stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_2.count = 0; } _mmstreamrec_dbg_log("DONE"); @@ -789,18 +789,32 @@ MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle) switch (stream_attrs_const_info[idx].validity_type) { case MM_ATTRS_VALID_TYPE_INT_ARRAY: - if (stream_attrs_const_info[idx].validity_value1 && stream_attrs_const_info[idx].validity_value2 > 0) - mmf_attrs_set_valid_array(attrs, idx, (const int *)(stream_attrs_const_info[idx].validity_value1), stream_attrs_const_info[idx].validity_value2, (int)(stream_attrs_const_info[idx].default_value.value_int)); + if (stream_attrs_const_info[idx].validity_value_1.int_array && + stream_attrs_const_info[idx].validity_value_2.count > 0) + mmf_attrs_set_valid_array(attrs, idx, + (const int *)(stream_attrs_const_info[idx].validity_value_1.int_array), + stream_attrs_const_info[idx].validity_value_2.count, + stream_attrs_const_info[idx].default_value.value_int); break; case MM_ATTRS_VALID_TYPE_INT_RANGE: - mmf_attrs_set_valid_range(attrs, idx, stream_attrs_const_info[idx].validity_value1, stream_attrs_const_info[idx].validity_value2, (int)(stream_attrs_const_info[idx].default_value.value_int)); + mmf_attrs_set_valid_range(attrs, idx, + stream_attrs_const_info[idx].validity_value_1.int_min, + stream_attrs_const_info[idx].validity_value_2.int_max, + stream_attrs_const_info[idx].default_value.value_int); break; case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY: - if (stream_attrs_const_info[idx].validity_value1 && stream_attrs_const_info[idx].validity_value2 > 0) - mmf_attrs_set_valid_double_array(attrs, idx, (const double *)(stream_attrs_const_info[idx].validity_value1), stream_attrs_const_info[idx].validity_value2, (double)(stream_attrs_const_info[idx].default_value.value_double)); + if (stream_attrs_const_info[idx].validity_value_1.double_array && + stream_attrs_const_info[idx].validity_value_2.count > 0) + mmf_attrs_set_valid_double_array(attrs, idx, + (const double *)(stream_attrs_const_info[idx].validity_value_1.double_array), + stream_attrs_const_info[idx].validity_value_2.count, + stream_attrs_const_info[idx].default_value.value_double); break; case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE: - mmf_attrs_set_valid_double_range(attrs, idx, (double)(stream_attrs_const_info[idx].validity_value1), (double)(stream_attrs_const_info[idx].validity_value2), (double)(stream_attrs_const_info[idx].default_value.value_double)); + mmf_attrs_set_valid_double_range(attrs, idx, + stream_attrs_const_info[idx].validity_value_1.double_min, + stream_attrs_const_info[idx].validity_value_2.double_max, + stream_attrs_const_info[idx].default_value.value_double); break; case MM_ATTRS_VALID_TYPE_NONE: break; diff --git a/src/mm_streamrecorder_gstdispatch.c b/src/mm_streamrecorder_gstdispatch.c index d572501..06d1b82 100644 --- a/src/mm_streamrecorder_gstdispatch.c +++ b/src/mm_streamrecorder_gstdispatch.c @@ -323,9 +323,9 @@ MSG_CALLBACK_DONE: MMStreamRecordingReport *report = (MMStreamRecordingReport *)item->param.data; if (report) { SAFE_FREE(report->recording_filename); + SAFE_FREE(report); item->param.data = NULL; } - SAFE_FREE(report); } SAFE_FREE(item); -- 2.7.4 From 811b9d8fab27c855ea9df405fa384717d3f9bd67 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Thu, 8 Dec 2016 15:06:38 +0900 Subject: [PATCH 08/16] move va_copy for unexpected return without va_end [Version] 0.0.11 [Profile] Common [Issue Type] Bug fix [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20161130.2] Signed-off-by: SeokHoon Lee Change-Id: I7999c4279d29823ab0404226da5ce148e4e19583 --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_attribute.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index f850b96..f63eaf5 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.10 +Version: 0.0.11 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index 6db79d1..e908d0f 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -864,15 +864,15 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, mmf_return_val_if_fail(handle, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT); - /* copy var_args to keep original var_args */ - va_copy(var_args_copy, var_args); - attrs = MMF_STREAMRECORDER_ATTRS(handle); if (!attrs) { _mmstreamrec_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name); return MM_ERROR_STREAMRECORDER_NOT_INITIALIZED; } + /* copy var_args to keep original var_args */ + va_copy(var_args_copy, var_args); + ret = __mmstreamrecorder_check_valid_pair(handle, err_attr_name, attribute_name, var_args); _mmstreamrec_dbg_err("__mmstreamrecorder_check_valid_pair handle 0x%x, attr name [%s] , ret = %d", handle, attribute_name, ret); -- 2.7.4 From d41599748a5fbdf268a4a7a483ec9d6f483b1631 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Fri, 20 Jan 2017 10:21:01 +0900 Subject: [PATCH 09/16] Fix build error for upgrading toolchain Different semantics for inline functions While -std=gnu89 employs the GNU89 inline semantics, -std=gnu11 uses the C99 inline semantics. For further informaion, please refer to 'https://gcc.gnu.org/gcc-5/porting_to.html' Remove unused function. Signed-off-by: SeokHoon Lee Change-Id: I8e7d567f35e3c82d7437619e7a4dab869a9ec3bb --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder_util.h | 6 ++---- src/mm_streamrecorder_util.c | 18 ++---------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index f63eaf5..be7d419 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.11 +Version: 0.0.12 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder_util.h b/src/include/mm_streamrecorder_util.h index 387badc..09bf1c2 100644 --- a/src/include/mm_streamrecorder_util.h +++ b/src/include/mm_streamrecorder_util.h @@ -170,10 +170,8 @@ void _mmstreamrecorder_err_trace_write(char *str_filename, char *func_name, int guint16 get_language_code(const char *str); gchar *str_to_utf8(const gchar *str); -inline gboolean write_tag(FILE *f, const gchar *tag); -inline gboolean write_to_32(FILE *f, guint val); -inline gboolean write_to_16(FILE *f, guint val); -inline gboolean write_to_24(FILE *f, guint val); +__attribute__ ((gnu_inline)) inline gboolean write_tag(FILE *f, const gchar *tag); +__attribute__ ((gnu_inline)) inline gboolean write_to_32(FILE *f, guint val); #ifdef __cplusplus } #endif diff --git a/src/mm_streamrecorder_util.c b/src/mm_streamrecorder_util.c index d7a5b96..6666ed5 100644 --- a/src/mm_streamrecorder_util.c +++ b/src/mm_streamrecorder_util.c @@ -313,7 +313,7 @@ gchar *str_to_utf8(const gchar * str) return g_convert(str, -1, "UTF-8", "ASCII", NULL, NULL, NULL); } -inline gboolean write_tag(FILE *f, const gchar *tag) +__attribute__ ((gnu_inline)) inline gboolean write_tag(FILE *f, const gchar *tag) { while (*tag) FPUTC_CHECK(*tag++, f); @@ -321,7 +321,7 @@ inline gboolean write_tag(FILE *f, const gchar *tag) return TRUE; } -inline gboolean write_to_32(FILE *f, guint val) +__attribute__ ((gnu_inline)) inline gboolean write_to_32(FILE *f, guint val) { FPUTC_CHECK(val >> 24, f); FPUTC_CHECK(val >> 16, f); @@ -329,17 +329,3 @@ inline gboolean write_to_32(FILE *f, guint val) FPUTC_CHECK(val, f); return TRUE; } - -inline gboolean write_to_16(FILE *f, guint val) -{ - FPUTC_CHECK(val >> 8, f); - FPUTC_CHECK(val, f); - return TRUE; -} - -inline gboolean write_to_24(FILE *f, guint val) -{ - write_to_16(f, val >> 8); - FPUTC_CHECK(val, f); - return TRUE; -} -- 2.7.4 From f3ed5d01b4b10c49ee8404db0a804b9c2233e35c Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 22 Mar 2017 16:04:14 +0900 Subject: [PATCH 10/16] Change license macro Signed-off-by: SeokHoon Lee Change-Id: I0b4cb2a561eb21455d6de05a3929a3ffa9ef81de --- packaging/libmm-streamrecorder.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index be7d419..4d59fff 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.12 +Version: 0.0.13 Release: 0 Group: Multimedia/Other License: Apache-2.0 @@ -42,8 +42,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -mkdir -p %{buildroot}/usr/share/license -cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} %make_install %clean @@ -56,10 +54,10 @@ rm -rf %{buildroot} %files %manifest libmm-streamrecorder.manifest +%license LICENSE.APLv2 %defattr(-,root,root,-) %{_bindir}/* %{_libdir}/*.so.* -%{_datadir}/license/%{name} %files devel -- 2.7.4 From f54c3e8d1fac7e6fe9238bff17f96726e8c4a09b Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Thu, 10 Aug 2017 11:18:05 +0900 Subject: [PATCH 11/16] Aplly ASLR to excutable file Signed-off-by: SeokHoon Lee Change-Id: Ic7cdbba5dde07326ee051a6ac231eb6341494d31 --- packaging/libmm-streamrecorder.spec | 2 +- test/Makefile.am | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 4d59fff..77a47b1 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.13 +Version: 0.0.14 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/test/Makefile.am b/test/Makefile.am index 5cd87f7..f22d5ae 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,8 @@ bin_PROGRAMS = mm_streamrecorder_testsuite mm_streamrecorder_testsuite_SOURCES = mm_streamrecorder_testsuite.c -mm_streamrecorder_testsuite_CFLAGS = -I$(srcdir)/../src/include \ +mm_streamrecorder_testsuite_CFLAGS = -fPIE \ + -I$(srcdir)/../src/include \ $(GLIB_CFLAGS)\ $(GST_CFLAGS)\ $(MM_COMMON_CFLAGS)\ @@ -22,4 +23,4 @@ mm_streamrecorder_testsuite_LDADD = $(top_builddir)/src/libmmfstreamrecorder.la $(MM_SOUND_LIBS)\ $(MDM_LIBS) - +mm_streamrecorder_testsuite_LDFLAGS = -pie -- 2.7.4 From a1c62f728e4b24c0dafcba8b647ddc781edf4717 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 12 Sep 2017 13:27:23 +0900 Subject: [PATCH 12/16] Tizen coding convention Signed-off-by: SeokHoon Lee Change-Id: Id9c1656fec213f481243c4ee525b69a1a68accff --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder.h | 44 ++++++++++----------- src/include/mm_streamrecorder_fileinfo.h | 12 +++--- src/include/mm_streamrecorder_gstcommon.h | 16 ++++---- src/include/mm_streamrecorder_gstdispatch.h | 28 +++++++------- src/include/mm_streamrecorder_ini.h | 7 +--- src/include/mm_streamrecorder_internal.h | 8 ++-- src/include/mm_streamrecorder_recorder.h | 2 +- src/include/mm_streamrecorder_util.h | 34 ++++++++--------- src/mm_streamrecorder_gstdispatch.c | 59 ++++++++++++----------------- src/mm_streamrecorder_ini.c | 2 +- src/mm_streamrecorder_recorder.c | 35 ++++++++--------- 12 files changed, 116 insertions(+), 133 deletions(-) mode change 100644 => 100755 src/include/mm_streamrecorder_util.h diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 77a47b1..81bf4e1 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.14 +Version: 0.0.15 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder.h b/src/include/mm_streamrecorder.h index a369d7b..66902e3 100644 --- a/src/include/mm_streamrecorder.h +++ b/src/include/mm_streamrecorder.h @@ -164,49 +164,49 @@ typedef struct { * An enumeration for attribute values types. */ typedef enum { - MM_STR_REC_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */ - MM_STR_REC_ATTRS_TYPE_INT, /**< Integer type attribute */ - MM_STR_REC_ATTRS_TYPE_DOUBLE, /**< Double type attribute */ - MM_STR_REC_ATTRS_TYPE_STRING, /**< UTF-8 String type attribute */ - MM_STR_REC_ATTRS_TYPE_DATA, /**< Pointer type attribute */ + MM_STR_REC_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */ + MM_STR_REC_ATTRS_TYPE_INT, /**< Integer type attribute */ + MM_STR_REC_ATTRS_TYPE_DOUBLE, /**< Double type attribute */ + MM_STR_REC_ATTRS_TYPE_STRING, /**< UTF-8 String type attribute */ + MM_STR_REC_ATTRS_TYPE_DATA, /**< Pointer type attribute */ } MMStreamRecorderAttrsType; /** * An enumeration for attribute validation type. */ typedef enum { - MM_STR_REC_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */ - MM_STR_REC_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */ - MM_STR_REC_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */ - MM_STR_REC_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */ - MM_STR_REC_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */ - MM_STR_REC_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */ + MM_STR_REC_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */ + MM_STR_REC_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */ + MM_STR_REC_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */ + MM_STR_REC_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */ + MM_STR_REC_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */ + MM_STR_REC_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */ } MMStreamRecorderAttrsValidType; /** * An enumeration for attribute access flag. */ typedef enum { - MM_STR_REC_ATTRS_FLAG_DISABLED = 0, /**< None flag is set. This means the attribute is not allowed to use. */ - MM_STR_REC_ATTRS_FLAG_READABLE = 1 << 0,/**< Readable */ - MM_STR_REC_ATTRS_FLAG_WRITABLE = 1 << 1,/**< Writable */ - MM_STR_REC_ATTRS_FLAG_MODIFIED = 1 << 2,/**< Modified */ - MM_STR_REC_ATTRS_FLAG_RW = MM_STR_REC_ATTRS_FLAG_READABLE | MM_STR_REC_ATTRS_FLAG_WRITABLE, - /**< Readable and Writable */ + MM_STR_REC_ATTRS_FLAG_DISABLED = 0, /**< None flag is set. This means the attribute is not allowed to use. */ + MM_STR_REC_ATTRS_FLAG_READABLE = 1 << 0,/**< Readable */ + MM_STR_REC_ATTRS_FLAG_WRITABLE = 1 << 1,/**< Writable */ + MM_STR_REC_ATTRS_FLAG_MODIFIED = 1 << 2,/**< Modified */ + MM_STR_REC_ATTRS_FLAG_RW = MM_STR_REC_ATTRS_FLAG_READABLE | MM_STR_REC_ATTRS_FLAG_WRITABLE, + /**< Readable and Writable */ } MMStreamRecorderAttrsFlag; /** * A structure for attribute information */ typedef struct { - MMStreamRecorderAttrsType type; - MMStreamRecorderAttrsFlag flag; - MMStreamRecorderAttrsValidType validity_type; + MMStreamRecorderAttrsType type; + MMStreamRecorderAttrsFlag flag; + MMStreamRecorderAttrsValidType validity_type; /** * A union that describes validity of the attribute. */ - union { + union { /** * Validity structure for integer array. */ @@ -242,7 +242,7 @@ typedef struct { double max; /**< maximum range */ double def; /**< default value */ } double_range; - }; + }; } MMStreamRecorderAttrsInfo; diff --git a/src/include/mm_streamrecorder_fileinfo.h b/src/include/mm_streamrecorder_fileinfo.h index c40a841..dfc96a5 100644 --- a/src/include/mm_streamrecorder_fileinfo.h +++ b/src/include/mm_streamrecorder_fileinfo.h @@ -38,12 +38,12 @@ extern "C" { | MACRO DEFINITIONS | ========================================================================================*/ -#define MMSTREAMRECORDER_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24) +#define MMSTREAMRECORDER_FOURCC(a, b, c, d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24) #define MMSTREAMRECORDER_FOURCC_ARGS(fourcc) \ - ((gchar)((fourcc)&0xff)), \ - ((gchar)(((fourcc)>>8)&0xff)), \ - ((gchar)(((fourcc)>>16)&0xff)), \ - ((gchar)(((fourcc)>>24)&0xff)) + ((gchar)((fourcc)&0xff)), \ + ((gchar)(((fourcc)>>8)&0xff)), \ + ((gchar)(((fourcc)>>16)&0xff)), \ + ((gchar)(((fourcc)>>24)&0xff)) /*======================================================================================= | ENUM DEFINITIONS | @@ -88,7 +88,7 @@ enum MMStreamReorderTagVideoOrientation { /** * */ -#define MMFILE_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24) +#define MMFILE_FOURCC(a, b, c, d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24) #define MMFILE_FOURCC_ARGS(fourcc) \ ((gchar)((fourcc)&0xff)), \ ((gchar)(((fourcc)>>8)&0xff)), \ diff --git a/src/include/mm_streamrecorder_gstcommon.h b/src/include/mm_streamrecorder_gstcommon.h index 2b832ea..4da1a79 100644 --- a/src/include/mm_streamrecorder_gstcommon.h +++ b/src/include/mm_streamrecorder_gstcommon.h @@ -121,9 +121,11 @@ extern "C" { /* GStreamer element remove macro */ #define _MMSTREAMRECORDER_ELEMENT_REMOVE(element, eid) \ - if (element[eid].gst != NULL) { \ - gst_object_unref(element[eid].gst); \ - } + do { \ + if (element[eid].gst != NULL) { \ + gst_object_unref(element[eid].gst); \ + } \ + } while (0) #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many #define _MM_GST_ELEMENT_LINK gst_element_link @@ -144,20 +146,20 @@ extern "C" { gst_object_unref(sink_parent); sink_parent = NULL;\ if (src_name) {\ free(src_name); src_name = NULL;\ - }\ + } \ if (sink_name) {\ free(sink_name); sink_name = NULL;\ - }\ + } \ gst_object_unref(srcpad); srcpad = NULL;\ gst_object_unref(sinkpad); sinkpad = NULL;\ err = MM_ERROR_STREAMRECORDER_GST_LINK;\ goto if_fail_goto;\ - }\ + } \ gst_object_unref(srcpad); srcpad = NULL;\ gst_object_unref(sinkpad); sinkpad = NULL;\ } -#define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \ +#define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \ if (srcpad && sinkpad) { \ gst_pad_unlink(srcpad, sinkpad); \ } else { \ diff --git a/src/include/mm_streamrecorder_gstdispatch.h b/src/include/mm_streamrecorder_gstdispatch.h index 53a7ed9..a681384 100644 --- a/src/include/mm_streamrecorder_gstdispatch.h +++ b/src/include/mm_streamrecorder_gstdispatch.h @@ -54,11 +54,11 @@ do { \ } else { \ item->object = G_OBJECT(x_pad); \ item->category = x_category; \ - item->handler_id = gst_pad_add_probe(x_pad,GST_PAD_PROBE_TYPE_BUFFER,x_callback, x_hstreamrecorder,NULL); \ + item->handler_id = gst_pad_add_probe(x_pad, GST_PAD_PROBE_TYPE_BUFFER, x_callback, x_hstreamrecorder, NULL); \ x_hstreamrecorder->buffer_probes = g_list_append(x_hstreamrecorder->buffer_probes, item); \ _mmstreamrec_dbg_log("Adding buffer probe on [%s:%s] - [ID : %lu], [Category : %x] ", GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \ } \ -} while (0); +} while (0) #define MMSTREAMRECORDER_ADD_EVENT_PROBE(x_pad, x_category, x_callback, x_hstreamrecorder) \ do { \ @@ -70,9 +70,9 @@ do { \ else if (x_category == 0 || !(x_category & _MMSTREAMRECORDER_HANDLER_CATEGORY_ALL)) { \ _mmstreamrec_dbg_err("Invalid handler category : %x \n", x_category); \ } else { \ - item->object =G_OBJECT(x_pad); \ + item->object = G_OBJECT(x_pad); \ item->category = x_category; \ - item->handler_id = gst_pad_add_probe(x_pad,GST_PAD_PROBE_TYPE_EVENT_BOTH,x_callback, x_hstreamrecorder,NULL); \ + item->handler_id = gst_pad_add_probe(x_pad, GST_PAD_PROBE_TYPE_EVENT_BOTH, x_callback, x_hstreamrecorder, NULL); \ x_hstreamrecorder->event_probes = g_list_append(x_hstreamrecorder->event_probes, item); \ _mmstreamrec_dbg_log("Adding event probe on [%s:%s] - [ID : %lu], [Category : %x] ", GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \ } \ @@ -87,7 +87,7 @@ do { \ } else if (x_category == 0 || !(x_category & _MMSTREAMRECORDER_HANDLER_CATEGORY_ALL)) { \ _mmstreamrec_dbg_err("Invalid handler category : %x \n", x_category); \ } else { \ - item->object =G_OBJECT(x_pad); \ + item->object = G_OBJECT(x_pad); \ item->category = x_category; \ item->handler_id = gst_pad_add_data_probe(x_pad, G_CALLBACK(x_callback), x_hstreamrecorder); \ x_hstreamrecorder->data_probes = g_list_append(x_hstreamrecorder->data_probes, item); \ @@ -95,19 +95,19 @@ do { \ } \ } while (0); -#define MMSTREAMRECORDER_SIGNAL_CONNECT( x_object, x_category, x_signal, x_callback, x_hstreamrecorder) \ +#define MMSTREAMRECORDER_SIGNAL_CONNECT(x_object, x_category, x_signal, x_callback, x_hstreamrecorder) \ do { \ MMStreamRecorderHandlerItem* item = NULL; \ item = (MMStreamRecorderHandlerItem *) g_malloc(sizeof(MMStreamRecorderHandlerItem)); \ if (!item) { \ - _mmstreamrec_dbg_err("Cannot connect signal [%s]\n", x_signal ); \ + _mmstreamrec_dbg_err("Cannot connect signal [%s]\n", x_signal); \ } else if (x_category == 0 || !(x_category & _MMSTREAMRECORDER_HANDLER_CATEGORY_ALL)) { \ _mmstreamrec_dbg_err("Invalid handler category : %x \n", x_category); \ } else { \ item->object = G_OBJECT(x_object); \ item->category = x_category; \ item->handler_id = g_signal_connect(G_OBJECT(x_object), x_signal,\ - G_CALLBACK(x_callback), x_hstreamrecorder ); \ + G_CALLBACK(x_callback), x_hstreamrecorder); \ x_hstreamrecorder->signals = g_list_append(x_hstreamrecorder->signals, item); \ _mmstreamrec_dbg_log("Connecting signal on [%s] - [ID : %lu], [Category : %x] ", GST_OBJECT_NAME(item->object), item->handler_id, item->category); \ } \ @@ -116,28 +116,28 @@ do { \ #define MMSTREAMRECORDER_G_OBJECT_GET(obj, name, value) \ do { \ if (obj) { \ - if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \ + if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \ g_object_get(G_OBJECT(obj), name, value, NULL); \ } else { \ - _mmstreamrec_dbg_warn ("The object doesn't have a property named(%s)", name); \ + _mmstreamrec_dbg_warn("The object doesn't have a property named(%s)", name); \ } \ } else { \ _mmstreamrec_dbg_err("Null object"); \ } \ -} while(0); +} while (0) #define MMSTREAMRECORDER_G_OBJECT_SET(obj, name, value) \ do { \ if (obj) { \ - if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \ + if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \ g_object_set(G_OBJECT(obj), name, value, NULL); \ } else { \ - _mmstreamrec_dbg_warn ("The object doesn't have a property named(%s)", name); \ + _mmstreamrec_dbg_warn("The object doesn't have a property named(%s)", name); \ } \ } else { \ _mmstreamrec_dbg_err("Null object"); \ } \ -} while(0); +} while (0) #define MMSTREAMRECORDER_SEND_MESSAGE(handle, msg_id, msg_code) \ {\ diff --git a/src/include/mm_streamrecorder_ini.h b/src/include/mm_streamrecorder_ini.h index 09fcfcd..e9b39f5 100644 --- a/src/include/mm_streamrecorder_ini.h +++ b/src/include/mm_streamrecorder_ini.h @@ -133,11 +133,8 @@ typedef struct __mm_streamrecorder_ini { #define DEFAULT_SUPPORTED_VIDEO_ENCODERS "" #define DEFAULT_SUPPORTED_FILE_FORMATS "" -int - _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t * ini); - -int - _mm_streamrecorder_ini_unload(mm_streamrecorder_ini_t * ini); +int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t * ini); +int _mm_streamrecorder_ini_unload(mm_streamrecorder_ini_t * ini); #ifdef __cplusplus } diff --git a/src/include/mm_streamrecorder_internal.h b/src/include/mm_streamrecorder_internal.h index 1e0e6ec..a29c3cf 100644 --- a/src/include/mm_streamrecorder_internal.h +++ b/src/include/mm_streamrecorder_internal.h @@ -81,7 +81,7 @@ extern "C" { #define _MMSTREAMRECORDER_GET_COND(handle) (_MMSTREAMRECORDER_CAST_MTSAFE(handle).cond) #define _MMSTREAMRECORDER_WAIT(handle) pthread_cond_wait(&_MMSTREAMRECORDER_GET_COND(handle), _MMSTREAMRECORDER_GET_LOCK(handle)) -#define _MMSTREAMRECORDER_TIMED_WAIT(handle, timeout) pthread_cond_timedwait(&_MMSTREAMRECORDER_GET_COND(handle), _MMSTREAMRECORDER_GET_LOCK(handle),&timeout) +#define _MMSTREAMRECORDER_TIMED_WAIT(handle, timeout) pthread_cond_timedwait(&_MMSTREAMRECORDER_GET_COND(handle), _MMSTREAMRECORDER_GET_LOCK(handle), &timeout) /* for command */ #define _MMSTREAMRECORDER_GET_CMD_LOCK(handle) (_MMSTREAMRECORDER_CAST_MTSAFE(handle).cmd_lock) @@ -410,15 +410,15 @@ int _mmstreamrecorder_cancel(MMHandleType hstreamrecorder); * @return This function returns zero on success, or negative value with error code. * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n * @n - * typedef union @n + * typedef union @n * { @n * int code; @n - * struct @n + * struct @n * { @n * int total; @n * int elapsed; @n * } time; @n - * struct @n + * struct @n * { @n * int previous; @n * int current; @n diff --git a/src/include/mm_streamrecorder_recorder.h b/src/include/mm_streamrecorder_recorder.h index 20a27b0..8b8c4ce 100644 --- a/src/include/mm_streamrecorder_recorder.h +++ b/src/include/mm_streamrecorder_recorder.h @@ -71,7 +71,7 @@ extern "C" { * @param[in] type Allocation type of streamrecorder context. * @return This function returns zero on success, or negative value with error code. * @remarks - * @see _mmstreamrecorder_destroy_pipeline() + * @see _mmstreamrecorder_destroy_pipeline() * */ int _mmstreamrecorder_create_pipeline(MMHandleType handle); diff --git a/src/include/mm_streamrecorder_util.h b/src/include/mm_streamrecorder_util.h old mode 100644 new mode 100755 index 09bf1c2..12f643b --- a/src/include/mm_streamrecorder_util.h +++ b/src/include/mm_streamrecorder_util.h @@ -44,7 +44,7 @@ extern "C" { | MACRO DEFINITIONS | ========================================================================================*/ #ifndef CLEAR -#define CLEAR(x) memset (&(x), 0, sizeof (x)) +#define CLEAR(x) memset(&(x), 0, sizeof(x)) #endif #define SAFE_FREE(x) \ @@ -62,24 +62,22 @@ extern "C" { /** * Macro for checking validity and debugging */ -#define mmf_return_if_fail( expr ) \ - if( expr ){} \ - else \ - { \ - _mmstreamrec_dbg_err( "failed [%s]", #expr); \ +#define mmf_return_if_fail(expr) \ + if (!(expr)) { \ + _mmstreamrec_dbg_err("failed [%s]", #expr); \ return; \ }; /** * Macro for checking validity and debugging */ -#define mmf_return_val_if_fail( expr, val ) \ - if( expr ){} \ - else \ - { \ - _mmstreamrec_dbg_err("failed [%s]", #expr); \ - return( val ); \ - }; +#define mmf_return_val_if_fail(expr, val) \ + do { \ + if (!(expr)) { \ + _mmstreamrec_dbg_err("failed [%s]", #expr); \ + return (val); \ + } \ + } while (0) /** * Minimum integer value @@ -110,21 +108,19 @@ enum { #define FPUTC_CHECK(x_char, x_file)\ {\ - if (fputc(x_char, x_file) == EOF) \ - {\ + if (fputc(x_char, x_file) == EOF) {\ _mmstreamrec_dbg_err("[Critical] fputc() returns fail.\n"); \ return FALSE;\ - }\ + } \ } #define FPUTS_CHECK(x_str, x_file)\ {\ - if (fputs(x_str, x_file) == EOF) \ - {\ + if (fputs(x_str, x_file) == EOF) {\ _mmstreamrec_dbg_err("[Critical] fputs() returns fail.\n");\ SAFE_FREE(str); \ return FALSE;\ - }\ + } \ } /*======================================================================================= diff --git a/src/mm_streamrecorder_gstdispatch.c b/src/mm_streamrecorder_gstdispatch.c index 06d1b82..9ff61cd 100644 --- a/src/mm_streamrecorder_gstdispatch.c +++ b/src/mm_streamrecorder_gstdispatch.c @@ -297,7 +297,7 @@ gboolean _mmstreamrecorder_msg_callback(void *data) mmf_return_val_if_fail(item, FALSE); hstreamrecorder = MMF_STREAMRECORDER(item->handle); - if(hstreamrecorder == NULL) { + if (hstreamrecorder == NULL) { _mmstreamrec_dbg_warn("msg id:0x%x, item:%p, handle is NULL", item->id, item); goto MSG_CALLBACK_DONE; } @@ -753,9 +753,8 @@ gboolean _mmstreamrecorder_pipeline_cb_message(GstBus *bus, GstMessage *message, mmf_return_val_if_fail(sc, TRUE); mmf_return_val_if_fail(sc->info_video, TRUE); - if (sc->info_video->b_commiting) { + if (sc->info_video->b_commiting) _mmstreamrecorder_video_handle_eos((MMHandleType) hstreamrecorder); - } sc->bget_eos = TRUE; @@ -1011,11 +1010,10 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP } /* get trailer size */ - if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) { + if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size); - } else { + else trailer_size = 0; - } /* to minimizing free space check overhead */ count = count % _MMSTREAMRECORDER_FREE_SPACE_CHECK_INTERVAL; @@ -1032,11 +1030,11 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP if (sc->ferror_count == 2 && sc->ferror_send == FALSE) { sc->ferror_send = TRUE; msg.id = MM_MESSAGE_STREAMRECORDER_ERROR; - if (ret == -2) { + if (ret == -2) msg.param.code = MM_ERROR_FILE_NOT_FOUND; - } else { + else msg.param.code = MM_ERROR_FILE_READ; - } + _mmstreamrecorder_send_message((MMHandleType) hstreamrecorder, &msg); } else { sc->ferror_count++; @@ -1047,12 +1045,11 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP default: /* succeeded to get free space */ /* check free space for recording */ /* get queued buffer size */ - if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst) { + if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst) MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst, "current-level-bytes", &aq_size); - } - if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst) { + + if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst) MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst, "current-level-bytes", &vq_size); - } queued_buffer = aq_size + vq_size; @@ -1114,11 +1111,10 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_audio_disable(GstPad *pad, rec_pipe_time = GST_TIME_AS_MSECONDS(b_time); - if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) { + if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size); - } else { + else trailer_size = 0; - } /* check max time */ if (videoinfo->max_time > 0 && rec_pipe_time > videoinfo->max_time) { @@ -1189,11 +1185,10 @@ GstPadProbeReturn __mmstreamrecorder_audioque_dataprobe(GstPad *pad, GstPadProbe rec_pipe_time = GST_TIME_AS_MSECONDS(GST_BUFFER_TIMESTAMP(buffer)); - if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) { + if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size); - } else { + else trailer_size = 0; - } if (videoinfo->max_time > 0 && videoinfo->max_time < (remained_time + rec_pipe_time)) remained_time = videoinfo->max_time - rec_pipe_time; @@ -1239,11 +1234,10 @@ void __mmstreamrecorder_audiorec_pad_added_cb(GstElement *element, GstPad *pad, _mmstreamrec_dbg_log("ENTER(%s)", GST_PAD_NAME(pad)); /* FIXME : the name of audio sink pad of wavparse, oggmux doesn't have 'audio'. How could I handle the name? */ - if ((strstr(GST_PAD_NAME(pad), "audio")) || (strstr(GST_PAD_NAME(pad), "sink"))) { + if ((strstr(GST_PAD_NAME(pad), "audio")) || (strstr(GST_PAD_NAME(pad), "sink"))) MMSTREAMRECORDER_ADD_BUFFER_PROBE(pad, _MMSTREAMRECORDER_HANDLER_AUDIOREC, __mmstreamrecorder_audio_dataprobe_record, hstreamrecorder); - } else { + else _mmstreamrec_dbg_warn("Unknow pad is added, check it : [%s]", GST_PAD_NAME(pad)); - } return; } @@ -1281,11 +1275,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP buffer_size = gst_buffer_get_size(buffer); if (audioinfo->filesize == 0) { - if (finfo->fileformat == MM_FILE_FORMAT_WAV) { + if (finfo->fileformat == MM_FILE_FORMAT_WAV) audioinfo->filesize += 44; /* wave header size */ - } else if (finfo->fileformat == MM_FILE_FORMAT_AMR) { + else if (finfo->fileformat == MM_FILE_FORMAT_AMR) audioinfo->filesize += 6; /* amr header size */ - } audioinfo->filesize += buffer_size; return GST_PAD_PROBE_OK; @@ -1320,11 +1313,11 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP if (sc->ferror_count == 2 && sc->ferror_send == FALSE) { sc->ferror_send = TRUE; msg.id = MM_MESSAGE_STREAMRECORDER_ERROR; - if (free_space_ret == -2) { + if (free_space_ret == -2) msg.param.code = MM_ERROR_FILE_NOT_FOUND; - } else { + else msg.param.code = MM_ERROR_FILE_READ; - } + _mmstreamrecorder_send_message((MMHandleType) hstreamrecorder, &msg); } else { sc->ferror_count++; @@ -1338,11 +1331,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP _mmstreamrec_dbg_warn("No more space for recording!!!"); _mmstreamrec_dbg_warn("Free Space : [%" G_GUINT64_FORMAT "], file size : [%" G_GUINT64_FORMAT "]", free_space, audioinfo->filesize); - if (audioinfo->bMuxing) { + if (audioinfo->bMuxing) MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", TRUE); - } else { + else MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", TRUE); - } sc->isMaxsizePausing = TRUE; msg.id = MM_MESSAGE_STREAMRECORDER_NO_FREE_SPACE; @@ -1370,11 +1362,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP if (audioinfo->max_time > 0 && rec_pipe_time > audioinfo->max_time) { _mmstreamrec_dbg_warn("Current time : [%" G_GUINT64_FORMAT "], Maximum time : [%" G_GUINT64_FORMAT "]", rec_pipe_time, audioinfo->max_time); - if (audioinfo->bMuxing) { + if (audioinfo->bMuxing) MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", TRUE); - } else { + else MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", TRUE); - } sc->isMaxtimePausing = TRUE; msg.id = MM_MESSAGE_STREAMRECORDER_TIME_LIMIT; diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index d5125e4..6c93740 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -178,7 +178,7 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) } /* free dict as we got our own structure */ - if(dict) + if (dict) iniparser_freedict(dict); /* dump structure */ diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index d59cea5..90db571 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -208,9 +208,8 @@ int _mmstreamrecorder_create_recorder_pipeline(MMHandleType handle) if (err != MM_ERROR_NONE) return err; - if (sc->audio_enable == TRUE) { + if (sc->audio_enable == TRUE) gst_bin_add(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_BIN].gst); - } /* add element and encodesink bin to encode main pipeline */ gst_bin_add_many(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_FILT].gst, sc->encode_element[_MMSTREAMRECORDER_ENCSINK_BIN].gst, NULL); @@ -283,9 +282,9 @@ int _mmstreamrecorder_create_recorder_pipeline(MMHandleType handle) return MM_ERROR_NONE; pipeline_creation_error: - for (i = _MMSTREAMRECORDER_AUDIOSRC_BIN; i <= _MMSTREAMRECORDER_ENCSINK_SINK; i++) { + for (i = _MMSTREAMRECORDER_AUDIOSRC_BIN; i <= _MMSTREAMRECORDER_ENCSINK_SINK; i++) _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, i); - } + _MMSTREAMRECORDER_ELEMENT_REMOVE(sc->encode_element, _MMSTREAMRECORDER_ENCODE_MAIN_PIPE); return err; } @@ -478,9 +477,9 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde /* TODO : check the last value ( set ) */ MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "profile", hstreamrecorder->ini.encsink_bin_profile); - if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) { + if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", hstreamrecorder->ini.encsink_bin_auto_audio_convert); - } + MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "auto-audio-resample", hstreamrecorder->ini.encsink_bin_auto_audio_resample); MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "auto-colorspace", hstreamrecorder->ini.encsink_bin_auto_colorspace); MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "use-video-toggle", hstreamrecorder->ini.encsink_bin_use_video_toggle); @@ -509,14 +508,14 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "auto-colorspace", hstreamrecorder->ini.encsink_bin_auto_colorspace); - if (video_src_format == MM_STREAMRECORDER_INPUT_FORMAT_NV12) { + if (video_src_format == MM_STREAMRECORDER_INPUT_FORMAT_NV12) video_src_format = MM_STREAMRECORDER_INPUT_FORMAT_I420; - } + caps = gst_set_videosrcpad_caps(video_src_format, video_width, video_height, video_fps, 1); MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "vcaps", caps); - if (video_src_format != MM_STREAMRECORDER_INPUT_FORMAT_NV12) { + if (video_src_format != MM_STREAMRECORDER_INPUT_FORMAT_NV12) MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VCONV].gst, "dst-buffer-num", hstreamrecorder->ini.convert_output_buffer_num); - } + /* state tuning */ err = gst_pad_set_caps(gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst, "sink"), caps); err = MM_ERROR_NONE; @@ -659,11 +658,10 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde if (profile == MM_STREAMRECORDER_ENCBIN_PROFILE_VIDEO) { /* video encoder attribute setting */ - if (v_bitrate > 0) { + if (v_bitrate > 0) MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst, "bitrate", v_bitrate); - } else { + else _mmstreamrec_dbg_warn("video bitrate is too small[%d], so skip setting. Use DEFAULT value.", v_bitrate); - } } if (sc->audio_enable == TRUE) { @@ -901,9 +899,9 @@ int _mmstreamrecorder_create_audiosrc_bin(MMHandleType handle) } if (caps) { - if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) { + if (rec_mode == MM_STREAMRECORDER_MODE_MEDIABUFFER) MMSTREAMRECORDER_G_OBJECT_SET((sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_SRC].gst), "caps", caps); - } + MMSTREAMRECORDER_G_OBJECT_SET((sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_FILT].gst), "caps", caps); { gchar *type = gst_caps_to_string(caps); @@ -1026,9 +1024,9 @@ int _mmstreamrecorder_video_command(MMHandleType handle, int command) mmf_return_val_if_fail(sc && sc->encode_element, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); mmf_return_val_if_fail(sc->info_video, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - if (sc->audio_enable == TRUE) { + if (sc->audio_enable == TRUE) mmf_return_val_if_fail(sc->info_audio, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - } + mmf_return_val_if_fail(sc->info_file, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); info = sc->info_video; @@ -1271,9 +1269,8 @@ int _mmstreamrecorder_video_handle_eos(MMHandleType handle) sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); mmf_return_val_if_fail(sc, FALSE); mmf_return_val_if_fail(sc->info_video, FALSE); - if (sc->audio_enable == TRUE) { + if (sc->audio_enable == TRUE) mmf_return_val_if_fail(sc->info_audio, FALSE); - } mmf_return_val_if_fail(sc->info_file, FALSE); -- 2.7.4 From 20c6f0c35ab0cbde7d4a5581ced87225edb7e3cc Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Fri, 15 Sep 2017 10:55:18 +0900 Subject: [PATCH 13/16] Remove mm-log dependency - change mm-log to dlog and remove mm-log dependency. Signed-off-by: SeokHoon Lee Change-Id: I8618bc17f89d1a177f3a67060d1cf18e745a32ce --- configure.ac | 6 +++--- mm-streamrecorder.pc.in | 2 +- packaging/libmm-streamrecorder.spec | 4 ++-- src/Makefile.am | 8 ++------ src/include/mm_streamrecorder_util.h | 19 ++++++++++++------- src/mm_streamrecorder_ini.c | 15 +++++++-------- 6 files changed, 27 insertions(+), 27 deletions(-) mode change 100755 => 100644 src/include/mm_streamrecorder_util.h diff --git a/configure.ac b/configure.ac index 91eadff..2de17cc 100644 --- a/configure.ac +++ b/configure.ac @@ -40,9 +40,9 @@ PKG_CHECK_MODULES(MM_COMMON, mm-common) AC_SUBST(MM_COMMON_CFLAGS) AC_SUBST(MM_COMMON_LIBS) -PKG_CHECK_MODULES(MM_LOG, mm-log) -AC_SUBST(MM_LOG_CFLAGS) -AC_SUBST(MM_LOG_LIBS) +PKG_CHECK_MODULES(DLOG, dlog) +AC_SUBST(DLOG_CFLAGS) +AC_SUBST(DLOG_LIBS) PKG_CHECK_MODULES(GLIB, glib-2.0) AC_SUBST(GLIB_CFLAGS) diff --git a/mm-streamrecorder.pc.in b/mm-streamrecorder.pc.in index 799aca2..7820809 100644 --- a/mm-streamrecorder.pc.in +++ b/mm-streamrecorder.pc.in @@ -5,7 +5,7 @@ includedir=@includedir@ Name: mm-streamrecorder Description: Multimedia Framework Stream Recorder Library -Requires: gstreamer-1.0 gstreamer-base-1.0 mm-common mm-log +Requires: gstreamer-1.0 gstreamer-base-1.0 mm-common dlog Version: $VERSION Libs: -L${libdir} -lmmfstreamrecorder Cflags: -I${includedir}/ -I${includedir}/mmf diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 81bf4e1..26fb19d 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.15 +Version: 0.0.16 Release: 0 Group: Multimedia/Other License: Apache-2.0 @@ -8,7 +8,7 @@ Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(mm-common) -BuildRequires: pkgconfig(mm-log) +BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gstreamer-base-1.0) BuildRequires: pkgconfig(gstreamer-video-1.0) BuildRequires: pkgconfig(gstreamer-app-1.0) diff --git a/src/Makefile.am b/src/Makefile.am index 13d6b6c..2138fc5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,7 +37,7 @@ libmmfstreamrecorder_la_CFLAGS = -I$(srcdir)/include \ $(GST_PLUGIN_BASE_CFLAGS) \ $(GST_VIDEO_CFLAGS) \ $(GST_INTERFACES_CFLAGS) \ - $(MM_LOG_CFLAGS) \ + $(DLOG_CFLAGS) \ $(MM_COMMON_CFLAGS) \ $(GST_APP_CFLAGS) @@ -47,11 +47,7 @@ libmmfstreamrecorder_la_LIBADD = \ $(GST_VIDEO_LIBS) \ $(GST_INTERFACES_LIBS) \ $(MM_COMMON_LIBS) \ - $(MM_LOG_LIBS) \ + $(DLOG_LIBS) \ $(VCONF_LIBS) \ $(GST_APP_LIBS) \ $(INIPARSER_LIBS) - -libmmfstreamrecorder_la_CFLAGS += $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x00400000 -DMMF_DEBUG_PREFIX=\"MMF-STREAMRECORDER\" -libmmfstreamrecorder_la_LIBADD += $(MMLOGSVR_LIBS) - diff --git a/src/include/mm_streamrecorder_util.h b/src/include/mm_streamrecorder_util.h old mode 100755 new mode 100644 index 12f643b..93f9a72 --- a/src/include/mm_streamrecorder_util.h +++ b/src/include/mm_streamrecorder_util.h @@ -28,9 +28,9 @@ #include #include #include -#include "mm_debug.h" #include -#include +#include +#include #ifdef __cplusplus extern "C" { @@ -53,11 +53,16 @@ extern "C" { x = NULL; \ } -#define _mmstreamrec_dbg_verb(fmt, args...) debug_verbose(" "fmt"\n", ##args); -#define _mmstreamrec_dbg_log(fmt, args...) debug_log(" "fmt"\n", ##args); -#define _mmstreamrec_dbg_warn(fmt, args...) debug_warning(" "fmt"\n", ##args); -#define _mmstreamrec_dbg_err(fmt, args...) debug_error(" "fmt"\n", ##args); -#define _mmstreamrec_dbg_crit(fmt, args...) debug_critical(" "fmt"\n", ##args); +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "MM_STREAMRECORDER" + +#define _mmstreamrec_dbg_verb(fmt, args...) SLOGI(fmt, ##args); +#define _mmstreamrec_dbg_log(fmt, args...) SLOGD(fmt, ##args); +#define _mmstreamrec_dbg_warn(fmt, args...) SLOGW(fmt, ##args); +#define _mmstreamrec_dbg_err(fmt, args...) SLOGE(fmt, ##args); +#define _mmstreamrec_dbg_crit(fmt, args...) SLOGF(fmt, ##args); /** * Macro for checking validity and debugging diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index 6c93740..d3f88c1 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "mm_streamrecorder_ini.h" @@ -64,7 +63,7 @@ do { \ token = strtok_r(temp_arr, delimiters, &usr_ptr); \ while (token) { \ if (index > x_list_max -1) { \ - debug_error("%d is not valid index\n", index); \ + _mmstreamrec_dbg_err("%d is not valid index\n", index); \ break; \ } else { \ value = atoi(token); \ @@ -79,7 +78,7 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) { dictionary *dict = NULL; - debug_fenter(); + _mmstreamrec_dbg_warn("enter"); __mm_streamrecorder_ini_check_status(); @@ -222,7 +221,7 @@ int _mm_streamrecorder_ini_load(mm_streamrecorder_ini_t *ini) loaded = TRUE; - debug_fleave(); + _mmstreamrec_dbg_warn("leave"); return MM_ERROR_NONE; } @@ -326,7 +325,7 @@ void __mm_streamrecorder_ini_check_status(void) { struct stat ini_buff; - debug_fenter(); + _mmstreamrec_dbg_warn("enter"); if (g_stat(MM_STREAMRECORDER_INI_DEFAULT_PATH, &ini_buff) < 0) { _mmstreamrec_dbg_err("failed to get mmfw_streamrecorder.ini status\n"); @@ -337,16 +336,16 @@ void __mm_streamrecorder_ini_check_status(void) } } - debug_fleave(); + _mmstreamrec_dbg_warn("leave"); } int _mm_streamrecorder_ini_unload(mm_streamrecorder_ini_t *ini) { - debug_fenter(); + _mmstreamrec_dbg_warn("enter"); loaded = FALSE; - debug_fleave(); + _mmstreamrec_dbg_warn("leave"); return MM_ERROR_NONE; } -- 2.7.4 From b1811be214bae6b84603c84d20571dd18a1395cb Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 20 Sep 2017 10:41:10 +0900 Subject: [PATCH 14/16] fix double free - remove g_list first, unexpected remove_message_all function within callback free list item first. so that, FREE after callback cause double free. Signed-off-by: SeokHoon Lee Change-Id: I28790e0d64daa3ecf3de79208d742ec6234041e7 --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_gstdispatch.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 26fb19d..6807f2a 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.16 +Version: 0.0.17 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_gstdispatch.c b/src/mm_streamrecorder_gstdispatch.c index 9ff61cd..8a0cf6a 100644 --- a/src/mm_streamrecorder_gstdispatch.c +++ b/src/mm_streamrecorder_gstdispatch.c @@ -302,6 +302,12 @@ gboolean _mmstreamrecorder_msg_callback(void *data) goto MSG_CALLBACK_DONE; } + _MMSTREAMRECORDER_LOCK((MMHandleType) hstreamrecorder); + if (hstreamrecorder->msg_data) + hstreamrecorder->msg_data = g_list_remove(hstreamrecorder->msg_data, item); + + _MMSTREAMRECORDER_UNLOCK((MMHandleType) hstreamrecorder); + /* _mmstreamrec_dbg_log("msg id:%x, msg_cb:%p, msg_data:%p, item:%p", item->id, hstreamrecorder->msg_cb, hstreamrecorder->msg_data, item); */ _MMSTREAMRECORDER_LOCK_MESSAGE_CALLBACK(hstreamrecorder); @@ -310,12 +316,6 @@ gboolean _mmstreamrecorder_msg_callback(void *data) _MMSTREAMRECORDER_UNLOCK_MESSAGE_CALLBACK(hstreamrecorder); - _MMSTREAMRECORDER_LOCK((MMHandleType) hstreamrecorder); - if (hstreamrecorder->msg_data) - hstreamrecorder->msg_data = g_list_remove(hstreamrecorder->msg_data, item); - - _MMSTREAMRECORDER_UNLOCK((MMHandleType) hstreamrecorder); - MSG_CALLBACK_DONE: /* release allocated memory */ if (item->id == MM_MESSAGE_STREAMRECORDER_VIDEO_CAPTURED || -- 2.7.4 From 7a33e3d60322cc4e662bda8fd7628755b9a7af1c Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Thu, 28 Sep 2017 10:24:42 +0900 Subject: [PATCH 15/16] Delete unused function - delete unused funcion(_mmstreamrecorder_find_fourcc and others) - delete err_attr_name in testsuite, it doesnt need to check. - add err_name check in mm_streamrecorder_recorder Signed-off-by: SeokHoon Lee Change-Id: I77c6babacf1702f7ed7402681a80c1a68fffa15c --- packaging/libmm-streamrecorder.spec | 2 +- src/include/mm_streamrecorder_fileinfo.h | 2 - src/mm_streamrecorder_fileinfo.c | 160 ------------------------------- src/mm_streamrecorder_recorder.c | 33 ++++--- test/mm_streamrecorder_testsuite.c | 7 +- 5 files changed, 25 insertions(+), 179 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 6807f2a..3c1ded6 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.17 +Version: 0.0.18 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/include/mm_streamrecorder_fileinfo.h b/src/include/mm_streamrecorder_fileinfo.h index dfc96a5..7e04c43 100644 --- a/src/include/mm_streamrecorder_fileinfo.h +++ b/src/include/mm_streamrecorder_fileinfo.h @@ -104,7 +104,6 @@ enum MMStreamReorderTagVideoOrientation { tag_fourcc is Four-character-code (FOURCC) */ // READER -gboolean _mmstreamrecorder_find_fourcc(FILE *f, guint32 tag_fourcc, gboolean do_rewind); gboolean _mmstreamrecorder_update_size(FILE *f, gint64 prev_pos, gint64 curr_pos); guint64 _mmstreamrecorder_get_container_size(const guchar *size); @@ -118,7 +117,6 @@ gboolean _mmstreamrecorder_write_udta(FILE *f, _MMStreamRecorderLocationInfo inf // AUDIO FOURCC gboolean _mmstreamrecorder_write_udta_m4a(FILE *f); -gboolean _mmstreamrecorder_audio_add_metadata_info_m4a(MMHandleType handle); #ifdef __cplusplus } diff --git a/src/mm_streamrecorder_fileinfo.c b/src/mm_streamrecorder_fileinfo.c index 61d9968..5b8d780 100644 --- a/src/mm_streamrecorder_fileinfo.c +++ b/src/mm_streamrecorder_fileinfo.c @@ -51,57 +51,6 @@ | GLOBAL FUNCTION DEFINITIONS: | ---------------------------------------------------------------------------*/ -gboolean _mmstreamrecorder_find_fourcc(FILE *f, guint32 tag_fourcc, gboolean do_rewind) -{ - guchar buf[8]; - - if (do_rewind) - rewind(f); - - while (fread(&buf, sizeof(guchar), 8, f) > 0) { - unsigned long long buf_size = 0; - unsigned int buf_fourcc = MMSTREAMRECORDER_FOURCC(buf[4], buf[5], buf[6], buf[7]); - - if (tag_fourcc == buf_fourcc) { - _mmstreamrec_dbg_log("find tag : %c%c%c%c", MMSTREAMRECORDER_FOURCC_ARGS(tag_fourcc)); - return TRUE; - } else if ((buf_fourcc == MMSTREAMRECORDER_FOURCC('m', 'o', 'o', 'v')) && (tag_fourcc != buf_fourcc)) { - if (_mmstreamrecorder_find_fourcc(f, tag_fourcc, FALSE)) - return TRUE; - else - continue; - } else { - _mmstreamrec_dbg_log("skip [%c%c%c%c] tag", MMSTREAMRECORDER_FOURCC_ARGS(buf_fourcc)); - - buf_size = (unsigned long long)_mmstreamrecorder_get_container_size(buf); - buf_size = buf_size - 8; /* include tag */ - - do { - if (buf_size > _MMSTREAMRECORDER_MAX_INT) { - _mmstreamrec_dbg_log("seek %d", _MMSTREAMRECORDER_MAX_INT); - if (fseek(f, _MMSTREAMRECORDER_MAX_INT, SEEK_CUR) != 0) { - _mmstreamrec_dbg_err("fseek() fail"); - return FALSE; - } - - buf_size -= _MMSTREAMRECORDER_MAX_INT; - } else { - _mmstreamrec_dbg_log("seek %d", buf_size); - if (fseek(f, buf_size, SEEK_CUR) != 0) { - _mmstreamrec_dbg_err("fseek() fail"); - return FALSE; - } - break; - } - } while (TRUE); - } - } - - _mmstreamrec_dbg_log("cannot find tag : %c%c%c%c", MMSTREAMRECORDER_FOURCC_ARGS(tag_fourcc)); - - return FALSE; -} - gboolean _mmstreamrecorder_update_composition_matrix(FILE *f, int orientation) { /* for 0 degree */ @@ -239,112 +188,3 @@ gboolean _mmstreamrecorder_write_udta(FILE *f, _MMStreamRecorderLocationInfo inf return TRUE; } - -/* START TAG HERE */ -gboolean _mmstreamrecorder_audio_add_metadata_info_m4a(MMHandleType handle) -{ - FILE *f = NULL; - guchar buf[4]; - guint64 udta_size = 0; - gint64 current_pos = 0; - gint64 moov_pos = 0; - gint64 udta_pos = 0; - char err_msg[128] = { '\0', }; - - _MMStreamRecorderFileInfo *finfo = NULL; - mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); - _MMStreamRecorderSubContext *sc = NULL; - - mmf_return_val_if_fail(hstreamrecorder, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - sc = MMF_STREAMRECORDER_SUBCONTEXT(handle); - - mmf_return_val_if_fail(sc, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - mmf_return_val_if_fail(sc->info_file, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); - - finfo = sc->info_file; - - f = fopen(finfo->filename, "rb+"); - if (f == NULL) { - strerror_r(errno, err_msg, 128); - _mmstreamrec_dbg_err("file open failed [%s]", err_msg); - return FALSE; - } - - /* find udta container. - if, there are udta container, write loci box after that - else, make udta container and write loci box. */ - if (_mmstreamrecorder_find_fourcc(f, MMSTREAMRECORDER_FOURCC('u', 'd', 't', 'a'), TRUE)) { - size_t nread = 0; - - _mmstreamrec_dbg_log("find udta container"); - - /* read size */ - if (fseek(f, -8L, SEEK_CUR) != 0) - goto fail; - - udta_pos = ftell(f); - if (udta_pos < 0) - goto ftell_fail; - - nread = fread(&buf, sizeof(char), sizeof(buf), f); - - _mmstreamrec_dbg_log("recorded file fread %d", nread); - - udta_size = _mmstreamrecorder_get_container_size(buf); - - /* goto end of udta and write 'smta' box */ - if (fseek(f, (udta_size - 4L), SEEK_CUR) != 0) - goto fail; - - current_pos = ftell(f); - if (current_pos < 0) - goto ftell_fail; - - if (!_mmstreamrecorder_update_size(f, udta_pos, current_pos)) - goto fail; - } else { - _mmstreamrec_dbg_log("No udta container"); - if (fseek(f, 0, SEEK_END) != 0) - goto fail; - - if (!_mmstreamrecorder_write_udta_m4a(f)) - goto fail; - } - - /* find moov container. - update moov container size. */ - if ((current_pos = ftell(f)) < 0) - goto ftell_fail; - - if (_mmstreamrecorder_find_fourcc(f, MMSTREAMRECORDER_FOURCC('m', 'o', 'o', 'v'), TRUE)) { - - _mmstreamrec_dbg_log("found moov container"); - if (fseek(f, -8L, SEEK_CUR) != 0) - goto fail; - - moov_pos = ftell(f); - if (moov_pos < 0) - goto ftell_fail; - - if (!_mmstreamrecorder_update_size(f, moov_pos, current_pos)) - goto fail; - - } else { - _mmstreamrec_dbg_err("No 'moov' container"); - goto fail; - } - - fclose(f); - return TRUE; - - fail: - fclose(f); - return FALSE; - - ftell_fail: - _mmstreamrec_dbg_err("ftell() returns negative value."); - fclose(f); - return FALSE; -} - -/* END TAG HERE */ diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index 90db571..9e3de20 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -257,18 +257,16 @@ int _mmstreamrecorder_create_recorder_pipeline(MMHandleType handle) sinkpad = NULL; } - if (!strcmp(/*gst_element_rsink_name */"filesink", "filesink")) { - srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst, "src"); - MMSTREAMRECORDER_ADD_BUFFER_PROBE(srcpad, _MMSTREAMRECORDER_HANDLER_VIDEOREC, __mmstreamrecorder_video_dataprobe_record, hstreamrecorder); + srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst, "src"); + MMSTREAMRECORDER_ADD_BUFFER_PROBE(srcpad, _MMSTREAMRECORDER_HANDLER_VIDEOREC, __mmstreamrecorder_video_dataprobe_record, hstreamrecorder); + gst_object_unref(srcpad); + srcpad = NULL; + + if (sc->audio_enable == TRUE) { + srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, "src"); + MMSTREAMRECORDER_ADD_BUFFER_PROBE(srcpad, _MMSTREAMRECORDER_HANDLER_VIDEOREC, __mmstreamrecorder_audio_dataprobe_check, hstreamrecorder); gst_object_unref(srcpad); srcpad = NULL; - - if (sc->audio_enable == TRUE) { - srcpad = gst_element_get_static_pad(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC].gst, "src"); - MMSTREAMRECORDER_ADD_BUFFER_PROBE(srcpad, _MMSTREAMRECORDER_HANDLER_VIDEOREC, __mmstreamrecorder_audio_dataprobe_check, hstreamrecorder); - gst_object_unref(srcpad); - srcpad = NULL; - } } bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst)); @@ -375,7 +373,7 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde const char *str_aar = NULL; const char *str_acs = NULL; char *err_name = NULL; - + int ret = MM_ERROR_NONE; GstCaps *caps = NULL; GstPad *pad = NULL; GList *element_list = NULL; @@ -407,7 +405,12 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde finfo = sc->info_file; /* check element availability */ - mm_streamrecorder_get_attributes(handle, &err_name, MMSTR_AUDIO_ENCODER, &audio_enc, MMSTR_AUDIO_CHANNEL, &channel, MMSTR_VIDEO_BITRATE, &v_bitrate, MMSTR_VIDEO_ENCODER, &video_enc, MMSTR_AUDIO_BITRATE, &a_bitrate, MMSTR_VIDEO_RESOLUTION_WIDTH, &video_width, MMSTR_VIDEO_RESOLUTION_HEIGHT, &video_height, MMSTR_VIDEO_FRAMERATE, &video_fps, MMSTR_FILE_FORMAT, &file_format, MMSTR_AUDIO_SAMPLERATE, &audio_samplerate, MMSTR_AUDIO_SOURCE_FORMAT, &audio_src_format, MMSTR_VIDEO_SOURCE_FORMAT, &video_src_format, MMSTR_RECORDER_MODE, &rec_mode, NULL); + ret = mm_streamrecorder_get_attributes(handle, &err_name, MMSTR_AUDIO_ENCODER, &audio_enc, MMSTR_AUDIO_CHANNEL, &channel, MMSTR_VIDEO_BITRATE, &v_bitrate, MMSTR_VIDEO_ENCODER, &video_enc, MMSTR_AUDIO_BITRATE, &a_bitrate, MMSTR_VIDEO_RESOLUTION_WIDTH, &video_width, MMSTR_VIDEO_RESOLUTION_HEIGHT, &video_height, MMSTR_VIDEO_FRAMERATE, &video_fps, MMSTR_FILE_FORMAT, &file_format, MMSTR_AUDIO_SAMPLERATE, &audio_samplerate, MMSTR_AUDIO_SOURCE_FORMAT, &audio_src_format, MMSTR_VIDEO_SOURCE_FORMAT, &video_src_format, MMSTR_RECORDER_MODE, &rec_mode, NULL); + if (ret != MM_ERROR_NONE) { + _mmstreamrec_dbg_err("Get attrs fail. (%s:%x)", err_name, ret); + SAFE_FREE(err_name); + return err; + } _mmstreamrec_dbg_err("audio encoder - %d , video encoder : %d", audio_enc, video_enc); _mmstreamrec_dbg_err("audio channel - %d , video v_bitrate : %d", channel, v_bitrate); @@ -1351,6 +1354,12 @@ int _mmstreamrecorder_push_videostream_buffer(MMHandleType handle, unsigned long /* check element availability */ ret = mm_streamrecorder_get_attributes(handle, &err_name, MMSTR_VIDEO_FRAMERATE, &video_fps, MMSTR_VIDEO_SOURCE_FORMAT, &video_src, MMSTR_VIDEO_RESOLUTION_WIDTH, &video_width, MMSTR_VIDEO_RESOLUTION_HEIGHT, &video_height, MMSTR_VIDEO_SOURCE_FORMAT, &video_source_format, NULL); + if (ret != MM_ERROR_NONE) { + _mmstreamrec_dbg_err("Error in mm_streamrecorder_get_attributes (%s:%d)", err_name, ret); + SAFE_FREE(err_name); + return ret; + } + if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_SRC].gst) { /*_mmstreamrec_dbg_log("Buffer Push start , time stamp %ld",timestamp);*/ diff --git a/test/mm_streamrecorder_testsuite.c b/test/mm_streamrecorder_testsuite.c index 5564ff6..06f5462 100644 --- a/test/mm_streamrecorder_testsuite.c +++ b/test/mm_streamrecorder_testsuite.c @@ -984,7 +984,6 @@ static gboolean init(int type) { MMHandleType str_handle = 0; - char *err_attr_name = NULL; int video_codec = MM_VIDEO_CODEC_INVALID; int file_format = MM_FILE_FORMAT_INVALID; int v_bitrate = 0; @@ -1021,12 +1020,12 @@ static gboolean init(int type) /* audio_src_format = 2; */ rec_mode = 0; video_src_format = MM_STREAMRECORDER_INPUT_FORMAT_NV12; - mm_streamrecorder_set_attributes((MMHandleType)str_handle, &err_attr_name, + mm_streamrecorder_set_attributes((MMHandleType)str_handle, NULL, MMSTR_VIDEO_ENABLE, TRUE, MMSTR_AUDIO_ENABLE, FALSE, NULL); - mm_streamrecorder_set_attributes((MMHandleType)str_handle, &err_attr_name, + mm_streamrecorder_set_attributes((MMHandleType)str_handle, NULL, MMSTR_VIDEO_ENCODER, video_codec, /*MMSTR_AUDIO_ENCODER, audio_codec,*/ MMSTR_FILE_FORMAT, file_format, @@ -1041,7 +1040,7 @@ static gboolean init(int type) MMSTR_VIDEO_SOURCE_FORMAT, video_src_format, MMSTR_RECORDER_MODE, rec_mode, NULL); - mm_streamrecorder_set_attributes((MMHandleType)str_handle, &err_attr_name, + mm_streamrecorder_set_attributes((MMHandleType)str_handle, NULL, MMSTR_FILENAME, filename, strlen(filename), NULL); -- 2.7.4 From 6ee3cfd20240b28acf1349e38344e24380f360c1 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Mon, 9 Apr 2018 18:21:16 +0900 Subject: [PATCH 16/16] Add free code - add g_free (type) for memory leak Signed-off-by: SeokHoon Lee Change-Id: I6a300efef88d5bf50fa0859a6cba39643d5a028f --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_recorder.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 3c1ded6..0cd8cae 100644 --- a/packaging/libmm-streamrecorder.spec +++ b/packaging/libmm-streamrecorder.spec @@ -1,6 +1,6 @@ Name: libmm-streamrecorder Summary: Media Stream Recorder library -Version: 0.0.18 +Version: 0.0.19 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index 9e3de20..75996d0 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -562,8 +562,8 @@ int _mmstreamrecorder_create_encodesink_bin(MMHandleType handle, MMStreamRecorde MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "acaps", caps); { gchar *type = gst_caps_to_string(caps); - _mmstreamrec_dbg_warn("Set srcpad caps: %s", type); + g_free(type); } gst_caps_unref(caps); caps = NULL; @@ -908,9 +908,8 @@ int _mmstreamrecorder_create_audiosrc_bin(MMHandleType handle) MMSTREAMRECORDER_G_OBJECT_SET((sc->encode_element[_MMSTREAMRECORDER_AUDIOSRC_FILT].gst), "caps", caps); { gchar *type = gst_caps_to_string(caps); - _mmstreamrec_dbg_err("_MMSTREAMRECORDER_AUDIOSRC_FILT %s", type); - + g_free(type); } gst_caps_unref(caps); caps = NULL; -- 2.7.4