[wfdsink] Change the way to wayland surface setting 51/232051/12 submit/tizen_5.5/20200514.063507
authorHyunsoo Park <hance.park@samsung.com>
Tue, 28 Apr 2020 02:03:19 +0000 (11:03 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Wed, 13 May 2020 08:32:13 +0000 (17:32 +0900)
Main thread should call display setting API direct.

Change-Id: I9fbc4d14a3e53322b5b4b3fbdc6521907d4e4a15
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
packaging/libmm-wfd.spec
src/include/mm_wfd_sink_attrs.h
src/include/mm_wfd_sink_priv.h
src/mm_wfd_sink_attrs.c
src/mm_wfd_sink_priv.c

index 0f0b277..6644f84 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.3.0
+Version:    0.3.1
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index cfa5067..941fc34 100644 (file)
@@ -75,6 +75,8 @@ typedef enum {
        MM_WFD_ATTRS_FLAG_RW = MM_WFD_ATTRS_FLAG_READABLE | MM_WFD_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
 } MMWfdAttrsFlag;
 
+typedef bool (*mm_wfd_sink_commit_func_t)(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
+
 /**
  * Attribute validity structure
  */
index cafd401..3e60037 100644 (file)
@@ -193,6 +193,7 @@ typedef struct {
        int(*unprepare)(MMHandleType wfd_sink);
 } MMWFDSinkPrivateFunc;
 
+#define MMWFDSINK_CAST(x_wfd)          ((mm_wfd_sink_t *)(x_wfd))
 #define MMWFDSINK_GET_ATTRS(x_wfd) ((x_wfd) ? ((mm_wfd_sink_t*)x_wfd)->attrs : (MMHandleType)NULL)
 
 typedef struct {
@@ -252,6 +253,7 @@ typedef struct {
        guint coupled_sink_status;
        gchar *coupled_sink_address;
        gboolean is_coupled_sink_supported;
+       int display_surface_id;
 } mm_wfd_sink_t;
 
 
@@ -296,6 +298,8 @@ int __mm_wfd_sink_destroy_audio_sinkbin(mm_wfd_sink_t *wfd_sink);
 int __mm_wfd_sink_destroy_video_sinkbin(mm_wfd_sink_t *wfd_sink);
 int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink);
 
+int _mm_wfd_sink_set_display_overlay(mm_wfd_sink_t *wfd_sink, void *display_object);
+
 /* state */
 int __mm_wfd_sink_set_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkStateType state);
 
index 6ff80f7..c1cd761 100644 (file)
@@ -21,6 +21,8 @@
  */
 
 #include "mm_wfd_sink_attrs.h"
+#include "mm_wfd_sink_dlog.h"
+#include "mm_wfd_sink_priv.h"
 
 typedef struct {
        char *name;
@@ -30,9 +32,396 @@ typedef struct {
        int valid_type;
        int value_min;
        int value_max;
+       mm_wfd_sink_commit_func_t attr_commit;
 } MMWfdAttrsSpec;
 
-/*static gboolean __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name); */
+static void __mm_wfd_sink_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
+{
+       switch (value->type) {
+       case MM_ATTRS_TYPE_INT:
+               wfd_sink_debug("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
+               break;
+       case MM_ATTRS_TYPE_DOUBLE:
+               wfd_sink_debug("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
+               break;
+       case MM_ATTRS_TYPE_STRING:
+               wfd_sink_debug("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
+               break;
+       case MM_ATTRS_TYPE_DATA:
+               wfd_sink_debug("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
+               break;
+       default:
+               break;
+       }
+
+       return;
+}
+
+static bool _mmwfd_set_display_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
+
+MMWfdAttrsSpec wfd_attrs[] = {
+       {
+               (char *)"server_ip",
+               MM_ATTRS_TYPE_STRING,
+               MM_ATTRS_FLAG_RW,
+               (void *)"127.0.0.1",
+               MM_ATTRS_VALID_TYPE_NONE,
+               0,
+               0,
+               NULL,
+       },
+       {
+               (char *)"server_port",
+               MM_ATTRS_TYPE_STRING,
+               MM_ATTRS_FLAG_RW,
+               (void *)"8554",
+               MM_ATTRS_VALID_TYPE_NONE,
+               0,
+               0,
+               NULL,
+       },
+       {
+               (char *)"max_client_count",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *)1,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               10,
+               NULL,
+       },
+       /* Initialized with invalid native type, if a valid value is set then only this atribute will be considered */
+       {
+               (char *)"native_resolution",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *)0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               3,
+               NULL,
+       },
+       /* Initialized with invalid resolution, if a valid value is set then only this atribute will be considered */
+       {
+               (char *)"prefered_resolutions",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *)2147483647,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               2147483647,
+               NULL,
+       },
+       /* Initialized with invalid uibc option, if a valid value is set then only this atribute will be considered */
+       {
+               (char *)"set_hdcp",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *)2,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               2,
+               NULL,
+       },
+       {
+               (char *)"display_rotate",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *)0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               3,
+               NULL,
+       },
+       {
+               (char *)"display_src_crop_x",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_src_crop_y",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_src_crop_width",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_src_crop_height",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_roi_x",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_roi_y",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_roi_width",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 480,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_roi_height",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 800,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_roi_mode",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
+               MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX,
+               NULL,
+       },
+       {
+               (char *)"display_rotation",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) MM_DISPLAY_ROTATION_NONE,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               MM_DISPLAY_ROTATION_NONE,
+               MM_DISPLAY_ROTATION_270,
+               NULL,
+       },
+       {
+               (char *)"display_visible",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) FALSE,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               1,
+               NULL,
+       },
+       {
+               (char *)"display_method",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) MM_DISPLAY_METHOD_LETTER_BOX,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               MM_DISPLAY_METHOD_LETTER_BOX,
+               MM_DISPLAY_METHOD_CUSTOM_ROI,
+               NULL,
+       },
+       {
+               (char *)"display_overlay",
+               MM_ATTRS_TYPE_DATA,
+               MM_ATTRS_FLAG_RW,
+               (void *) NULL,
+               MM_ATTRS_VALID_TYPE_NONE,
+               0,
+               0,
+               _mmwfd_set_display_info,
+       },
+       {
+               (char *)"display_overlay_user_data",
+               MM_ATTRS_TYPE_DATA,
+               MM_ATTRS_FLAG_RW,
+               (void *) NULL,
+               MM_ATTRS_VALID_TYPE_NONE,
+               0,
+               0,
+               NULL,
+       },
+       {
+               (char *)"display_zoom",
+               MM_ATTRS_TYPE_DOUBLE,
+               MM_ATTRS_FLAG_RW,
+               (void *) 1,
+               MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
+               1.0,
+               9.0,
+               NULL,
+       },
+       {
+               (char *)"display_surface_type",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) MM_DISPLAY_SURFACE_OVERLAY,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               MM_DISPLAY_SURFACE_OVERLAY,
+               MM_DISPLAY_SURFACE_REMOTE,
+               NULL,
+       },
+       {
+               (char *)"display_width",   /* dest width of fimcconvert ouput */
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_height",   /* dest height of fimcconvert ouput */
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_evas_do_scaling",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) TRUE,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               FALSE,
+               TRUE,
+               NULL,
+       },
+       {
+               (char *)"display_x",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"display_y",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"hdcp_version",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               2,
+               NULL,
+       },
+       {
+               (char *)"hdcp_port",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               2147483647,
+               NULL,
+       },
+       {
+               (char *)"hdcp_handle",
+               MM_ATTRS_TYPE_DATA,
+               MM_ATTRS_FLAG_RW,
+               (void *) NULL,
+               MM_ATTRS_VALID_TYPE_NONE,
+               0,
+               0,
+               NULL,
+       },
+       {
+               (char *)"window_width",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"window_height",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 0,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               0,
+               4096,
+               NULL,
+       },
+       {
+               (char *)"resource_priority",
+               MM_ATTRS_TYPE_INT,
+               MM_ATTRS_FLAG_RW,
+               (void *) 1000,
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               1000,
+               1001,
+               NULL,
+       }
+};
+
+bool _mm_wfd_sink_commit_wfd_attrs(int attr_idx, const char *attr_name, const MMAttrsValue * value, void *commit_param)
+{
+       bool ret = true;
+       return_val_if_fail(commit_param, FALSE);
+       return_val_if_fail(attr_idx >= 0, FALSE);
+       return_val_if_fail(attr_name, FALSE);
+       return_val_if_fail(value, FALSE);
+
+       if (wfd_attrs[attr_idx].attr_commit) {
+               __mm_wfd_sink_print_attrs(attr_name, value, "Dynamic");
+               ret = wfd_attrs[attr_idx].attr_commit((MMHandleType) commit_param, attr_idx, value);
+       } else {
+               __mm_wfd_sink_print_attrs(attr_name, value, "Static");
+       }
+
+       return ret;
+}
 
 MMHandleType
 _mmwfd_construct_attribute(MMHandleType handle)
