Fix coverity issue - Resource leak
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_gstcommon.c
index 5a9377b..cd7b0ac 100644 (file)
@@ -1439,8 +1439,7 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        _mmcam_dbg_log("(dp_handle=%p, size=%d)", dp_handle, size);
 
        /* Set display handle */
-       if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink") ||
-               !strcmp(videosink_name, "directvideosink")) {
+       if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
                if (dp_handle) {
                        xid = *dp_handle;
                        _mmcam_dbg_log("xid = %lu )", xid);
@@ -1473,6 +1472,29 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                } else {
                        _mmcam_dbg_warn("Handle is NULL. skip setting.");
                }
+       } else if (!strcmp(videosink_name, "directvideosink")) {
+               if (dp_handle) {
+                       window_info = (MMCamWindowInfo *)dp_handle;
+                       _mmcam_dbg_log("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
+                               window_info->surface_id,
+                               window_info->rect.x,
+                               window_info->rect.y,
+                               window_info->rect.width,
+                               window_info->rect.height);
+                       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), (guintptr)window_info->surface_id);
+                       gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(vsink),
+                               window_info->rect.x,
+                               window_info->rect.y,
+                               window_info->rect.width,
+                               window_info->rect.height);
+               } else {
+                       _mmcam_dbg_warn("dp_handle is null");
+               }
+#ifdef _MMCAMCORDER_RM_SUPPORT
+               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+                       display_scaler = 1;
+               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
        } else {
                _mmcam_dbg_warn("Who are you?? (Videosink: %s)", videosink_name);
        }
@@ -1889,9 +1911,13 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
                                stream.data_type = MM_CAM_STREAM_DATA_ENCODED;
                                stream.data.encoded.data = mapinfo.data;
                                stream.data.encoded.length_data = stream.length_total;
+                               stream.data.encoded.is_delta_frame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
                                /*
-                               _mmcam_dbg_log("H264[num_planes:%d] [0]p:%p,size:%d",
-                                       stream.num_planes, stream.data.encoded.data, stream.data.encoded.length_data);
+                               _mmcam_dbg_log("H264[num_planes:%d] [0]p:%p,size:%d,is_delta:%d",
+                                       stream.num_planes,
+                                       stream.data.encoded.data,
+                                       stream.data.encoded.length_data,
+                                       stream.data.encoded.is_delta_frame);
                                */
                                break;
                        case MM_PIXEL_FORMAT_INVZ:
@@ -2931,10 +2957,6 @@ bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int heig
 bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
 {
        _MMCamcorderSubContext *sc = NULL;
-       GstCameraControl *CameraControl = NULL;
-       GstCameraControlChannel *CameraControlChannel = NULL;
-       const GList *controls = NULL;
-       const GList *item = NULL;
 
        if ((void *)handle == NULL) {
                _mmcam_dbg_warn("handle is NULL");
@@ -2954,27 +2976,13 @@ bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
 
        _mmcam_dbg_log("set encoded preview bitrate : %d bps", bitrate);
 
-       CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
-       controls = gst_camera_control_list_channels(CameraControl);
-       _mmcam_dbg_log("controls : %p", controls);
-       if (controls != NULL) {
-               for (item = controls ; item && item->data ; item = item->next) {
-                       CameraControlChannel = item->data;
-                       _mmcam_dbg_log("label : %s", CameraControlChannel->label);
-                       if (!strcmp(CameraControlChannel->label, "bitrate")) {
-                               _mmcam_dbg_log("set encoded preview bitrate %d", bitrate);
-                               return gst_camera_control_set_value(CameraControl, CameraControlChannel, bitrate);
-                       }
-               }
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", bitrate);
 
-               _mmcam_dbg_warn("failed to find \"bitrate\" control channel");
-       }
-
-       return FALSE;
+       return TRUE;
 }
 
 
-bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int interval)
+bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop_interval)
 {
        _MMCamcorderSubContext *sc = NULL;
 
@@ -2994,9 +3002,9 @@ bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int inte
                return FALSE;
        }
 
-       _mmcam_dbg_log("set encoded preview GOP interval : %d ms", interval);
+       _mmcam_dbg_log("set encoded preview GOP interval : %d ms", gop_interval);
 
-       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", interval);
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "gop-interval", gop_interval);
 
        return TRUE;
 }