From: SeokHoon Lee Date: Tue, 12 Sep 2017 04:27:23 +0000 (+0900) Subject: Tizen coding convention X-Git-Tag: accepted/tizen/unified/20170920.081149~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=a1c62f728e4b24c0dafcba8b647ddc781edf4717;p=platform%2Fcore%2Fmultimedia%2Flibmm-streamrecorder.git Tizen coding convention Signed-off-by: SeokHoon Lee Change-Id: Id9c1656fec213f481243c4ee525b69a1a68accff --- 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);