@@ -43,330 +432,16 @@ _mmwfd_construct_attribute(MMHandleType handle)
        MMAttrsConstructInfo *base = NULL;
        int ret = MM_ERROR_NONE;
 
-       debug_fenter();
+       wfd_sink_debug_fenter();
 
        return_val_if_fail(handle, (MMHandleType) NULL);
 
-       MMWfdAttrsSpec wfd_attrs[] = {
-               {
-                       (char *)"server_ip",
-                       MM_ATTRS_TYPE_STRING,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)"127.0.0.1",
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-
-               {
-                       (char *)"server_port",
-                       MM_ATTRS_TYPE_STRING,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)"8554",
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-
-               {
-                       (char *)"max_client_count",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)1,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       10
-               },
-               /* Initialized with invalid native type, if a valid value is set then only this atribute will be considered */
-               {
-                       (char *)"native_resolution",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       3
-               },
-               /* Initialized with invalid resolution, if a valid value is set then only this atribute will be considered */
-               {
-                       (char *)"prefered_resolutions",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)2147483647,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       2147483647
-               },
-               /* Initialized with invalid uibc option, if a valid value is set then only this atribute will be considered */
-               {
-                       (char *)"set_hdcp",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)2,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       2
-               },
-               {
-                       (char *)"display_rotate",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       3
-               },
-               {
-                       (char *)"display_src_crop_x",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_src_crop_y",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_src_crop_width",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_src_crop_height",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_roi_x",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_roi_y",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_roi_width",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 480,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_roi_height",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 800,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_roi_mode",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
-                       MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
-               },
-               {
-                       (char *)"display_rotation",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) MM_DISPLAY_ROTATION_NONE,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       MM_DISPLAY_ROTATION_NONE,
-                       MM_DISPLAY_ROTATION_270
-               },
-               {
-                       (char *)"display_visible",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) FALSE,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       1
-               },
-               {
-                       (char *)"display_method",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) MM_DISPLAY_METHOD_LETTER_BOX,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       MM_DISPLAY_METHOD_LETTER_BOX,
-                       MM_DISPLAY_METHOD_CUSTOM_ROI
-               },
-               {
-                       (char *)"display_overlay",
-                       MM_ATTRS_TYPE_DATA,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) NULL,
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-               {
-                       (char *)"display_overlay_user_data",
-                       MM_ATTRS_TYPE_DATA,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) NULL,
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-               {
-                       (char *)"display_zoom",
-                       MM_ATTRS_TYPE_DOUBLE,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 1,
-                       MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
-                       1.0,
-                       9.0
-               },
-               {
-                       (char *)"display_surface_type",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) MM_DISPLAY_SURFACE_OVERLAY,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       MM_DISPLAY_SURFACE_OVERLAY,
-                       MM_DISPLAY_SURFACE_REMOTE
-               },
-               {
-                       (char *)"display_width",   /* dest width of fimcconvert ouput */
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_height",   /* dest height of fimcconvert ouput */
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_evas_do_scaling",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) TRUE,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       FALSE,
-                       TRUE
-               },
-               {
-                       (char *)"display_x",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"display_y",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"hdcp_version",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       2
-               },
-               {
-                       (char *)"hdcp_port",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       2147483647
-               },
-               {
-                       (char *)"hdcp_handle",
-                       MM_ATTRS_TYPE_DATA,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) NULL,
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-               {
-                       (char *)"window_width",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"window_height",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 0,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       4096
-               },
-               {
-                       (char *)"resource_priority",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *) 1000,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       1000,
-                       1001
-               }
-       };
-
        num_of_attrs = ARRAY_SIZE(wfd_attrs);
 
        base = (MMAttrsConstructInfo *)malloc(num_of_attrs * sizeof(MMAttrsConstructInfo));
 
        if (!base) {
-               debug_error("Cannot create mmwfd attribute\n");
+               wfd_sink_error("Cannot create mmwfd attribute\n");
                goto ERROR;
        }
 
