Below functions are moved and have platform privilege.
- webrtc_screen_source_set_crop()
- webrtc_screen_source_unset_crop()
[Version] 0.3.247
[Issue Type] API
Change-Id: Iad8d3b9842db4c033052e62596c5a79610de22b1
*/
int webrtc_file_source_get_looping(webrtc_h webrtc, unsigned int source_id, bool *looping);
+/**
+ * @platform
+ * @brief Sets the crop coordinates of a screen source.
+ * @since_tizen 7.0
+ * @remarks The coordinates are in UI (screen) units, and the start coordinate refers to the upper left corner of the video display area on the screen.\n
+ * If we give a rectangle within that area (described by x, y, width, height) then this sub-area will be sent to peer and \n
+ * it changes the video resolution.
+ * The changed resolution can be checked through webrtc_media_source_get_video_resolution().\n
+ * Even when the crop area is reset, the rectangle coordinates are based on the original UI (screen) as in the first setting.\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 screen source id
+ * @param[in] x The start X coordinate of the UI for cropping
+ * @param[in] y The start Y coordinate of the UI for cropping
+ * @param[in] width Width of the UI for cropping
+ * @param[in] height Height of the UI for cropping
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE Successful
+ * @retval #WEBRTC_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state
+ * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
+ * @see webrtc_screen_source_unset_crop()
+ * @see webrtc_media_source_get_video_resolution()
+ */
+int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x, int y, int width, int height);
+
+/**
+ * @platform
+ * @brief Unsets the crop coordinates of a screen source.
+ * @since_tizen 7.0
+ * @param[in] webrtc WebRTC handle
+ * @param[in] source_id The screen source id
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE Successful
+ * @retval #WEBRTC_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state
+ * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
+ * @see webrtc_screen_source_set_crop()
+ */
+int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id);
+
/**
* @}
*/
*/
int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, unsigned int *pt);
-/**
- * @internal
- * @brief Sets the crop coordinates of screen source.
- * @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.\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
- * @param[in] y Y coordinate of the upper left conner of the result area
- * @param[in] w Width of UI for cropping
- * @param[in] h Height of UI for cropping
- * @param[out] width Cropped video resolution width
- * @param[out] height Cropped video resolution height
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #WEBRTC_ERROR_NONE Successful
- * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
- * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state
- * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
- * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
- * @see webrtc_screen_source_unset_crop()
- */
-int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x, int y, int w, int h, int *width, int *height);
-
-/**
- * @internal
- * @brief Unsets the crop coordinates of screen source.
- * @since_tizen 6.5
- * @param[in] webrtc WebRTC handle
- * @param[in] source_id The file source id
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #WEBRTC_ERROR_NONE Successful
- * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
- * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state
- * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
- * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
- * @see webrtc_screen_source_set_crop()
- */
-int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id);
-
/**
* @internal
* @brief Sets the probability of RTP packet dropping.
int _get_screen_resolution(int *width, int *height);
int _set_screen_rotation_changed_cb(webrtc_s *webrtc);
void _unset_screen_rotation_changed_cb(webrtc_s *webrtc);
-int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, int *width, int *height);
+int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int width, int height);
int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id);
bool _is_screen_source_cropped(webrtc_gst_slot_s *source);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.246
+Version: 0.3.247
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _get_filesrc_looping(_webrtc, source_id, looping);
}
+//LCOV_EXCL_START
+int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x, int y, int width, int height)
+{
+ g_autoptr(GMutexLocker) locker = NULL;
+ webrtc_s *_webrtc = (webrtc_s *)webrtc;
+
+ 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(x < 0, WEBRTC_ERROR_INVALID_PARAMETER, "x < 0");
+ RET_VAL_IF(y < 0, WEBRTC_ERROR_INVALID_PARAMETER, "y < 0");
+ RET_VAL_IF(width == 0, WEBRTC_ERROR_INVALID_PARAMETER, "width is 0");
+ RET_VAL_IF(height == 0, WEBRTC_ERROR_INVALID_PARAMETER, "height is 0");
+ RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE");
+ RET_ERR_IF_PRIVILEGE_IS_NOT_ALLOWED(_WEBRTC_PRIVILEGE_PLATFORM);
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+#ifdef TIZEN_FEATURE_UI
+ return _set_screen_source_crop(_webrtc, source_id, x, y, width, height);
+#else
+ LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+#endif
+}
+
+int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id)
+{
+ g_autoptr(GMutexLocker) locker = NULL;
+ webrtc_s *_webrtc = (webrtc_s *)webrtc;
+
+ 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(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE");
+ RET_ERR_IF_PRIVILEGE_IS_NOT_ALLOWED(_WEBRTC_PRIVILEGE_PLATFORM);
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+#ifdef TIZEN_FEATURE_UI
+ return _unset_screen_source_crop(_webrtc, source_id);
+#else
+ LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+#endif
+}
+//LCOV_EXCL_STOP
+
int webrtc_set_sound_stream_info(webrtc_h webrtc, unsigned int track_id, sound_stream_info_h stream_info)
{
g_autoptr(GMutexLocker) locker = NULL;
return WEBRTC_ERROR_NONE;
}
-int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x, int y, int w, int h, int *width, int *height)
-{
- g_autoptr(GMutexLocker) locker = NULL;
- webrtc_s *_webrtc = (webrtc_s *)webrtc;
-
- 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");
- /* FIXME: need to check x, y? */
- RET_VAL_IF(w == 0, WEBRTC_ERROR_INVALID_PARAMETER, "w is 0");
- RET_VAL_IF(h == 0, WEBRTC_ERROR_INVALID_PARAMETER, "h is 0");
- RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
- RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
- RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE");
-
- locker = g_mutex_locker_new(&_webrtc->mutex);
-
-#ifdef TIZEN_FEATURE_UI
- return _set_screen_source_crop(_webrtc, source_id, x, y, w, h, width, height);
-#else
- LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
- return WEBRTC_ERROR_INVALID_OPERATION;
-#endif
-}
-
-int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id)
-{
- g_autoptr(GMutexLocker) locker = NULL;
- webrtc_s *_webrtc = (webrtc_s *)webrtc;
-
- 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(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE");
-
- locker = g_mutex_locker_new(&_webrtc->mutex);
-
-#ifdef TIZEN_FEATURE_UI
- return _unset_screen_source_crop(_webrtc, source_id);
-#else
- LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
- return WEBRTC_ERROR_INVALID_OPERATION;
-#endif
-}
-
int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability)
{
webrtc_s *_webrtc = (webrtc_s *)webrtc;
#endif
//LCOV_EXCL_START
-int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, int *width, int *height)
+int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int width, int height)
{
webrtc_gst_slot_s *source = NULL;
GstElement *screen_source = 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(w == 0, WEBRTC_ERROR_INVALID_PARAMETER, "w is 0");
- RET_VAL_IF(h == 0, WEBRTC_ERROR_INVALID_PARAMETER, "h is 0");
- RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
- RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
+ RET_VAL_IF(width == 0, WEBRTC_ERROR_INVALID_PARAMETER, "width is 0");
+ RET_VAL_IF(height == 0, WEBRTC_ERROR_INVALID_PARAMETER, "height is 0");
if ((!_is_screen_source_cropped(source)) &&
((source->video_info.origin_width != source->video_info.width) || (source->video_info.origin_height != source->video_info.height))) {
else if (!rotated && (source->video_info.origin_width > source->video_info.origin_height))
portrait_mode = false;
- LOG_INFO("set source crop x:%d, y:%d, width:%d, height:%d, mode:%s", x, y, w, h, (portrait_mode) ? "portrait" : "landscape");
+ LOG_INFO("set source crop x:%d, y:%d, width:%d, height:%d, mode:%s", x, y, width, height, (portrait_mode) ? "portrait" : "landscape");
g_object_get(G_OBJECT(screen_source),
portrait_mode ? "mirroring-v-src-width" : "mirroring-h-src-width", &src_width,
rw = (float)src_width / mirroring_width;
rh = (float)src_height / mirroring_height;
left = mirroring_x + ((float)x / rw);
- right = output_width - (left + (float)w / rw);
+ right = output_width - (left + (float)width / rw);
top = mirroring_y + ((float)y /rh);
- bottom = output_height - (top + (float)h / rh);
+ bottom = output_height - (top + (float)height / rh);
LOG_INFO("Screen source info: source[width:%d, height:%d], output[width:%d, height:%d] mirroring[x:%d y:%d width:%d, height:%d]",
src_width, src_height, output_width, output_height, mirroring_x, mirroring_y, mirroring_width, mirroring_height);
_set_video_src_resolution(source, _width, _height);
- *width = _width;
- *height = _height;
-
- LOG_INFO("source_id[%u], video resolution is changed [%dx%d] ==> [%dx%d]", source_id, output_width, output_height, *width, *height);
+ LOG_INFO("source_id[%u], video resolution is changed [%dx%d] ==> [%dx%d]", source_id, output_width, output_height, _width, _height);
return WEBRTC_ERROR_NONE;
}
source_id, g_webrtc_media_type_str[media_type], bitrate);
}
-static void _webrtc_screen_source_set_crop(int index, unsigned int source_id, int x, int y, int w, int h, int *width, int *height)
+static void _webrtc_screen_source_set_crop(int index, unsigned int source_id, int x, int y, int w, int h)
{
int ret = WEBRTC_ERROR_NONE;
- ret = webrtc_screen_source_set_crop(g_ad.conns[index].webrtc, source_id, x, y, w, h, width, height);
+ ret = webrtc_screen_source_set_crop(g_ad.conns[index].webrtc, source_id, x, y, w, h);
if (ret != WEBRTC_ERROR_NONE)
g_print("failed to webrtc_screen_source_set_crop(), source_id[%d], ret[0x%x]\n", source_id, ret);
-
- g_print("cropped video resolution[%dx%d]\n", *width, *height);
}
static void _webrtc_screen_source_unset_crop(int index, unsigned int source_id)
return;
case 4:
h = value;
- int width, height;
- _webrtc_screen_source_set_crop(0, id, x, y, w, h, &width, &height);
+ _webrtc_screen_source_set_crop(0, id, x, y, w, h);
x = y = w = h = 0;
g_ad.input_count = 0;
break;