PROP_BUNDLE_POLICY,
PROP_ICE_TRANSPORT_POLICY,
PROP_ICE_AGENT,
+#ifndef TIZEN_FEATURE_IMPORT_NETSIM
PROP_LATENCY
+#else
+ PROP_LATENCY,
+ PROP_NETSIM,
+ PROP_DROP_PROBABILITY_SENDER
+#endif
};
static guint gst_webrtc_bin_signals[LAST_SIGNAL] = { 0 };
return ret;
}
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+static void
+_insert_netsim_element_between (GstWebRTCBin * webrtc, GstElement * srcbin,
+ const gchar * srcpadname, GstElement * sinkbin, const gchar * sinkpadname)
+{
+ GstElement *netsim = gst_element_factory_make ("netsim", NULL);
+ gst_bin_add (GST_BIN (webrtc), netsim);
+ g_object_set (netsim, "drop-probability", webrtc->priv->drop_probability_sender, NULL);
+ gst_element_sync_state_with_parent (netsim);
+
+ if (!gst_element_link_pads (srcbin, srcpadname, netsim, "sink"))
+ g_warn_if_reached ();
+
+ if (!gst_element_link_pads (netsim, "src", sinkbin, sinkpadname))
+ g_warn_if_reached ();
+}
+
+#endif
static GstPad *
_connect_input_stream (GstWebRTCBin * webrtc, GstWebRTCBinPad * pad)
{
gst_object_unref (rtp_sink);
pad_name = g_strdup_printf ("send_rtp_src_%u", pad->mlineindex);
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ if (webrtc->priv->netsim) {
+ _insert_netsim_element_between (webrtc, GST_ELEMENT (webrtc->rtpbin), pad_name,
+ GST_ELEMENT (trans->stream->send_bin), "rtp_sink");
+ } else {
+#endif
if (!gst_element_link_pads (GST_ELEMENT (webrtc->rtpbin), pad_name,
GST_ELEMENT (trans->stream->send_bin), "rtp_sink"))
g_warn_if_reached ();
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ }
+#endif
g_free (pad_name);
} else {
gchar *pad_name = g_strdup_printf ("sink_%u", pad->mlineindex);
gst_object_unref (rtp_sink);
pad_name = g_strdup_printf ("send_rtp_src_%d", session_id);
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ if (webrtc->priv->netsim) {
+ _insert_netsim_element_between (webrtc, GST_ELEMENT (webrtc->rtpbin), pad_name,
+ GST_ELEMENT (stream->send_bin), "rtp_sink");
+ } else {
+#endif
if (!gst_element_link_pads (GST_ELEMENT (webrtc->rtpbin), pad_name,
GST_ELEMENT (stream->send_bin), "rtp_sink"))
g_warn_if_reached ();
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ }
+#endif
g_free (pad_name);
done:
}
}
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+static void
+_update_drop_probability (GstWebRTCBin * webrtc, gfloat probability)
+{
+ GValue value = G_VALUE_INIT;
+ GstElement *element;
+ GstIterator *bin_iterator = gst_bin_iterate_sorted (GST_BIN (webrtc));
+ g_assert (bin_iterator);
+
+ while (gst_iterator_next (bin_iterator, &value) == GST_ITERATOR_OK) {
+ element = GST_ELEMENT (g_value_get_object (&value));
+ if (g_strrstr (GST_ELEMENT_NAME (element), "netsim"))
+ g_object_set (element, "drop-probability", probability, NULL);
+ g_value_reset (&value);
+ }
+
+ g_value_unset (&value);
+ gst_iterator_free (bin_iterator);
+}
+
+#endif
static void
gst_webrtc_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
webrtc->priv->jb_latency = g_value_get_uint (value);
_update_rtpstorage_latency (webrtc);
break;
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ case PROP_NETSIM:
+ webrtc->priv->netsim = g_value_get_boolean (value);
+ _update_drop_probability (webrtc, webrtc->priv->netsim ?
+ webrtc->priv->drop_probability_sender : 0.0);
+ break;
+ case PROP_DROP_PROBABILITY_SENDER:
+ webrtc->priv->drop_probability_sender = g_value_get_float (value);
+ _update_drop_probability (webrtc, webrtc->priv->drop_probability_sender);
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_LATENCY:
g_value_set_uint (value, webrtc->priv->jb_latency);
break;
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ case PROP_NETSIM:
+ g_value_set_boolean (value, webrtc->priv->netsim);
+ break;
+ case PROP_DROP_PROBABILITY_SENDER:
+ g_value_set_float (value, webrtc->priv->drop_probability_sender);
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
"Default duration to buffer in the jitterbuffers (in ms)",
0, G_MAXUINT, 200, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#ifdef TIZEN_FEATURE_IMPORT_NETSIM
+ g_object_class_install_property (gobject_class,
+ PROP_NETSIM,
+ g_param_spec_boolean ("netsim", "Use network simulator",
+ "Use network simulator for packet loss",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_DROP_PROBABILITY_SENDER,
+ g_param_spec_float ("drop-probability-sender", "Drop Probability for sender",
+ "The Probability a sending RTP buffer is dropped",
+ 0.0, 1.0, 0.0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+#endif
/**
* GstWebRTCBin::create-offer:
* @object: the #webrtcbin