Change mediapacket usage 07/227607/14 submit/tizen/20200325.100145
authorHyunsoo Park <hance.park@samsung.com>
Fri, 13 Mar 2020 05:56:21 +0000 (14:56 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Wed, 25 Mar 2020 08:10:09 +0000 (17:10 +0900)
Change-Id: Ib65a525577e70c9656fb63177aa5df97f02a155d
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
packaging/capi-media-streamrecorder.spec
src/streamrecorder.c
test/streamrecorder_test.c

index 9f717ee..0bdb58e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamrecorder
 Summary:    A Streamrecorder library in Tizen Native API
-Version:    0.0.28
+Version:    0.0.29
 Release:    0
 Group:      Multimedia/Other
 License:    Apache-2.0
index fde1b08..ad1295d 100644 (file)
@@ -31,6 +31,7 @@
 #include <tbm_surface.h>
 #include <tbm_bufmgr.h>
 #include <tbm_surface_internal.h>
+#include <inttypes.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -122,6 +123,7 @@ int streamrecorder_push_stream_buffer(streamrecorder_h recorder, media_packet_h
        /* pts */
        media_packet_get_pts(packet, &pts);
        media_packet_is_video(packet, &flag);
+
        if (flag) {
                media_format_h fmt = NULL;
                media_format_mimetype_e mimetype = 0;
@@ -131,14 +133,30 @@ int streamrecorder_push_stream_buffer(streamrecorder_h recorder, media_packet_h
 
                if ((mimetype == MEDIA_FORMAT_NV12) || (mimetype == MEDIA_FORMAT_NV21)) {
                        MMVideoBuffer *video_buf = NULL;
-                       void *dataPtr = NULL;
+                       void *dataPtrY = NULL;
+                       void *dataPtrUV = NULL;
+
                        video_buf = (MMVideoBuffer *)malloc(sizeof(MMVideoBuffer));
                        if (!video_buf) {
                                LOGE("Failed to alloc MMVideoBuffer");
                                return STREAMRECORDER_ERROR_OUT_OF_MEMORY;
                        }
                        memset(video_buf, 0x00, sizeof(MMVideoBuffer));
-                       media_packet_get_buffer_data_ptr(packet, (void **)&dataPtr);
+
+                       ret = media_packet_get_video_plane_data_ptr(packet, 0, &dataPtrY);
+                       if (ret != MEDIA_PACKET_ERROR_NONE) {
+                               LOGE(" media_packet_get_video_plane_data_ptr failed");
+                               free(video_buf);
+                               return STREAMRECORDER_ERROR_INVALID_OPERATION;
+                       }
+
+                       ret = media_packet_get_video_plane_data_ptr(packet, 1, &dataPtrUV);
+                       if (ret != MEDIA_PACKET_ERROR_NONE) {
+                               LOGE(" media_packet_get_video_plane_data_ptr failed");
+                               free(video_buf);
+                               return STREAMRECORDER_ERROR_INVALID_OPERATION;
+                       }
+
                        media_packet_get_tbm_surface(packet, &surface);
                        if (surface == NULL) {
                                LOGE("Failed to get surface");
@@ -148,12 +166,15 @@ int streamrecorder_push_stream_buffer(streamrecorder_h recorder, media_packet_h
                        video_buf->handle_num = tbm_surface_internal_get_num_bos(surface);
                        video_buf->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
                        /* video_buf->handle.paddr[0] = dataPtr; */
-                       video_buf->data[0] =  dataPtr;
+                       video_buf->data[0] =  dataPtrY;
                        video_buf->width[0] = width;
                        video_buf->height[0] = height;
-                       media_packet_get_video_stride_width(packet, 0, &video_buf->stride_width[0]);
-                       media_packet_get_video_stride_width(packet, 0, &video_buf->stride_height[0]);
-                       video_buf->size[0] = width*height*3/2; // 1392640
+                       video_buf->size[0] = width * height;
+
+                       video_buf->data[1] =  dataPtrUV;
+                       video_buf->width[1] = width;
+                       video_buf->height[1] = height >> 1;
+                       video_buf->size[1] = video_buf->size[0] >> 1;
 
                        for (i = 0; i < MAX_MPACKET_DATA; i++) {
                                if (pkt->packet[i] == NULL) {
@@ -168,7 +189,6 @@ int streamrecorder_push_stream_buffer(streamrecorder_h recorder, media_packet_h
                                        }
                                }
                        }
-
                        ret = mm_streamrecorder_push_stream_buffer(handle->mm_handle, MM_STREAM_TYPE_VIDEO, pts, video_buf, video_buf->size[0]);
                } else if (mimetype == MEDIA_FORMAT_I420 || mimetype == MEDIA_FORMAT_BGRA) {
                        void *buf_data = NULL;
index 47484ab..04037fb 100644 (file)
@@ -31,9 +31,6 @@
 #include <streamrecorder.h>
 #include <streamrecorder_private.h>
 
-#define LOGD g_print
-#define LOGE g_print
-#define LOGW g_print
 /*-----------------------------------------------------------------------
 |    GLOBAL VARIABLE DEFINITIONS:                                       |
 -----------------------------------------------------------------------*/
@@ -70,10 +67,8 @@ void *display;
 |    LOCAL #defines:                                                    |
 -----------------------------------------------------------------------*/
 
-
-#define DISPLAY_W_320                       320                 /*for direct FB*/
-#define DISPLAY_H_240                       240                 /*for direct FB*/
-
+#define DISPLAY_W                      1280
+#define DISPLAY_H                       720
 
 #define SRC_VIDEO_FRAME_RATE_15         15    /* video input frame rate */
 #define SRC_VIDEO_FRAME_RATE_30         30    /* video input frame rate */
@@ -100,6 +95,7 @@ void *display;
 #define AUDIO_SOURCE_CHANNEL_AMR        1
 #define VIDEO_ENCODE_BITRATE            40000000 /* bps */
 
+
 #define CHECK_MM_ERROR(expr) \
 do {\
        int ret = 0; \
@@ -115,12 +111,6 @@ do {\
 #define SAFE_FREE(x)       if (x) { g_free(x); x = NULL; }
 #endif
 
-
-GTimeVal previous;
-GTimeVal current;
-GTimeVal result;
-/*temp*/
-
 /**
 * Enumerations for command
 */
@@ -217,7 +207,7 @@ static void print_menu()
        break;
 
        default:
-               LOGE("unknow menu state !!\n");
+               g_print("unknow menu state !!\n");
                break;
        }
        return;
@@ -225,52 +215,121 @@ static void print_menu()
 
 media_packet_h streamrecorder_make_media_packet(int video, void *data, int size)
 {
-       guint8 *pkt_data;
-       media_packet_h out_pkt;
-       media_format_h output_fmt;
-       if (media_format_create(&output_fmt)) {
-               g_print("media_format_create failed\n");
+       media_packet_h out_pkt = NULL;
+       media_format_h output_fmt = NULL;
+       gint stride_width = 0, stride_height = 0;
+       gint ret = 0;
+       size_t plane_size = 0;
+       size_t buffer_offset = 0;
+       void *plane_ptr = NULL;
+
+       g_print("size [%d]\n", size);
+
+       ret = media_format_create(&output_fmt);
+       if (ret != MEDIA_FORMAT_ERROR_NONE) {
+               g_print("media_format_create failed (%d) \n", ret);
                return NULL;
        }
 
        if (video) {
-               if (hmstreamrecorder->mode == MODE_LIVE_BUFFER_NV12_VIDEO_SW)
-                       media_format_set_video_mime(output_fmt, MEDIA_FORMAT_NV12);
-               else if (hmstreamrecorder->mode == MODE_LIVE_BUFFER_I420_VIDEO)
-                       media_format_set_video_mime(output_fmt, MEDIA_FORMAT_I420);
-
-               media_format_set_video_width(output_fmt, 1280);
-               media_format_set_video_height(output_fmt, 720);
-               media_format_set_video_frame_rate(output_fmt, 30);
+               if (hmstreamrecorder->mode == MODE_LIVE_BUFFER_NV12_VIDEO_SW) {
+                       ret = media_format_set_video_mime(output_fmt, MEDIA_FORMAT_NV12);
+                       if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                               g_print("media_format_set_video_mime failed (%d) \n", ret);
+                               goto error;
+                       }
+               } else if (hmstreamrecorder->mode == MODE_LIVE_BUFFER_I420_VIDEO) {
+                       ret = media_format_set_video_mime(output_fmt, MEDIA_FORMAT_I420);
+                       if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                               g_print("media_format_set_video_mime failed (%d) \n", ret);
+                               goto error;
+                       }
+               }
+               ret = media_format_set_video_width(output_fmt, DISPLAY_W);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_set_video_width failed (%d) \n", ret);
+                       goto error;
+               }
+               ret = media_format_set_video_height(output_fmt, DISPLAY_H);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_set_video_height failed (%d) \n", ret);
+                       goto error;
+               }
+               ret = media_format_set_video_frame_rate(output_fmt, SRC_VIDEO_FRAME_RATE_30);
+               if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_set_video_frame_rate failed (%d) \n", ret);
+                       goto error;
+               }
        } else {
                media_format_set_audio_mime(output_fmt, MEDIA_FORMAT_PCM);
                media_format_set_audio_channel(output_fmt, 1);
                media_format_set_audio_samplerate(output_fmt, 44100);
                /*media_format_set_audio_bit(core->output_fmt, info->bit);*/
        }
-       if (media_packet_create(output_fmt, NULL, NULL, &out_pkt)) {
-               g_print("create video media_packet failed\n");
-               return NULL;
+       ret = media_packet_create_alloc(output_fmt, NULL, NULL, &out_pkt);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print("create media_packet_create_alloc failed\n");
+               goto error;
        }
-       if (media_packet_alloc(out_pkt)) {
-               g_print("video media_packet alloc failed\n");
-               return NULL;
+
+       ret = media_packet_get_video_stride_width(out_pkt, 0, &stride_width);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print(" media_packet_get_video_stride_width failed\n");
+               goto error;
        }
-       media_packet_get_buffer_data_ptr(out_pkt, (void **)&pkt_data);
-       memcpy((char *)pkt_data, data, size);
-       if (media_packet_set_buffer_size(out_pkt, (uint64_t)(size))) {
-               g_print("video set_buffer_size failed\n");
-               return NULL;
+       ret = media_packet_get_video_stride_height(out_pkt, 0, &stride_height);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print(" media_packet_get_video_stride_height failed\n");
+               goto error;
        }
+       plane_size = stride_width * stride_height;
+       g_print("stride_width stride_height of plane index 0, plane_size [%d][%d][%zu]\n", stride_width, stride_height, plane_size);
+       ret = media_packet_get_video_plane_data_ptr(out_pkt, 0, &plane_ptr);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print(" media_packet_get_video_plane_data_ptr failed\n");
+               goto error;
+       }
+
+       memcpy(plane_ptr, data, DISPLAY_W * DISPLAY_H);
+       buffer_offset += DISPLAY_W * DISPLAY_H;
+
+       ret = media_packet_get_video_stride_width(out_pkt, 1, &stride_width);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print(" media_packet_get_video_stride_width failed\n");
+               goto error;
+       }
+       ret = media_packet_get_video_stride_height(out_pkt, 1, &stride_height);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print(" media_packet_get_video_stride_height failed\n");
+               goto error;
+       }
+       plane_size = stride_width * stride_height;
+       g_print("stride_width stride_height of plane index 1, plane_size [%d][%d][%zu]\n", stride_width, stride_height, plane_size);
+
+       ret = media_packet_get_video_plane_data_ptr(out_pkt, 1, &plane_ptr);
+       if (ret != MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_video_plane_data_ptr failed\n");
+               goto error;
+       }
+
+       memcpy(plane_ptr, data+buffer_offset, DISPLAY_W * DISPLAY_H / 2);
 
        return out_pkt;
+
+error:
+       if (out_pkt)
+               media_packet_destroy(out_pkt);
+       if (output_fmt)
+               media_format_unref(output_fmt);
+
+       return NULL;
 }
 
 static void _consume_completed_cb(void *buffer , void *user_data)
 {
        media_packet_h pkt = NULL;
        media_format_h fmt = NULL;
-       LOGD("_consume_completed_cb : Used mediapacket will be free");
+       g_print("_consume_completed_cb : Used mediapacket will be free\n");
 
        pkt = buffer;
        media_packet_get_format(pkt, &fmt);
@@ -281,11 +340,12 @@ static void _consume_completed_cb(void *buffer , void *user_data)
 
 void feed_video_es(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer data)
 {
+       g_print("%s \n", __func__);
        guint n;
        GstMemory *mem;
        GstMapInfo map = GST_MAP_INFO_INIT;
        media_packet_h out_pkt = NULL;
-
+       gboolean flag = FALSE;
        gst_buffer_ref(buffer);
 
        n = gst_buffer_n_memory(buffer);
@@ -296,7 +356,13 @@ void feed_video_es(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer
        }
        mem = gst_buffer_peek_memory(buffer, n-1);
 
-       gst_memory_map(mem, &map, GST_MAP_READ);
+       flag = gst_memory_map(mem, &map, GST_MAP_READ);
+
+       if (!flag)
+               g_print("gst_memory_map is failed.\n");
+       else
+               g_print("map.data.size [%d] map.data.maxsize [%d] map.data.data [%p] map.data.flag [%d]\n", map.size, map.maxsize, map.data, map.flags);
+
        out_pkt = streamrecorder_make_media_packet(1, map.data, map.size);
        gst_memory_unmap(mem, &map);
        gst_buffer_unref(buffer);
@@ -347,7 +413,7 @@ int __feed_buffer_test(MMHandleType handle, int mode)
                return FALSE;
        }
        if (mode == MODE_LIVE_BUFFER_NV12_VIDEO_SW) {
-       vconvert = gst_element_factory_make("videoconvert", NULL);
+               vconvert = gst_element_factory_make("videoconvert", NULL);
                if (!vconvert) {
                        g_print("convert element creation failed\n");
                        return FALSE;
@@ -359,16 +425,16 @@ int __feed_buffer_test(MMHandleType handle, int mode)
            return FALSE;
        }
        if (mode == MODE_LIVE_BUFFER_I420_VIDEO) {
-       caps = gst_caps_new_simple("video/x-raw",
-                               "format", G_TYPE_STRING, "I420",
-                               "width", G_TYPE_INT, 1280,
-                               "height", G_TYPE_INT, 720, NULL);
+               caps = gst_caps_new_simple("video/x-raw",
+                                       "format", G_TYPE_STRING, "I420",
+                                       "width", G_TYPE_INT, DISPLAY_W,
+                                       "height", G_TYPE_INT, DISPLAY_H, NULL);
        } else if (mode == MODE_LIVE_BUFFER_NV12_VIDEO_SW) {
-       caps = gst_caps_new_simple("video/x-raw",
-                               "format", G_TYPE_STRING, "NV12",
-                               "width", G_TYPE_INT, 1280,
-                               "height", G_TYPE_INT, 720,
-                               "framerate", GST_TYPE_FRACTION, 30, 1,  NULL);
+               caps = gst_caps_new_simple("video/x-raw",
+                                       "format", G_TYPE_STRING, "NV12",
+                                       "width", G_TYPE_INT, DISPLAY_W,
+                                       "height", G_TYPE_INT, DISPLAY_H,
+                                       "framerate", GST_TYPE_FRACTION, SRC_VIDEO_FRAME_RATE_30, 1,  NULL);
        }
        g_object_set(vcaps, "caps", caps, NULL);
        gst_caps_unref(caps);
@@ -452,9 +518,9 @@ static void main_menu(gchar buf)
                                err = __feed_buffer_test(hmstreamrecorder->recorder, hmstreamrecorder->mode);
                                if (err != MM_ERROR_NONE)
 
-                               g_print("Rec star in live buffer 0x%x", err);
+                               g_print("Rec star in live buffer 0x%x\n", err);
                                if (err == 0)
-                                   LOGE("Rec start live buffer 0x%x", err);
+                                   g_print("Rec start live buffer 0x%x\n", err);
 
                                recorder_state = STREAMRECORDER_STATE_RECORDING;
                        break;
@@ -476,7 +542,7 @@ static void main_menu(gchar buf)
                                        err = streamrecorder_pause(hmstreamrecorder->recorder);
 
                                        if (err < 0)
-                                               LOGE("Rec pause streamrecorder_pause  = %x", err);
+                                               g_print("Rec pause streamrecorder_pause  = %x\n", err);
 
                                        recorder_state = STREAMRECORDER_STATE_PAUSED;
                            }
@@ -486,7 +552,7 @@ static void main_menu(gchar buf)
                                        g_print("*Resume!\n");
                                        err = streamrecorder_start(hmstreamrecorder->recorder);
                                        if (err < 0)
-                                               LOGE("Rec start streamrecorder_record  = %x", err);
+                                               g_print("Rec start streamrecorder_record  = %x\n", err);
 
                                        recorder_state = STREAMRECORDER_STATE_RECORDING;
                            }
