Bug fix - correct preview resolution for video stream callback 57/244057/1 accepted/tizen/unified/20200915.014554 submit/tizen/20200914.110003
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 14 Sep 2020 10:53:20 +0000 (19:53 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 14 Sep 2020 10:55:48 +0000 (19:55 +0900)
- 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 <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/mm_camcorder_gstcommon.c

index 8d2443c..40f6d7d 100644 (file)
@@ -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
index 6124149..8e1af22 100644 (file)
@@ -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;