Add new internal API to get meta timestamp 30/290530/1
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 21 Mar 2023 06:52:22 +0000 (15:52 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 28 Mar 2023 07:16:01 +0000 (16:16 +0900)
[Version] 0.4.101
[Issue Type] New feature

Change-Id: Id54842c6fea4bc2fd02ce413c0df9114c0f1722e
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/camera_internal.h
packaging/capi-media-camera.spec
src/camera.c
src/camera_internal.c
test/camera_test.c

index 913539d..4de519e 100644 (file)
@@ -39,11 +39,35 @@ extern "C" {
 
 #define CAMERA_DEVICE_MAX        ((CAMERA_DEVICE_CAMERA9 + 1) * 2)
 
+/**
+ * @internal
+ * @brief The structure type of the camera device list.
+ * @since_tizen 6.0
+ */
 typedef struct _camera_device_list_s {
        unsigned int count;
        camera_device_s device[CAMERA_DEVICE_MAX];
 } camera_device_list_s;
 
+/**
+ * @internal
+ * @brief The structure type of the meta timestamp.
+ * @since_tizen 7.0
+ * @remarks This is available for specific device only.
+ */
+typedef struct _camera_meta_timestamp_s {
+       unsigned long long ts_soe;
+       unsigned long long ts_eoe;
+       unsigned long long ts_sof;
+       unsigned long long ts_eof;
+       unsigned long long ts_hal;
+       unsigned long long ts_qmf;
+       unsigned long long ts_gst;
+       unsigned long long td_exp;
+       unsigned long long ts_aux;
+       unsigned long long td_aux;
+} camera_meta_timestamp_s;
+
 
 /**
  * @internal
@@ -256,9 +280,9 @@ int camera_request_codec_config(camera_h camera);
  * @internal
  * @brief Gets the timestamp of preview frame in nano second.
  * @since_tizen 7.0
- * @remarks The function should be called in camera_preview_cb(),\n
+ * @remarks The function should be called in camera_preview_cb() or camera_media_packet_preview_cb(),\n
  *          otherwise, it will return #CAMERA_ERROR_INVALID_OPERATION.
- * @param[in] camera    The handle to the camera
+ * @param[in] camera     The handle to the camera
  * @param[out] timestamp The timestamp of preview frame (in nsec)
  * @return @c 0 on success, otherwise a negative error value
  * @retval #CAMERA_ERROR_NONE Successful
@@ -268,6 +292,22 @@ int camera_request_codec_config(camera_h camera);
 int camera_attr_get_preview_frame_timestamp(camera_h camera, unsigned long *timestamp);
 
 /**
+ * @internal
+ * @brief Gets the meta timestamp of preview frame in nano second.
+ * @since_tizen 7.0
+ * @remarks The function should be called in camera_preview_cb() or camera_media_packet_preview_cb(),\n
+ *          otherwise, it will return #CAMERA_ERROR_INVALID_OPERATION.
+ * @param[in] camera          The handle to the camera
+ * @param[out] meta_timestamp The meta timestamp of preview frame (in nsec)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int camera_attr_get_preview_frame_meta_timestamp(camera_h camera, camera_meta_timestamp_s *meta_timestamp);
+
+
+/**
  * @}
  */
 #ifdef __cplusplus
index 8a79716..c8682f5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.100
+Version:    0.4.101
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 121ba32..96a3039 100644 (file)
@@ -425,6 +425,13 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv
        /* get stream info */
        stream = (MMCamcorderVideoStreamDataType *)buf_pos;
 
+       CAM_LOG_VERBOSE("meta ts: [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu]",
+               stream->ts_soe, stream->ts_eoe,
+               stream->ts_sof, stream->ts_eof,
+               stream->ts_hal, stream->ts_qmf,
+               stream->ts_gst, stream->td_exp,
+               stream->ts_aux, stream->td_aux);
+
        if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
                /* import tbm data_bo and get virtual address */
                if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
index 577ab8e..b5f2082 100644 (file)
@@ -400,4 +400,35 @@ int camera_attr_get_preview_frame_timestamp(camera_h camera, unsigned long *time
 
        return CAMERA_ERROR_NONE;
 }
+
+
+int camera_attr_get_preview_frame_meta_timestamp(camera_h camera, camera_meta_timestamp_s *meta_timestamp)
+{
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       MMCamcorderVideoStreamDataType *stream = NULL;
+
+       if (!pc || !pc->cb_info || !meta_timestamp) {
+               CAM_LOG_ERROR("NULL pointer %p %p", pc, meta_timestamp);
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       stream = pc->cb_info->stream_data;
+       if (!stream) {
+               CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
+               return CAMERA_ERROR_INVALID_OPERATION;
+       }
+
+       meta_timestamp->ts_soe = stream->ts_soe;
+       meta_timestamp->ts_eoe = stream->ts_eoe;
+       meta_timestamp->ts_sof = stream->ts_sof;
+       meta_timestamp->ts_eof = stream->ts_eof;
+       meta_timestamp->ts_hal = stream->ts_hal;
+       meta_timestamp->ts_qmf = stream->ts_qmf;
+       meta_timestamp->ts_gst = stream->ts_gst;
+       meta_timestamp->td_exp = stream->td_exp;
+       meta_timestamp->ts_aux = stream->ts_aux;
+       meta_timestamp->td_aux = stream->td_aux;
+
+       return CAMERA_ERROR_NONE;
+}
 //LCOV_EXCL_STOP
index 3b6c50b..c824ad1 100644 (file)
@@ -463,6 +463,7 @@ static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
        camera_h cam_handle = (camera_h)user_data;
        camera_rotation_e rotation = CAMERA_ROTATION_NONE;
        unsigned long timestamp = 0;
+       camera_meta_timestamp_s meta_timestamp = {0, };
 
        if (!cam_handle || !frame) {
                LOGE("NULL param! %p %p", cam_handle, frame);
@@ -479,6 +480,18 @@ static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
 
        LOGI("rotation[%d], timestamp[%lu]", rotation, timestamp);
 
+       ret = camera_attr_get_preview_frame_meta_timestamp(cam_handle, &meta_timestamp);
+       if (ret == CAMERA_ERROR_NONE) {
+               LOGD("meta %llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu",
+                       meta_timestamp.ts_soe, meta_timestamp.ts_eoe,
+                       meta_timestamp.ts_sof, meta_timestamp.ts_eof,
+                       meta_timestamp.ts_hal, meta_timestamp.ts_qmf,
+                       meta_timestamp.ts_gst, meta_timestamp.td_exp,
+                       meta_timestamp.ts_aux, meta_timestamp.td_aux);
+       } else {
+               LOGW("get preview frame meta timestamp failed[0x%x]", ret);
+       }
+
        _camera_print_preview_info(frame, -1);
 
        if (g_camera_preview_cb_dump)