Change attribute value type of display_overlay 25/209725/4
authorHyunil <hyunil46.park@samsung.com>
Wed, 10 Jul 2019 08:27:38 +0000 (17:27 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 10 Jul 2019 08:58:17 +0000 (17:58 +0900)
Change-Id: I3b06d30832543043e94798ca11de0e5ab40e8e5c
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
src/include/mm_player.h
src/include/mm_player_priv.h
src/mm_player.c
src/mm_player_attrs.c
src/mm_player_priv.c

index d7eab67..768b034 100644 (file)
@@ -1504,7 +1504,7 @@ int mm_player_do_video_capture(MMHandleType player);
  *
  * @param      player                  [in]    Handle of player.
  * @param      display_surface_type    [in]    display surface type to set
- * @param      display_overlay                 [in]    display overlay to set
+ * @param      wl_surface_id                   [in]    wayland surface id to set
  *
  * @return     This function returns zero on success, or negative value with error
  *                     code.
@@ -1512,7 +1512,7 @@ int mm_player_do_video_capture(MMHandleType player);
  * @see
  * @since
  */
-int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay);
+int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, unsigned int wl_surface_id);
 
 /**
  * This function set the application PID.
index 0fdbf4c..cf2d2bc 100644 (file)
@@ -837,7 +837,7 @@ int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
 int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
 int _mmplayer_update_video_overlay_param(mmplayer_t *player, const char *param_name);
-int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
+int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, unsigned int wl_surface_id);
 int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
 int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
 int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
index 1692628..4e54a02 100644 (file)
@@ -306,7 +306,7 @@ int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
 }
 
 /* NOTE : It does not support some use cases, eg using colorspace converter */
