*/
int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id);
+/**
+ * @internal
+ * @brief Sets the probability of RTP packet dropping.
+ * @since_tizen 7.0
+ * @param[in] webrtc WebRTC handle
+ * @param[in] source_id The file source id
+ * @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
+ * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ * @see webrtc_media_source_get_rtp_packet_drop_probability()
+ */
+int webrtc_media_source_set_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, 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] source_id The file source id
+ * @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
+ * @pre Add screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ * @see webrtc_media_source_set_rtp_packet_drop_probability()
+ */
+int webrtc_media_source_get_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float *probability);
+
/**
* @internal
* @brief Creates a signaling server for private network.
return _unset_screen_source_crop(_webrtc, source_id);
}
+
+int webrtc_media_source_set_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, 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(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+ 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_rtp_packet_drop_probability(webrtc, source_id, probability);
+}
+
+int webrtc_media_source_get_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, 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(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+ RET_VAL_IF(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+ return _get_rtp_packet_drop_probability(webrtc, source_id, probability);
+}
//LCOV_EXCL_STOP
\ No newline at end of file
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, "could not find source");
+ 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(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, "could not find source");
+ 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");
screen_source = gst_bin_get_by_name(source->bin, DEFAULT_NAME_SCREENSRC);
int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping)
{
- webrtc_gst_slot_s *source = NULL;
+ webrtc_gst_slot_s *source;
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, "could not find source");
+ 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_FILE, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type [%d]", source->type);
source->filesrc_loop = looping;
int _get_filesrc_looping(webrtc_s * webrtc, unsigned int source_id, bool *looping)
{
- webrtc_gst_slot_s *source = NULL;
+ webrtc_gst_slot_s *source;
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(looping == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "looping is NULL");
-
- RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
+ 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_FILE, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type [%d]", source->type);
*looping = source->filesrc_loop;
return WEBRTC_ERROR_NONE;
}
+
+int _set_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float probability)
+{
+ webrtc_gst_slot_s *source;
+ GstElement *netsim;
+ GstBin *bin;
+
+ 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(probability > 1.0, WEBRTC_ERROR_INVALID_PARAMETER, "probability > 1.0");
+ RET_VAL_IF(probability < 0, WEBRTC_ERROR_INVALID_PARAMETER, "probability < 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(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
+ bin = (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) ? GST_BIN(source->filesrc_pipeline) : GST_BIN(source->bin);
+ RET_VAL_IF(bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+
+ if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) {
+ int count = 0;
+ if ((netsim = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_NETWORK_SIMULATOR))) {
+ g_object_set(G_OBJECT(netsim), "drop-probability", probability, NULL);
+ LOG_INFO("webrtc[%p] source_id[%u] probability[%f] applies to [%s]", webrtc, source_id, probability, GST_ELEMENT_NAME(netsim));
+ count++;
+ }
+ if ((netsim = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_NETWORK_SIMULATOR))) {
+ g_object_set(G_OBJECT(netsim), "drop-probability", probability, NULL);
+ LOG_INFO("webrtc[%p] source_id[%u] probability[%f] applies to [%s]", webrtc, source_id, probability, GST_ELEMENT_NAME(netsim));
+ count++;
+ }
+ RET_VAL_IF(count == 0, WEBRTC_ERROR_INVALID_OPERATION, "could not find any element for network simulator");
+ return WEBRTC_ERROR_NONE;
+ }
+
+ if (!(netsim = __find_element_in_bin(bin, DEFAULT_ELEMENT_NETWORK_SIMULATOR))) {
+ LOG_ERROR("could not find any element for network simulator");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+ g_object_set(G_OBJECT(netsim), "drop-probability", probability, NULL);
+
+ LOG_INFO("webrtc[%p] source_id[%u] probability[%f] applies to [%s]", webrtc, source_id, probability, GST_ELEMENT_NAME(netsim));
+
+ return WEBRTC_ERROR_NONE;
+}
+
+int _get_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float *probability)
+{
+ webrtc_gst_slot_s *source;
+ GstElement *netsim;
+ GstBin *bin;
+
+ 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(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
+ 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(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
+ bin = (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) ? GST_BIN(source->filesrc_pipeline) : GST_BIN(source->bin);
+ RET_VAL_IF(bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+
+ if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) {
+ if (!(netsim = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_NETWORK_SIMULATOR)) &&
+ !(netsim = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_NETWORK_SIMULATOR))) {
+ LOG_ERROR("could not find any element for network simulator");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ if (!(netsim = __find_element_in_bin(bin, DEFAULT_ELEMENT_NETWORK_SIMULATOR))) {
+ LOG_ERROR("could not find any element for network simulator");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+ }
+
+ g_object_get(G_OBJECT(netsim), "drop-probability", (gfloat *)probability, NULL);
+ LOG_INFO("webrtc[%p] source_id[%u] probability[%f]", webrtc, source_id, *probability);
+
+ return WEBRTC_ERROR_NONE;
+}
//LCOV_EXCL_STOP