Remove ‘MM_WFD_SINK_UNKNOWN’ enum and add create apis for primary / secondary sink. 58/194358/11
authorHyunsoo Park <hance.park@samsung.com>
Mon, 3 Dec 2018 11:16:08 +0000 (20:16 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Thu, 20 Dec 2018 01:20:44 +0000 (10:20 +0900)
- MM_WFD_SINK_UNKNOWN is not needed.
- For seperate operation of between R1 and R2 sink, i added create api 'mm_wfd_create_r2'
- change ‘status’ parameter return type gint to MMWFDCoupledSinkStatus

Change-Id: I7995e1d96f349186bbb2636193e7f61b79eb68c1
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
src/include/mm_wfd_sink.h
src/include/mm_wfd_sink_priv.h
src/mm_wfd_sink.c
src/mm_wfd_sink_priv.c

index 977ebaa..458827e 100644 (file)
@@ -65,11 +65,10 @@ typedef enum {
 } MMWFDSinkVideoCodec;
 
 typedef enum {
-  MM_WFD_SINK_UNKNOWN = -1,
-  MM_WFD_SINK_NOT_COUPLED      = 0,
-  MM_WFD_SINK_COUPLED,
-  MM_WFD_SINK_TEARDOWN_COUPLING,
-  MM_WFD_SINK_RESERVED
+  MM_WFD_COUPLED_SINK_STATUS_NOT_COUPLED       = 0,
+  MM_WFD_COUPLED_SINK_STATUS_COUPLED,
+  MM_WFD_COUPLED_SINK_STATUS_TEARDOWN_COUPLING,
+  MM_WFD_COUPLED_SINK_STATUS_RESERVED
 } MMWFDCoupledSinkStatus;
 
 typedef void(*MMWFDMessageCallback)(int error_type, MMWFDSinkStateType state_type, void *user_data);
@@ -104,6 +103,14 @@ mm_wfd_sink_set_message_callback(g_wfd_sink_handle, msg_callback, (void*)g_wfd_s
 int mm_wfd_sink_create(MMHandleType *wfd_sink);
 
 /**
+ * This function creates a wi-fi display wi-fi display R2 sink object. \n
+ * Description is same to 'mm_wfd_sink_create' but 'wfd_sink' parameter should be handle of wi-fi display R2(primary/secondary) sink. \n
+ *
+ * @param      wfd_sink                [out]   Handle of wi-fi display R2(primary/secondary) sink
+ */
+int mm_wfd_sink_create_r2(MMHandleType *wfd_sink);
+
+/**
  * This function trys to make gstreamer pipeline. \n
  * If wi-fi display sink is realized, the state will become MM_WFD_SINK_STATE_READY.. \n
  *
@@ -490,15 +497,14 @@ int mm_wfd_sink_get_negotiated_audio_bitwidth(MMHandleType wfd_sink_handle,  gin
 int mm_wfd_sink_get_current_state(MMHandleType wfd_sink_handle, gint *state);
 
 /**
- * This function sets the coupled sink ip to sink\n
+ * This function sets the MAC address of wi-fi display sink for coupling wi-fi display sink.\n
  *
  * @param   wfd_sink_handle     [in]    Handle of wi-fi display sink
- * @param   status              [in]   Status which present the status of a wi-fi display sink's coupling with another wi-fi display sink
  * @param   address             [in]   Mac address of coupled wi-fi display sink.
  *
  * @return  This function returns zero on success, or negative value with error code.
  *
  */
-int mm_wfd_sink_set_coupled_sink(MMHandleType wfd_sink_handle, gint status, gchar* address);
+int mm_wfd_sink_set_coupled_sink(MMHandleType wfd_sink_handle, gchar* address);
 
 #endif
index 9af7129..cafd401 100644 (file)
@@ -251,6 +251,7 @@ typedef struct {
 
        guint coupled_sink_status;
        gchar *coupled_sink_address;
+       gboolean is_coupled_sink_supported;
 } mm_wfd_sink_t;
 
 
index 1b75c55..746e9a7 100644 (file)
@@ -54,6 +54,22 @@ int mm_wfd_sink_create(MMHandleType *wfd_sink)
 
 }
 
+int mm_wfd_sink_create_r2(MMHandleType *wfd_sink)
+{
+       int result = MM_ERROR_NONE;
+
+       result = mm_wfd_sink_create(wfd_sink);
+       if (result != MM_ERROR_NONE) {
+               wfd_sink_error("fail to create wi-fi display r2 sink handle. ret[%d]", result);
+               *wfd_sink = (MMHandleType)NULL;
+               return result;
+       }
+
+       ((mm_wfd_sink_t *)*wfd_sink)->is_coupled_sink_supported = TRUE;
+
+       return result;
+}
+
 int mm_wfd_sink_prepare(MMHandleType wfd_sink_handle)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)wfd_sink_handle;
