webrtc_source: Remove 'Elementary' dependency with a compiling option 88/278488/4
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 21 Jul 2022 05:36:57 +0000 (14:36 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 22 Jul 2022 00:39:37 +0000 (09:39 +0900)
To remove the 'Elementary' dependency, pass an option of gbs build below.
--define "without_ui 1"

[Version] 0.3.160
[Issue Type] Dependency

Change-Id: I8475675970e77017ae58d691ee68bf739d58dad9
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
CMakeLists.txt
include/webrtc_source_private.h
packaging/capi-media-webrtc.spec
src/webrtc_internal.c
src/webrtc_source.c
src/webrtc_source_screen.c

index e1a3e194505bd7fa740eccfff406eca111a68ce4..49f4ee876a592fdf989242b19bad2a83c0226e07 100644 (file)
@@ -12,12 +12,16 @@ INCLUDE_DIRECTORIES(${INC_DIR})
 
 SET(dependents "dlog glib-2.0 gstreamer-1.0 gstreamer-webrtc-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 \
                 gstreamer-allocators-1.0 libpulse json-glib-1.0 iniparser mm-common mm-display-interface capi-media-tool \
-                libtbm libwebsockets cynara-client libsmack capi-system-info libsoup-2.4 bundle capi-media-sound-manager elementary")
+                libtbm libwebsockets cynara-client libsmack capi-system-info libsoup-2.4 bundle capi-media-sound-manager")
 IF(NOT TIZEN_PROFILE_TV)
     SET(dependents "${dependents} mm-resource-manager")
 ELSE()
     ADD_DEFINITIONS("-DTIZEN_TV")
 ENDIF()
+IF(TIZEN_FEATURE_UI)
+    SET(dependents "${dependents} elementary")
+    ADD_DEFINITIONS("-DTIZEN_FEATURE_UI")
+ENDIF()
 
 SET(pc_dependents "capi-base-common capi-media-sound-manager capi-media-tool bundle" )
 
@@ -40,13 +44,17 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 AUX_SOURCE_DIRECTORY (src MAIN_SRC)
 
-LIST (APPEND SOURCES
+LIST(APPEND SOURCES
      ${MAIN_SRC}
 )
 IF(TIZEN_PROFILE_TV)
-    LIST (REMOVE_ITEM SOURCES src/webrtc_resource.c)
+    LIST(REMOVE_ITEM SOURCES src/webrtc_resource.c)
+ENDIF()
+IF(NOT TIZEN_FEATURE_UI)
+    LIST(REMOVE_ITEM SOURCES src/webrtc_source_screen.c)
 ENDIF()
 
+
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
 
 TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
index 48a60cc0cf74757c6a1de1e67b72a2b2d3e1431e..7bacbaa2245fc7ce19c63ea3f8826d45adce929e 100644 (file)
@@ -79,5 +79,6 @@ GstCaps *_get_caps_from_encoded_video_media_type(const char *media_type, int wid
 unsigned int _get_available_payload_type(webrtc_s *webrtc);
 GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source);
 int _set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_type);
+int _get_screen_resolution(int *width, int *height);
 
 #endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */
index dad4dd69f766750d73bb038121b105e050d2399f..99c635e8488bc17a994b4f3d4cee1c489a6bf360 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.159
+Version:    0.3.160
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -79,9 +79,14 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 -DTIZEN_PROFILE_TV=off \
 %endif
 %if "%{test_espp_render}" == "1"
--DTIZEN_FEATURE_ESPP=on
+-DTIZEN_FEATURE_ESPP=on \
 %else
--DTIZEN_FEATURE_ESPP=off
+-DTIZEN_FEATURE_ESPP=off \
+%endif
+%if "%{without_ui}" == "1"
+-DTIZEN_FEATURE_UI=off
+%else
+-DTIZEN_FEATURE_UI=on
 %endif
 
 make %{?jobs:-j%jobs}
index e5f1f9ff8e194642179f50b8762fe092f7a66f2b..9845d6447478c03670a2718d5e930c8be9e84a64 100644 (file)
@@ -95,7 +95,12 @@ int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x
 
        locker = g_mutex_locker_new(&_webrtc->mutex);
 
+#ifdef TIZEN_FEATURE_UI
        return _set_screen_source_crop(_webrtc, source_id, x, y, w, h, portrait_mode, width, height);
+#else
+       LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
+       return WEBRTC_ERROR_INVALID_OPERATION;
+#endif
 }
 
 int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id)
