Bugfix - directvideosink settings and add exception case without resource manager... 89/211489/2 accepted/tizen/unified/20190823.092334 submit/tizen/20190814.051743
authorHyuntae Kim <ht1211.kim@samsung.com>
Tue, 6 Aug 2019 01:29:10 +0000 (10:29 +0900)
committerHyuntae Kim <ht1211.kim@samsung.com>
Tue, 6 Aug 2019 01:54:59 +0000 (10:54 +0900)
1. Adding directvideosink propery settings
2. Do not control resource manager when display null

    [Version] 0.10.184
    [Profile] TV Profile
    [Issue Type] Bug fix

Change-Id: Ib3071a857e183d69afa37c2fc0ebf9ec91dc47e5

src/mm_camcorder_attribute.c
src/mm_camcorder_gstcommon.c
src/mm_camcorder_internal.c

index c066d49..39c3ac4 100644 (file)
@@ -2647,7 +2647,7 @@ bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, cons
                        }
                }
 
-               _mmcam_dbg_warn("failed to find tilt control channel");
+               _mmcam_dbg_warn("failed to find ptz type control channel");
        }
 
        return FALSE;
@@ -3985,7 +3985,8 @@ bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_i
        }
 
        if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
-           !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
+           !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
+           !strcmp(videosink_name, "directvideosink")) {
                method = value->value.i_val;
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
        } else {
@@ -4030,7 +4031,7 @@ bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const M
        }
 
        if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
-           !strcmp(videosink_name, "evaspixmapsink")) {
+           !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
                int rect_x = 0;
                int rect_y = 0;
                int rect_width = 0;
index a63c595..4ccac2e 100644 (file)
@@ -155,6 +155,10 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_push_buffer_to_record(Gst
 static int __mmcamcorder_get_amrnb_bitrate_mode(int bitrate);
 static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name);
 
+#ifdef _MMCAMCORDER_PRODUCT_TV
+static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+
 /*=======================================================================================
 |  FUNCTION DEFINITIONS                                                                        |
 =======================================================================================*/
@@ -322,7 +326,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
        }
 
        /* make demux and decoder for H264 stream from videosrc */
