From fb4455ce3bd8880b97568e44f2d78455073964db Mon Sep 17 00:00:00 2001 From: Hyunil Date: Wed, 29 Aug 2018 19:17:40 +0900 Subject: [PATCH] [VPR-306/ACR-1275] Add new API to set/get the video roi area Change-Id: I611cde3ef186b35ecea5d90a13329511fedf9407 Signed-off-by: Hyunil --- src/player.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/player.c b/src/player.c index a04c6b9..de8a98f 100644 --- a/src/player.c +++ b/src/player.c @@ -318,6 +318,17 @@ EXIT: return ret; } +static bool _player_video_roi_area_is_valid(double x_scale, double y_scale, + double w_scale, double h_scale) +{ + if (x_scale >= 0.0 && x_scale <= 1.0 && y_scale >= 0.0 && y_scale <= 1.0 + && w_scale > 0.0 && w_scale <= 1.0 && h_scale > 0.0 && h_scale <= 1.0) + return true; + + LOGE("Video roi area is not valid"); + return false; +} + static bool _player_check_network_availability(void) { #define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" @@ -3065,6 +3076,73 @@ int player_get_display_mode(player_h player, player_display_mode_e * pmode) return ret; } +int player_set_video_roi_area(player_h player, double x_scale, double y_scale, + double w_scale, double h_scale) +{ + PLAYER_INSTANCE_CHECK(player); + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_ROI_AREA; + player_cli_s *pc = (player_cli_s *) player; + char *ret_buf = NULL; + + LOGD("ENTER"); + PLAYER_VIDEO_SUPPORTABLE_CHECK(pc); + PLAYER_CHECK_CONDITION(CALLBACK_INFO(pc) != NULL && EVAS_HANDLE(pc) == NULL, + PLAYER_ERROR_INVALID_OPERATION, "Display type is EVAS, video display interface is not supported"); + + if (!_player_video_roi_area_is_valid(x_scale, y_scale, w_scale, h_scale)) + return PLAYER_ERROR_INVALID_PARAMETER; + + PLAYER_SEND_MSG(api, pc, ret_buf, ret, + MUSE_TYPE_DOUBLE, "x_scale", x_scale, + MUSE_TYPE_DOUBLE, "y_scale", y_scale, + MUSE_TYPE_DOUBLE, "w_scale", w_scale, + MUSE_TYPE_DOUBLE, "h_scale", h_scale); + + g_free(ret_buf); + + return ret; +} + + +int player_get_video_roi_area(player_h player, double *x_scale, double *y_scale, + double *w_scale, double *h_scale) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(x_scale && y_scale && w_scale && h_scale); + + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_ROI_AREA; + player_cli_s *pc = (player_cli_s *) player; + char *ret_buf = NULL; + double scale_x = 0, scale_y = 0, scale_w = 0, scale_h = 0; + + PLAYER_SEND_MSG(api, pc, ret_buf, ret); + + if (ret == PLAYER_ERROR_NONE) { + if (player_msg_get_type(scale_x, ret_buf, DOUBLE)) + *x_scale = scale_x; + else + LOGE("failed to get value from msg"); + if (player_msg_get_type(scale_y, ret_buf, DOUBLE)) + *y_scale = scale_y; + else + LOGE("failed to get value from msg"); + if (player_msg_get_type(scale_w, ret_buf, DOUBLE)) + *w_scale = scale_w; + else + LOGE("failed to get value from msg"); + if (player_msg_get_type(scale_h, ret_buf, DOUBLE)) + *h_scale = scale_h; + else + LOGE("failed to get value from msg"); + } + + g_free(ret_buf); + + return ret; +} + int player_set_display_roi_area(player_h player, int x, int y, int width, int height) { -- 2.34.1