@@ -382,8 +457,8 @@ _mmwfd_construct_attribute(MMHandleType handle)
                                        base,
                                        num_of_attrs,
                                        "mmwfd_attrs",
-                                       NULL,
-                                       NULL, &attrs);
+                                       _mm_wfd_sink_commit_wfd_attrs,
+                                       (void *)handle, &attrs);
 
        if (base) {
                g_free(base);
@@ -391,7 +466,7 @@ _mmwfd_construct_attribute(MMHandleType handle)
        }
 
        if (ret != MM_ERROR_NONE) {
-               debug_error("Cannot create mmwfd attribute\n");
+               wfd_sink_error("Cannot create mmwfd attribute\n");
                goto ERROR;
        }
 
@@ -415,7 +490,7 @@ _mmwfd_construct_attribute(MMHandleType handle)
                }
        }
 
-       debug_fleave();
+       wfd_sink_debug_fleave();
 
        return attrs;
 
@@ -428,14 +503,14 @@ ERROR:
 void
 _mmwfd_deconstruct_attribute(MMHandleType handle)
 {
-       debug_fenter();
+       wfd_sink_debug_fenter();
 
        return_if_fail(handle);
 
        if (handle)
                mm_attrs_free(handle);
 
-       debug_fleave();
+       wfd_sink_debug_fleave();
 }
 
 int
