From 6c4a23e4213a4899b2372ba0b3de7d398b4fb277 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Mon, 14 Sep 2020 19:53:20 +0900 Subject: [PATCH] Bug fix - correct preview resolution for video stream callback - The actual preview resolution could be changed while video recording, but, the fixed resolution was used for video stream callback. [Version] 0.10.214 [Issue Type] Bug fix Change-Id: I41c942d97b617bd887bb9f63ad26c5e4614ae7dd Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/mm_camcorder_gstcommon.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index 8d2443c..40f6d7d 100644 --- 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.213 +Version: 0.10.214 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c index 6124149..8e1af22 100644 --- a/src/mm_camcorder_gstcommon.c +++ b/src/mm_camcorder_gstcommon.c @@ -312,6 +312,9 @@ gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstBuffer *buf GstMemory *memory = NULL; GstMapInfo map_info; + GstCaps *caps = NULL; + GstPad *pad = NULL; + GstStructure *structure = NULL; mmf_return_val_if_fail(hcamcorder, FALSE); mmf_return_val_if_fail(buffer, FALSE); @@ -326,9 +329,32 @@ gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstBuffer *buf stream.format = sc->info_image->preview_format; if (is_preview) { - /* preview buffer */ - stream.width = sc->info_video->preview_width; - stream.height = sc->info_video->preview_height; + /* preview buffer - get resolution from caps */ + pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src"); + mmf_return_val_if_fail(pad, FALSE); + + caps = gst_pad_get_allowed_caps(pad); + if (!caps) { + _mmcam_dbg_err("failed to get caps from pad %p", pad); + gst_object_unref(pad); + return FALSE; + } + + structure = gst_caps_get_structure(caps, 0); + if (!structure) { + _mmcam_dbg_err("failed to get structure from caps %p", caps); + gst_caps_unref(caps); + gst_object_unref(pad); + return FALSE; + } + + gst_structure_get_int(structure, "width", &stream.width); + gst_structure_get_int(structure, "height", &stream.height); + + gst_caps_unref(caps); + caps = NULL; + gst_object_unref(pad); + pad = NULL; } else { /* video recording buffer */ stream.width = sc->info_video->video_width; -- 2.7.4