Add webrtc_start_sync() 85/315885/1
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 9 Aug 2024 01:02:45 +0000 (10:02 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 9 Aug 2024 01:02:45 +0000 (10:02 +0900)
[Version] 1.1.23
[Issue Type] API

Change-Id: I1093273002c4774835cdf067d89ef25ae138a3c3
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc.h
include/webrtc_internal.h
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_internal.c

index 5131a17b0b5b9a8244cd78ba096d0bef2b8c6c42..de8d44900f165258ac48507ad571fda4f8716130 100644 (file)
@@ -940,12 +940,37 @@ int webrtc_create(webrtc_h *webrtc);
  * @pre webrtc_ice_candidate_cb() must be set by calling webrtc_set_ice_candidate_cb().
  * @pre webrtc_media_packet_source_set_format() must be called if @a webrtc has a media packet source.
  * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE.
+ * @post webrtc_state_changed_cb() will be invoked.
  * @post @a webrtc state will be #WEBRTC_STATE_NEGOTIATING.
  * @see webrtc_create()
  * @see webrtc_stop()
+ * @see webrtc_start_sync()
  */
 int webrtc_start(webrtc_h webrtc);
 
+/**
+ * @brief Starts the WebRTC synchronously.
+ * @since_tizen 9.0
+ * @remarks The main difference with webrtc_start() is that this returns after changing state to #WEBRTC_STATE_NEGOTIATING.\n
+ *          webrtc_state_changed_cb() will not be invoked.
+ * @param[in] webrtc    WebRTC handle
+ * @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
+ * @retval #WEBRTC_ERROR_RESOURCE_FAILED Resource failed
+ * @pre webrtc_ice_candidate_cb() must be set by calling webrtc_set_ice_candidate_cb().
+ * @pre webrtc_media_packet_source_set_format() must be called if @a webrtc has a media packet source.
+ * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE.
+ * @post @a webrtc state will be #WEBRTC_STATE_NEGOTIATING.
+ * @see webrtc_create()
+ * @see webrtc_start()
+ * @see webrtc_stop()
+ */
+int webrtc_start_sync(webrtc_h webrtc);
+
 /**
  * @brief Stops the WebRTC.
  * @since_tizen 6.5
index f7660705c4e1d79761319653a32760f7c16fccdd..5a8e63d746b9416403293725a4cb521f15addbad 100644 (file)
@@ -511,30 +511,6 @@ int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float p
  */
 int webrtc_get_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float *probability);
 
