camera_test: Replace g_print() by dlog macro 90/287690/2 accepted/tizen/unified/20230207.165815
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 2 Feb 2023 08:12:07 +0000 (17:12 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 2 Feb 2023 10:48:42 +0000 (19:48 +0900)
- It's replaced in only preview callback related functions.

[Version] 0.4.99
[Issue Type] Log

Change-Id: Iee826252bee40967e4c7cd6ce2fabb29e36fff4a
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-camera.spec
test/CMakeLists.txt
test/camera_test.c

index ba29c34..cc873fe 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.98
+Version:    0.4.99
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 807a61d..f86c5de 100644 (file)
@@ -9,7 +9,7 @@ SET(COMMON_SRC_NAME "camera_test.c")
 SET(fw_test_headed "${fw_test}-headed")
 
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(${fw_test_headed} REQUIRED elementary evas appcore-efl libtbm)
+PKG_CHECK_MODULES(${fw_test_headed} REQUIRED elementary evas appcore-efl libtbm dlog)
 FOREACH(flag ${${fw_test_headed}_CFLAGS})
     SET(EXTRA_CFLAGS_HEADED "${EXTRA_CFLAGS_HEADED} ${flag}")
     MESSAGE(${flag})
index bca41fe..bf60c7a 100644 (file)
 -----------------------------------------------------------------------*/
 #define EXPORT_API __attribute__((__visibility__("default")))
 
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAMERA_TEST"
+
+
 static cam_handle_t *hcamcorder;
 static camera_device_e camera_device;
 static int g_camera_device_state_changed_cb_id;
@@ -42,24 +48,6 @@ static struct timeval current_time;
 static struct timeval result_time;
 
 static media_bridge_h bridge;
-
-/*-----------------------------------------------------------------------
-|    GLOBAL CONSTANT DEFINITIONS:                                       |
------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------
-|    IMPORTED VARIABLE DECLARATIONS:                                    |
------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------
-|    IMPORTED FUNCTION DECLARATIONS:                                    |
------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-  |    LOCAL VARIABLE DEFINITIONS:                                            |
-  ---------------------------------------------------------------------------*/
 static camera_device_manager_h g_device_manager;
 
 const char *wb[SENSOR_WHITEBALANCE_NUM] = {
@@ -374,7 +362,7 @@ static void _dump_preview_data(camera_preview_data_s *frame, const char *file_na
        FILE *fp = NULL;
 
        if (!frame) {
-               g_print("\n[DUMP_PREVIEW_DATA] NULL frame\n");
+               LOGE("NULL frame");
                return;
        }
 
@@ -382,7 +370,7 @@ static void _dump_preview_data(camera_preview_data_s *frame, const char *file_na
 
        fp = fopen(dump_path, "a");
        if (fp == NULL) {
-               g_print("\n[DUMP_PREVIEW_DATA] file[%s] open failed\n", dump_path);
+               LOGE("file[%s] open failed", dump_path);
                return;
        }
 
@@ -390,9 +378,11 @@ static void _dump_preview_data(camera_preview_data_s *frame, const char *file_na
        case CAMERA_PIXEL_FORMAT_RGBA:
                /* fall through */
        case CAMERA_PIXEL_FORMAT_ARGB:
+               LOGD("RGB p[%p] size[%u]", frame->data.rgb_plane.data, frame->data.rgb_plane.size);
                fwrite(frame->data.rgb_plane.data, 1, frame->data.rgb_plane.size, fp);
                break;
        case CAMERA_PIXEL_FORMAT_INVZ:
+               LOGD("INVZ p[%p] size[%u]", frame->data.depth_plane.data, frame->data.depth_plane.size);
                fwrite(frame->data.depth_plane.data, 1, frame->data.depth_plane.size, fp);
                break;
        case CAMERA_PIXEL_FORMAT_H264:
@@ -402,18 +392,28 @@ static void _dump_preview_data(camera_preview_data_s *frame, const char *file_na
        case CAMERA_PIXEL_FORMAT_VP8:
                /* fall through */
        case CAMERA_PIXEL_FORMAT_VP9:
+               LOGD("ENCODED[%d] p[%p] size[%u]",
+                       frame->format, frame->data.encoded_plane.data, frame->data.encoded_plane.size);
                fwrite(frame->data.encoded_plane.data, 1, frame->data.encoded_plane.size, fp);
                break;
        default:
                switch (frame->num_of_planes) {
                case 1:
+                       LOGD("SINGLE plane p[%p], size[%u]",
+                               frame->data.single_plane.yuv, frame->data.single_plane.size);
                        fwrite(frame->data.single_plane.yuv, 1, frame->data.single_plane.size, fp);
                        break;
                case 2:
+                       LOGD("DOUBLE plane p[%p,%p], size[%u,%u]",
+                               frame->data.double_plane.y, frame->data.double_plane.uv,
+                               frame->data.double_plane.y_size, frame->data.double_plane.uv_size);
                        fwrite(frame->data.double_plane.y, 1, frame->data.double_plane.y_size, fp);
                        fwrite(frame->data.double_plane.uv, 1, frame->data.double_plane.uv_size, fp);
                        break;
                case 3:
+                       LOGD("TRIPLE plane p[%p,%p,%p], size[%u,%u,%u]",
+                               frame->data.triple_plane.y, frame->data.triple_plane.u, frame->data.triple_plane.v,
+                               frame->data.triple_plane.y_size, frame->data.triple_plane.u_size, frame->data.triple_plane.v_size);
                        fwrite(frame->data.triple_plane.y, 1, frame->data.triple_plane.y_size, fp);
                        fwrite(frame->data.triple_plane.u, 1, frame->data.triple_plane.u_size, fp);
                        fwrite(frame->data.triple_plane.v, 1, frame->data.triple_plane.v_size, fp);
@@ -424,30 +424,33 @@ static void _dump_preview_data(camera_preview_data_s *frame, const char *file_na
                break;
        }
 
-       g_print("[DUMP_PREVIEW_DATA] file[%s] write done\n", dump_path);
-
        fclose(fp);
 }
 
-static void _camera_print_preview_info(camera_preview_data_s *frame)
+static void _camera_print_preview_info(camera_preview_data_s *frame, int stream_id)
 {
+       char frame_info[128] = {'\0', };
+
        if (!frame) {
-               g_print("\n[PREVIEW_CB] NULL frame!\n");
+               LOGE("[PREVIEW_CB] NULL frame!");
                return;
        }
 
-       g_print("format[%d] res[%dx%d] num plane[%d] ",
-               frame->format, frame->width, frame->height, frame->num_of_planes);
+       snprintf(frame_info, sizeof(frame_info), "stream_id[%d] format[%d] res[%dx%d] num plane[%d]",
+               stream_id, frame->format, frame->width, frame->height, frame->num_of_planes);
 
        if (frame->num_of_planes == 1) {
-               g_print("size [%d]\n",
+               LOGD("%s size [%d]",
+                       frame_info,
                        frame->data.single_plane.size);
        } else if (frame->num_of_planes == 2) {
-               g_print("size Y[%d] UV[%d]\n",
+               LOGD("%s size Y[%d] UV[%d]",
+                       frame_info,
                        frame->data.double_plane.y_size,
                        frame->data.double_plane.uv_size);
        } else if (frame->num_of_planes == 3) {
-               g_print("size Y[%d] U[%d] V[%d]\n",
+               LOGD("%s size Y[%d] U[%d] V[%d]",
+                       frame_info,
                        frame->data.triple_plane.y_size,
                        frame->data.triple_plane.u_size,
                        frame->data.triple_plane.v_size);
@@ -462,22 +465,21 @@ static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
        unsigned long timestamp = 0;
 
        if (!cam_handle || !frame) {
-               g_print("\n[PREVIEW_CB] NULL param! %p %p\n", cam_handle, frame);
+               LOGE("NULL param! %p %p", cam_handle, frame);
                return;
        }
 
        ret = camera_attr_get_preview_frame_rotation(cam_handle, &rotation);
        if (ret != CAMERA_ERROR_NONE)
-               g_print("[PREVIEW_CB] get preview frame rotation failed[0x%x]\n", ret);
+               LOGW("get preview frame rotation failed[0x%x]", ret);
 
        ret = camera_attr_get_preview_frame_timestamp(cam_handle, &timestamp);
        if (ret != CAMERA_ERROR_NONE)
-               g_print("[PREVIEW_CB] get preview frame timestamp failed[0x%x]\n", ret);
+               LOGW("get preview frame timestamp failed[0x%x]", ret);
 
-       g_print("[PREVIEW_CB] preview[rotation:%d,timestamp:%lu] callback\n",
-               rotation, timestamp);
+       LOGI("rotation[%d], timestamp[%lu]", rotation, timestamp);
 
-       _camera_print_preview_info(frame);
+       _camera_print_preview_info(frame, -1);
 
        if (g_camera_preview_cb_dump)
                _dump_preview_data(frame, PREVIEW_CB_DUMP_FILE_NAME);
@@ -486,13 +488,11 @@ static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
 static void _camera_extra_preview_cb(camera_preview_data_s *frame, int stream_id, void *user_data)
 {
        if (!frame) {
-               g_print("\n[PREVIEW_CB] NULL frame!\n");
+               LOGE("NULL frame!");
                return;
        }
 
-       g_print("[EXTRA_PREVIEW_CB][stream_id:%d] preview callback - ", stream_id);
-
-       _camera_print_preview_info(frame);
+       _camera_print_preview_info(frame, stream_id);
 
        if (g_camera_extra_preview_cb_dump)
                _dump_preview_data(frame, EXTRA_PREVIEW_CB_DUMP_FILE_NAME);
@@ -511,58 +511,58 @@ static void _dump_media_packet_data(media_packet_h pkt, const char *file_name)
        uint64_t data_size = 0;
 
        if (!pkt) {
-               g_print("\n[DUMP_MEDIA_PACKET_DATA] NULL packet\n");
+               LOGE("NULL packet");
                return;
        }
 
        snprintf(dump_path, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, file_name);
        fp = fopen(dump_path, "a");
        if (fp == NULL) {
-               g_print("\n[DUMP_MEDIA_PACKET_DATA] file[%s] open failed ====\n", dump_path);
+               LOGE("file[%s] open failed[errno:%d]", dump_path, errno);
                goto _DUMP_MEDIA_PACKET_DATA_OUT;
        }
 
        ret = media_packet_has_tbm_surface_buffer(pkt, &has_surface);
        if (ret != MEDIA_PACKET_ERROR_NONE) {
-               g_print("\n[DUMP_MEDIA_PACKET_DATA] has tbm surface failed[0x%x] ====\n", ret);
+               LOGE("has tbm surface failed[0x%x]", ret);
                goto _DUMP_MEDIA_PACKET_DATA_OUT;
        }
 
        if (has_surface) {
                ret = media_packet_get_tbm_surface(pkt, &surface);
                if (ret != MEDIA_PACKET_ERROR_NONE) {
-                       g_print("\n[DUMP_MEDIA_PACKET_DATA] get tbm surface failed[0x%x] ====\n", ret);
+                       LOGE("get tbm surface failed[0x%x]", ret);
                        goto _DUMP_MEDIA_PACKET_DATA_OUT;
                }
 
                ret = tbm_surface_get_info(surface, &s_info);
                if (ret != TBM_SURFACE_ERROR_NONE) {
-                       g_print("\n[DUMP_MEDIA_PACKET_DATA] get tbm surface info failed[0x%x] ====\n", ret);
+                       LOGE("get tbm surface info failed[0x%x]", ret);
                        goto _DUMP_MEDIA_PACKET_DATA_OUT;
                }
 
-               g_print("    tbm surface [%dx%d], total size[%u]\n",
-                       s_info.width, s_info.height, s_info.size);
+               LOGD("tbm surface[%dx%d], size[%u]", s_info.width, s_info.height, s_info.size);
 
                for (i = 0 ; i < s_info.num_planes ; i++) {
-                       g_print("        plane[%d][%p] stride[%u] size[%u]\n",
+                       LOGD("  plane[%d][%p] stride[%u] size[%u]",
                                i, s_info.planes[i].ptr, s_info.planes[i].stride, s_info.planes[i].size);
+
                        fwrite(s_info.planes[i].ptr, 1, s_info.planes[i].size, fp);
                }
        } else {
                ret = media_packet_get_buffer_data_ptr(pkt, &data);
                if (ret != MEDIA_PACKET_ERROR_NONE) {
-                       g_print("\n[DUMP_MEDIA_PACKET_DATA] get data ptr failed[0x%x] ====\n", ret);
+                       LOGE("get data ptr failed[0x%x]", ret);
                        goto _DUMP_MEDIA_PACKET_DATA_OUT;
                }
 
                ret = media_packet_get_buffer_size(pkt, &data_size);
                if (ret != MEDIA_PACKET_ERROR_NONE) {
-                       g_print("\n[DUMP_MEDIA_PACKET_DATA] get data size failed[0x%x] ====\n", ret);
+                       LOGE("get data size failed[0x%x]", ret);
                        goto _DUMP_MEDIA_PACKET_DATA_OUT;
                }
 
-               g_print("    no tbm surface, data[%p], size[%"PRIu64"]\n", data, data_size);
+               LOGD("no tbm surface, data[%p], size[%"PRIu64"]", data, data_size);
 
                fwrite(data, 1, data_size, fp);
        }
@@ -581,23 +581,23 @@ static void _camera_media_packet_preview_cb(media_packet_h pkt, void *user_data)
        media_format_mimetype_e type = MEDIA_FORMAT_I420;
 
        if (!pkt) {
-               g_print("\n[MP_PREVIEW_CB] NULL packet!\n");
+               LOGE("NULL packet!");
                return;
        }
 
        ret = media_packet_get_format(pkt, &fmt);
        if (ret != MEDIA_PACKET_ERROR_NONE) {
-               g_print("\n[MP_PREVIEW_CB] get media format failed[0x%x]", ret);
+               LOGW("get media format failed[0x%x]", ret);
                goto _MEDIA_PACKET_PREVIEW_CB_OUT;
        }
 
        ret = media_format_get_video_info(fmt, &type, &width, &height, NULL, NULL);
        if (ret != MEDIA_FORMAT_ERROR_NONE) {
-               g_print("\n[MP_PREVIEW_CB] get video info failed[0x%x]", ret);
+               LOGW("get video info failed[0x%x]", ret);
                goto _MEDIA_PACKET_PREVIEW_CB_OUT;
        }
 
-       g_print("[MP_PREVIEW_CB] media_packet_preview_cb[mimetype:0x%x, %dx%d]\n", type, width, height);
+       LOGD("mimetype[0x%x], resolution[%dx%d]", type, width, height);
 
        if (g_camera_mp_preview_cb_dump)
                _dump_media_packet_data(pkt, MP_PREVIEW_CB_DUMP_FILE_NAME);