-       if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+       if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 && display_surface_type != MM_DISPLAY_SURFACE_NULL) {
                int preview_bitrate = 0;
                int gop_interval = 0;
                const char *videodecoder_name = NULL;
@@ -1434,8 +1438,8 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        _mmcam_dbg_log("(overlay=%p, size=%d)", overlay, size);
 
        /* Set display handle */
-       if (!strcmp(videosink_name, "xvimagesink") ||
-           !strcmp(videosink_name, "ximagesink")) {
+       if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink") ||
+               !strcmp(videosink_name, "directvideosink")) {
                if (overlay) {
                        xid = *overlay;
                        _mmcam_dbg_log("xid = %lu )", xid);
@@ -1460,7 +1464,7 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                        _mmcam_dbg_err("display handle(eavs object) is NULL");
                        return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
                }
-       } else if (!strcmp(videosink_name, "tizenwlsink") || !strcmp(videosink_name, "directvideosink")) {
+       } else if (!strcmp(videosink_name, "tizenwlsink")) {
                if (overlay) {
                        _mmcam_dbg_log("wayland global surface id : %d", *overlay);
                        gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(vsink), *overlay);
@@ -2520,13 +2524,6 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
        gboolean do_set_caps = FALSE;
 
        GstCaps *caps = NULL;
-#ifdef _MMCAMCORDER_PRODUCT_TV
-       GstPad *sinkpad;
-       GstCaps *decsink_caps = NULL;
-       GstStructure *decsink_struct = NULL;
-       int maxwidth = 0;
-       int maxheight = 0;
-#endif /*_MMCAMCORDER_PRODUCT_TV */
 
        mmf_camcorder_t *hcamcorder = NULL;
        _MMCamcorderSubContext *sc = NULL;
@@ -2689,34 +2686,21 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
        if (do_set_caps) {
                if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
 #ifdef _MMCAMCORDER_PRODUCT_TV
-                       sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
-                       if (!sinkpad) {
-                               _mmcam_dbg_err("There are no decoder caps");
-                               return FALSE;
-                       }
-
-                       decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
-                       if (!decsink_caps) {
-                               gst_object_unref(sinkpad);
-                               _mmcam_dbg_err("There is no decoder sink caps");
-                               return FALSE;
-                       }
+                       gint maxwidth = 0;
+                       gint maxheight = 0;
+                       int display_surface_type = MM_DISPLAY_SURFACE_NULL;
+                       mm_camcorder_get_attributes(handle, NULL,
+                                       MMCAM_DISPLAY_SURFACE, &display_surface_type,
+                                       NULL);
 
-                       decsink_struct = gst_caps_get_structure(decsink_caps, 0);
-                       if (!decsink_struct) {
-                               _mmcam_dbg_err("There are no structure from caps");
-                               gst_object_unref(decsink_caps);
-                               gst_object_unref(sinkpad);
-                               return FALSE;
+                       if (display_surface_type != MM_DISPLAY_SURFACE_NULL && __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
+                               _mmcam_dbg_err("can not find max resolution limitation");
+                               return false;
+                       } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
+                               maxwidth = set_width;
+                               maxheight = set_height;
                        }
-
-                       if (gst_structure_has_field(decsink_struct, "maxwidth"))
-                               gst_structure_get_int(decsink_struct, "maxwidth", &maxwidth);
-
-                       if (gst_structure_has_field(decsink_struct, "maxheight"))
-                               gst_structure_get_int(decsink_struct, "maxheight", &maxheight);
 #endif /* _MMCAMCORDER_PRODUCT_TV */
-
                        caps = gst_caps_new_simple("video/x-h264",
                                "width", G_TYPE_INT, set_width,
                                "height", G_TYPE_INT, set_height,
@@ -2728,11 +2712,6 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                                "alignment", G_TYPE_STRING, "au",
 #endif /* _MMCAMCORDER_PRODUCT_TV */
                                NULL);
-
-#ifdef _MMCAMCORDER_PRODUCT_TV
-                       gst_object_unref(decsink_caps);
-                       gst_object_unref(sinkpad);
-#endif /* _MMCAMCORDER_PRODUCT_TV */
                } else {
                        char fourcc_string[sizeof(fourcc)+1];
                        strncpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
@@ -3173,3 +3152,65 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
 
        return TRUE;
 }
+
+#ifdef _MMCAMCORDER_PRODUCT_TV
+static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height)
+{
+       _MMCamcorderSubContext *sc = NULL;
+       mmf_camcorder_t *hcamcorder = NULL;
+       int index = 0;
+       const gchar *mime = NULL;
+       GstPad *sinkpad;
+       GstCaps *decsink_caps = NULL;
+       GstStructure *decsink_struct = NULL;
+
+       mmf_return_val_if_fail(handle, false);
+       mmf_return_val_if_fail(max_width, false);
+       mmf_return_val_if_fail(max_height, false);
+
+       hcamcorder = MMF_CAMCORDER(handle);
+       mmf_return_val_if_fail(hcamcorder, false);
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+
+       sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
+       if (!sinkpad) {
+               _mmcam_dbg_err("There are no decoder caps");
+               return false;
+       }
+
+       decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
+       if (!decsink_caps) {
+               gst_object_unref(sinkpad);
+               _mmcam_dbg_err("There is no decoder sink caps");
+               return false;
+       }
+
+       for (index = 0; index < gst_caps_get_size(decsink_caps); index++) {
+               decsink_struct = gst_caps_get_structure(decsink_caps, index);
+               if (!decsink_struct) {
+                       _mmcam_dbg_err("There are no structure from caps");
+                       gst_object_unref(decsink_caps);
+                       gst_object_unref(sinkpad);
+                       return false;
+               }
+               mime = gst_structure_get_name(decsink_struct);
+               if (!strcmp(mime, "video/x-h264")) {
+                       _mmcam_dbg_log("h264 caps structure found");
+                       if (gst_structure_has_field(decsink_struct, "maxwidth"))
+                               *max_width = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxwidth"));
+                       if (gst_structure_has_field(decsink_struct, "maxheight"))
+                               *max_height = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxheight"));
+                       break;
+               }
+       }
+       _mmcam_dbg_log("maxwidth = %d , maxheight = %d", (int)*max_width, (int)*max_height);
+       gst_object_unref(decsink_caps);
+       gst_object_unref(sinkpad);
+
+       if (*max_width <= 0 || *max_height <= 0)
+               return false;
+
+       return true;
+}
+#endif /* _MMCAMCORDER_PRODUCT_TV */
index a4ab29d..ac131e2 100644 (file)
@@ -1010,82 +1010,84 @@ int _mmcamcorder_realize(MMHandleType handle)
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
 #ifdef _MMCAMCORDER_RM_SUPPORT
-               mm_camcorder_get_attributes(handle, NULL,
-                       MMCAM_CLIENT_PID, &app_pid,
-                       NULL);
-               rci.app_pid = app_pid;
-               aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
-
-               /* RM register */
-               if (hcamcorder->rm_handle == 0) {
-                       iret = rm_register((rm_resource_cb)_mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
-                       if (iret != RM_OK) {
-                               _mmcam_dbg_err("rm_register fail");
-                               ret = MM_ERROR_RESOURCE_INTERNAL;
-                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+               if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
+                       mm_camcorder_get_attributes(handle, NULL,
+                               MMCAM_CLIENT_PID, &app_pid,
+                               NULL);
+                       rci.app_pid = app_pid;
+                       aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
+
+                       /* RM register */
+                       if (hcamcorder->rm_handle == 0) {
+                               iret = rm_register((rm_resource_cb)_mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
+                               if (iret != RM_OK) {
+                                       _mmcam_dbg_err("rm_register fail");
+                                       ret = MM_ERROR_RESOURCE_INTERNAL;
+                                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+                               }
                        }
-               }
 
-               mm_camcorder_get_attributes(handle, NULL,
-                       MMCAM_CAMERA_FORMAT, &preview_format,
-                       NULL);
+                       mm_camcorder_get_attributes(handle, NULL,
+                               MMCAM_CAMERA_FORMAT, &preview_format,
+                               NULL);
 
-               resource_count = 0;
-               memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
-               memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+                       resource_count = 0;
+                       memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+                       memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
 
-               if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
+                       if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
 
-                       _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
+                               _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
 
-                       resource_count++;
-               }
+                               resource_count++;
+                       }
 
-               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+                       if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
 
-                       _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
+                               _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
 
-                       resource_count++;
-               }
+                               resource_count++;
+                       }
 
