From f35edb3c646ba2f82618fc8fef0998a8f078137c Mon Sep 17 00:00:00 2001 From: Hyunil Date: Mon, 25 Apr 2016 11:21:28 +0900 Subject: [PATCH] Add new internal api for setting ecore wayland display Change-Id: I5554e86240d4410845a1f628ee775d8b87960277 Signed-off-by: Hyunil --- include/common/player_internal.h | 28 ++++++++++++++++ src/player.c | 3 ++ src/player_internal.c | 72 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/include/common/player_internal.h b/include/common/player_internal.h index 7ecd169..0a90072 100644 --- a/include/common/player_internal.h +++ b/include/common/player_internal.h @@ -20,6 +20,9 @@ #ifdef TIZEN_TV #include #endif +#ifdef HAVE_WAYLAND +#include +#endif #ifdef __cplusplus extern "C" { #endif @@ -379,6 +382,31 @@ int player_set_display_parent_win_id(player_h player, int win_id); #endif +#ifdef HAVE_WAYLAND +/** + * @brief Sets the ecore wayland video display. + * @since_tizen 3.0 + * @remarks This API support PLAYER_DISPLAY_TYPE_OVERLAY type only. + * @param[in] player The handle to the media player + * @param[in] type The display type + * @param[in] ecore_wl_window The ecore wayland window handle + * @param[in] x the x coordinate of window + * @param[in] y the y coordinate of window + * @param[in] width the width of window + * @param[in] height the height of window + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_set_display_rotation + */ +int player_set_ecore_wl_display(player_h player, player_display_type_e type, Ecore_Wl_Window *ecore_wl_window, int x, int y, int width, int height); + +#endif + /** * @} */ diff --git a/src/player.c b/src/player.c index aba0b27..c640c48 100644 --- a/src/player.c +++ b/src/player.c @@ -1775,6 +1775,9 @@ int player_set_display(player_h player, player_display_type_e type, player_displ LOGD("wl_surface_id = %d", wl_surface_id); wl_win.wl_surface_id = wl_surface_id; LOGD("wl_win.wl_surface_id = %d", wl_win.wl_surface_id); + } else { + LOGE("Fail to get wl_surface or wl_display"); + return PLAYER_ERROR_INVALID_OPERATION; } if (pc->wlclient) { g_free(pc->wlclient); diff --git a/src/player_internal.c b/src/player_internal.c index dec427c..fd88744 100644 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -254,3 +254,75 @@ int player_unset_evas_object_cb(player_h player) return MM_ERROR_NONE; } + +#ifdef HAVE_WAYLAND +int player_set_ecore_wl_display(player_h player, player_display_type_e type, Ecore_Wl_Window *ecore_wl_window, int x, int y, int width, int height) +{ + PLAYER_INSTANCE_CHECK(player); + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY; + player_cli_s *pc = (player_cli_s *) player; + char *ret_buf = NULL; + wl_win_msg_type wl_win; + char *wl_win_msg = (char *)&wl_win; + unsigned int wl_surface_id; + struct wl_surface *wl_surface; + struct wl_display *wl_display; + Ecore_Wl_Window *wl_window = NULL; + + LOGD("ENTER"); + if (type !=PLAYER_DISPLAY_TYPE_OVERLAY) { + LOGE("Display type(%d) is not overlay", type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + if (!ecore_wl_window) + return PLAYER_ERROR_INVALID_PARAMETER; + + LOGI("Wayland overlay surface type"); + LOGD("Ecore Wayland Window handle(%p), size (%d, %d, %d, %d)", ecore_wl_window, x, y, width, height); + wl_window = ecore_wl_window; + + /* set wl_win */ + wl_win.type = type; + wl_win.wl_window_x = x; + wl_win.wl_window_y = y; + wl_win.wl_window_width = width; + wl_win.wl_window_height = height; + + wl_surface = (struct wl_surface *)ecore_wl_window_surface_get(wl_window); + /* get wl_display */ + wl_display = (struct wl_display *)ecore_wl_display_get(); + + if (!pc->wlclient) { + ret = _wlclient_create(&pc->wlclient); + if (ret != MM_ERROR_NONE) { + LOGE("Wayland client create failure"); + return ret; + } + } + + if (wl_surface && wl_display) { + LOGD("surface = %p, wl_display = %p", wl_surface, wl_display); + wl_surface_id = _wlclient_get_wl_window_wl_surface_id(pc->wlclient, wl_surface, wl_display); + LOGD("wl_surface_id = %d", wl_surface_id); + wl_win.wl_surface_id = wl_surface_id; + LOGD("wl_win.wl_surface_id = %d", wl_win.wl_surface_id); + } else { + LOGE("Fail to get wl_surface or wl_display"); + return PLAYER_ERROR_INVALID_OPERATION; + } + + if (pc->wlclient) { + g_free(pc->wlclient); + pc->wlclient = NULL; + } + + player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char)); + + g_free(ret_buf); + + return ret; +} + +#endif + -- 2.7.4