From: Volodymyr Brynza Date: Fri, 9 Sep 2016 14:09:31 +0000 (+0300) Subject: [v0.1.8] add implementation of feature check when create node X-Git-Tag: submit/tizen/20160928.043825~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4d258af1cddc3dcafd6d396a641e5796231e68c;p=platform%2Fcore%2Fapi%2Fmediastreamer.git [v0.1.8] add implementation of feature check when create node Change-Id: I48eee1b3378a9b49bb59978552a52dc46f9b68fe Signed-off-by: Volodymyr Brynza --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e56979..c87ed30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog glib-2.0 mm-common capi-media-tool iniparser bundle libtbm gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 cynara-client") -SET(pc_dependents "capi-base-common capi-media-tool gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 cynara-client") +SET(dependents "dlog glib-2.0 mm-common capi-media-tool iniparser bundle libtbm gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 cynara-client capi-system-info") +SET(pc_dependents "capi-base-common capi-media-tool gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 cynara-client capi-system-info") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) diff --git a/doc/mediastreamer_doc.h b/doc/mediastreamer_doc.h index 3d07310..117e05b 100755 --- a/doc/mediastreamer_doc.h +++ b/doc/mediastreamer_doc.h @@ -25,16 +25,35 @@ /** * @ingroup CAPI_MEDIA_FRAMEWORK * @defgroup CAPI_MEDIA_STREAMER_MODULE Media Streamer - * @brief The @ref CAPI_MEDIA_STREAMER_MODULE APIs provides functions for building custom pipeline + * @brief The @ref CAPI_MEDIA_STREAMER_MODULE APIs provides functions for building custom player * * @section CAPI_MEDIA_STREAMER_MODULE_HEADER Required Header * \#include * * @section CAPI_MEDIA_STREAMER_MODULE_OVERVIEW Overview + * The Media Streamer API allows application developers to construct the custom player. + * It includes provides a way to handle media content by user speicific player. * * MEDIASTREAMER allows : - * Create streamer handle and elements to build custom pipeline. - * Application can create, add and link elements manually. + * - Application can decide input type of media source. + * - Application can decide output type of media content. + * - Application can create filter nodes considering requirements. + * - Application can set/get properties of each nodes. + * + * The Media Streamer API also notifies you by callback mechanism when state is changed. + * + * @section CAPI_MEDIA_STREAMER_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.wifi\n + * - http://tizen.org/feature/network.telephony\n + * - http://tizen.org/feature/network.ethernet\n + * - http://tizen.org/feature/camera\n + * - http://tizen.org/feature/microphone + * + * It is recommended to design feature related codes in your application for reliability.\n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * More details on featuring your application can be found from Feature Element. * */ diff --git a/include/media_streamer.h b/include/media_streamer.h index bff337e..2b3f9c7 100644 --- a/include/media_streamer.h +++ b/include/media_streamer.h @@ -103,7 +103,7 @@ typedef enum { MEDIA_STREAMER_NODE_SRC_TYPE_AUDIO_TEST, /**< Audio test src type */ MEDIA_STREAMER_NODE_SRC_TYPE_VIDEO_TEST, /**< Video test src type */ MEDIA_STREAMER_NODE_SRC_TYPE_CUSTOM, /**< Custom src type */ - MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE /**< Adaptive src type */ + MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE /**< Adaptive src type, Network internet feature is required */ } media_streamer_node_src_type_e; /** @@ -121,7 +121,7 @@ typedef enum { MEDIA_STREAMER_NODE_SINK_TYPE_EVAS, /**< EVAS sink type */ MEDIA_STREAMER_NODE_SINK_TYPE_FAKE, /**< Fake sink type */ MEDIA_STREAMER_NODE_SINK_TYPE_CUSTOM, /**< Custom sink type */ - MEDIA_STREAMER_NODE_SINK_TYPE_ADAPTIVE /**< Adaptive sink type */ + MEDIA_STREAMER_NODE_SINK_TYPE_ADAPTIVE /**< Adaptive sink type to generate fragmented files */ } media_streamer_node_sink_type_e; /** @@ -148,7 +148,7 @@ typedef enum { MEDIA_STREAMER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ MEDIA_STREAMER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ MEDIA_STREAMER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on the device */ - MEDIA_STREAMER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + MEDIA_STREAMER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< The feature is not supported */ MEDIA_STREAMER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ MEDIA_STREAMER_ERROR_INVALID_STATE = TIZEN_ERROR_MEDIA_STREAMER | 0x01, /**< Invalid state */ MEDIA_STREAMER_ERROR_CONNECTION_FAILED = TIZEN_ERROR_MEDIA_STREAMER | 0x02, /**< Connection failed */ diff --git a/packaging/capi-media-streamer.spec b/packaging/capi-media-streamer.spec index d0c2ad1..22d40d3 100644 --- a/packaging/capi-media-streamer.spec +++ b/packaging/capi-media-streamer.spec @@ -1,6 +1,6 @@ Name: capi-media-streamer -Summary: A Media Streamer library in Tizen Native API -Version: 0.1.7 +Summary: A Media Streamer API +Version: 0.1.8 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -21,13 +21,14 @@ BuildRequires: pkgconfig(gstreamer-app-1.0) BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(capi-system-info) %description A MediaStreamer library in Tizen Native API. %package devel -Summary: Multimedia Streamer Library in Tizen Native API (Development) -Group: TO_BE/FILLED_IN +Summary: Multimedia Streamer API (Development) +Group: Multimedia/Development Requires: %{name} = %{version}-%{release} %description devel diff --git a/src/media_streamer_node.c b/src/media_streamer_node.c index b509e03..efd7905 100644 --- a/src/media_streamer_node.c +++ b/src/media_streamer_node.c @@ -18,6 +18,7 @@ #include #include #include +#include #define SMACK_LABEL_LEN 255 #define DEFAULT_URI_SCHEME_LENGTH 10 @@ -373,6 +374,118 @@ static int __ms_node_check_priveleges(media_streamer_node_s *node) return ret; } +static int __ms_node_check_feature(media_streamer_node_s *node) +{ +#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" +#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony" +#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet" +#define _FEATURE_NAME_CAMERA "http://tizen.org/feature/camera" +#define _FEATURE_NAME_MICROPHONE "http://tizen.org/feature/microphone" + + int ret = MEDIA_STREAMER_ERROR_NONE; + bool enabled = FALSE; + bool supported = FALSE; + + if (node->type == MEDIA_STREAMER_NODE_TYPE_SRC) { + switch (node->subtype) { + case MEDIA_STREAMER_NODE_SRC_TYPE_HTTP: + case MEDIA_STREAMER_NODE_SRC_TYPE_RTSP: + case MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE: + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) { + ms_info("wifi status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) { + ms_info("telephony status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) { + ms_info("ethernet status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + if (!supported) + ret = MEDIA_STREAMER_ERROR_NOT_SUPPORTED; + break; + case MEDIA_STREAMER_NODE_SRC_TYPE_AUDIO_CAPTURE: + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_MICROPHONE, &enabled)) { + ms_info("ethernet status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + if (!supported) + ret = MEDIA_STREAMER_ERROR_NOT_SUPPORTED; + break; + case MEDIA_STREAMER_NODE_SRC_TYPE_CAMERA: + case MEDIA_STREAMER_NODE_SRC_TYPE_VIDEO_CAPTURE: + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_CAMERA, &enabled)) { + ms_info("ethernet status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + if (!supported) + ret = MEDIA_STREAMER_ERROR_NOT_SUPPORTED; + break; + default: + ms_info("For current Src Node [%s] subtype [%d] privileges are not needed", node->name, node->subtype); + break; + } + } + + if (node->type == MEDIA_STREAMER_NODE_TYPE_SINK) { + switch (node->subtype) { + case MEDIA_STREAMER_NODE_SINK_TYPE_HTTP: + case MEDIA_STREAMER_NODE_SINK_TYPE_RTSP: + /* case MEDIA_STREAMER_NODE_SINK_TYPE_ADAPTIVE: */ + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) { + ms_info("wifi status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) { + ms_info("telephony status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) { + ms_info("ethernet status = %d", enabled); + if (enabled) + supported = TRUE; + } else { + ms_error("SYSTEM_INFO_ERROR"); + } + if (!supported) + ret = MEDIA_STREAMER_ERROR_NOT_SUPPORTED; + break; + default: + ms_info("For current Sink Node [%s] subtype [%d] privileges are not needed", node->name, node->subtype); + break; + } + } + + return ret; +} + int __ms_src_node_create(media_streamer_node_s *node) { ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL"); @@ -386,6 +499,12 @@ int __ms_src_node_create(media_streamer_node_s *node) return ret; } + ret = __ms_node_check_feature(node); + if (ret != MEDIA_STREAMER_ERROR_NONE) { + ms_error("Error getting feature for Src Node"); + return ret; + } + switch (node->subtype) { case MEDIA_STREAMER_NODE_SRC_TYPE_FILE: plugin_name = __ms_ini_get_string("node type 1:file", DEFAULT_FILE_SOURCE); @@ -489,6 +608,12 @@ int __ms_sink_node_create(media_streamer_node_s *node) return ret; } + ret = __ms_node_check_feature(node); + if (ret != MEDIA_STREAMER_ERROR_NONE) { + ms_error("Error getting feature for Sink Node"); + return ret; + } + switch (node->subtype) { case MEDIA_STREAMER_NODE_SINK_TYPE_FILE: plugin_name = __ms_ini_get_string("node type 2:file", DEFAULT_FILE_SINK);