* @since_tizen 6.5
* @remarks The base position is always the upper left conner of the UI coordinates.\n
* The display resolution and video resolution of this screen source are different,
- * this function uses the input parameters to crop the screen source based on the display resolution and it changes the video resolution of the screen source as a result.
+ * this function uses the input parameters to crop the screen source based on the display resolution and it changes the video resolution of the screen source as a result.\n
+ * If the video resolution is changed by webrtc_media_source_set_video_resolution(), then crop cannot be performed.\n
+ * Crop and resolution change cannot be done at the same time.
* @param[in] webrtc WebRTC handle
* @param[in] source_id The file source id
* @param[in] x X coordinate of the upper left conner of the result area
RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
+ if ((!_is_screen_source_cropped(source)) &&
+ ((source->video_info.origin_width != source->video_info.width) || (source->video_info.origin_height != source->video_info.height))) {
+ LOG_ERROR("resolution is already changed. crop and resolution change cannot be done at the same time.");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
screen_source = gst_bin_get_by_name(source->bin, ELEMENT_NAME_SCREENSRC);
RET_VAL_IF(screen_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "sreen_source is NULL");
webrtc_gst_slot_s *source = NULL;
GstElement *videocrop = NULL;
GstElement *screen_source = NULL;
- int left, right, top, bottom;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, WEBRTC_ERROR_INVALID_PARAMETER, "source type is not screen");
+ RET_VAL_IF(!_is_screen_source_cropped(source), WEBRTC_ERROR_INVALID_OPERATION, "source is not cropped");
screen_source = gst_bin_get_by_name(source->bin, ELEMENT_NAME_SCREENSRC);
RET_VAL_IF(screen_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "sreen_source is NULL");
videocrop = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEOCROP);
RET_VAL_IF(videocrop == NULL, WEBRTC_ERROR_INVALID_OPERATION, "videocrop is NULL");
- g_object_get(G_OBJECT(videocrop),
- "left", &left,
- "right", &right,
- "top", &top,
- "bottom", &bottom,
- NULL);
- RET_VAL_IF(left == 0 && right == 0 && top == 0 && bottom == 0, WEBRTC_ERROR_INVALID_OPERATION, "webrtc_screen_source_set_crop was not set");
-
g_object_set(G_OBJECT(videocrop),
"left", 0,
"right", 0,
return WEBRTC_ERROR_NONE;
}
+
+bool _is_screen_source_cropped(webrtc_gst_slot_s *source)
+{
+ GstElement *videocrop;
+ int left, right, top, bottom;
+
+ RET_VAL_IF(source == NULL, false, "source is NULL");
+ RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, false, "invalid source type [%d]", source->type);
+
+ videocrop = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEOCROP);
+ RET_VAL_IF(videocrop == NULL, false, "videocrop is NULL");
+
+ g_object_get(G_OBJECT(videocrop),
+ "left", &left,
+ "right", &right,
+ "top", &top,
+ "bottom", &bottom,
+ NULL);
+
+ if (left == 0 && right == 0 && top == 0 && bottom == 0) {
+ LOG_DEBUG("source is not cropped");
+ return false;
+ }
+
+ LOG_DEBUG("source is cropped");
+
+ return true;
+}
//LCOV_EXCL_STOP