Functions below are added.
- webrtc_set_rtp_packet_drop_probability()
- webrtc_get_rtp_packet_drop_probability()
RTP packets can be dropped before sending or after being received
with this new function.
[Version] 0.3.27
[Issue Type] New feature
Change-Id: I8d2ca412bb272d750e40d39332d999e3b0cc0085
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
*/
int webrtc_media_source_get_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float *probability);
+/**
+ * @internal
+ * @brief Sets the probability of RTP packet dropping.
+ * @since_tizen 7.0
+ * @param[in] webrtc WebRTC handle
+ * @param[in] sender Sender or receiver
+ * @param[in] probability The probability to be dropped (from @c 0 to @c 1.0 = 100%)
+ * @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
+ * @see webrtc_get_rtp_packet_drop_probability()
+ */
+int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability);
+
+/**
+ * @internal
+ * @brief Gets the probability of RTP packet dropping.
+ * @since_tizen 7.0
+ * @remarks The default value is 0.
+ * @param[in] webrtc WebRTC handle
+ * @param[in] sender Sender or receiver
+ * @param[out] probability The probability to be dropped (from @c 0 to @c 1.0 = 100%)
+ * @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
+ * @see webrtc_set_rtp_packet_drop_probability()
+ */
+int webrtc_get_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float *probability);
+
/**
* @internal
* @brief Creates a signaling server for private network.
bool _is_supported_media_type(const char *media_type);
bool _is_audio_media_type(const char *media_type);
+int _set_packet_drop_probability(webrtc_s *webrtc, bool sender, float probability);
+int _get_packet_drop_probability(webrtc_s *webrtc, bool sender, float *probability);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.26
+Version: 0.3.27
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _get_rtp_packet_drop_probability(webrtc, source_id, probability);
}
+
+int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability)
+{
+ webrtc_s *_webrtc = (webrtc_s*)webrtc;
+ g_autoptr(GMutexLocker) locker = NULL;
+
+ RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(probability > 1.0, WEBRTC_ERROR_INVALID_PARAMETER, "probability > 1.0");
+ RET_VAL_IF(probability < 0, WEBRTC_ERROR_INVALID_PARAMETER, "probability < 0");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+ return _set_packet_drop_probability(webrtc, sender, probability);
+}
+
+int webrtc_get_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float *probability)
+{
+ webrtc_s *_webrtc = (webrtc_s*)webrtc;
+ g_autoptr(GMutexLocker) locker = NULL;
+
+ RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+ return _get_packet_drop_probability(webrtc, sender, probability);
+}
//LCOV_EXCL_STOP
\ No newline at end of file
}
g_free(webrtcbin_name);
- g_object_set(G_OBJECT(webrtc->gst.webrtcbin), "bundle-policy", 3, NULL); /* 3 for max-bundle */
+ g_object_set(G_OBJECT(webrtc->gst.webrtcbin),
+ "bundle-policy", 3, /* 3 for max-bundle */
+ "latency", webrtc->ini.general.jitterbuffer_latency,
+ "netsim", webrtc->ini.general.network_simulator,
+ NULL);
if (webrtc->ini.general.stun_server) {
webrtc->stun_server_url = g_strdup(webrtc->ini.general.stun_server);
LOG_INFO("stun_server[%s]", webrtc->stun_server_url);
}
- g_object_set(G_OBJECT(webrtc->gst.webrtcbin), "latency", webrtc->ini.general.jitterbuffer_latency, NULL);
-
_connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "on-negotiation-needed", G_CALLBACK(__webrtcbin_on_negotiation_needed_cb), webrtc);
_connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "on-ice-candidate", G_CALLBACK(__webrtcbin_on_ice_candidate_cb), webrtc);
_connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "notify::connection-state", G_CALLBACK(__webrtcbin_peer_connection_state_cb), webrtc);
return WEBRTC_ERROR_NONE;
}
+
+int _set_packet_drop_probability(webrtc_s *webrtc, bool sender, float probability)
+{
+ const char *prop_name = sender ? "drop-probability-sender" : "drop-probability-receiver";
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(probability > 1.0, WEBRTC_ERROR_INVALID_PARAMETER, "probability > 1.0");
+ RET_VAL_IF(probability < 0, WEBRTC_ERROR_INVALID_PARAMETER, "probability < 0");
+ RET_VAL_IF(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
+
+ g_object_set(G_OBJECT(webrtc->gst.webrtcbin), prop_name, probability, NULL);
+
+ LOG_INFO("webrtc[%p] set [%s] to [%f]", webrtc, prop_name, probability);
+
+ return WEBRTC_ERROR_NONE;
+}
+
+int _get_packet_drop_probability(webrtc_s *webrtc, bool sender, float *probability)
+{
+ const char *prop_name = sender ? "drop-probability-sender" : "drop-probability-receiver";
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
+ RET_VAL_IF(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
+
+ g_object_get(G_OBJECT(webrtc->gst.webrtcbin), prop_name, probability, NULL);
+
+ LOG_INFO("webrtc[%p] [%s] is [%f]", webrtc, prop_name, *probability);
+
+ return WEBRTC_ERROR_NONE;
+}
\ No newline at end of file