@@ -109,7 +114,12 @@ int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id)
 
        locker = g_mutex_locker_new(&_webrtc->mutex);
 
+#ifdef TIZEN_FEATURE_UI
        return _unset_screen_source_crop(_webrtc, source_id);
+#else
+       LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
+       return WEBRTC_ERROR_INVALID_OPERATION;
+#endif
 }
 
 int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability)
index 0d59ff7852d19a304a7a0174be438b2188425939..ecb78ed7562b26d05f9531e51aeac8e574bd4c93 100644 (file)
@@ -22,7 +22,6 @@
 #include "webrtc_source_private.h"
 
 #include <tbm_surface_internal.h>
-#include <Elementary.h>
 #include <sound_manager_internal.h>
 
 #define MIN_DYNAMIC_PAYLOAD_TYPE             96
@@ -602,28 +601,22 @@ static bool __set_default_video_info(webrtc_gst_slot_s *source, const ini_item_m
        source->video_info.height = ini_source->v_height;
 
        if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN) {
-               Evas_Object *eo = NULL;
+#ifdef TIZEN_FEATURE_UI
                int width = 0;
                int height = 0;
 
-               eo = elm_win_add(NULL, "screen_source", ELM_WIN_BASIC);
-               if (!eo) {
-                       LOG_WARNING("failed to add window to get screen size. use values of ini");
-                       return true;
-               }
-
-               elm_win_screen_size_get(eo, NULL, NULL, &width, &height);
-               LOG_DEBUG("window size: %d x %d", width, height);
-
-               if (width == 0 || height == 0) {
-                       LOG_WARNING("failed to get screen size. use values of ini");
-                       return true;
+               if (_get_screen_resolution(&width, &height) != WEBRTC_ERROR_NONE) {
+                       if (width == 0 || height == 0) {
+                               LOG_WARNING("failed to _get_screen_resolution(). use values of ini");
+                               return true;
+                       }
                }
-
                source->video_info.width = width;
                source->video_info.height = height;
+#else
+               LOG_WARNING("TIZEN_FEATURE_UI is disabled, skip this function, use values of ini");
+#endif
        }
-
        return true;
 }
 
@@ -2216,6 +2209,12 @@ int _add_media_source(webrtc_s *webrtc, int type, unsigned int *source_id)
 
        if (type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)
                return __add_null_source(webrtc, source_id);
+#ifndef TIZEN_FEATURE_UI
+       if (type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN) {
+               LOG_ERROR("TIZEN_FEATURE_UI is disabled, screen source is not supported");
+               return WEBRTC_ERROR_INVALID_OPERATION;
+       }
+#endif
 
        return __add_media_source(webrtc, type, source_id);
 }
index b8a7b5300238e41154a26c405b175d5cb2986c24..8e43899468795e791faee676fb605db13e427141 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "webrtc_private.h"
 #include "webrtc_source_private.h"
+#include <Elementary.h>
 
 //LCOV_EXCL_START
 int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, bool portrait_mode, int *width, int *height)
@@ -120,4 +121,28 @@ int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id)
        return WEBRTC_ERROR_NONE;
 }
 
+int _get_screen_resolution(int *width, int *height)
+{
+       Evas_Object *eo;
+       int _width;
+       int _height;
+
+       RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
+       RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
+
+       eo = elm_win_add(NULL, "screen_source", ELM_WIN_BASIC);
+       if (!eo) {
+               LOG_ERROR("failed to elm_win_add()");
+               return WEBRTC_ERROR_INVALID_OPERATION;
+       }
+
+       elm_win_screen_size_get(eo, NULL, NULL, &_width, &_height);
+       LOG_DEBUG("window size: %d x %d", _width, _height);
+
+       *width = _width;
+       *height = _height;
+
+       return WEBRTC_ERROR_NONE;
+}
+
 //LCOV_EXCL_STOP
\ No newline at end of file