[Mirroring][Add] Add internal api for checking screen mirroring sink state. 20/136120/13 accepted/tizen/unified/20170712.164859 submit/tizen/20170705.004233 submit/tizen/20170710.075343
authorHyunsoo <hance.park@samsung.com>
Wed, 28 Jun 2017 06:39:48 +0000 (15:39 +0900)
committerHyunsoo <hance.park@samsung.com>
Tue, 4 Jul 2017 06:47:25 +0000 (15:47 +0900)
-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 <hance.park@samsung.com>
include/scmirroring_internal.h
packaging/capi-media-screen-mirroring.spec
src/scmirroring_sink_internal.c [new file with mode: 0644]

index ece8e68c82615e8ebb0df5763cdac1e2f89e8877..0c5b29f47e40ffc02d88b2452110ec4279805552 100644 (file)
@@ -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 */
index 4ee301880d0ade0b56ce1d9e814608676f468e3d..c3f7aaf465174d2b584cf3825c1e6a349fcb2504 100644 (file)
@@ -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 (file)
index 0000000..63ddc2d
--- /dev/null
@@ -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 <stdio.h>
+#include <mmf/mm_wfd_sink.h>
+#include <scmirroring_sink.h>
+#include <scmirroring_internal.h>
+#include <scmirroring_private.h>
+
+
+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