Add API - espp_client_set_display_roi()
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 12 May 2023 07:53:01 +0000 (16:53 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Fri, 12 May 2023 09:31:43 +0000 (18:31 +0900)
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
src/client/espp_service_client.c
src/client/espp_service_client.h
src/client/espp_service_client_priv.h
src/client/espp_service_client_socket.c
src/common/espp_service_ipc.c
src/common/espp_service_ipc.h
src/daemon/espp_service_handler.c

index 29b0841ecaf946e4b618799743c81d9ef0e30aef..18496b5606481639d96db244310b010177e3c2b2 100644 (file)
@@ -449,6 +449,23 @@ int espp_client_set_display_mode(espp_h espp, espp_display_mode_e mode)
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_set_display_roi(espp_h espp, int x, int y, int w, int h)
+{
+       espp_s *_espp = (espp_s *)espp;
+       g_autoptr(GMutexLocker) locker = NULL;
+
+       RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+
+       locker = g_mutex_locker_new(&_espp->mutex);
+
+       if (espp_service_client_socket_request_set_display_roi(_espp, x, y, w, h) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] x[%d] y[%d] w[%d] h[%d]", espp, x, y, w, h);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
 int espp_client_set_audio_mute(espp_h espp, bool mute)
 {
        espp_s *_espp = (espp_s *)espp;
index 99ce03ddca71208fe8199a51a8302a250e6f64b2..45c033d7cfdeacef97575cec5d76748aa6e51d78 100644 (file)
@@ -531,6 +531,8 @@ int espp_client_set_video_stream_info(espp_h espp, espp_video_stream_info_s *inf
  * @retval #ESPP_CLIENT_ERROR_NONE Successful
  * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
+ * @see espp_client_set_display_mode()
+ * @see espp_client_set_display_roi()
  */
 int espp_client_set_display_surface_id(espp_h espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h);
 
@@ -545,9 +547,29 @@ int espp_client_set_display_surface_id(espp_h espp, espp_display_type_e type, un
  * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
  * @pre espp_client_open() must be called before calling this function.
  * @see espp_client_open()
+ * @see espp_client_set_display_surface_id()
+ * @see espp_client_set_display_roi()
  */
 int espp_client_set_display_mode(espp_h espp, espp_display_mode_e mode);
 
+/**
+ * @brief Sets the video display RoI(Region of Interest).
+ * @param[in] espp       ESPP service client handle
+ * @param[in] x          The x coordinate of window
+ * @param[in] y          The y coordinate of window
+ * @param[in] w          The width of window
+ * @param[in] h          The height of window
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ESPP_CLIENT_ERROR_NONE Successful
+ * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
+ * @pre #ESPP_DISPLAY_MODE_DST_ROI must be set by espp_client_set_display_mode() before calling this function.
+ * @see espp_client_set_display_surface_id()
+ * @see espp_client_set_display_mode()
+ */
+int espp_client_set_display_roi(espp_h espp, int x, int y, int w, int h);
+
 /**
  * @brief Sets mute of the audio stream.
  * @param[in] espp    ESPP service client handle
index 7b7d4b252f7381aaaff46f4a4767d59dc53aa425..473aee2085799ef28553d81427a6da4a85a7bd02 100644 (file)
@@ -84,6 +84,7 @@ int espp_service_client_socket_request_set_audio_stream_info(espp_s *espp, espp_
 int espp_service_client_socket_request_set_video_stream_info(espp_s *espp, espp_video_stream_info_s *info);
 int espp_service_client_socket_request_set_display_surface_id(espp_s *espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h);
 int espp_service_client_socket_request_set_display_mode(espp_s *espp, espp_display_mode_e mode);
+int espp_service_client_socket_request_set_display_roi(espp_s *espp, int x, int y, int w, int h);
 int espp_service_client_socket_request_set_audio_mute(espp_s *espp, bool mute);
 int espp_service_client_socket_request_set_callback(espp_s *espp, espp_service_event_e type, void *callback, void *user_data);
 int espp_service_client_socket_request_submit_packet(espp_s *espp, espp_packet_s *packet, espp_submit_error_e *error);
index 3963fc1c0875027a313fc46d5e7060d83ae13dda..ec6aefbfbaa33195f59ee4f36f2b43c0150b271e 100644 (file)
@@ -587,6 +587,27 @@ int espp_service_client_socket_request_set_display_mode(espp_s *espp, espp_displ
        return 0;
 }
 
+int espp_service_client_socket_request_set_display_roi(espp_s *espp, int x, int y, int w, int h)
+{
+       espp_service_data_from_client_s data;
+       espp_service_data_from_server_s result;
+
+       ASSERT(espp);
+       RET_VAL_IF(espp->fd == -1, -1, "fd is -1");
+
+       FILL_SOCKET_MSG_REQUEST(data, ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI,
+               "x", x, "y", y, "w", w, "h", h);
+       if (send_data(espp->fd, &data, &result) != 0)
+               return -1;
+
+       RET_VAL_IF_SERVER_RESULT_ERROR(result, -1);
+
+       LOG_DEBUG("espp[%p], fd[%d]", espp, espp->fd);
+
+       return 0;
+}
+
 int espp_service_client_socket_request_set_audio_mute(espp_s *espp, bool mute)
 {
        espp_service_data_from_client_s data;
index 9afbfe87476684330cd0c8d9f0ec08aea19a8300..8be34fae1720f8138446191f1a7dcf2172231651 100644 (file)
@@ -34,6 +34,7 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = { "SetVideoStreamInfo", "suiuuuuuu" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = { "SetDisplaySurfaceId", "iuiiii" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE] = { "SetDisplayMode", "i" },
+       [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = { "SetDisplayRoi", "iiii" },
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = { "SetAudioMute", "b" },
        [ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = { "SubmitPacket", "iukku" },
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = { "SetCallback", "i" },
index 36b3db66035d2af0e649722956570855e1389b4f..37ec40e5b8fc671efca2b0868bc6d76f5f64b559 100644 (file)
@@ -43,6 +43,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE,
+       ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI,
        ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE,
        ESPP_SERVICE_REQUEST_SUBMIT_PACKET,
        ESPP_SERVICE_REQUEST_SET_CALLBACK,
index 6f08ff43dbda24eb13456de67ab5b79ab9f59ad3..56554178974218fb56b0f23e02ca863e075ee3c4 100644 (file)
@@ -442,6 +442,36 @@ static void __handle_set_display_mode(handler_userdata_s *hdata, espp_service_da
        result->ret = 0;
 }
 
+static void __handle_set_display_roi(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       int x, y, w, h;
+
+       ASSERT(hdata);
+       ASSERT(data);
+       ASSERT(result);
+       ASSERT(hdata->svc);
+       ASSERT(hdata->fd >= 0);
+
+       result->ret = -1;
+
+       RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
+
+       ret = espp_service_msg_parse_params(data->params, data->request,
+               &x, &y, &w, &h);
+       if (ret != 0)
+               return;
+
+       ret = esplusplayer_set_display_roi((esplusplayer_handle)hdata->espp, x, y, w, h);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_display_roi(), ESPP[%p], x[%d], y[%d], w[%d], h[%d]",
+               hdata->espp, x, y, w, h);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_display_roi() success, x[%d], y[%d], w[%d], h[%d]",
+               hdata->fd, hdata->espp, x, y, w, h);
+
+       result->ret = 0;
+}
+
 static void __handle_set_audio_mute(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
 {
        int ret;
@@ -686,6 +716,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = __handle_set_video_stream_info,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = __handle_set_display_surface_id,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE] = __handle_set_display_mode,
+       [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = __handle_set_display_roi,
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = __handle_set_audio_mute,
        [ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = __handle_submit_packet,
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = __handle_set_callback,