@@ -444,7 +519,7 @@ _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *att
        int result = MM_ERROR_NONE;
        MMHandleType attrs = 0;
 
-       debug_fenter();
+       wfd_sink_debug_fenter();
 
        /* NOTE : Don't need to check err_attr_name because it can be set NULL */
        /* if it's not want to know it. */
@@ -458,9 +533,9 @@ _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *att
        result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
 
        if (result != MM_ERROR_NONE)
-               debug_error("failed to get %s attribute\n", attribute_name);
+               wfd_sink_error("failed to get %s attribute\n", attribute_name);
 
-       debug_fleave();
+       wfd_sink_debug_fleave();
 
        return result;
 }
@@ -471,7 +546,7 @@ _mmwfd_set_attribute(MMHandleType handle,  char **err_attr_name, const char *att
        int result = MM_ERROR_NONE;
        MMHandleType attrs = 0;
 
-       debug_fenter();
+       wfd_sink_debug_fenter();
 
        /* NOTE : Don't need to check err_attr_name because it can be set NULL */
        /* if it's not want to know it. */
@@ -486,42 +561,17 @@ _mmwfd_set_attribute(MMHandleType handle,  char **err_attr_name, const char *att
        result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
 
        if (result != MM_ERROR_NONE) {
-               debug_error("failed to set %s attribute\n", attribute_name);
+               wfd_sink_error("failed to set %s attribute\n", attribute_name);
                return result;
        }
 
        /*__mmwfd_apply_attribute(handle, attribute_name); */
 
-       debug_fleave();
+       wfd_sink_debug_fleave();
 
        return result;
 }
 
-/* Currently not used. */
-/*static gboolean
-__mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name)
-{
-  MMHandleType attrs = 0;
-  mm_wfd_t* wfd = 0;
-
-  debug_fenter();
-
-  return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-  return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-  attrs = handle;
-
-  return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-  wfd = (mm_wfd_t*)handle;
-
-  // TODO: This function is not useful at this moment
-
-  debug_fleave();
-
-  return TRUE;
-}*/
-
 int
 _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info)
 {
@@ -529,7 +579,7 @@ _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMW
        MMHandleType attrs = 0;
        MMAttrsInfo src_info = {0, };
 
-       debug_fenter();
+       wfd_sink_debug_fenter();
 
        return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
        return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
@@ -542,7 +592,7 @@ _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMW
        result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
 
        if (result != MM_ERROR_NONE) {
-               debug_error("failed to get attribute info\n");
+               wfd_sink_error("failed to get attribute info\n");
                return result;
        }
 
@@ -581,9 +631,41 @@ _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMW
                break;
        }
 
