webrtc_display: Revise logic for display mode/visible 62/264562/3
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 24 Sep 2021 09:22:56 +0000 (18:22 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Sep 2021 06:05:01 +0000 (15:05 +0900)
Default mode and visible values are set when allocating display.
These values can be updated by setter APIs regardless of sink_element set.
Check properties for mode and visible before g_object_set().

[Version] 0.2.103
[Issue Type] Improvement

Change-Id: I9f98c764e73e23e7f6a87a167ba1211460b45360
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_display.c
src/webrtc_sink.c
src/webrtc_source.c

index a7ae00faeb490d3312125d3bd4b6c998a0b68879..e621d8bd3fcfe5392c2bd22bb3f50aa607ad51ce 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.102
+Version:    0.2.103
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 6af2bf1aff8033ba9ae2f89f888a09df3cba6215..af531b01c6dd5b5b51ce16a2e3e2074462793817 100644 (file)
@@ -668,18 +668,15 @@ static int __set_evas_display(webrtc_display_s *display)
        RET_VAL_IF(ret != MM_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION, "failed to mm_display_interface_set_display_mainloop_sync()");
 
        /* FIXE: get mode and rotation value from handle */
-       ret = mm_display_interface_evas_set_mode(display->mm_display, 0); /* 0: letter box, 1: origin size, 2: full screen */
+       ret = mm_display_interface_evas_set_mode(display->mm_display, (int)display->mode); /* 0: letter box, 1: origin size, 2: full screen */
        RET_VAL_IF(ret != MM_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION, "failed to mm_display_interface_evas_set_mode()");
 
        ret = mm_display_interface_evas_set_rotation(display->mm_display, 0); /* 0: not rotate, 1: 90 degree, 2, 180 degree, 3, 270 degree */
        RET_VAL_IF(ret != MM_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION, "failed to mm_display_interface_evas_set_rotation()");
 
-       ret = mm_display_interface_evas_set_visible(display->mm_display, true);
+       ret = mm_display_interface_evas_set_visible(display->mm_display, display->visible);
        RET_VAL_IF(ret != MM_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION, "failed to mm_display_interface_evas_set_visible()");
 
-       display->mode = WEBRTC_DISPLAY_MODE_LETTER_BOX;
-       display->visible = true;
-
        LOG_INFO("surface[%p], mode[%u], visible[%u]", display->surface, display->mode, display->visible);
 
        return WEBRTC_ERROR_NONE;
@@ -736,7 +733,10 @@ webrtc_display_s *_alloc_display(void)
        else
                LOG_DEBUG("init mm_display[%p]", display->mm_display);
 
-       LOG_DEBUG("alloc display[%p]", display);
+       display->mode = WEBRTC_DISPLAY_MODE_LETTER_BOX;
+       display->visible = true;
+
+       LOG_DEBUG("alloc display[%p, mode:%u, visible:%u]", display, display->mode, display->visible);
 
        return display;
 }
@@ -796,11 +796,11 @@ int _set_display_mode(webrtc_display_s *display, webrtc_display_mode_e mode)
        case WEBRTC_DISPLAY_TYPE_OVERLAY:
        case WEBRTC_DISPLAY_TYPE_ECORE_WL:
                LOG_INFO("it's %s type, mode[%d]", display->type == WEBRTC_DISPLAY_TYPE_OVERLAY ? "OVERLAY" : "ECORE_WL", mode);
-               RET_VAL_IF(display->sink_element == NULL, WEBRTC_ERROR_INVALID_OPERATION, "sink_element is NULL");
-               RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(display->sink_element)), "display-geometry-method"),
-                       WEBRTC_ERROR_INVALID_OPERATION, "could not find 'display-geometry-method'");
-
-               g_object_set(G_OBJECT(display->sink_element), "display-geometry-method", (gint)mode, NULL);
+               if (display->sink_element) {
+                       RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(display->sink_element)), "display-geometry-method"),
+                               WEBRTC_ERROR_INVALID_OPERATION, "could not find 'display-geometry-method' property");
+                       g_object_set(G_OBJECT(display->sink_element), "display-geometry-method", (gint)mode, NULL);
+               }
                display->mode = mode;
                break;
 
