[4.0] Remove Profile Build Dependency: Do it at runtime 94/98894/4 accepted/tizen/common/20161129.173637 accepted/tizen/ivi/20161130.015441 accepted/tizen/mobile/20161130.015221 accepted/tizen/tv/20161130.015306 submit/tizen/20161129.052917
authorhk57.kim <hk57.kim@samsung.com>
Mon, 21 Nov 2016 06:19:56 +0000 (15:19 +0900)
committerSeokHoon Lee <andy.shlee@samsung.com>
Fri, 25 Nov 2016 08:49:16 +0000 (17:49 +0900)
- This is for Tizen 4.0.

  : Tizen 4.0 Configurability and Build Blocks require
  to remove all profile-depending build options in spec files.
  (No More profile macros)

- It is recommended to distinguish features/profiles at runtime.
 unless it incurs too much overhead, which requires you to
 create multiple binaries and subpackages.

Change-Id: I24bf74bbdf7bbf55e687f404c078ee4ec19a5b11
Signed-off-by: hk57.kim <hk57.kim@samsung.com>
configure.ac
packaging/libmm-wfd.spec
src/Makefile.am
src/include/mm_wfd_sink_config.h [new file with mode: 0755]
src/mm_wfd_sink_config.c [new file with mode: 0644]
src/mm_wfd_sink_priv.c