-               hcamcorder->request_resources.request_num = resource_count;
+                       hcamcorder->request_resources.request_num = resource_count;
 
-               if (resource_count > 0) {
-                       qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
-                       if (qret != RM_OK || qret_avail != 1) {
-                               _mmcam_dbg_log("rm query failed. retry with sub devices");
+                       if (resource_count > 0) {
+                               qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
+                               if (qret != RM_OK || qret_avail != 1) {
+                                       _mmcam_dbg_log("rm query failed. retry with sub devices");
 
-                               resource_count = 0;
+                                       resource_count = 0;
 
-                               if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
-                                       _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
-                                       resource_count++;
-                               }
+                                       if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+                                               _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
+                                               resource_count++;
+                                       }
 
-                               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
-                                       _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
-                                       resource_count++;
+                                       if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+                                               _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
+                                               resource_count++;
+                                       }
                                }
                        }
-               }
 
-               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
+                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
 
-               hcamcorder->request_resources.request_num = resource_count + 1;
-               _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
+                       hcamcorder->request_resources.request_num = resource_count + 1;
+                       _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
 
-               iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
-               if (iret != RM_OK) {
-                       _mmcam_dbg_err("Resource allocation request failed");
-                       ret = MM_ERROR_RESOURCE_INTERNAL;
-                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+                       iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
+                       if (iret != RM_OK) {
+                               _mmcam_dbg_err("Resource allocation request failed");
+                               ret = MM_ERROR_RESOURCE_INTERNAL;
+                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+                       }
                }
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        }