-       debug_fleave();
+       wfd_sink_debug_fleave();
 
        return result;
 }
 
 
+static bool _mmwfd_set_display_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
+{
+       gint surface_type = MM_DISPLAY_SURFACE_OVERLAY;
+       mm_wfd_sink_t *wfd_sink = MMWFDSINK_CAST(handle);
+
+       wfd_sink_debug_fenter();
+
+       /* update display surface */
+       mm_attrs_get_int_by_name(MMWFDSINK_GET_ATTRS(wfd_sink), "display_surface_type", &surface_type);
+       wfd_sink_info("check display surface type attribute: %d", surface_type);
+
+       /* configuring display */
+       switch (surface_type) {
+       case MM_DISPLAY_SURFACE_EVAS:
+               /* nothing to do */
+               break;
+       case MM_DISPLAY_SURFACE_OVERLAY:
+               if (MM_ERROR_NONE != _mm_wfd_sink_set_display_overlay(wfd_sink, value->value.p_val)) {
+                       wfd_sink_error("Setting overlay display is failed.");
+                       return false;
+               }
+               break;
+       case MM_DISPLAY_SURFACE_NULL:
+       default:
+               wfd_sink_error("Not Supported Surface. surface_type: [%d]", surface_type);
+               return false;
+       }
+
+       wfd_sink_debug_fleave();
+
+       return true;
+}
index e76bbd8..2742ec7 100644 (file)
@@ -24,6 +24,7 @@
 #include <gst/video/videooverlay.h>
 #include <Elementary.h>
 #include <Ecore_Wl2.h>
+#include <sys/syscall.h>
 
 #include "mm_wfd_sink_util.h"
 #include "mm_wfd_sink_priv.h"