@@ -498,7 +564,7 @@ static void main_menu(gchar buf)
                                err = streamrecorder_cancel(hmstreamrecorder->recorder);
 
                                if (err < 0)
-                                   LOGE("Cancel recording streamrecorder_cancel  = %x", err);
+                                   g_print("Cancel recording streamrecorder_cancel  = %x\n", err);
 
                                recorder_state = STREAMRECORDER_STATE_NONE;
                                break;
@@ -510,7 +576,7 @@ static void main_menu(gchar buf)
                                err = streamrecorder_commit(hmstreamrecorder->recorder);
 
                                if (err < 0)
-                                   LOGE("Save recording streamrecorder_commit  = %x", err);
+                                   g_print("Save recording streamrecorder_commit  = %x\n", err);
 
                                recorder_state = STREAMRECORDER_STATE_NONE;
                                break;
@@ -520,7 +586,7 @@ static void main_menu(gchar buf)
                                break;
                        } /*switch*/
            } else {
-                       LOGE("Wrong streamrecorder state, check status!!");
+                       g_print("Wrong streamrecorder state, check status!!\n");
                }
        } else {
            g_print("\t Invalid mode, back to upper menu \n");
@@ -545,11 +611,11 @@ static gboolean cmd_input(GIOChannel *channel)
        gsize read_size;
        GError *g_error = NULL;
 
-       LOGD("ENTER");
+       g_print("ENTER\n");
 
        g_io_channel_read_line(channel, &buf, &read_size, NULL, &g_error);
        if (g_error) {
-           LOGD("g_io_channel_read_chars error");
+           g_print("g_io_channel_read_chars error\n");
            g_error_free(g_error);
            g_error = NULL;
        }
@@ -557,13 +623,13 @@ static gboolean cmd_input(GIOChannel *channel)
        if (buf) {
            g_strstrip(buf);
 
-           LOGD("Menu Status : %d", hmstreamrecorder->menu_state);
+           g_print("Menu Status : %d\n", hmstreamrecorder->menu_state);
            switch (hmstreamrecorder->menu_state) {
            case MENU_STATE_MAIN:
                        main_menu(buf[0]);
-               break;
+                       break;
            default:
-               break;
+                       break;
            }
 
            g_free(buf);
@@ -571,7 +637,7 @@ static gboolean cmd_input(GIOChannel *channel)
 
            print_menu();
        } else {
-           LOGD("No read input");
+           g_print("No read input\n");
        }
 
        return TRUE;
@@ -595,39 +661,39 @@ static gboolean init(int type)
                if (type == MODE_LIVE_BUFFER_I420_VIDEO) {
                        err = streamrecorder_set_video_source_format(hmstreamrecorder->recorder, STREAMRECORDER_VIDEO_SOURCE_FORMAT_I420);
                        if (err < 0) {
-                               LOGE("Init fail. (%x)", err);
+                               g_print("Init fail. (%x)\n", err);
                                goto ERROR;
                        }
                } else if (type == MODE_LIVE_BUFFER_NV12_VIDEO_SW) {
                        err = streamrecorder_set_video_source_format(hmstreamrecorder->recorder, STREAMRECORDER_VIDEO_SOURCE_FORMAT_NV12);
                        if (err < 0) {
-                               LOGE("Init fail. (%x)", err);
+                               g_print("Init fail. (%x)\n", err);
                                goto ERROR;
                        }
                }
            err = streamrecorder_set_file_format(hmstreamrecorder->recorder, STREAMRECORDER_FILE_FORMAT_MP4);
            if (err < 0) {
-                       LOGE("aInit fail. (%x)", err);
+                       g_print("aInit fail. (%x)\n", err);
                        goto ERROR;
            }
            err = streamrecorder_set_video_encoder(hmstreamrecorder->recorder, STREAMRECORDER_VIDEO_CODEC_MPEG4);
            if (err < 0) {
-                       LOGE("bInit fail. (%x)", err);
+                       g_print("bInit fail. (%x)\n", err);
                        goto ERROR;
            }
-           err = streamrecorder_set_video_resolution(hmstreamrecorder->recorder, 1280, 720);
+           err = streamrecorder_set_video_resolution(hmstreamrecorder->recorder, DISPLAY_W, DISPLAY_H);
            if (err < 0) {
-                       LOGE("dInit fail. (%x)", err);
+                       g_print("dInit fail. (%x)\n", err);
                        goto ERROR;
            }
-           err = streamrecorder_set_video_framerate(hmstreamrecorder->recorder, 30);
+           err = streamrecorder_set_video_framerate(hmstreamrecorder->recorder, SRC_VIDEO_FRAME_RATE_30);
            if (err < 0) {
-                       LOGE("dInit fail. (%x)", err);
+                       g_print("dInit fail. (%x)\n", err);
                        goto ERROR;
            }
            err = streamrecorder_set_filename(hmstreamrecorder->recorder, TARGET_FILENAME_VIDEO);
            if (err < 0) {
-                       LOGE("dInit fail. (%x)", err);
+                       g_print("dInit fail. (%x)\n", err);
                        goto ERROR;
                }
        }
