Add internal API for support ecore wl2 display 57/262757/3 submit/tizen/20210820.053816
authorHyunsoo Park <hance.park@samsung.com>
Thu, 19 Aug 2021 07:52:49 +0000 (16:52 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Thu, 19 Aug 2021 09:37:06 +0000 (18:37 +0900)
Change-Id: Iea98116be61998fe4f5c5d925c638ac9677ecbd2
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
CMakeLists.txt
include/scmirroring_internal.h
include/scmirroring_private.h
packaging/capi-media-screen-mirroring.spec
src/scmirroring_primary_sink.c
src/scmirroring_sink.c
src/scmirroring_sink_internal.c [new file with mode: 0644]
src/scmirroring_util.c
test_sink/CMakeLists.txt
test_sink/scmirroring_sink_test.c

index 411dd86f66069d79aaf96d3b96c03174a8b97d2c..5ac91fd220aabc1f792dca41096d2dc43ba84aff 100644 (file)
@@ -8,7 +8,7 @@ SET(service "media")
 SET(submodule "screen-mirroring")
 
 # for package file
-SET(dependents "mm-wfd dlog glib-2.0 gio-2.0 capi-base-common capi-network-wifi-direct iniparser")
+SET(dependents "mm-wfd dlog glib-2.0 gio-2.0 capi-base-common capi-network-wifi-direct iniparser mm-display-interface")
 
 SET(fw_name "${project_prefix}-${service}-${submodule}")
 
index 2b8f42d85958726e701477b100358825ca69c3f7..e75990505298a89dc83291ee67afeb55b849fe3b 100644 (file)
@@ -73,6 +73,32 @@ typedef enum {
  */
 typedef void(*scmirroring_state_cb)(scmirroring_error_e error, scmirroring_state_e state, void *user_data);
 
+/**
+ * @internal
+ * @brief Sets the ecore wayland video display.
+ *
+ * @since_tizen 6.5
+ *
+ * @remarks This function must be called in main thread of the application.
+ *          Otherwise, it will return #SCMIRRORING_ERROR_INVALID_OPERATION by internal restriction.
+ *          To avoid #SCMIRRORING_ERROR_INVALID_OPERATION in sub thread, ecore_thread_main_loop_begin() and
+ *          ecore_thread_main_loop_end() can be used, but deadlock can occur if the main thread is busy.
+ *          So, it's not recommended to use them.
+ *
+ * @param[in] scmirroring_sink The handle to the screen mirroring sink
+ * @param[in] display_surface The ecore wayland window handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SCMIRRORING_ERROR_NONE Successful
+ * @retval #SCMIRRORING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SCMIRRORING_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #SCMIRRORING_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a screen mirroring sink handle by calling scmirroring_sink_create().
+ *
+ * @see scmirroring_sink_create()
+ */
+int scmirroring_sink_set_ecore_wl_display(scmirroring_sink_h scmirroring_sink, void *display_surface);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 196857d0e302ce59f5d230a1c06cffb0ef3dd3af..ca86c25c7d8d8fab53998db8b709cb46076df07e 100644 (file)
@@ -24,6 +24,7 @@
 #include <system_info.h>
 #include <scmirroring_internal.h>
 #include <mmf/mm_wfd_sink.h>
+#include <mm_display_interface.h>
 
 #ifndef TRUE
 #define TRUE 1
@@ -286,7 +287,7 @@ int _scmirroring_sink_start(MMHandleType handle);
 int _scmirroring_sink_pause(MMHandleType handle);
 int _scmirroring_sink_resume(MMHandleType handle);
 int _scmirroring_sink_disconnect(MMHandleType handle);
-int _scmirroring_sink_set_display(MMHandleType handle, scmirroring_display_type_e type, void *display_surface);
+int _scmirroring_sink_set_display(MMHandleType handle, scmirroring_display_type_e type, void *display_surface, mm_display_type_e display_type);
 int _scmirroring_sink_set_resolution(MMHandleType handle, int resolution);
 int _scmirroring_sink_get_negotiated_video_codec(MMHandleType handle, scmirroring_video_codec_e *codec);
 int _scmirroring_sink_get_negotiated_video_resolution(MMHandleType handle, int *width, int *height);
index f4448dba502c871437490487b450bc6decaa25c2..82a44ae477364a3d703623a2d0189eb044cc632d 100644 (file)
@@ -20,6 +20,9 @@ BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(mm-display-interface)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(ecore-wl2)
 
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index 035040e2e6081821146ad6da8a09f9545e647bd6..86f654226fa2f31bff5503edf2ff4342a39c3ca0 100644 (file)
@@ -246,7 +246,7 @@ int scmirroring_primary_sink_set_display(scmirroring_primary_sink_h scmirroring_
 
        scmirroring_retvm_if(!__is_valid_handle(handle), SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_primary_sink is invalid");
 
-       return _scmirroring_sink_set_display(handle->mm_handle, type, display_surface);
+       return _scmirroring_sink_set_display(handle->mm_handle, type, display_surface, MM_DISPLAY_TYPE_OVERLAY);
 }
 
 int scmirroring_primary_sink_set_resolution(scmirroring_primary_sink_h scmirroring_primary_sink, int resolution)
index 681f8d57fbe978ddbd0cdf5faf4ba546ff7301df..e1d73c219fc6d17b80ea3277255d71f856d3aab8 100644 (file)
@@ -215,7 +215,7 @@ int scmirroring_sink_set_display(scmirroring_sink_h scmirroring_sink, scmirrorin
 
        scmirroring_retvm_if(!__is_valid_handle(handle), SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink is invalid");
 
-       return _scmirroring_sink_set_display(handle->mm_handle, type, display_surface);
+       return _scmirroring_sink_set_display(handle->mm_handle, type, display_surface, MM_DISPLAY_TYPE_OVERLAY);
 }
 
 int scmirroring_sink_set_resolution(scmirroring_sink_h scmirroring_sink, int resolution)
diff --git a/src/scmirroring_sink_internal.c b/src/scmirroring_sink_internal.c
new file mode 100644 (file)
index 0000000..c66d602
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include <stdio.h>
+#include <mm.h>
+#include <mm_types.h>
+#include <mmf/mm_wfd_sink.h>
+#include <scmirroring_sink.h>
+#include <scmirroring_internal.h>
+#include <scmirroring_private.h>
+
+static gboolean __is_valid_handle(scmirroring_sink_s *handle)
+{
+       scmirroring_retvm_if(!handle, FALSE, "scmirroring_sink_s is NULL");
+       scmirroring_retvm_if(handle->magic_num != SCMIRRORING_MAGIC_NUMBER, FALSE, "invalid magic_num");
+
+       return TRUE;
+}
+
+int scmirroring_sink_set_ecore_wl_display(scmirroring_sink_h scmirroring_sink, void *display_surface)
+{
+    scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
+
+       scmirroring_retvm_if(!__is_valid_handle(handle), SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink is invalid");
+
+       return _scmirroring_sink_set_display(handle->mm_handle, SCMIRRORING_DISPLAY_TYPE_OVERLAY, display_surface, MM_DISPLAY_TYPE_OVERLAY_EXT);
+}
index d1706017677b94acec291e257e42160584459e2b..7146b74affe6ee1cc2b0e2ac133a5f68ecd3ccec 100644 (file)
@@ -168,7 +168,7 @@ int _scmirroring_sink_disconnect(MMHandleType handle)
        return _scmirroring_error_convert(__func__, mm_wfd_sink_disconnect(handle));
 }
 
-int _scmirroring_sink_set_display(MMHandleType handle, scmirroring_display_type_e type, void *display_surface)
+int _scmirroring_sink_set_display(MMHandleType handle, scmirroring_display_type_e type, void *display_surface, mm_display_type_e display_type)
 {
        int ret = SCMIRRORING_ERROR_NONE;
 
@@ -176,25 +176,38 @@ int _scmirroring_sink_set_display(MMHandleType handle, scmirroring_display_type_
 
        scmirroring_retvm_if(!display_surface, SCMIRRORING_ERROR_INVALID_PARAMETER, "display_surface is NULL");
 
-       if ((type != SCMIRRORING_DISPLAY_TYPE_OVERLAY) && (type != SCMIRRORING_DISPLAY_TYPE_EVAS)) {
+       scmirroring_debug("display surface type(%d)", type);
+       scmirroring_debug("display type(%d)", display_type);
+
+       if (type >= SCMIRRORING_DISPLAY_TYPE_MAX) {
+               scmirroring_error("Invalid surface type [%d]", type);
+               return SCMIRRORING_ERROR_INVALID_PARAMETER;
+       }
+
+       if (display_type > MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
                scmirroring_error("Invalid display type [%d]", type);
                return SCMIRRORING_ERROR_INVALID_PARAMETER;
        }
 
-       scmirroring_debug("display type(%d)", type);
 
        ret = mm_wfd_sink_set_attribute(handle, NULL, "display_visible", TRUE, NULL);
        if (ret != MM_ERROR_NONE) {
-               scmirroring_error("Fail to Set Display Visible as TRUE");
+               scmirroring_error("Fail to set Display Visible as TRUE");
                return _scmirroring_error_convert(__func__, ret);
        }
 
-       ret = mm_wfd_sink_set_attribute(handle, NULL, "display_surface_type", type, NULL);
+       ret = mm_wfd_sink_set_attribute(handle, NULL, "display_type", display_type, NULL);
        if (ret != MM_ERROR_NONE) {
                scmirroring_error("Fail to Set Display Type");
                return _scmirroring_error_convert(__func__, ret);
        }
 
+       ret = mm_wfd_sink_set_attribute(handle, NULL, "display_surface_type", type, NULL);
+       if (ret != MM_ERROR_NONE) {
+               scmirroring_error("Fail to Set Display Surface Type");
+               return _scmirroring_error_convert(__func__, ret);
+       }
+
        ret = mm_wfd_sink_set_attribute(handle, NULL, "display_overlay", display_surface, sizeof(void *), NULL);
        if (ret != MM_ERROR_NONE) {
                scmirroring_error("Fail to Set Display Overlay");
@@ -575,5 +588,4 @@ int _scmirroring_server_launch(const char *server_name)
        scmirroring_debug("Miracast server is launched successfully");
 
        return ret;
-}
-
+}
\ No newline at end of file
index bb152ed8963ddd47250f5120c120c16dc0087e09..a67b502c61d7f97642b5e90cf2896ad6e27c3f0f 100755 (executable)
@@ -2,7 +2,7 @@ SET(fw_name "capi-media-screen-mirroring")
 SET(fw_test "${fw_name}-test-sink")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog capi-base-common mm-wfd capi-network-wifi-direct elementary evas appcore-efl)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog capi-base-common mm-wfd capi-network-wifi-direct elementary evas appcore-efl ecore ecore-wl2)
 FOREACH(flag ${${fw_test}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
index b278314c733fd47a198f4f4a09ac6fd293715d58..bdc6d5f59b653dde1f313cc1c2a62dc800dd09f5 100644 (file)
@@ -24,7 +24,8 @@
 
 #include <Elementary.h>
 #include <appcore-efl.h>
-
+#include <Ecore_Wayland2.h>
+#include <Ecore.h>
 #define MAX_STRING_LEN    2048
 #define SINKTEST_EXECUTE_DELAY 5000
 #define MAIN_MENU 0
@@ -32,7 +33,7 @@
 #define SUBMENU_GETTING_STREAM_INFO 2
 #define SUBMENU_SETTING_SINK 3
 #define SUBMENU_SETTING_WINDOW_SIZE 4
-
+//#define WL_DISPLAY
 //#define TEST_WITH_WIFI_DIRECT
 
 #define PACKAGE "screen_mirroring_sink_test"
@@ -56,6 +57,11 @@ static gint g_sinktype = SCMIRRORING_DISPLAY_TYPE_OVERLAY;
 
 static gint g_menu = MAIN_MENU;
 
+#ifdef WL_DISPLAY
+static Ecore_Wl2_Subsurface *g_ecore_wl2_subsurface = NULL;
+static Ecore_Wl2_Window *g_ecore_wl2_window = NULL;
+#endif
+
 #ifdef TEST_WITH_WIFI_DIRECT
 static int g_peer_cnt = 0;
 static char g_peer_ip[32];
@@ -1090,9 +1096,30 @@ static int __scmirroring_sink_create(gpointer data)
        }
        if (g_sinktype != -1) {
                if (g_sinktype == SCMIRRORING_DISPLAY_TYPE_OVERLAY) {
+#ifdef WL_DISPLAY
+                       g_print("display type is overlay\n");
+                       Eina_Bool res = EINA_FALSE;
+                       Ecore_Wl2_Window *ecore_wl2_win = (Ecore_Wl2_Window *)elm_win_wl_window_get(g_evas);
+                       Ecore_Wl2_Subsurface *ecore_wl2_subsurface = ecore_wl2_subsurface_new(ecore_wl2_win);
+                       g_ecore_wl2_window = ecore_wl2_win;
+                       res = ecore_wl2_subsurface_export(ecore_wl2_subsurface);
+                       if (res != EINA_TRUE) {
+                               g_print("failed to export foreign shell");
+                       }
+                       ecore_wl2_subsurface_exported_surface_sync_set(ecore_wl2_subsurface, EINA_TRUE);
+                       ecore_wl2_subsurface_exported_surface_place_below(ecore_wl2_subsurface, NULL);
+                       ecore_wl2_subsurface_exported_surface_move(ecore_wl2_subsurface, 200, 200);
+                       ecore_wl2_subsurface_exported_surface_resize(ecore_wl2_subsurface, 500, 500);
+                       ecore_wl2_subsurface_exported_surface_show(ecore_wl2_subsurface);
+                       ecore_wl2_subsurface_exported_surface_commit(ecore_wl2_subsurface);
+                       g_ecore_wl2_subsurface = ecore_wl2_subsurface;
+                       ret = scmirroring_sink_set_ecore_wl_display(g_scmirroring, (void *)g_ecore_wl2_window);
+#else
                        evas_object_show(g_evas);
                        ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_OVERLAY, (void *)g_evas);
+#endif
                } else if (g_sinktype == SCMIRRORING_DISPLAY_TYPE_EVAS) {
+                       g_print("display type is evas\n");
                        g_eo = create_evas_image_object(g_evas);
                        evas_object_image_size_set(g_eo, 800, 1200);
                        evas_object_image_fill_set(g_eo, 0, 0, 800, 1200);