@@ -4066,110 +4067,38 @@ static int __mm_wfd_sink_prepare_videosink(mm_wfd_sink_t *wfd_sink, GstElement *
 
        /* configuring display */
        switch (surface_type) {
-               case MM_DISPLAY_SURFACE_EVAS: {
-                               void *object = NULL;
-                               gint scaling = 0;
-
-                               /* common case if using evas surface */
-                               mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", &object);
-                               mm_attrs_get_int_by_name(wfd_sink->attrs, "display_evas_do_scaling", &scaling);
-                               if (object) {
-                                       wfd_sink_debug("set video param : evas-object %p", object);
-                                       g_object_set(G_OBJECT(video_sink), "evas-object", object, NULL);
-                               } else {
-                                       wfd_sink_error("no evas object");
-                                       return MM_ERROR_WFD_INTERNAL;
-                               }
-                       }
-                       break;
-
-               case MM_DISPLAY_SURFACE_OVERLAY: {
-                               static unsigned int wl_surface_id = 0;
-                               static void *display_overlay = NULL;
-                               int wl_window_x = 0;
-                               int wl_window_y = 0;
-                               int wl_window_width = 0;
-                               int wl_window_height = 0;
-                               struct wl_surface *wl_surface = NULL;
-                               struct wl_display *wl_display = NULL;
-                               Ecore_Wl2_Window *wl2_window = NULL;
-                               Ecore_Wl2_Display *wl2_display = NULL;
-                               wl_client *wlclient = NULL;
-                               Evas_Object *obj = NULL;
-                               void *object = NULL;
-                               const char *object_type = NULL;
-                               int ret = 0;
-
-                               mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", &object);
-
-                               if (object != NULL) {
-                                       obj = (Evas_Object *)object;
-                                       object_type = evas_object_type_get(obj);
-                                       wfd_sink_debug("window object type : %s", object_type);
-
-                                       /* wayland overlay surface */
-                                       LOGI("Wayland overlay surface type");
-                                       evas_object_geometry_get(obj, &wl_window_x, &wl_window_y, &wl_window_width, &wl_window_height);
-
-                                       wfd_sink_debug("x[%d] y[%d] width[%d] height[%d]", wl_window_x, wl_window_y,
-                                                                       wl_window_width, wl_window_height);
-
-                                       wl2_window = ecore_evas_wayland2_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
-                                       ecore_wl2_window_video_has(wl2_window, EINA_TRUE);
-                                       wl_surface = ecore_wl2_window_surface_get(wl2_window);
-
-                                       /* get wl_display */
-                                       wl2_display = ecore_wl2_connected_display_get(NULL);
-                                       wl_display = ecore_wl2_display_get(wl2_display);
-
-                                       wfd_sink_debug("previous display object : %p current object : %p", display_overlay, object);
-                                       if (wl_surface && wl_display && (wl_surface_id == 0 || display_overlay != object)) {
-                                               wfd_sink_debug("surface = %p, wl_display = %p", wl_surface, wl_display);
-                                               display_overlay = object;
-
-                                               ret = mm_wfd_sink_wlclient_create(&wlclient);
-                                               if (ret != MM_ERROR_NONE) {
-                                                       wfd_sink_error("Wayland client create failure");
-                                                       return ret;
-                                               }
-                                               wfd_sink_debug("Try to get surface id");
-
-                                               wl_surface_id = mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wlclient, wl_surface, wl_display);
-
-                                               wfd_sink_debug("wl_surface_id = %d", wl_surface_id);
-
-                                               if (wlclient) {
-                                                       g_free(wlclient);
-                                                       wlclient = NULL;
-                                               }
-                                       }
-                                       wfd_sink_debug("set video param : surface_id %d", wl_surface_id);
-
-                                       if (USE_EXTERNAL_WL_DISPLAY_HANDLE) {
-                                               gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink),
-                                                                                                               wl_surface_id);
-                                       } else {
-                                               gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(video_sink),
-                                                                                                                               wl_surface_id);
-                                       }
-                               } else {
-                                       wfd_sink_debug("display object is NULL!");
-                                       return MM_ERROR_WFD_INTERNAL;
-                               }
-                       }
-                       break;
-
-               case MM_DISPLAY_SURFACE_NULL: {
-                               /* do nothing */
-                               wfd_sink_error("Not Supported Surface.");
-                               return MM_ERROR_WFD_INTERNAL;
-                       }
-                       break;
-               default: {
-                               wfd_sink_error("Not Supported Surface.(default case)");
+       case MM_DISPLAY_SURFACE_EVAS: {
+                       void *object = NULL;
+                       gint scaling = 0;
+
+                       /* common case if using evas surface */
+                       mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", &object);
+                       mm_attrs_get_int_by_name(wfd_sink->attrs, "display_evas_do_scaling", &scaling);
+                       if (object) {
+                               wfd_sink_debug("set video param : evas-object %p", object);
+                               g_object_set(G_OBJECT(video_sink), "evas-object", object, NULL);
+                       } else {
+                               wfd_sink_error("no evas object");
                                return MM_ERROR_WFD_INTERNAL;
                        }
-                       break;
+               }
+               break;
+       case MM_DISPLAY_SURFACE_OVERLAY:
+               if (USE_EXTERNAL_WL_DISPLAY_HANDLE) {
+                       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink),
+                                                                                       wfd_sink->display_surface_id);
+               } else {
+                       gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(video_sink),
+                                                                                                       wfd_sink->display_surface_id);
+               }
+               break;
+       case MM_DISPLAY_SURFACE_NULL:
+               /* do nothing */
+               wfd_sink_error("Not Supported Surface.");
+               return MM_ERROR_WFD_INTERNAL;
+       default:
+               wfd_sink_error("Not Supported Surface.(default case)");
+               return MM_ERROR_WFD_INTERNAL;
        }
 
        g_object_set(G_OBJECT(video_sink), "qos", FALSE, NULL);
