From 8261ec40f00729e67107d7f7c1fa8138050aab44 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Tue, 21 Mar 2023 15:50:15 +0900 Subject: [PATCH] Support timestamp in protection meta [Version] 0.10.288 [Issue Type] New feature Change-Id: If8193d90dccab88aaa5a30abd7eb4bb24802905d Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/include/mm_camcorder.h | 10 +++++++ src/mm_camcorder_gstcommon.c | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index ecbb645..c6f10a3 100755 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -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 diff --git a/src/include/mm_camcorder.h b/src/include/mm_camcorder.h index 4b4d7e7..9077402 100644 --- a/src/include/mm_camcorder.h +++ b/src/include/mm_camcorder.h @@ -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; diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c index 6f2bf75..0eb02ff 100644 --- a/src/mm_camcorder_gstcommon.c +++ b/src/mm_camcorder_gstcommon.c @@ -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); -- 2.34.1