Support timestamp in protection meta 29/290529/1
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 21 Mar 2023 06:50:15 +0000 (15:50 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 28 Mar 2023 07:17:03 +0000 (16:17 +0900)
[Version] 0.10.288
[Issue Type] New feature

Change-Id: If8193d90dccab88aaa5a30abd7eb4bb24802905d
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/mm_camcorder_gstcommon.c

index ecbb645..c6f10a3 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.287
+Version:    0.10.288
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 4b4d7e7..9077402 100644 (file)
@@ -1912,6 +1912,16 @@ typedef struct {
        int flip;                           /**< Flip */
        int rotation;                       /**< Rotation */
        unsigned long long timestamp_nsec;  /**< timestamp of stream buffer(nsec) */
+       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;
 } MMCamcorderVideoStreamDataType;
 
 
index 6f2bf75..0eb02ff 100644 (file)
@@ -131,6 +131,7 @@ static gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM
 #define _MMCAMCORDER_NANOSEC_PER_1MILISEC         1000
 #define _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG  "request-codec-config"
 #define _MMCAMCORDER_CROP_ARRAY_LENGTH            4
+#define META_TIMESTAMP_FIELD_LENGTH               6
 
 
 /*-----------------------------------------------------------------------
@@ -158,6 +159,7 @@ static guint32 _mmcamcorder_get_structure_fourcc(const GstStructure *structure);
 static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
 static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
 static const char *__mmcamcorder_get_parser_name(MMPixelFormatType format);
+static gboolean __mmcamcorder_frame_meta_foreach_func(GQuark field_id, const GValue *value, gpointer user_data);
 
 /*=======================================================================================
 |  FUNCTION DEFINITIONS                                                                 |
@@ -392,6 +394,53 @@ static const char *__mmcamcorder_get_parser_name(MMPixelFormatType format)
 }
 
 
+static gboolean __mmcamcorder_frame_meta_foreach_func(GQuark field_id, const GValue *value, gpointer user_data)
+{
+       MMCamcorderVideoStreamDataType *stream = (MMCamcorderVideoStreamDataType *)user_data;
+       const char *field_name = g_quark_to_string(field_id);
+       guint64 field_value = g_value_get_uint64(value);
+
+       if (!stream || !field_name) {
+               MMCAM_LOG_WARNING("invalid ptr[%p, %p]", stream, field_name);
+               return TRUE;
+       }
+
+       if (!strncmp("ts_soe", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_soe = field_value;
+               MMCAM_LOG_VERBOSE("[TS] SOE -> %llu", stream->ts_soe);
+       } else if (!strncmp("ts_eoe", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_eoe = field_value;
+               MMCAM_LOG_VERBOSE("[TS] EOE -> %llu", stream->ts_eoe);
+       } else if (!strncmp("ts_sof", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_sof = field_value;
+               MMCAM_LOG_VERBOSE("[TS] SOF -> %llu", stream->ts_sof);
+       } else if (!strncmp("ts_eof", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_eof = field_value;
+               MMCAM_LOG_VERBOSE("[TS] EOF -> %llu", stream->ts_eof);
+       } else if (!strncmp("ts_hal", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_hal = field_value;
+               MMCAM_LOG_VERBOSE("[TS] HAL -> %llu", stream->ts_hal);
+       } else if (!strncmp("ts_qmf", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_qmf = field_value;
+               MMCAM_LOG_VERBOSE("[TS] QMF -> %llu", stream->ts_qmf);
+       } else if (!strncmp("ts_gst", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_gst = field_value;
+               MMCAM_LOG_VERBOSE("[TS] GST -> %llu", stream->ts_gst);
+       } else if (!strncmp("td_exp", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->td_exp = field_value;
+               MMCAM_LOG_VERBOSE("[TD] EXP -> %llu", stream->td_exp);
+       } else if (!strncmp("ts_aux", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->ts_aux = field_value;
+               MMCAM_LOG_VERBOSE("[TS] AUX -> %llu", stream->ts_aux);
+       } else if (!strncmp("td_aux", field_name, META_TIMESTAMP_FIELD_LENGTH)) {
+               stream->td_aux = field_value;
+               MMCAM_LOG_VERBOSE("[TD] AUX -> %llu", stream->td_aux);
+       }
+
+       return TRUE;
+}
+
+
 int _mmcamcorder_request_codec_config(GstElement *videosrc_element)
 {
        if (!videosrc_element || !G_TYPE_CHECK_INSTANCE(videosrc_element)) {
@@ -426,6 +475,7 @@ gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstSample *sam
        GstMapInfo map_info;
        GstCaps *caps = NULL;
        GstStructure *structure = NULL;
+       GstProtectionMeta *p_meta = NULL;
 
        mmf_return_val_if_fail(hcamcorder, FALSE);
 
@@ -484,6 +534,10 @@ gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstSample *sam
                        goto _INVOKE_VIDEO_STREAM_CB_DONE;
        }
 
+       p_meta = gst_buffer_get_protection_meta(buffer);
+       if (p_meta)
+               gst_structure_foreach(p_meta->info, __mmcamcorder_frame_meta_foreach_func, &stream);
+
        MMCAM_LOG_DEBUG("VideoStreamData : format[%d], resolution[%dx%d], stream_id[%d]",
                stream.format, stream.width, stream.height, stream_id);