@@ -4895,6 +4824,88 @@ int _mm_wfd_sink_set_resolution(mm_wfd_sink_t *wfd_sink, MMWFDSinkResolution res
        return MM_ERROR_NONE;
 }
 
+int _mm_wfd_sink_set_display_overlay(mm_wfd_sink_t *wfd_sink, void *display_object)
+{
+       int wl_surface_id = 0;
+       static void *display_overlay = NULL;
+       int wl_window_x = 0;
+       int wl_window_y = 0;
+       int wl_window_width = 0;
+       int wl_window_height = 0;
+       struct wl_surface *wl_surface = NULL;
+       struct wl_display *wl_display = NULL;
+       Ecore_Wl2_Window *wl2_window = NULL;
+       Ecore_Wl2_Display *wl2_display = NULL;
+       wl_client *wlclient = NULL;
+       Evas_Object *obj = NULL;
+       void *object = display_object;
+       const char *object_type = NULL;
+       int ret = 0;
+       pid_t pid = getpid();
+       pid_t tid = syscall(SYS_gettid);
+
+       if (pid != tid) {
+               wfd_sink_error("API isn't called in main thread");
+               return MM_ERROR_WFD_INTERNAL;
+       }
+
+       if (object == NULL) {
+               wfd_sink_debug("display object is NULL!");
+               return MM_ERROR_WFD_INTERNAL;
+       }
+       obj = (Evas_Object *)object;
+       object_type = evas_object_type_get(obj);
+       wfd_sink_debug("window object type : %s", object_type);
+
+       if (strcmp(object_type, "elm_win")) {
+               wfd_sink_error("Window type is not elm_win");
+               return MM_ERROR_WFD_INTERNAL;
+       }
+
+       /* wayland overlay surface */
+       wfd_sink_info("Wayland overlay surface type");
+       evas_object_geometry_get(obj, &wl_window_x, &wl_window_y, &wl_window_width, &wl_window_height);
+
+       wfd_sink_debug("x[%d] y[%d] width[%d] height[%d]", wl_window_x, wl_window_y,
+                                       wl_window_width, wl_window_height);
+
+       wl2_window = ecore_evas_wayland2_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
+       ecore_wl2_window_video_has(wl2_window, EINA_TRUE);
+       wl_surface = ecore_wl2_window_surface_get(wl2_window);
+
+       /* get wl_display */
+       wl2_display = ecore_wl2_connected_display_get(NULL);
+       wl_display = ecore_wl2_display_get(wl2_display);
+
+       wfd_sink_debug("previous display object : %p current object : %p", display_overlay, object);
+       if (wl_surface && wl_display && (wl_surface_id == 0 || display_overlay != object)) {
+               wfd_sink_debug("surface = %p, wl_display = %p", wl_surface, wl_display);
+               display_overlay = object;
+
+               ret = mm_wfd_sink_wlclient_create(&wlclient);
+               if (ret != MM_ERROR_NONE) {
+                       wfd_sink_error("Wayland client create failure");
+                       return MM_ERROR_WFD_INTERNAL;
+               }
+               wfd_sink_debug("Try to get surface id");
+
+               wl_surface_id = mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wlclient, wl_surface, wl_display);
+
+               wfd_sink_debug("wl_surface_id = %d", wl_surface_id);
+               if (wl_surface_id == 0) {
+                       wfd_sink_error("wl_surface_id cannot be zero.");
+                       return MM_ERROR_WFD_INTERNAL;
+               }
+               wfd_sink->display_surface_id = wl_surface_id;
+
+               if (wlclient) {
+                       g_free(wlclient);
+                       wlclient = NULL;
+               }
+       }
+       return MM_ERROR_NONE;
+}
+
 void __mm_wfd_sink_print_ref_count(mm_wfd_sink_t *wfd_sink)
 {
        int i = 0;