index 8488f12..a78a071 100755 (executable)
@@ -93,6 +93,10 @@ PKG_CHECK_MODULES(TZPLATFORM_CONFIG, libtzplatform-config)
 AC_SUBST(TZPLATFORM_CONFIG_CFLAGS)
 AC_SUBST(TZPLATFORM_CONFIG_LIBS)
 
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
+AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS)
+AC_SUBST(CAPI_SYSTEM_INFO_LIBS)
+
 # for testsuite
 
 AC_ARG_ENABLE(sdk, AC_HELP_STRING([--enable-sdk], [sdk build]),
index 99c4101..edd96cb 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.2.212
+Version:    0.2.213
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -20,23 +20,20 @@ BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(ecore-wayland)
 BuildRequires: pkgconfig(libtbm)
 BuildRequires: pkgconfig(libtzplatform-config)
-
+BuildRequires: pkgconfig(capi-system-info)
 BuildRoot:  %{_tmppath}/%{name}-%{version}-build
-
 %description
 
 %package devel
 Summary:    Multimedia Framework Wifi-Display Library (DEV)
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
-
 %description devel
 
 %package factory
 Summary:    Multimedia Framework Wifi-Display Library (Factory)
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
-
 %description factory
 
 %prep
@@ -49,9 +46,6 @@ export CFLAGS+=" -Wwrite-strings -Wswitch-default"
 export CFLAGS+=" -DSYSCONFDIR=\\\"%{_sysconfdir}\\\""
 ./autogen.sh
 
-%if "%{?profile}" == "tv"
-CFLAGS+=" -DUSE_EXTERNAL_WL_DISPLAY_HANDLE"
-%endif
 CFLAGS+=" -DMMFW_DEBUG_MODE -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" "; export CFLAGS
 LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--hash-style=both -Wl,--as-needed"; export LDFLAGS
 
@@ -64,6 +58,7 @@ make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
+
 %make_install
 mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/dbus-1/services/
 mkdir -p %{buildroot}/%{_datadir}/license
@@ -88,6 +83,7 @@ rm -rf %{buildroot}
 %defattr(-,root,root,-)
 %{_libdir}/*.so
 %{_includedir}/mmf/mm_wfd_sink.h
+%{_includedir}/mmf/mm_wfd_sink_config.h
 %{_includedir}/mmf/mm_wfd_sink_priv.h
 %{_includedir}/mmf/mm_wfd_sink_dlog.h
 %{_includedir}/mmf/mm_wfd_sink_util.h
index ee9c464..cf6cabd 100644 (file)
@@ -4,6 +4,7 @@ includelibmmfwfdsinkdir = $(includedir)/mmf
 
 includelibmmfwfdsink_HEADERS = include/mm_wfd_sink.h \
                                include/mm_wfd_sink_ini.h \
+                               include/mm_wfd_sink_config.h \
                                include/mm_wfd_sink_priv.h \
                                include/mm_wfd_sink_dlog.h \
                                include/mm_wfd_sink_attrs.h \
@@ -15,6 +16,7 @@ libmmfwfdsink_la_SOURCES = mm_wfd_sink_attrs.c \
                                mm_wfd_sink_util.c \
                                mm_wfd_sink.c \
                                mm_wfd_sink_manager.c \
+                               mm_wfd_sink_config.c \
                                mm_wfd_sink_priv.c \
                                mm_wfd_sink_wayland.c
 
@@ -27,6 +29,7 @@ libmmfwfdsink_la_CFLAGS = -I$(srcdir)/include \
                        $(GST_PLUGINS_BASE_CFLAGS) \
                        $(GST_VIDEO_CFLAGS) \
                        $(TZPLATFORM_CONFIG_CFLAGS) \
+                       $(CAPI_SYSTEM_INFO_CFLAGS) \
                        $(AUDIOSESSIONMGR_CFLAGS)
 
 libmmfwfdsink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
@@ -42,6 +45,7 @@ libmmfwfdsink_la_LIBADD = $(GST_LIBS) \
                        $(MMCOMMON_LIBS) \
                        $(AUDIOSESSIONMGR_LIBS) \
                        $(TZPLATFORM_CONFIG_LIBS) \
+                       $(CAPI_SYSTEM_INFO_LIBS) \
                        $(GST_VIDEO_LIBS)
 
 libmmfwfdsink_la_CFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x02000000 -DMMF_DEBUG_PREFIX=\"MMF-WFD-SINK\"
diff --git a/src/include/mm_wfd_sink_config.h b/src/include/mm_wfd_sink_config.h
new file mode 100755 (executable)
index 0000000..9636491
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 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.
+ *
+ */
+
+typedef enum {
+       TIZEN_PROFILE_UNKNOWN = 0,
+       TIZEN_PROFILE_MOBILE = 0x1,
+       TIZEN_PROFILE_WEARABLE = 0x2,
+       TIZEN_PROFILE_TV = 0x4,
+       TIZEN_PROFILE_IVI = 0x8,
+       TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+extern tizen_profile_t _get_tizen_profile();
+
+#define USE_EXTERNAL_WL_DISPLAY_HANDLE (_get_tizen_profile() & (TIZEN_PROFILE_TV))
+
diff --git a/src/mm_wfd_sink_config.c b/src/mm_wfd_sink_config.c
new file mode 100644 (file)
index 0000000..0644d8d
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 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.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <system_info.h>
+#include "mm_wfd_sink_config.h"
+
+
+tizen_profile_t _get_tizen_profile()
+{
+       static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       char *profileName;
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+               case 'm':
+               case 'M':
+                       profile = TIZEN_PROFILE_MOBILE;
+                       break;
+               case 'w':
+               case 'W':
+                       profile = TIZEN_PROFILE_WEARABLE;
+                       break;
+               case 't':
+               case 'T':
+                       profile = TIZEN_PROFILE_TV;
+                       break;
+               case 'i':
+               case 'I':
+                       profile = TIZEN_PROFILE_IVI;
+                       break;
+               default: // common or unknown ==> ALL ARE COMMON.
+                       profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
index 4512305..35a96c1 100644 (file)
@@ -31,6 +31,7 @@
 #include "mm_wfd_sink_dlog.h"
 #include "mm_wfd_sink_enum.h"
 #include "mm_wfd_sink_wayland.h"
+#include "mm_wfd_sink_config.h"
 
 #define PRINT_WFD_REF_COUNT(wfd_sink)\
        do {\
@@ -4026,13 +4027,15 @@ static int __mm_wfd_sink_prepare_videosink(mm_wfd_sink_t *wfd_sink, GstElement *
                                                }
                                        }
                                        wfd_sink_debug("set video param : surface_id %d", wl_surface_id);
-#ifdef USE_EXTERNAL_WL_DISPLAY_HANDLE
-                                       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink),
+
+                                       if(USE_EXTERNAL_WL_DISPLAY_HANDLE) {
+                                               gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink),
                                                                                                                wl_surface_id);
-#else
-                                       gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(video_sink),
+                                       }
+                                       else {
+                                               gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(video_sink),
                                                                                                                                wl_surface_id);
-#endif
+                                       }
 
                                        /* After setting window handle, set render rectangle */
                                        gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(video_sink),