[VPR-306/ACR-1275] Add new API to set/get the video roi area 11/187911/5
authorHyunil <hyunil46.park@samsung.com>
Wed, 29 Aug 2018 10:17:40 +0000 (19:17 +0900)
committerHyunil <hyunil46.park@samsung.com>
Thu, 30 Aug 2018 09:11:56 +0000 (18:11 +0900)
Change-Id: I611cde3ef186b35ecea5d90a13329511fedf9407
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
src/player.c

index a04c6b9a6a04ab364f89833129c99b52751dc35a..de8a98fd70c1c7b21d543adf4cf535371b4f8e9a 100644 (file)
@@ -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)
 {