-/**
- * @internal
- * @brief Starts the WebRTC synchronously.
- * @since_tizen 8.0
- * @remarks The main difference with webrtc_start() is that this returns after changing state to #WEBRTC_STATE_NEGOTIATING.\n
- *          webrtc_state_changed_cb() will not be invoked.
- * @param[in] webrtc    WebRTC handle
- * @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
- * @retval #WEBRTC_ERROR_RESOURCE_FAILED Resource failed
- * @pre webrtc_ice_candidate_cb() must be set by calling webrtc_set_ice_candidate_cb().
- * @pre webrtc_media_packet_source_set_format() must be called if @a webrtc has a media packet source.
- * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE.
- * @post @a webrtc state is #WEBRTC_STATE_NEGOTIATING.
- * @see webrtc_create()
- * @see webrtc_start()
- * @see webrtc_stop()
- */
-int webrtc_start_sync(webrtc_h webrtc);
-
 /**
  * @internal
  * @brief Strips the session description.
index d5b9f3d64ec47437d1a2b2e5c22a3e6664eec996..09c3e7528f864c648ba1ac90fb7f4264ad161db4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    1.1.22
+Version:    1.1.23
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d20fed62fba94fe8bdb597f840e5d3416d967796..e90425649fb1f36e1a78ea9185c43ed9d3dbfa05 100644 (file)
@@ -227,7 +227,6 @@ int webrtc_start(webrtc_h webrtc)
 
        RET_VAL_IF(_webrtc->ice_candidate_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, "the ice candidate callback should be set");
        RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE");
-       RET_VAL_IF(_webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
        RET_VAL_IF(!_check_if_format_is_set_to_packet_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media format should be set");
        RET_VAL_IF(!_check_if_path_is_set_to_file_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media path should be set");
        RET_VAL_IF(!_check_if_codec_is_set_to_null_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "transceiver codec is should be set");
@@ -249,6 +248,57 @@ int webrtc_start(webrtc_h webrtc)
        return WEBRTC_ERROR_NONE;
 }
 
+int webrtc_start_sync(webrtc_h webrtc)
+{
+       int ret = WEBRTC_ERROR_NONE;
+       g_autoptr(GMutexLocker) locker = NULL;
+       webrtc_s *_webrtc = (webrtc_s *)webrtc;
+       gint64 end_time;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       RET_VAL_IF(_webrtc->ice_candidate_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, "the ice candidate callback should be set");
+       RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE");
+       RET_VAL_IF(!_check_if_format_is_set_to_packet_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media format should be set");
+       RET_VAL_IF(!_check_if_path_is_set_to_file_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media path should be set");
+       RET_VAL_IF(!_check_if_codec_is_set_to_null_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "transceiver codec is should be set");
+
+#ifndef TIZEN_TV
+       if ((ret = _acquire_resource_if_needed(_webrtc)) != WEBRTC_ERROR_NONE)
+               return ret;
+#endif
+       ret = _complete_sources(_webrtc);
+       RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to complete sources");
+
+       g_mutex_lock(&_webrtc->state_mutex);
+
+       _webrtc->is_start_sync = true;
+       _webrtc->pend_state = WEBRTC_STATE_NEGOTIATING;
+
+       if ((ret = _gst_pipeline_set_state(_webrtc, GST_STATE_PLAYING)) != WEBRTC_ERROR_NONE) {
+               _webrtc->pend_state = WEBRTC_STATE_IDLE;
+               goto out;
+       }
+
+       end_time = g_get_monotonic_time() + 10 * G_TIME_SPAN_SECOND;
+       LOG_DEBUG("wait...");
+       if (!g_cond_wait_until(&_webrtc->state_cond, &_webrtc->state_mutex, end_time)) {
+               LOG_ERROR("timeout of g_cond_wait_until()");
+               _webrtc->pend_state = WEBRTC_STATE_IDLE;
+               ret = WEBRTC_ERROR_INVALID_OPERATION;
+               goto out;
+       }
+
+       LOG_INFO("webrtc[%p] is started", webrtc);
+
+out:
+       _webrtc->is_start_sync = false;
+       g_mutex_unlock(&_webrtc->state_mutex);
+       return ret;
+}
+
 int webrtc_stop(webrtc_h webrtc)
 {
        webrtc_s *_webrtc = (webrtc_s *)webrtc;
index 0a6338149f03bd5a39615bcd6cf9dba0d59ddd59..a4f5d71b507fe6c8647d6aaacf20c4eab316cf42 100644 (file)
@@ -567,56 +567,4 @@ int webrtc_get_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float *
 
        return _get_packet_drop_probability(webrtc, sender, probability);
 }
-
-int webrtc_start_sync(webrtc_h webrtc)
-{
-       int ret = WEBRTC_ERROR_NONE;
-       g_autoptr(GMutexLocker) locker = NULL;
-       webrtc_s *_webrtc = (webrtc_s *)webrtc;
-       gint64 end_time;
-
-       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-
-       locker = g_mutex_locker_new(&_webrtc->mutex);
-
-       RET_VAL_IF(_webrtc->ice_candidate_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, "the ice candidate callback should be set");
-       RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE");
-       RET_VAL_IF(_webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(!_check_if_format_is_set_to_packet_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media format should be set");
-       RET_VAL_IF(!_check_if_path_is_set_to_file_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "the media path should be set");
-       RET_VAL_IF(!_check_if_codec_is_set_to_null_sources(_webrtc), WEBRTC_ERROR_INVALID_OPERATION, "transceiver codec is should be set");
-
-#ifndef TIZEN_TV
-       if ((ret = _acquire_resource_if_needed(_webrtc)) != WEBRTC_ERROR_NONE)
-               return ret;
-#endif
-       ret = _complete_sources(_webrtc);
-       RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to complete sources");
-
-       g_mutex_lock(&_webrtc->state_mutex);
-
-       _webrtc->is_start_sync = true;
-       _webrtc->pend_state = WEBRTC_STATE_NEGOTIATING;
-
-       if ((ret = _gst_pipeline_set_state(_webrtc, GST_STATE_PLAYING)) != WEBRTC_ERROR_NONE) {
-               _webrtc->pend_state = WEBRTC_STATE_IDLE;
-               goto out;
-       }
-
-       end_time = g_get_monotonic_time() + 10 * G_TIME_SPAN_SECOND;
-       LOG_DEBUG("wait...");
-       if (!g_cond_wait_until(&_webrtc->state_cond, &_webrtc->state_mutex, end_time)) {
-               LOG_ERROR("timeout of g_cond_wait_until()");
-               _webrtc->pend_state = WEBRTC_STATE_IDLE;
-               ret = WEBRTC_ERROR_INVALID_OPERATION;
-               goto out;
-       }
-
-       LOG_INFO("webrtc[%p] is started", webrtc);
-
-out:
-       _webrtc->is_start_sync = false;
-       g_mutex_unlock(&_webrtc->state_mutex);
-       return ret;
-}
 //LCOV_EXCL_STOP