Delete mv_source_fill_by_buffer_da 48/291048/5 accepted/tizen/7.0/unified/20230412.153443
authorKwanghoon Son <k.son@samsung.com>
Fri, 7 Apr 2023 02:41:48 +0000 (11:41 +0900)
committerKwanghoon Son <k.son@samsung.com>
Mon, 10 Apr 2023 04:56:45 +0000 (13:56 +0900)
It replaced with fill_by_media_packet.
timestamp data can be used with {get/set}_timstamp function.

Change-Id: I5de0042e7b9473337960e5c65b3b29ee750f423b
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
include/mv_common_internal.h
mv_3d/3d/src/Mv3d.cpp
mv_common/include/MediaSource.h
mv_common/include/mv_common_c.h
mv_common/src/MediaSource.cpp
mv_common/src/mv_common.c
mv_common/src/mv_common_c.cpp
test/testsuites/common/test_common.cpp
test/testsuites/mv3d/depthstream_test_suite.cpp

index 661d61805f3e0366035ac2b155af9d30cf59f741..c84554c21c0d5c81033371f689c2a9850fd2de30 100644 (file)
@@ -40,9 +40,7 @@ typedef struct {
 } da_timestamp_s;
 
 int mv_source_get_timestamp(mv_source_h source, da_timestamp_s *stamp);
-int mv_source_fill_by_buffer_da(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
-                                                               unsigned int image_width, unsigned int image_height, unsigned int stride,
-                                                               mv_colorspace_e image_colorspace, da_timestamp_s *stamp);
+int mv_source_set_timestamp(mv_source_h source, da_timestamp_s *stamp);
 
 #endif
 
index aa6796f9b0348e83708226aa214efa56c710c04e..04897bd310534c7dc7e089349b588f189af3bb37 100644 (file)
@@ -430,17 +430,14 @@ gpointer Mv3d::DfsThreadLoop(gpointer data)
 
                auto depthData = handle->mDfsAdaptor->getOutputData();
                auto leftData = handle->mDfsAdaptor->getLeftData();
-#ifdef WITH_DA_PROFILE
-               int ret = mv_source_fill_by_buffer_da(
-                               handle->mInternalSource, static_cast<unsigned char *>(leftData.data), leftData.stride * leftData.height,
-                               leftData.width, leftData.height, leftData.stride,
-                               leftData.type == DFS_DATA_TYPE_UINT8C3 ? MEDIA_VISION_COLORSPACE_RGB888 : MEDIA_VISION_COLORSPACE_Y800,
-                               static_cast<da_timestamp_s *>(pInput->timestamp));
-#else
+
                int ret = mv_source_fill_by_buffer(handle->mInternalSource, static_cast<unsigned char *>(leftData.data),
                                                                                   leftData.stride * leftData.height, leftData.width, leftData.height,
                                                                                   leftData.type == DFS_DATA_TYPE_UINT8C3 ? MEDIA_VISION_COLORSPACE_RGB888 :
                                                                                                                                                                        MEDIA_VISION_COLORSPACE_Y800);