@@ -854,11 +854,11 @@ int _set_display_visible(webrtc_display_s *display, bool visible)
        case WEBRTC_DISPLAY_TYPE_OVERLAY:
        case WEBRTC_DISPLAY_TYPE_ECORE_WL:
                LOG_INFO("it's %s type, visible[%u]", display->type == WEBRTC_DISPLAY_TYPE_OVERLAY ? "OVERLAY" : "ECORE_WL", visible);
-               RET_VAL_IF(display->sink_element == NULL, WEBRTC_ERROR_INVALID_OPERATION, "sink_element is NULL");
-               RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(display->sink_element)), "visible"),
-                       WEBRTC_ERROR_INVALID_OPERATION, "could not find 'visible'");
-
-               g_object_set(G_OBJECT(display->sink_element), "visible", (gboolean)visible, NULL);
+               if (display->sink_element) {
+                       RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(display->sink_element)), "visible"),
+                               WEBRTC_ERROR_INVALID_OPERATION, "could not find 'visible' property");
+                       g_object_set(G_OBJECT(display->sink_element), "visible", (gboolean)visible, NULL);
+               }
                display->visible = visible;
                break;
 
index 585d9c2a5999621a092c8cf26a0d0f8eac96045e..8e47b75650a2d39d0bdf3ea427d49490f0966522 100644 (file)
@@ -161,12 +161,14 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr
                if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY ||
                        sink->display->type == WEBRTC_DISPLAY_TYPE_ECORE_WL) {
                        gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), sink->display->overlay_surface_id);
+                       RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosink)), "display-geometry-method"),
+                               WEBRTC_ERROR_INVALID_OPERATION, "could not find 'display-geometry-method' property");
+                       RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosink)), "visible"),
+                               WEBRTC_ERROR_INVALID_OPERATION, "could not find 'visible' property");
                        g_object_set(G_OBJECT(videosink),
-                               "display-geometry-method", (gint)0, /* 0: letter box, 1: origin size, 2: full screen */
-                               "visible", TRUE,
+                               "display-geometry-method", (gint)sink->display->mode, /* 0: letter box, 1: origin size, 2: full screen */
+                               "visible", (gboolean)sink->display->visible,
                                NULL);
-                       sink->display->mode = WEBRTC_DISPLAY_MODE_LETTER_BOX;
-                       sink->display->visible = true;
 
                } else if (sink->display->type == WEBRTC_DISPLAY_TYPE_EVAS) {
                        g_object_set(G_OBJECT(videosink),
index 2ffd0bdc18be4e847a90e3b84b96028ffb688587..dd0876c48a092b47a6d5c10ad71c25cd6c5e0731 100644 (file)
@@ -3536,13 +3536,14 @@ static int __build_loopback_videosink(webrtc_gst_slot_s *source, GstElement *lin
        if (source->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY ||
                source->display->type == WEBRTC_DISPLAY_TYPE_ECORE_WL) {
                gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), source->display->overlay_surface_id);
+               RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosink)), "display-geometry-method"),
+                       WEBRTC_ERROR_INVALID_OPERATION, "could not find 'display-geometry-method' property");
+               RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosink)), "visible"),
+                       WEBRTC_ERROR_INVALID_OPERATION, "could not find 'visible' property");
                g_object_set(G_OBJECT(videosink),
-                       "display-geometry-method", (gint)0, /* 0: letter box, 1: origin size, 2: full screen */
-                       "visible", TRUE,
+                       "display-geometry-method", (gint)source->display->mode, /* 0: letter box, 1: origin size, 2: full screen */
+                       "visible", (gboolean)source->display->visible,
                        NULL);
-               source->display->mode = WEBRTC_DISPLAY_MODE_LETTER_BOX;
-               source->display->visible = true;
-               source->display->sink_element = videosink;
 
        } else if (source->display->type == WEBRTC_DISPLAY_TYPE_EVAS) {
                g_object_set(videosink, "signal-handoffs", TRUE, NULL);
@@ -3566,6 +3567,8 @@ static int __build_loopback_videosink(webrtc_gst_slot_s *source, GstElement *lin
                return WEBRTC_ERROR_INVALID_OPERATION;
        }
 
+       source->display->sink_element = videosink;
+
        return WEBRTC_ERROR_NONE;
 }