Fix vision-source API 65/300265/2
authorKwanghoon Son <k.son@samsung.com>
Thu, 19 Oct 2023 10:18:16 +0000 (19:18 +0900)
committerKwanghoon Son <k.son@samsung.com>
Tue, 24 Oct 2023 06:44:35 +0000 (15:44 +0900)
[Version] 0.28.19

Change-Id: I56a7582af5009149f796f48c00b15e2b075518d1
Link: https://review.tizen.org/gerrit/c/platform/core/multimedia/vision-source/+/299618
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
packaging/capi-media-vision.spec
test/testsuites/mv3d/depthstream_test_suite.cpp

index 80a4c02..8da3d41 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.28.18
+Version:     0.28.19
 Release:     1
 Group:       Multimedia/Framework
 License:     Apache-2.0
index 3ab83b1..90befae 100644 (file)
@@ -53,6 +53,7 @@ using namespace open3d;
 #endif
 
 #define VISION_SOURCE_DEVICE_ID 3
+#define VISION_SOURCE_CAPS_ID 0
 #define __max(a, b) (((a) > (b)) ? (a) : (b))
 #define __min(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -202,22 +203,18 @@ static int _vision_source_cb(media_packet_h packet, void *user_data)
        printf("_vision_source_cb: %lld ms\n", static_cast<long long int>(app->stopWatch.elapsedTime().count()));
 
        char *plane_data_ptr;
-       int stride_w, height, width;
+       int height, width;
        media_format_h fmt;
        media_packet_get_format(packet, &fmt);
        media_format_get_video_info(fmt, nullptr, &width, &height, nullptr, nullptr);
        media_format_unref(fmt);
 
-       media_packet_get_video_stride_width(packet, 0, &stride_w);
-       media_packet_get_video_plane_data_ptr(packet, 0, (void **) (&plane_data_ptr));
+       media_packet_get_buffer_data_ptr(packet, (void **) (&plane_data_ptr));
 
-       for (int h = 0; h < height; h++) {
-               memcpy(app->buffer + width * h, plane_data_ptr + stride_w * h, width);
-       }
+       memcpy(app->buffer, plane_data_ptr, width * height);
 
        mv_source_fill_by_buffer(app->mv_source, app->buffer, app->imgWidth * app->imgHeight, app->imgWidth, app->imgHeight,
                                                         MEDIA_VISION_COLORSPACE_Y800);
-       media_packet_unref(packet);
 
        if (isAsync)
                mv_3d_run_async(app->mv3d_handle, app->mv_source, nullptr, nullptr);
@@ -263,13 +260,6 @@ int main(int argc, char *argv[])
        int ret = MEDIA_VISION_ERROR_NONE;
        printf("enter main\n");
 
-       vision_source_format_s format { .pixel_format = VISION_SOURCE_PIXEL_FORMAT_NV12,
-                                                                       .resolution = { static_cast<unsigned int>(camWidth << 1),
-                                                                                                       static_cast<unsigned int>(camHeight) },
-                                                                       .fps = 10,
-                                                                       .quality = 0,
-                                                                       .bitrate = 0 };
-
        // mediavision
        // engine_config
        ret = mv_create_engine_config(&engine_config);
@@ -350,24 +340,41 @@ int main(int argc, char *argv[])
                goto _err;
        }
 
-       // vision-source
        ret = vision_source_init(&vision_source_handle);
        if (ret != VISION_SOURCE_ERROR_NONE) {
                goto _err;
        }
 
+       const vision_source_device_info_s *dev_list;
+       int dev_cnt;
+
+       ret = vision_source_list_devices(vision_source_handle, &dev_list, &dev_cnt);
+       if (ret != VISION_SOURCE_ERROR_NONE) {
+               goto _err;
+       }
+
        ret = vision_source_open_device(vision_source_handle, VISION_SOURCE_DEVICE_ID);
        if (ret != VISION_SOURCE_ERROR_NONE) {
                goto _err;
        }
 
+       const media_format_h *fmt_list;
+       int fmt_count;
+
+       ret = vision_source_list_device_caps(vision_source_handle, VISION_SOURCE_CAPS_ID, &fmt_list, &fmt_count);
+       if (ret != VISION_SOURCE_ERROR_NONE) {
+               goto _err;
+       }
+
        loop = g_main_loop_new(NULL, false);
-       ret = vision_source_set_stream_format(vision_source_handle, &format);
+
+       ret = vision_source_set_stream_format(vision_source_handle, fmt_list[VISION_SOURCE_CAPS_ID]);
        if (ret != VISION_SOURCE_ERROR_NONE) {
                goto _err;
        }
 
-       vision_source_start_stream(vision_source_handle, _vision_source_cb, &app);
+       vision_source_set_stream_cb(vision_source_handle, _vision_source_cb, &app);
+       vision_source_start_stream(vision_source_handle);
        printf("starting...\n");
        g_main_loop_run(loop);
        printf("stop\n");