From d41599748a5fbdf268a4a7a483ec9d6f483b1631 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Fri, 20 Jan 2017 10:21:01 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 From 2bb17acd28312accdfff577848e7e6bc85d48b05 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 2 Oct 2018 16:04:43 +0900 Subject: [PATCH 09/16] Adding initial structure for unittest - It has only one testcases for skeleton of unittest - It would be enabled by gtest build with '--define "gtests 1" Signed-off-by: SeokHoon Lee Change-Id: Ic0753be99906b17a7edc4bd20a8cdb4471003112 --- Makefile.am | 3 ++ configure.ac | 20 +++++++++++++ packaging/libmm-streamrecorder.spec | 15 ++++++++-- unittest/Makefile.am | 12 ++++++++ unittest/libmm_streamrecorder_unittest.cpp | 45 ++++++++++++++++++++++++++++++ unittest/libmm_streamrecorder_unittest.h | 26 +++++++++++++++++ 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 unittest/Makefile.am create mode 100644 unittest/libmm_streamrecorder_unittest.cpp create mode 100644 unittest/libmm_streamrecorder_unittest.h diff --git a/Makefile.am b/Makefile.am index 3839fb0..a4ced02 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,9 @@ ACLOCAL_AMFLAGS='-I m4' SUBDIRS = src test +if IS_TESTS +SUBDIRS += unittest +endif pcfiles = mm-streamrecorder.pc pkgconfigdir = $(libdir)/pkgconfig diff --git a/configure.ac b/configure.ac index 2de17cc..b07c4c7 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,7 @@ AM_PROG_AR # Checks for programs. AC_PROG_CC +AC_PROG_CXX AC_C_CONST dnl AC_FUNC_MALLOC AC_FUNC_MMAP @@ -22,6 +23,7 @@ AC_HEADER_STDC AC_HEADER_TIME AC_PROG_GCC_TRADITIONAL AC_PROG_LIBTOOL +AC_SUBST(GCC_CXXFLAGS) # Checks for libraries. PKG_CHECK_MODULES(GST, gstreamer-1.0 >= 1.2.0) @@ -56,6 +58,23 @@ PKG_CHECK_MODULES(INIPARSER, iniparser) AC_SUBST(INIPARSER_CFLAGS) AC_SUBST(INIPARSER_LIBS) +AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]), + [ + case "${enableval}" in + yes) IS_TESTS=yes ;; + no) IS_TESTS=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;; + esac + ], +[IS_TESTS=no]) +AM_CONDITIONAL([IS_TESTS], [test "x$IS_TESTS" = "xyes"]) + +AS_IF([test "x$enable_tests" = "xyes"], [ + PKG_CHECK_MODULES(GTESTS, gmock) + AC_SUBST(GTESTS_CFLAGS) + AC_SUBST(GTESTS_LIBS) +]) + # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h]) @@ -77,6 +96,7 @@ AC_CONFIG_FILES([ Makefile src/Makefile test/Makefile +unittest/Makefile mm-streamrecorder.pc ]) AC_OUTPUT diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 0cd8cae..9b15991 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.19 +Version: 0.0.20 Release: 0 Group: Multimedia/Other License: Apache-2.0 @@ -13,6 +13,9 @@ BuildRequires: pkgconfig(gstreamer-base-1.0) BuildRequires: pkgconfig(gstreamer-video-1.0) BuildRequires: pkgconfig(gstreamer-app-1.0) BuildRequires: pkgconfig(iniparser) +%if 0%{?gtests:1} +BuildRequires: pkgconfig(gmock) +%endif %description This library is for making video/audio files with gstreamer @@ -37,7 +40,12 @@ Media Stream Recorder development library 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 +%configure \ +%if 0%{?gtests:1} +--enable-tests \ +%endif +--disable-static + make %{?jobs:-j%jobs} %install @@ -58,6 +66,9 @@ rm -rf %{buildroot} %defattr(-,root,root,-) %{_bindir}/* %{_libdir}/*.so.* +%if 0%{?gtests:1} +%{_bindir}/gtest-libmm-streamrecorder +%endif %files devel diff --git a/unittest/Makefile.am b/unittest/Makefile.am new file mode 100644 index 0000000..26acced --- /dev/null +++ b/unittest/Makefile.am @@ -0,0 +1,12 @@ +bin_PROGRAMS = gtest-libmm-streamrecorder + +gtest_libmm_streamrecorder_SOURCES = libmm_streamrecorder_unittest.cpp + +gtest_libmm_streamrecorder_CXXFLAGS = -I$(top_srcdir)/src/include \ + $(GTESTS_CFLAGS) + +gtest_libmm_streamrecorder_DEPENDENCIES = $(top_srcdir)/src/libmmfstreamrecorder.la + +gtest_libmm_streamrecorder_LDADD = \ + $(GTESTS_LIBS) \ + $(top_srcdir)/src/libmmfstreamrecorder.la diff --git a/unittest/libmm_streamrecorder_unittest.cpp b/unittest/libmm_streamrecorder_unittest.cpp new file mode 100644 index 0000000..eb41236 --- /dev/null +++ b/unittest/libmm_streamrecorder_unittest.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "libmm_streamrecorder_unittest.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +class libmm_streamrecorder_Test : public ::testing::Test { + protected: + void SetUp() { + std::cout << "SetUp()" << std::endl; + } + + void TearDown() { + std::cout << "TearDown()" << std::endl; + } +}; + +TEST(libmm_streamrecorderTest, __srecorder_get_fourcc_p1) +{ + EXPECT_EQ(1, 1); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/libmm_streamrecorder_unittest.h b/unittest/libmm_streamrecorder_unittest.h new file mode 100644 index 0000000..bdc7956 --- /dev/null +++ b/unittest/libmm_streamrecorder_unittest.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LIB_MM_STREAMRECORDER_UNITTEST_H__ +#define __LIB_MM_STREAMRECORDER_UNITTEST_H__ + +#include +#include + +#undef LOG_TAG +#define LOG_TAG "GTEST_LIBMM_STREAMRECORDER" + +#endif /*__LIB_MM_STREAMRECORDER_UNITTEST_H__*/ -- 2.7.4 From 5c08d0e6897174ef26b0ff7fcce7c422dc732cca Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 2 Nov 2018 16:16:15 +0900 Subject: [PATCH 10/16] Apply new attribute API of libmm-common - Remove dependency of mm_attrs_private.h. - Use new API set in mm_attrs.h instead of those. Change-Id: I235197cfa1d89ea656238709ac25b66ba02af19b Signed-off-by: Sangchul Lee --- src/include/mm_streamrecorder_attribute.h | 23 ++++--- src/include/mm_streamrecorder_internal.h | 1 - src/mm_streamrecorder.c | 1 - src/mm_streamrecorder_attribute.c | 102 +++++++++++++++--------------- 4 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/include/mm_streamrecorder_attribute.h b/src/include/mm_streamrecorder_attribute.h index 9879e7c..8114b00 100644 --- a/src/include/mm_streamrecorder_attribute.h +++ b/src/include/mm_streamrecorder_attribute.h @@ -27,7 +27,6 @@ ========================================================================================*/ #include #include -#include #include #include "mm_streamrecorder_internal.h" @@ -83,7 +82,7 @@ typedef enum { /*======================================================================================= | TYPE DEFINITIONS | ========================================================================================*/ -typedef bool(*mmf_streamrecorder_commit_func_t) (MMHandleType handle, int attr_idx, const mmf_value_t *value); +typedef bool(*mmf_streamrecorder_commit_func_t) (MMHandleType handle, int attr_idx, const MMAttrsValue *value); /*======================================================================================= | STRUCTURE DEFINITIONS | @@ -208,23 +207,23 @@ int _mmstreamrecorder_get_attribute_info(MMHandleType handle, const char *attr_n * @see * */ -bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const mmf_value_t *value, void *commit_param); +bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param); -bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const MMAttrsValue *value); -bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value); /** * check whether supported or not @@ -235,7 +234,7 @@ bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, c */ bool _mmstreamrecorder_check_supported_attribute(MMHandleType handle, int attr_index); -bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value); #ifdef __cplusplus } diff --git a/src/include/mm_streamrecorder_internal.h b/src/include/mm_streamrecorder_internal.h index a29c3cf..61cb31e 100644 --- a/src/include/mm_streamrecorder_internal.h +++ b/src/include/mm_streamrecorder_internal.h @@ -33,7 +33,6 @@ #include #include -#include #include #include "mm_streamrecorder.h" diff --git a/src/mm_streamrecorder.c b/src/mm_streamrecorder.c index ec4c9b6..d2b70b8 100644 --- a/src/mm_streamrecorder.c +++ b/src/mm_streamrecorder.c @@ -27,7 +27,6 @@ #include -#include #include "mm_streamrecorder.h" #include "mm_streamrecorder_internal.h" #include "mm_streamrecorder_attribute.h" diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index e908d0f..f64b0dd 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -44,7 +44,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_BUFFER_TYPE, /* ID */ (char *)"videobuffer-type", /* Name */ - MMF_VALUE_TYPE_INT, /* Type */ + MM_ATTRS_TYPE_INT, /* Type */ MM_ATTRS_FLAG_RW, /* Flag */ {(void *)MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO}, /* Default value */ MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */ @@ -55,7 +55,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { /* 1 */ {MM_STR_VIDEO_FORMAT, (char *)"videosource-format", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_INPUT_FORMAT_NV12}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -67,7 +67,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_FRAMERATE, (char *)"video-framerate", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -79,7 +79,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_ENCODER_BITRATE, (char *)"video-bitrate", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -91,7 +91,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_RESOLUTION_WIDTH, (char *)"video-resolution-width", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, @@ -103,7 +103,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_RESOLUTION_HEIGHT, (char *)"video-resolution-height", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, @@ -115,7 +115,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_FORMAT, (char *)"audio-source-format", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -127,7 +127,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_ENCODER_BITRATE, (char *)"audio-bitrate", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)128000}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -139,7 +139,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_SAMPLERATE, (char *)"audio-samplerate", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -151,7 +151,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_ENCODER, (char *)"video-encoder", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, @@ -163,7 +163,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_ENCODER, (char *)"audio-encoder", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, @@ -175,7 +175,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_CHENNEL_COUNT, (char *)"audio-channel-count", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)2}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -187,7 +187,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_FILE_FORMAT, (char *)"file-format", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_ARRAY, @@ -199,7 +199,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_TARGET_FILE_NAME, (char *)"filename", - MMF_VALUE_TYPE_STRING, + MM_ATTRS_TYPE_STRING, MM_ATTRS_FLAG_RW, {NULL}, MM_ATTRS_VALID_TYPE_NONE, @@ -211,7 +211,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_VIDEO_ENABLE, (char *)"video-enable", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)FALSE}, MM_ATTRS_VALID_TYPE_NONE, @@ -223,7 +223,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_AUDIO_ENABLE, (char *)"audio-enable", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)FALSE}, MM_ATTRS_VALID_TYPE_NONE, @@ -235,7 +235,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_MODE, (char *)"recorder-mode", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)MM_STREAMRECORDER_MODE_MEDIABUFFER}, MM_ATTRS_VALID_TYPE_NONE, @@ -247,7 +247,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_TARGET_MAX_SIZE, (char *)"target-max-size", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -259,7 +259,7 @@ mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = { { MM_STR_TARGET_TIME_LIMIT, (char *)"target-time-limit", - MMF_VALUE_TYPE_INT, + MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, {(void *)0}, MM_ATTRS_VALID_TYPE_INT_RANGE, @@ -362,7 +362,6 @@ static int __mmstreamrecorder_release_conf_valid_info(MMHandleType handle) #if 0 static bool __mmstreamrecorder_attrs_is_supported(MMHandleType handle, int idx) { - mmf_attrs_t *attr = (mmf_attrs_t *) handle; int flag; if (mm_attrs_get_flags(handle, idx, &flag) == MM_ERROR_NONE) { @@ -372,15 +371,15 @@ static bool __mmstreamrecorder_attrs_is_supported(MMHandleType handle, int idx) return FALSE; } - if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_RANGE) { + if (mm_attrs_get_valid_type(handle, idx) == MM_ATTRS_VALID_TYPE_INT_RANGE) { int min, max; - mm_attrs_get_valid_range((MMHandleType) attr, idx, &min, &max); + mm_attrs_get_valid_range(handle, idx, &min, &max); if (max < min) return FALSE; - } else if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_ARRAY) { + } else if (mm_attrs_get_valid_type(handle, idx) == MM_ATTRS_VALID_TYPE_INT_ARRAY) { int count; int *array; - mm_attrs_get_valid_array((MMHandleType) attr, idx, &count, &array); + mm_attrs_get_valid_array(handle, idx, &count, &array); if (count == 0) return FALSE; } @@ -525,19 +524,19 @@ static int __mmstreamrecorder_check_valid_pair(MMHandleType handle, char **err_a } /* attribute commiter */ -void __mmstreamrecorder_print_attrs(const char *attr_name, const mmf_value_t * value, const char *cmt_way) +void __mmstreamrecorder_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *cmt_way) { switch (value->type) { - case MMF_VALUE_TYPE_INT: + case MM_ATTRS_TYPE_INT: _mmstreamrec_dbg_log("%s :(%s:%d)", cmt_way, attr_name, value->value.i_val); break; - case MMF_VALUE_TYPE_DOUBLE: + case MM_ATTRS_TYPE_DOUBLE: _mmstreamrec_dbg_log("%s :(%s:%f)", cmt_way, attr_name, value->value.d_val); break; - case MMF_VALUE_TYPE_STRING: + case MM_ATTRS_TYPE_STRING: _mmstreamrec_dbg_log("%s :(%s:%s)", cmt_way, attr_name, value->value.s_val); break; - case MMF_VALUE_TYPE_DATA: + case MM_ATTRS_TYPE_DATA: _mmstreamrec_dbg_log("%s :(%s:%p)", cmt_way, attr_name, value->value.p_val); break; default: @@ -738,17 +737,18 @@ MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle) { _mmstreamrec_dbg_log(""); - MMHandleType attrs = 0; - mmf_attrs_construct_info_t *attrs_const_info = NULL; + MMHandleType attrs = NULL; + MMAttrsConstructInfo *attrs_const_info = NULL; unsigned int attr_count = 0; unsigned int idx; + int ret = MM_ERROR_NONE; /* Create attribute constructor */ _mmstreamrec_dbg_log("start"); - /* alloc 'mmf_attrs_construct_info_t' */ + /* alloc 'mm_attrs_construct_info_t' */ attr_count = ARRAY_SIZE(stream_attrs_const_info); - attrs_const_info = malloc(attr_count * sizeof(mmf_attrs_construct_info_t)); + attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo)); if (!attrs_const_info) { _mmstreamrec_dbg_err("Fail to alloc constructor."); @@ -772,12 +772,12 @@ MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle) _mmstreamrec_dbg_log("Create Streamrecorder Attributes[%p, %d]", attrs_const_info, attr_count); - attrs = mmf_attrs_new_from_data("Streamrecorder_Attributes", attrs_const_info, attr_count, _mmstreamrecorder_commit_streamrecorder_attrs, (void *)handle); + ret = mm_attrs_new(attrs_const_info, attr_count, "Streamrecorder_Attributes", _mmstreamrecorder_commit_streamrecorder_attrs, (void *)handle, &attrs); free(attrs_const_info); attrs_const_info = NULL; - if (attrs == 0) { + if (ret != MM_ERROR_NONE) { _mmstreamrec_dbg_err("Fail to alloc attribute handle"); return 0; } @@ -785,19 +785,19 @@ MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle) __mmstreamrecorder_set_conf_to_valid_info(handle); for (idx = 0; idx < attr_count; idx++) { - mmf_attrs_set_valid_type(attrs, idx, stream_attrs_const_info[idx].validity_type); + mm_attrs_set_valid_type(attrs, idx, stream_attrs_const_info[idx].validity_type); switch (stream_attrs_const_info[idx].validity_type) { case MM_ATTRS_VALID_TYPE_INT_ARRAY: 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, + mm_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, + mm_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); @@ -805,13 +805,13 @@ MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle) case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY: 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, + mm_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, + mm_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); @@ -835,7 +835,7 @@ void _mmstreamrecorder_dealloc_attribute(MMHandleType attrs) _mmstreamrec_dbg_log(""); if (attrs) { - mmf_attrs_free(attrs); + mm_attrs_free(attrs); _mmstreamrec_dbg_log("released attribute"); } @@ -940,7 +940,7 @@ int _mmstreamrecorder_get_attribute_info(MMHandleType handle, const char *attr_n return ret; } -bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const mmf_value_t * value, void *commit_param) +bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue * value, void *commit_param) { bool bret = FALSE; @@ -962,7 +962,7 @@ bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *att return bret; } -bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; /* mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); */ @@ -988,7 +988,7 @@ bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, co return TRUE; } -bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1010,7 +1010,7 @@ bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, c return TRUE; } -bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; /* mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); */ @@ -1035,7 +1035,7 @@ bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, co return TRUE; } -bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1057,7 +1057,7 @@ bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, c return TRUE; } -bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1079,7 +1079,7 @@ bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_i return TRUE; } -bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1104,7 +1104,7 @@ bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, return TRUE; } -bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1127,7 +1127,7 @@ bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, c return TRUE; } -bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; @@ -1149,7 +1149,7 @@ bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, c return TRUE; } -bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const MMAttrsValue *value) { MMHandleType attr = 0; _MMStreamRecorderSubContext *sc = NULL; -- 2.7.4 From 289110907217124cd33d42657a879a2f7eeb4221 Mon Sep 17 00:00:00 2001 From: SeokHoon LEE Date: Fri, 7 Dec 2018 15:11:14 +0900 Subject: [PATCH 11/16] fix dlog format Change-Id: I69b8f2568dbd51451e0d061baf2595084ac4fd70 Signed-off-by: SeokHoon LEE --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_attribute.c | 8 ++++---- src/mm_streamrecorder_recorder.c | 2 +- test/mm_streamrecorder_testsuite.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 9b15991..df7002e 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.20 +Version: 0.0.21 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_attribute.c b/src/mm_streamrecorder_attribute.c index f64b0dd..02e45b0 100644 --- a/src/mm_streamrecorder_attribute.c +++ b/src/mm_streamrecorder_attribute.c @@ -705,7 +705,7 @@ _mmstreamrecorder_get_available_format(MMHandleType handle, int type, int ** for arr = (int*) g_malloc0(count * sizeof(int)); if (arr == NULL) { - _mmstreamrec_dbg_err("malloc failed : %d", count * sizeof(int)); + _mmstreamrec_dbg_err("malloc failed : %zu", count * sizeof(int)); return -1; } @@ -866,7 +866,7 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, attrs = MMF_STREAMRECORDER_ATTRS(handle); if (!attrs) { - _mmstreamrec_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name); + _mmstreamrec_dbg_err("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name); return MM_ERROR_STREAMRECORDER_NOT_INITIALIZED; } @@ -875,7 +875,7 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, 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); + _mmstreamrec_dbg_err("__mmstreamrecorder_check_valid_pair handle %p, attr name [%s] , ret = %d", handle, attribute_name, ret); if (ret == MM_ERROR_NONE) { /* In 64bit environment, unexpected result is returned if var_args is used again. */ @@ -883,7 +883,7 @@ int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, } va_end(var_args_copy); - _mmstreamrec_dbg_err("mm_attrs_set_valist handle 0x%x, attr name [%s] , ret = %d", handle, attribute_name, ret); + _mmstreamrec_dbg_err("mm_attrs_set_valist handle %p, attr name [%s] , ret = %d", handle, attribute_name, ret); return ret; } diff --git a/src/mm_streamrecorder_recorder.c b/src/mm_streamrecorder_recorder.c index 75996d0..d9eaeb0 100644 --- a/src/mm_streamrecorder_recorder.c +++ b/src/mm_streamrecorder_recorder.c @@ -67,7 +67,7 @@ int _mmstreamrecorder_create_pipeline(MMHandleType handle) _MMStreamRecorderSubContext *sc = NULL; GstElement *pipeline = NULL; - _mmstreamrec_dbg_log("handle : %x", handle); + _mmstreamrec_dbg_log("handle : %p", handle); mmf_return_val_if_fail(hstreamrecorder, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED); diff --git a/test/mm_streamrecorder_testsuite.c b/test/mm_streamrecorder_testsuite.c index 06f5462..c6f570d 100644 --- a/test/mm_streamrecorder_testsuite.c +++ b/test/mm_streamrecorder_testsuite.c @@ -1169,7 +1169,7 @@ static gboolean mode_change() if (!fp) return -1; nread = fread(&buffer, sizeof(char), sizeof(buffer), fp); - time_msg_t("mm_streamrecorder_create() : nread %d, sizeof(buffer) %d", nread, sizeof(buffer)); + time_msg_t("mm_streamrecorder_create() : nread %zu, sizeof(buffer) %zu", nread, sizeof(buffer)); fclose(fp); err = mm_streamrecorder_create(&hstreamrecorder->streamrecorder); -- 2.7.4 From 5d284ab8c7320f836a522fb9db5df8a6ac5d0c43 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Mon, 9 Apr 2018 18:21:16 +0900 Subject: [PATCH 12/16] Add free code - add g_free (type) for memory leak Signed-off-by: SeokHoon Lee Change-Id: I6a300efef88d5bf50fa0859a6cba39643d5a028f --- packaging/libmm-streamrecorder.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index df7002e..7454e41 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.21 +Version: 0.0.22 Release: 0 Group: Multimedia/Other License: Apache-2.0 -- 2.7.4 From 0aee4a2c55166b78fcec8dcda732f33841e89158 Mon Sep 17 00:00:00 2001 From: SeokHoon LEE Date: Mon, 21 Jan 2019 10:07:30 +0900 Subject: [PATCH 13/16] Add failure log for removing corrupted ini file - Add g_remove failed log Change-Id: Id3a7f0533385e9fba0212bd83b1590af08f08d28 Signed-off-by: SeokHoon LEE --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_ini.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 7454e41..3a23d44 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.22 +Version: 0.0.23 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_ini.c b/src/mm_streamrecorder_ini.c index d3f88c1..787c0c3 100644 --- a/src/mm_streamrecorder_ini.c +++ b/src/mm_streamrecorder_ini.c @@ -323,7 +323,8 @@ void __get_element_list(mm_streamrecorder_ini_t* ini, gchar* str, int keyword static void __mm_streamrecorder_ini_check_status(void) { - struct stat ini_buff; + GStatBuf ini_buff; + char buf[255] = {0, }; _mmstreamrec_dbg_warn("enter"); @@ -332,7 +333,10 @@ void __mm_streamrecorder_ini_check_status(void) } else { if (ini_buff.st_size < 5) { _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); + if (g_remove(MM_STREAMRECORDER_INI_DEFAULT_PATH) == -1) { + strerror_r(errno, buf, sizeof(buf)); + _mmstreamrec_dbg_err("failed to delete corrupted ini [%s]", buf); + } } } -- 2.7.4 From 0e515ac8edb22e4515f5954224ebff9aa5234c92 Mon Sep 17 00:00:00 2001 From: SeokHoon LEE Date: Mon, 22 Apr 2019 14:29:23 +0900 Subject: [PATCH 14/16] Add push_vidoe_packet for i420 format - add new function to process video packet that have separate plane in I420 format Change-Id: Id1abdcf1bf2562092e02ee352779afa45b7aaf94 Signed-off-by: SeokHoon LEE --- configure.ac | 4 ++ packaging/libmm-streamrecorder.spec | 3 +- src/Makefile.am | 2 + src/include/mm_streamrecorder.h | 3 ++ src/include/mm_streamrecorder_internal.h | 2 + src/mm_streamrecorder.c | 16 ++++++++ src/mm_streamrecorder_internal.c | 70 ++++++++++++++++++++++++++++++++ test/Makefile.am | 2 + 8 files changed, 101 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b07c4c7..f28cbea 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,10 @@ PKG_CHECK_MODULES(MM_COMMON, mm-common) AC_SUBST(MM_COMMON_CFLAGS) AC_SUBST(MM_COMMON_LIBS) +PKG_CHECK_MODULES(MEDIA_TOOL, capi-media-tool) +AC_SUBST(MEDIA_TOOL_CFLAGS) +AC_SUBST(MEDIA_TOOL_LIBS) + PKG_CHECK_MODULES(DLOG, dlog) AC_SUBST(DLOG_CFLAGS) AC_SUBST(DLOG_LIBS) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 3a23d44..c78bfdb 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.23 +Version: 0.0.24 Release: 0 Group: Multimedia/Other License: Apache-2.0 @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(mm-common) +BuildRequires: pkgconfig(capi-media-tool) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gstreamer-base-1.0) BuildRequires: pkgconfig(gstreamer-video-1.0) diff --git a/src/Makefile.am b/src/Makefile.am index 2138fc5..a1e672c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,7 @@ libmmfstreamrecorder_la_CFLAGS = -I$(srcdir)/include \ $(GST_INTERFACES_CFLAGS) \ $(DLOG_CFLAGS) \ $(MM_COMMON_CFLAGS) \ + $(MEDIA_TOOL_CFLAGS) \ $(GST_APP_CFLAGS) libmmfstreamrecorder_la_LIBADD = \ @@ -47,6 +48,7 @@ libmmfstreamrecorder_la_LIBADD = \ $(GST_VIDEO_LIBS) \ $(GST_INTERFACES_LIBS) \ $(MM_COMMON_LIBS) \ + $(MEDIA_TOOL_LIBS) \ $(DLOG_LIBS) \ $(VCONF_LIBS) \ $(GST_APP_LIBS) \ diff --git a/src/include/mm_streamrecorder.h b/src/include/mm_streamrecorder.h index 66902e3..b32ba7d 100644 --- a/src/include/mm_streamrecorder.h +++ b/src/include/mm_streamrecorder.h @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -442,6 +443,8 @@ int mm_streamrecorder_commit(MMHandleType streamrecorder); int mm_streamrecorder_cancel(MMHandleType streamrecorder); +int mm_streamrecorder_push_video_packet(MMHandleType streamrecorder, media_packet_h packet, unsigned long timestamp, void *buffer); + int mm_streamrecorder_push_stream_buffer(MMHandleType streamrecorder, MMStreamRecorderStreamType streamtype, unsigned long timestamp, void *buffer, int size); /** diff --git a/src/include/mm_streamrecorder_internal.h b/src/include/mm_streamrecorder_internal.h index 61cb31e..5bd3d2c 100644 --- a/src/include/mm_streamrecorder_internal.h +++ b/src/include/mm_streamrecorder_internal.h @@ -359,6 +359,8 @@ int _mmstreamrecorder_unrealize(MMHandleType hstreamrecorder); */ int _mmstreamrecorder_record(MMHandleType hstreamrecorder); +int _mmstreamrecorder_push_video_packet(MMHandleType handle, media_packet_h packet, unsigned long timestamp, void *buffer); + int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderStreamType streamtype, unsigned long timestamp, void *buffer, int size); /** diff --git a/src/mm_streamrecorder.c b/src/mm_streamrecorder.c index d2b70b8..b4c639b 100644 --- a/src/mm_streamrecorder.c +++ b/src/mm_streamrecorder.c @@ -160,6 +160,22 @@ int mm_streamrecorder_push_stream_buffer(MMHandleType streamrecorder, MMStreamRe return error; } +int mm_streamrecorder_push_video_packet(MMHandleType streamrecorder, media_packet_h packet, unsigned long timestamp, void *buffer) +{ + int error = MM_ERROR_NONE; + + mmf_return_val_if_fail((void *)streamrecorder, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT); + + _mmstreamrec_dbg_log(""); + + error = _mmstreamrecorder_push_video_packet(streamrecorder, packet, timestamp, buffer); + + _mmstreamrec_dbg_log("END"); + + return error; +} + + int mm_streamrecorder_commit(MMHandleType streamrecorder) { int error = MM_ERROR_NONE; diff --git a/src/mm_streamrecorder_internal.c b/src/mm_streamrecorder_internal.c index 5293609..127ff69 100644 --- a/src/mm_streamrecorder_internal.c +++ b/src/mm_streamrecorder_internal.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "mm_streamrecorder_internal.h" #include "mm_streamrecorder_recorder.h" @@ -388,6 +389,75 @@ int _mmstreamrecorder_record(MMHandleType handle) return ret; } +int _mmstreamrecorder_push_video_packet(MMHandleType handle, media_packet_h media_packet, unsigned long timestamp, void *buffer) +{ + int ret = MM_ERROR_NONE; + unsigned int ind = 0; + uint32_t plane_num = 0; + mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); + GstStreamRecorderBuffer *stream_buffer = NULL; + int image_width = 0; + int image_height = 0; + unsigned char *data_buffer = NULL; + int size = 0, total_size = 0; + + if (!hstreamrecorder) { + _mmstreamrec_dbg_err("Not initialized"); + ret = MM_ERROR_STREAMRECORDER_NOT_INITIALIZED; + return ret; + } + + ret = media_packet_get_number_of_video_planes(media_packet, &plane_num); + if (plane_num <= 0 || ret != MEDIA_PACKET_ERROR_NONE) { + LOGE("invalid plane_num [%d] is returned", plane_num); + return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT; + } + + stream_buffer = (GstStreamRecorderBuffer *) malloc(sizeof(GstStreamRecorderBuffer)); + if (stream_buffer == NULL) { + _mmstreamrec_dbg_err("stream buffer allocation fail"); + return MM_ERROR_STREAMRECORDER_LOW_MEMORY; + } + + stream_buffer->str_handle = handle; + stream_buffer->buffer = gst_buffer_new(); + if (stream_buffer->buffer == NULL) { + free(stream_buffer); + stream_buffer = NULL; + _mmstreamrec_dbg_err("gst buffer allocation fail"); + return MM_ERROR_STREAMRECORDER_LOW_MEMORY; + } + stream_buffer->user_buffer = buffer; + stream_buffer->buffer->pts = timestamp; + GST_BUFFER_DURATION(stream_buffer->buffer) = GST_CLOCK_TIME_NONE; + + for (ind = 0; ind < plane_num; ++ind) { + ret = media_packet_get_video_stride_width(media_packet, ind, &image_width); + ret |= media_packet_get_video_stride_height(media_packet, ind, &image_height); + ret |= media_packet_get_video_plane_data_ptr(media_packet, ind, (void**)&data_buffer); + + if (ret != MEDIA_PACKET_ERROR_NONE) { + LOGE("media_packet_get_video_plane_data_ptr() plane[%d] failed", ind); + return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT; + } + + size = image_width * image_height; + total_size += size; + _mmstreamrec_dbg_err("Plane[%d] info : %d x %d (%p) size = %d\n", ind, image_width, image_height, data_buffer, total_size); + + if (ind == plane_num - 1) //last plane + gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, + data_buffer, size, 0, size, stream_buffer, _mmstreamrecorder_buffer_destroy)); + else + gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, + data_buffer, size, 0, size, NULL, NULL)); + } + + ret = _mmstreamrecorder_push_videostream_buffer(handle, timestamp, stream_buffer->buffer, total_size); + + return ret; +} + int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderStreamType streamtype, unsigned long timestamp, void *buffer, int size) { int ret = MM_ERROR_NONE; diff --git a/test/Makefile.am b/test/Makefile.am index f22d5ae..344277e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,6 +7,7 @@ mm_streamrecorder_testsuite_CFLAGS = -fPIE \ $(GLIB_CFLAGS)\ $(GST_CFLAGS)\ $(MM_COMMON_CFLAGS)\ + $(MEDIA_TOOL_CFLAGS) \ $(MM_SOUND_CFLAGS)\ $(MDM_CFLAGS) @@ -20,6 +21,7 @@ mm_streamrecorder_testsuite_LDADD = $(top_builddir)/src/libmmfstreamrecorder.la $(GLIB_LIBS)\ $(GST_LIBS)\ $(MM_COMMON_LIBS)\ + $(MEDIA_TOOL_LIBS) \ $(MM_SOUND_LIBS)\ $(MDM_LIBS) -- 2.7.4 From aec382cc3fb04883b0a5beb0a02a0e2932f7c63c Mon Sep 17 00:00:00 2001 From: SeokHoon LEE Date: Wed, 17 Jul 2019 13:45:34 +0900 Subject: [PATCH 15/16] Remove unnecessary map - _mmstreamrecordder_push_videostream_buffer and audiostream_buffer take onwership of buffer so, - remove unnecessary map/unmap. Change-Id: Ie2e3561d8d79f2de2f5318d1c331b56faeec216b Signed-off-by: SeokHoon LEE --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_internal.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index c78bfdb..8218720 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.24 +Version: 0.0.25 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_internal.c b/src/mm_streamrecorder_internal.c index 127ff69..fe6b723 100644 --- a/src/mm_streamrecorder_internal.c +++ b/src/mm_streamrecorder_internal.c @@ -463,7 +463,6 @@ int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderSt int ret = MM_ERROR_NONE; int format; - GstMapInfo map; mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); /* _mmstreamrec_dbg_log(""); */ @@ -496,7 +495,6 @@ int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderSt stream_buffer->buffer->pts = timestamp; GST_BUFFER_DURATION(stream_buffer->buffer) = GST_CLOCK_TIME_NONE; - gst_buffer_map(stream_buffer->buffer, &map, GST_MAP_READWRITE); if (streamtype == MM_STREAM_TYPE_VIDEO) { if (format == MM_STREAMRECORDER_INPUT_FORMAT_NV12 || format == MM_STREAMRECORDER_INPUT_FORMAT_NV21) { @@ -517,15 +515,13 @@ int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderSt 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); gst_object_unref(stream_buffer->buffer); free(stream_buffer); stream_buffer = NULL; return MM_ERROR_STREAMRECORDER_INVALID_CONDITION; } - gst_buffer_unmap(stream_buffer->buffer, &map); - return ret; + return ret; } int _mmstreamrecorder_pause(MMHandleType handle) -- 2.7.4 From 91785ae80b12885fe45ce36664bf8ee0ef51b36e Mon Sep 17 00:00:00 2001 From: Hyunsoo Park Date: Tue, 20 Aug 2019 16:36:08 +0900 Subject: [PATCH 16/16] Change stream buffer data pointer location. Data pointer of 'MediaPacket' is assigned to 'data[0]' member variable but 'gst_buffer_append_memory' api try to get pointer from 'handle.paddr[0]'. So i change it to 'data[0]'. Change-Id: Ice515241ffa0e03ff580744242b6417401dfd38f Signed-off-by: Hyunsoo Park --- packaging/libmm-streamrecorder.spec | 2 +- src/mm_streamrecorder_internal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libmm-streamrecorder.spec b/packaging/libmm-streamrecorder.spec index 8218720..49a0505 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.25 +Version: 0.0.26 Release: 0 Group: Multimedia/Other License: Apache-2.0 diff --git a/src/mm_streamrecorder_internal.c b/src/mm_streamrecorder_internal.c index fe6b723..1846328 100644 --- a/src/mm_streamrecorder_internal.c +++ b/src/mm_streamrecorder_internal.c @@ -501,7 +501,7 @@ int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderSt MMVideoBuffer *video_buf = (MMVideoBuffer *)buffer; /* Buffer at 0th position */ gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, - video_buf->handle.paddr[0], size, 0, size, video_buf->handle.paddr[0], NULL)); + video_buf->data[0], size, 0, size, video_buf->data[0], NULL)); /* Buffer at 1st position */ gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, video_buf, sizeof(MMVideoBuffer), 0, sizeof(MMVideoBuffer), stream_buffer, _mmstreamrecorder_buffer_destroy)); -- 2.7.4