--- /dev/null
+/*
+* 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