+#ifdef WITH_DA_PROFILE
+               ret = mv_source_set_timestamp(handle->mInternalSource, static_cast<da_timestamp_s *>(pInput->timestamp));
+
 #endif
                if (MEDIA_VISION_ERROR_NONE != ret) {
                        LOGW("Errors were occurred during source filling %i", ret);
index 362010d65952599cbe533bc1b43bf1f9d3b1dfb8..7d1f4a3fb4e89f158eada259becfa84f45547f7f 100644 (file)
@@ -103,8 +103,7 @@ public:
 
 #ifdef WITH_DA_PROFILE
        da_timestamp_s getTimeStamp();
-       bool fill(const unsigned char *buffer, unsigned int bufferSize, unsigned int width, unsigned int height,
-                         unsigned int stride, mv_colorspace_e colorspace, da_timestamp_s &stamp);
+       void setTimeStamp(da_timestamp_s &stamp);
 #endif
 
        /**
index dc1876992d9e66ddfbd87be1dd178b0c694d1dff..94a3e602617bec83ddd95ef8d107c37295ea882c 100644 (file)
@@ -102,10 +102,7 @@ int mv_source_fill_by_buffer_c(mv_source_h source, unsigned char *data_buffer, u
 
 #ifdef WITH_DA_PROFILE
 int mv_source_get_timestamp_c(mv_source_h source, da_timestamp_s *stamp);
-
-int mv_source_fill_by_buffer_da_c(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
-                                                                 unsigned int image_width, unsigned int image_height, unsigned int stride,
-                                                                 mv_colorspace_e image_colorspace, da_timestamp_s *stamp);
+int mv_source_set_timestamp_c(mv_source_h source, da_timestamp_s *stamp);
 #endif
 
 /**
index b902cd847ea2e9e0ae0005cfef7cc5cea164f66e..dd20c07221ea66f299a3c9ab3f173570aefccbb2 100644 (file)
@@ -172,59 +172,11 @@ da_timestamp_s MediaSource::getTimeStamp()
 {
        return _stamp;
 }
-
-bool MediaSource::fill(const unsigned char *buffer, unsigned int bufferSize, unsigned int width, unsigned int height,
-                                          unsigned int stride, mv_colorspace_e colorspace, da_timestamp_s &stamp)
+void MediaSource::setTimeStamp(da_timestamp_s &stamp)
 {
-       if (!buffer || bufferSize == 0)
-               return false;
-
-       LOGD("Call clear() first for media source %p", this);
-       clear();
-
-       Plane plane;
-       auto &pBuffer = plane.buffer;
-       auto &pImageSize = plane.imageSize;
-
-       LOGD("Allocate memory [%i] for buffer in media source %p", bufferSize, this);
-       LOGD("Assign new size (%ui x %ui) of the internal buffer image for "
-                "the media source %p",
-                width, height, this);
-       LOGD("Assign new colorspace (%i) of the internal buffer image for "
-                "the media source %p",
-                colorspace, this);
-       pBuffer = new (std::nothrow) unsigned char[bufferSize];
-       if (pBuffer == NULL) {
-               LOGE("Memory allocating for buffer in media source %p failed!", this);
-               return false;
-       }
-
-       LOGD("Copy data from external buffer (%p) to the internal buffer (%p) of "
-                "media source %p",
-                buffer, pBuffer, this);
-       for (unsigned h = 0; h < height; h++) {
-               std::memcpy(pBuffer + (width * h), buffer + (stride * h), width);
-       }
-
-       LOGD("Assign new size of the internal buffer of media source %p. "
-                "New size is %ui.",
-                this, bufferSize);
-       pImageSize = bufferSize;
-
-       LOGD("Assign new size (%ui x %ui) of the internal buffer image for "
-                "the media source %p",
-                width, height, this);
-       _width = width;
-       _height = height;
-
-       LOGD("Assign new colorspace (%i) of the internal buffer image for "
-                "the media source %p",
-                colorspace, this);
-       _colorspace = colorspace;
        _stamp = stamp;
-
-       return true;
 }
+
 #endif
 
 unsigned char *MediaSource::getBuffer(void) const
index 6b7d528a44cb533d29e43d75c234cdd1d4c78d80..163ce9f8f550b27ebab00816e173f4d6a4b7b753 100644 (file)
@@ -83,18 +83,13 @@ int mv_source_get_timestamp(mv_source_h source, da_timestamp_s *stamp)
        return ret;
 }
 
-int mv_source_fill_by_buffer_da(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
-                                                               unsigned int image_width, unsigned int image_height, unsigned int stride,
-                                                               mv_colorspace_e image_colorspace, da_timestamp_s *stamp)
+int mv_source_set_timestamp(mv_source_h source, da_timestamp_s *stamp)
 {
        MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
        MEDIA_VISION_INSTANCE_CHECK(source);
-       MEDIA_VISION_NULL_ARG_CHECK(data_buffer);
        MEDIA_VISION_INSTANCE_CHECK(stamp);
-
        MEDIA_VISION_FUNCTION_ENTER();
-       int ret = mv_source_fill_by_buffer_da_c(source, data_buffer, buffer_size, image_width, image_height, stride,
-                                                                                       image_colorspace, stamp);
+       int ret = mv_source_set_timestamp_c(source, stamp);
        MEDIA_VISION_FUNCTION_LEAVE();
 
        return ret;
index 3d6a2fd549598006e21dfeea7e28c2be55fd278a..22e5daefe2618ef569e79145c556c9907d1d3c1b 100644 (file)
@@ -220,7 +220,7 @@ int mv_source_fill_by_buffer_c(mv_source_h source, unsigned char *data_buffer, u
 int mv_source_get_timestamp_c(mv_source_h source, da_timestamp_s *stamp)
 {
        try {
-               MediaVision::Common::MediaSource *mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+               auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
                *stamp = mediaSource->getTimeStamp();
        } catch (const std::exception &e) {
                LOGE("%s", e.what());
@@ -228,25 +228,15 @@ int mv_source_get_timestamp_c(mv_source_h source, da_timestamp_s *stamp)
        }
        return MEDIA_VISION_ERROR_NONE;
 }
-int mv_source_fill_by_buffer_da_c(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
-                                                                 unsigned int image_width, unsigned int image_height, unsigned int stride,
-                                                                 mv_colorspace_e image_colorspace, da_timestamp_s *stamp)
+int mv_source_set_timestamp_c(mv_source_h source, da_timestamp_s *stamp)
 {
-       if (!source || buffer_size == 0 || data_buffer == NULL) {
-               LOGE("Media source can't be filled by buffer because "
-                        "one of the source or data_buffer is NULL or buffer_size = 0. "
-                        "source = %p; data_buffer = %p; buffer_size = %u",
-                        source, data_buffer, buffer_size);
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!(static_cast<MediaVision::Common::MediaSource *>(source))
-                                ->fill(data_buffer, buffer_size, image_width, image_height, stride, image_colorspace, *stamp)) {
-               LOGE("mv_source_h filling from buffer failed");
-               return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+       try {
+               auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+               mediaSource->setTimeStamp(*stamp);
+       } catch (const std::exception &e) {
+               LOGE("%s", e.what());
+               return MEDIA_VISION_ERROR_INTERNAL;
        }
-
-       LOGD("Media source has been filled from buffer");
        return MEDIA_VISION_ERROR_NONE;
 }
 #endif
index afd99ccf5a9db1472bc2acad3f189b3232cbdc22..785cdc427434a2b7887919c9a1c96d27dfe7d426 100644 (file)
 TEST(Common_DA, Simple)
 {
        mv_source_h mv_source;
-       unsigned char fake_data[10];
-       da_timestamp_s fake_stamp;
+       da_timestamp_s fake_stamp { 1, 2, 3, 4, 5 };
 
        ASSERT_EQ(mv_create_source(&mv_source), VISION_SOURCE_ERROR_NONE);
-       ASSERT_EQ(mv_source_fill_by_buffer_da(mv_source, fake_data, 6, 3, 2, 5, MEDIA_VISION_COLORSPACE_Y800, &fake_stamp),
-                         VISION_SOURCE_ERROR_NONE);
+       EXPECT_EQ(mv_source_set_timestamp(mv_source, nullptr), MEDIA_VISION_ERROR_INVALID_PARAMETER);
+       EXPECT_EQ(mv_source_set_timestamp(mv_source, &fake_stamp), VISION_SOURCE_ERROR_NONE);
+       fake_stamp.timestamp = -1;
+       EXPECT_EQ(mv_source_get_timestamp(mv_source, &fake_stamp), VISION_SOURCE_ERROR_NONE);
+       EXPECT_EQ(fake_stamp.timestamp, 1);
        ASSERT_EQ(mv_destroy_source(mv_source), VISION_SOURCE_ERROR_NONE);
-}
-
-static int nv12_test_cb(vision_source_buffer_s *buffer, void *user_data)
-{
-       clock_t end = clock();
-       clock_t *start = (clock_t *) user_data;
-
-       double delta_ms = (double) (end - *start) / CLOCKS_PER_SEC * 1000;
-
-       std::cout << "delta_ms :" << delta_ms << std::endl;
-
-       mv_source_h mv_source;
-       mv_create_source(&mv_source);
-       da_timestamp_s *fake_stamp = (da_timestamp_s *) buffer->priv;
-       std::cout << "buffer timestamp : " << fake_stamp->timestamp << std::endl;
-
-       mv_source_fill_by_buffer_da(mv_source, buffer->planes[0].data, buffer->resolution.width * buffer->resolution.height,
-                                                               buffer->resolution.width, buffer->resolution.height, buffer->planes[0].align_width,
-                                                               MEDIA_VISION_COLORSPACE_Y800, fake_stamp);
-       da_timestamp_s copy_stamp;
-       mv_source_get_timestamp(mv_source, &copy_stamp);
-       std::cout << "copy timestamp : " << copy_stamp.timestamp << std::endl;
-       mv_destroy_source(mv_source);
-       return 0;
-}
-
-TEST(Common_DA, Callback)
-{
-       vision_source_h ms_handle_cam3;
-       vision_source_format_s format;
-
-       format.pixel_format = VISION_SOURCE_PIXEL_FORMAT_NV12;
-       format.resolution.width = 640;
-       format.resolution.height = 800;
-       format.fps = 10;
-       ASSERT_EQ(vision_source_init(&ms_handle_cam3), VISION_SOURCE_ERROR_NONE);
-       ASSERT_EQ(vision_source_open_device(ms_handle_cam3, 3), VISION_SOURCE_ERROR_NONE);
-       ASSERT_EQ(vision_source_set_stream_format(ms_handle_cam3, &format), VISION_SOURCE_ERROR_NONE);
-
-       clock_t start = clock();
-       ASSERT_EQ(vision_source_start_stream(ms_handle_cam3, nv12_test_cb, &start), VISION_SOURCE_ERROR_NONE);
-       sleep(1);
-       ASSERT_EQ(vision_source_stop_stream(ms_handle_cam3), VISION_SOURCE_ERROR_NONE);
-
-       ASSERT_EQ(vision_source_close_device(ms_handle_cam3), VISION_SOURCE_ERROR_NONE);
-       ASSERT_EQ(vision_source_exit(ms_handle_cam3), VISION_SOURCE_ERROR_NONE);
 }
\ No newline at end of file
index 68c09a8fe06072f677588724707020984a77457b..195e93fe53d573e7e29abea8c27a980fb1be91ee 100644 (file)
@@ -218,18 +218,14 @@ static int _vision_source_cb(vision_source_buffer_s *buffer, void *user_data)
 
        printf("_vision_source_cb: %lld ms\n", static_cast<long long int>(app->stopWatch.elapsedTime().count()));
 
-#ifdef WITH_DA_PROFILE
-       mv_source_fill_by_buffer_da(app->mv_source, buffer->planes[0].data,
-                                                               buffer->resolution.width * buffer->resolution.height, buffer->resolution.width,
-                                                               buffer->resolution.height, buffer->planes[0].align_width, MEDIA_VISION_COLORSPACE_Y800,
-                                                               static_cast<da_timestamp_s *>(buffer->priv));
-#else
        for (unsigned int h = 0; h < buffer->resolution.height; h++) {
                memcpy(app->buffer + buffer->resolution.width * h, buffer->planes[0].data + (buffer->planes[0].align_width * h),
                           buffer->resolution.width);
        }
        mv_source_fill_by_buffer(app->mv_source, app->buffer, app->imgWidth * app->imgHeight, app->imgWidth, app->imgHeight,
                                                         MEDIA_VISION_COLORSPACE_Y800);
+#ifdef WITH_DA_PROFILE
+       mv_source_set_timestamp(app->mv_source, static_cast<da_timestamp_s *>(buffer->priv));
 #endif
 
        if (isAsync)