@@ -515,26 +531,32 @@ int mm_wfd_sink_get_current_state(MMHandleType wfd_sink_handle, gint *state)
        return result;
 }
 
-int mm_wfd_sink_set_coupled_sink(MMHandleType wfd_sink_handle, gint status, gchar* address)
+int mm_wfd_sink_set_coupled_sink(MMHandleType wfd_sink_handle, gchar* address)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)wfd_sink_handle;
+       MMWFDSinkStateType cur_state = MM_WFD_SINK_STATE_NONE;
        int result = MM_ERROR_NONE;
+
        wfd_sink_debug_fenter();
+
        wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail(status, MM_ERROR_WFD_INVALID_ARGUMENT);
        wfd_sink_return_val_if_fail(address, MM_ERROR_WFD_INVALID_ARGUMENT);
 
-       if (status < MM_WFD_SINK_UNKNOWN || status > MM_WFD_SINK_TEARDOWN_COUPLING) {
-               wfd_sink_error("Wrong status is returned. status [%d]", status);
-               result = MM_ERROR_WFD_INVALID_ARGUMENT;
+       MMWFDSINK_CMD_LOCK(wfd_sink);
+       cur_state = MMWFDSINK_CURRENT_STATE(wfd_sink);
+       if (cur_state == MM_WFD_SINK_STATE_CONNECTED ||
+               cur_state == MM_WFD_SINK_STATE_PLAYING ||
+               cur_state == MM_WFD_SINK_STATE_PAUSED) {
+               wfd_sink_error("This function must be called before MM_WFD_SINK_STATE_CONNECTED");
+               result = MM_ERROR_WFD_INVALID_STATE;
        } else {
-               result = MM_ERROR_NONE;
+               if (wfd_sink->coupled_sink_address) {
+                       wfd_sink_debug("coupled_sink_address is already set. [ %s]", wfd_sink->coupled_sink_address);
+               } else {
+                       wfd_sink->coupled_sink_address = g_strdup(address);
+                       wfd_sink_debug("coupled_sink_address is set [%s]", wfd_sink->coupled_sink_address);
+               }
        }
-
-       MMWFDSINK_CMD_LOCK(wfd_sink);
-       wfd_sink->coupled_sink_status = status;
-       wfd_sink->coupled_sink_address = g_strdup(address);
-       wfd_sink_debug("coupled_sink in sink_t is [%d, %s]", wfd_sink->coupled_sink_status, wfd_sink->coupled_sink_address);
        MMWFDSINK_CMD_UNLOCK(wfd_sink);
 
        wfd_sink_debug_fleave();
index 0d80358..8b1b302 100644 (file)
@@ -112,9 +112,12 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink, const char *ini_path)
        /* Initialize video resolution */
        new_wfd_sink->supportive_resolution = MM_WFD_SINK_RESOLUTION_UNKNOWN;
 
-       /*Initialize coulped sink information*/
+       /* Initialize coulped sink information */
        new_wfd_sink->coupled_sink_address = NULL;
-       new_wfd_sink->coupled_sink_status = MM_WFD_SINK_NOT_COUPLED;
+       new_wfd_sink->coupled_sink_status = MM_WFD_COUPLED_SINK_STATUS_NOT_COUPLED;
+
+       /* In case of R2 sink, it would be TRUE */
+       new_wfd_sink->is_coupled_sink_supported = FALSE;
 
        /* construct attributes */
        new_wfd_sink->attrs = _mmwfd_construct_attribute((MMHandleType)new_wfd_sink);
@@ -419,6 +422,9 @@ int _mm_wfd_sink_destroy(mm_wfd_sink_t *wfd_sink)
        /* release attributes */
        _mmwfd_deconstruct_attribute(wfd_sink->attrs);
 
+       /* release the others */
+       g_free(wfd_sink->coupled_sink_address);
+
        /* release manager thread  */
        if (MM_ERROR_NONE != _mm_wfd_sink_release_manager(wfd_sink)) {
                wfd_sink_error("failed to release manager");
@@ -2802,8 +2808,8 @@ static int __mm_wfd_sink_prepare_source(mm_wfd_sink_t *wfd_sink, GstElement *wfd
        wfd_coupled_sink = gst_structure_new("wfd_coupled_sink",
                                                                                        "coupled_sink_status", G_TYPE_INT, wfd_sink->coupled_sink_status,
                                                                                        "coupled_sink_address", G_TYPE_STRING, wfd_sink->coupled_sink_address,
+                                                                                       "is_coupled_sink_supported", G_TYPE_BOOLEAN, wfd_sink->is_coupled_sink_supported,
                                                                                        NULL);
-       wfd_sink_debug("set wfd-coupled-sink status %d address %s", wfd_sink->coupled_sink_status, wfd_sink->coupled_sink_address);
 
        if (wfd_coupled_sink) {
                g_object_set(G_OBJECT(wfdsrc), "wfd-coupled-sink", wfd_coupled_sink, NULL);