@@ -635,12 +701,12 @@ static gboolean init(int type)
        streamrecorder_set_recording_status_cb(hmstreamrecorder->recorder, _recording_status_cb, NULL);
        streamrecorder_set_recording_limit_reached_cb(hmstreamrecorder->recorder, _recording_limit_reached_cb, &ischeck);
 
-       LOGD("Init DONE.");
+       g_print("Init DONE.\n");
 
        return TRUE;
 
 ERROR:
-       LOGE("init failed.");
+       g_print("init failed.\n");
        return FALSE;
 }
 
@@ -670,34 +736,37 @@ static gboolean mode_change()
        char media_type = '\0';
        bool check = FALSE;
 
+       GDateTime *previous;
+       GDateTime *current;
+
        err = streamrecorder_get_state(hmstreamrecorder->recorder, (streamrecorder_state_e *)&state);
        if (state != STREAMRECORDER_STATE_NONE) {
            if ((state == STREAMRECORDER_STATE_RECORDING) || (state == STREAMRECORDER_STATE_PAUSED)) {
-                   LOGD("streamrecorder_cancel");
+                   g_print("streamrecorder_cancel\n");
                    err = streamrecorder_cancel(hmstreamrecorder->recorder);
 
                    if (err < 0) {
-                           LOGE("exit streamrecorder_cancel  = %x", err);
+                           g_print("exit streamrecorder_cancel  = %x\n", err);
                            return FALSE;
                    }
            }
 
                err = streamrecorder_get_state(hmstreamrecorder->recorder, (streamrecorder_state_e *)&state);
                if (state == STREAMRECORDER_STATE_PREPARED) {
-                   LOGD("streamrecorder_destroy");
+                   g_print("streamrecorder_destroy\n");
                    streamrecorder_unprepare(hmstreamrecorder->recorder);
                }
 
                err = streamrecorder_get_state(hmstreamrecorder->recorder, (streamrecorder_state_e *)&state);
                if (state == STREAMRECORDER_STATE_CREATED) {
-                   LOGD("streamrecorder_destroy");
+                   g_print("streamrecorder_destroy\n");
                    streamrecorder_destroy(hmstreamrecorder->recorder);
                }
        }
 
        init_handle();
        streamrecorder_create(&hmstreamrecorder->recorder);
