webrtc: Add reuse-source-pads property

Add a property to avoid sending EOS on source pads when the
associated transceiver becomes inactive during renegotiation.
This allows the pads to become active again in a later
renegotiation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7237>
This commit is contained in:
Jan Schmidt 2024-07-30 12:49:04 +10:00 committed by GStreamer Marge Bot
parent cafb999fb0
commit 455b6a33b2
3 changed files with 52 additions and 13 deletions

View file

@ -245929,6 +245929,18 @@
"type": "GstWebRTCSessionDescription",
"writable": false
},
"reuse-source-pads": {
"blurb": "If FALSE, webrtcbin will send EOS on source pads with inactive transceivers. TRUE to reuse pads after renegotiation with no EOS",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "false",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
},
"sctp-transport": {
"blurb": "The WebRTC SCTP Transport",
"conditionally-available": false,

View file

@ -678,7 +678,8 @@ enum
PROP_ICE_AGENT,
PROP_LATENCY,
PROP_SCTP_TRANSPORT,
PROP_HTTP_PROXY
PROP_HTTP_PROXY,
PROP_REUSE_SRC_PADS,
};
static guint gst_webrtc_bin_signals[LAST_SIGNAL] = { 0 };
@ -5750,20 +5751,22 @@ _update_transceiver_from_sdp_media (GstWebRTCBin * webrtc,
gst_webrtc_rtp_transceiver_direction_to_string (new_dir));
if (new_dir == GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_INACTIVE) {
GstWebRTCBinPad *pad;
pad = _find_pad_for_mline (webrtc, GST_PAD_SRC, media_idx);
if (pad) {
GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
if (target) {
GstPad *peer = gst_pad_get_peer (target);
if (peer) {
gst_pad_send_event (peer, gst_event_new_eos ());
gst_object_unref (peer);
if (!webrtc->priv->reuse_source_pads) {
/* pad reuse is disallowed, so send EOS on this pad */
GstWebRTCBinPad *pad =
_find_pad_for_mline (webrtc, GST_PAD_SRC, media_idx);
if (pad) {
GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
if (target) {
GstPad *peer = gst_pad_get_peer (target);
if (peer) {
gst_pad_send_event (peer, gst_event_new_eos ());
gst_object_unref (peer);
}
gst_object_unref (target);
}
gst_object_unref (target);
gst_object_unref (pad);
}
gst_object_unref (pad);
}
/* XXX: send eos event up the sink pad as well? */
@ -8539,6 +8542,9 @@ gst_webrtc_bin_set_property (GObject * object, guint prop_id,
gst_webrtc_ice_set_http_proxy (webrtc->priv->ice,
g_value_get_string (value));
break;
case PROP_REUSE_SRC_PADS:
webrtc->priv->reuse_source_pads = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -8620,6 +8626,9 @@ gst_webrtc_bin_get_property (GObject * object, guint prop_id,
g_value_take_string (value,
gst_webrtc_ice_get_http_proxy (webrtc->priv->ice));
break;
case PROP_REUSE_SRC_PADS:
g_value_set_boolean (value, webrtc->priv->reuse_source_pads);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -8934,6 +8943,23 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
GST_TYPE_WEBRTC_SCTP_TRANSPORT,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCBin:reuse-source-pads:
*
* When set to FALSE, if a transceiver becomes send-only or inactive then
* pre-existing source pads will receive an EOS event and no further traffic
* even after further renegotiation. When TRUE, pads will simply not
* receive any output when the negotiated transceiver state doesn't have
* incoming traffic. If renegotiated later, the pad will receive data again.
*
* Since: 1.26
*/
g_object_class_install_property (gobject_class,
PROP_REUSE_SRC_PADS,
g_param_spec_boolean ("reuse-source-pads", "Reuse source pads",
"If FALSE, webrtcbin will send EOS on source pads with inactive transceivers. TRUE to reuse pads after renegotiation with no EOS",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCBin::create-offer:
* @object: the #webrtcbin

View file

@ -104,6 +104,7 @@ struct _GstWebRTCBinPrivate
{
guint max_sink_pad_serial;
guint src_pad_counter;
gboolean reuse_source_pads;
gboolean bundle;
GPtrArray *transceivers;