-int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
+int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, unsigned int wl_surface_id)
 {
        int result = MM_ERROR_NONE;
 
@@ -314,7 +314,7 @@ int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display
 
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
+       result = _mmplayer_change_videosink(player, display_surface_type, wl_surface_id);
 
        MMPLAYER_CMD_UNLOCK(player);
 
index e15b676..8502acc 100644 (file)
@@ -458,12 +458,12 @@ mmplayer_attrs_spec_t player_attrs[] = {
        {
                MMPLAYER_ATTRS_DISPLAY_OVERLAY,
                (char *)"display_overlay",
-               MM_ATTRS_TYPE_DATA,
+               MM_ATTRS_TYPE_INT,
                MM_ATTRS_FLAG_RW,
-               {(void *)NULL},
-               MM_ATTRS_VALID_TYPE_NONE,
-               {0},
-               {0},
+               {(void *)0},
+               MM_ATTRS_VALID_TYPE_INT_RANGE,
+               {.int_min = 0},
+               {.int_max = MMPLAYER_MAX_INT},
                NULL,
        },
        {
index a925cef..b4d944a 100644 (file)
@@ -1891,7 +1891,7 @@ static void __mmplayer_video_param_set_display_method(mmplayer_t *player)
 static void __mmplayer_video_param_set_video_roi_area(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
-       void *handle = NULL;
+       int handle = 0;
        MMPLAYER_FENTER();
 
        /* check video sinkbin is created */
@@ -1900,20 +1900,21 @@ static void __mmplayer_video_param_set_video_roi_area(mmplayer_t *player)
 
        attrs = MMPLAYER_GET_ATTRS(player);
        MMPLAYER_RETURN_IF_FAIL(attrs);
-       mm_attrs_get_data_by_name(attrs, "display_overlay", &handle);
-       if (handle) {
-               gst_video_overlay_set_video_roi_area(
-                        GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                        player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height);
-               LOGD("set video param : video roi area scale value: x(%f) y(%f) width(%f) height(%f)",
-                       player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height);
-       }
+
+       mm_attrs_get_int_by_name(attrs, "display_overlay", &handle);
+       MMPLAYER_RETURN_IF_FAIL(handle);
+
+       gst_video_overlay_set_video_roi_area(
+                GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height);
+       LOGD("set video param : video roi area scale value: x(%f) y(%f) width(%f) height(%f)",
+               player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height);
 }
 
 static void __mmplayer_video_param_set_roi_area(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
-       void *handle = NULL;
+       int handle = 0;
        /*set wl_display*/
        int win_roi_x = 0;
        int win_roi_y = 0;
@@ -1928,29 +1929,28 @@ static void __mmplayer_video_param_set_roi_area(mmplayer_t *player)
        attrs = MMPLAYER_GET_ATTRS(player);
        MMPLAYER_RETURN_IF_FAIL(attrs);
 
-       mm_attrs_get_data_by_name(attrs, "display_overlay", &handle);
+       mm_attrs_get_int_by_name(attrs, "display_overlay", &handle);
+       MMPLAYER_RETURN_IF_FAIL(handle);
 
-       if (handle) {
-               /* It should be set after setting window */
-               mm_attrs_multiple_get(attrs, NULL,
-                                       "display_win_roi_x", &win_roi_x,
-                                       "display_win_roi_y", &win_roi_y,
-                                       "display_win_roi_width", &win_roi_width,
-                                       "display_win_roi_height", &win_roi_height, NULL);
+       /* It should be set after setting window */
+       mm_attrs_multiple_get(attrs, NULL,
+                               "display_win_roi_x", &win_roi_x,
+                               "display_win_roi_y", &win_roi_y,
+                               "display_win_roi_width", &win_roi_width,
+                               "display_win_roi_height", &win_roi_height, NULL);
 
-               /* After setting window handle, set display roi area */
-               gst_video_overlay_set_display_roi_area(
-                        GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                        win_roi_x, win_roi_y, win_roi_width, win_roi_height);
-               LOGD("set video param : roi area : x(%d) y(%d) width(%d) height(%d)",
-                       win_roi_x, win_roi_y, win_roi_width, win_roi_height);
-       }
+       /* After setting window handle, set display roi area */
+       gst_video_overlay_set_display_roi_area(
+                GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                win_roi_x, win_roi_y, win_roi_width, win_roi_height);
+       LOGD("set video param : roi area : x(%d) y(%d) width(%d) height(%d)",
+               win_roi_x, win_roi_y, win_roi_width, win_roi_height);
 }
 
 static void __mmplayer_video_param_set_display_overlay(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
-       void *handle = NULL;
+       int handle = 0;
 
        /* check video sinkbin is created */
        if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_OVERLAY))
@@ -1960,20 +1960,14 @@ static void __mmplayer_video_param_set_display_overlay(mmplayer_t *player)
        MMPLAYER_RETURN_IF_FAIL(attrs);
 
        /* common case if using overlay surface */
-       mm_attrs_get_data_by_name(attrs, "display_overlay", &handle);
-
-       if (handle) {
-               /* default is using wl_surface_id */
-               unsigned int wl_surface_id      = 0;
-               wl_surface_id = *(int *)handle;
-               LOGD("set video param : wl_surface_id %d", wl_surface_id);
-               gst_video_overlay_set_wl_window_wl_surface_id(
-                               GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                               *(int *)handle);
-       } else {
-               /* FIXIT : is it error case? */
-               LOGW("still we don't have a window handle on player attribute. create it's own surface.");
-       }
+       mm_attrs_get_int_by_name(attrs, "display_overlay", &handle);
+       MMPLAYER_RETURN_IF_FAIL(handle);
+
+       /* default is using wl_surface_id */
+       LOGD("set video param : wl_surface_id %d", handle);
+       gst_video_overlay_set_wl_window_wl_surface_id(
+                       GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                       (guintptr)handle);
 }
 
 int
@@ -7661,16 +7655,14 @@ __mmplayer_release_signal_connection(mmplayer_t *player, mmplayer_signal_type_e
 }
 
 int
-_mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay)
+_mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, unsigned int wl_surface_id)
 {
        mmplayer_t *player = 0;
        int prev_display_surface_type = 0;
-       void *prev_display_overlay = NULL;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       MMPLAYER_RETURN_VAL_IF_FAIL(display_overlay, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
        player = MM_PLAYER_CAST(handle);
 
@@ -7691,7 +7683,6 @@ _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_typ
        /* load previous attributes */
        if (player->attrs) {
                mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &prev_display_surface_type);
-               mm_attrs_get_data_by_name(player->attrs, "display_overlay", &prev_display_overlay);
                LOGD("[0: Video surface, 4: EVAS surface] previous surface type(%d), new surface type(%d)", prev_display_surface_type, surface_type);
                if (prev_display_surface_type == surface_type) {
                        LOGD("incoming display surface type is same as previous one, do nothing..");
@@ -7707,7 +7698,7 @@ _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_typ
        /* videobin is not created yet, so we just set attributes related to display surface */
        LOGD("store display attribute for given surface type(%d)", surface_type);
        mm_player_set_attribute(handle, NULL, "display_surface_type", surface_type,
-                       "display_overlay", display_overlay, sizeof(display_overlay), NULL);
+                       "display_overlay", (int)wl_surface_id, NULL);
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
@@ -8634,7 +8625,7 @@ _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_
 {
        mmplayer_t *player = (mmplayer_t *)hplayer;
        MMHandleType attrs = 0;
-       void *handle = NULL;
+       int handle = 0;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -8644,7 +8635,7 @@ _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_
        attrs = MMPLAYER_GET_ATTRS(player);
        MMPLAYER_RETURN_VAL_IF_FAIL(attrs, MM_ERROR_PLAYER_INTERNAL);
 
-       mm_attrs_get_data_by_name(attrs, "display_overlay", &handle);
+       mm_attrs_get_int_by_name(attrs, "display_overlay", &handle);
        if (!handle) {
                LOGE("Display handle is NULL, after setting window handle, set video roi area");
                return MM_ERROR_PLAYER_INTERNAL;