-       g_get_current_time(&previous);
+       previous = g_date_time_new_now_local();
        g_timer_reset(timer);
        while (!check) {
                g_print("\n\t=======================================\n");
@@ -744,7 +813,7 @@ static gboolean mode_change()
 
        if (!init(hmstreamrecorder->mode)) {
                g_print("hmstreamrecorder->mode = %d\n", hmstreamrecorder->mode);
-               LOGE("testsuite init() failed.");
+               g_print("testsuite init() failed.\n");
                return -1;
        }
 
@@ -753,16 +822,18 @@ static gboolean mode_change()
        g_timer_reset(timer);
 
        err = streamrecorder_prepare(hmstreamrecorder->recorder);
-       LOGD("streamrecorder_start()  : %12.6lfs", g_timer_elapsed(timer, NULL));
+       g_print("streamrecorder_start()  : %12.6lfs\n", g_timer_elapsed(timer, NULL));
 
        if (err != 0) {
-               LOGE("streamrecorder_prepare  = %x", err);
+               g_print("streamrecorder_prepare  = %x\n", err);
                return -1;
        }
+       current = g_date_time_new_now_local();
+
+       g_print("Streamrecorder Starting Time  : [%lf]\n", g_date_time_get_seconds(current) - g_date_time_get_seconds(previous));
 
-       g_get_current_time(&current);
-       timersub(&current, &previous, &result);
-       LOGD("Streamrecorder Starting Time  : %ld.%lds", result.tv_sec, result.tv_usec);
+       g_date_time_unref(previous);
+       g_date_time_unref(current);
 
        return TRUE;
 }
@@ -785,7 +856,7 @@ int main(int argc, char **argv)
 
        gst_init(&argc, &argv);
 
-       LOGD("gst_init() : %12.6lfs", g_timer_elapsed(timer, NULL));
+       g_print("gst_init() : %12.6lfs\n", g_timer_elapsed(timer, NULL));
 
        hmstreamrecorder = (mstreamrecorder_handle_t *) g_malloc0(sizeof(mstreamrecorder_handle_t));
 
@@ -804,11 +875,11 @@ int main(int argc, char **argv)
        stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
        g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
 
-       LOGD("RUN main loop");
+       g_print("RUN main loop\n");
 
        g_main_loop_run(g_loop);
 
-       LOGD("STOP main loop");
+       g_print("STOP main loop\n");
 
        if (timer) {
                g_timer_stop(timer);