From: Hyunsoo Date: Wed, 28 Jun 2017 06:39:48 +0000 (+0900) Subject: [Mirroring][Add] Add internal api for checking screen mirroring sink state. X-Git-Tag: submit/tizen/20170705.004233^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76d94ebee15199519a60406e2214bdce8ab51554;p=platform%2Fcore%2Fapi%2Fscreen-mirroring.git [Mirroring][Add] Add internal api for checking screen mirroring sink state. -Initial version. -It returns screen mirorring sink state when it is called. -It will be more robust after about exception case. [Version] 0.1.81 [Profile] Common [Issue Type] Add internal api [Dependency module] libmm-wfd, https://review.tizen.org/gerrit/#/c/136123/ [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20170620.1] Change-Id: I7ccb481f37ce2e367d488757b583f155c906fb80 Signed-off-by: Hyunsoo --- diff --git a/include/scmirroring_internal.h b/include/scmirroring_internal.h index ece8e68..0c5b29f 100644 --- a/include/scmirroring_internal.h +++ b/include/scmirroring_internal.h @@ -72,6 +72,13 @@ typedef enum { */ typedef void(*scmirroring_state_cb)(scmirroring_error_e error, scmirroring_state_e state, void *user_data); +/** + * @brief Gets state of screen mirroring sink. + * + * @param[in] scmirroring_sink The screen mirroring object + @param[out] state The screen mirroring state + */ +int scmirroring_sink_get_state(scmirroring_sink_h scmirroring_sink, scmirroring_sink_state_e *state); #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/packaging/capi-media-screen-mirroring.spec b/packaging/capi-media-screen-mirroring.spec index 4ee3018..c3f7aaf 100644 --- a/packaging/capi-media-screen-mirroring.spec +++ b/packaging/capi-media-screen-mirroring.spec @@ -1,6 +1,6 @@ Name: capi-media-screen-mirroring Summary: A screen mirroring library in Tizen C API -Version: 0.1.81 +Version: 0.1.82 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/scmirroring_sink_internal.c b/src/scmirroring_sink_internal.c new file mode 100644 index 0000000..63ddc2d --- /dev/null +++ b/src/scmirroring_sink_internal.c @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2017 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 +#include +#include +#include +#include + + +static scmirroring_error_e __scmirroring_sink_error_convert(const char *func, int error) +{ + int ret = SCMIRRORING_ERROR_NONE; + const char *errorstr = NULL; + + switch (error) { + case MM_ERROR_NONE: + ret = SCMIRRORING_ERROR_NONE; + errorstr = "ERROR_NONE"; + break; + + case MM_ERROR_WFD_NO_FREE_SPACE: + ret = SCMIRRORING_ERROR_OUT_OF_MEMORY; + errorstr = "OUT_OF_MEMORY"; + break; + + case MM_ERROR_WFD_NOT_INITIALIZED: + case MM_ERROR_COMMON_INVALID_ATTRTYPE: + case MM_ERROR_COMMON_INVALID_PERMISSION: + case MM_ERROR_COMMON_OUT_OF_ARRAY: + case MM_ERROR_COMMON_OUT_OF_RANGE: + case MM_ERROR_COMMON_ATTR_NOT_EXIST: + ret = SCMIRRORING_ERROR_INVALID_PARAMETER; + errorstr = "INVALID_PARAMETER"; + break; + + default: + ret = SCMIRRORING_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + } + + if (ret != SCMIRRORING_ERROR_NONE) + scmirroring_error("[%s] %s (0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, error); + else + scmirroring_debug("[%s] %s", func, errorstr); + + return ret; +} + + +static scmirroring_sink_state_e __scmirroring_sink_state_convert(MMWFDSinkStateType mm_state) +{ + scmirroring_sink_state_e temp_state = SCMIRRORING_SINK_STATE_NONE; + + switch (mm_state) { + case MM_WFD_SINK_STATE_NONE: + temp_state = SCMIRRORING_SINK_STATE_NONE; + break; + case MM_WFD_SINK_STATE_NULL: + temp_state = SCMIRRORING_SINK_STATE_NULL; + break; + case MM_WFD_SINK_STATE_PREPARED: + temp_state = SCMIRRORING_SINK_STATE_PREPARED; + break; + case MM_WFD_SINK_STATE_CONNECTED: + temp_state = SCMIRRORING_SINK_STATE_CONNECTED; + break; + case MM_WFD_SINK_STATE_PLAYING: + temp_state = SCMIRRORING_SINK_STATE_PLAYING; + break; + case MM_WFD_SINK_STATE_PAUSED: + temp_state = SCMIRRORING_SINK_STATE_PAUSED; + break; + case MM_WFD_SINK_STATE_DISCONNECTED: + temp_state = SCMIRRORING_SINK_STATE_DISCONNECTED; + break; + default: + temp_state = SCMIRRORING_SINK_STATE_NONE; + scmirroring_debug("In default case, MMWFDSinkStateType is [%d]", mm_state); + break; + } + + return temp_state; +} + +int scmirroring_sink_get_state(scmirroring_sink_h scmirroring_sink, scmirroring_sink_state_e *state) +{ + int result = MM_ERROR_NONE; + int mm_state = MM_WFD_SINK_STATE_NONE; + scmirroring_sink_s *handle = (scmirroring_sink_s *)(scmirroring_sink); + + scmirroring_debug_fenter(); + scmirroring_retvm_if(scmirroring_sink == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink* is NULL"); + scmirroring_retvm_if(state == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "state is NULL"); + scmirroring_retvm_if(handle->magic_num != SCMIRRORING_MAGIC_NUMBER, SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink is invalid handle"); + + result = mm_wfd_sink_get_state(handle->mm_handle, &mm_state); + if (result == MM_ERROR_NONE) { + *state = __scmirroring_sink_state_convert(mm_state); + scmirroring_debug("ScreenMirroring state is [%d]", *state); + } + scmirroring_debug_fleave(); + + return __scmirroring_sink_error_convert(__func__, result); +} \ No newline at end of file