mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
webrtc/dc: move some code from webrtcbin into the datachannel
This commit is contained in:
parent
a51db86ac4
commit
be011d2086
2 changed files with 55 additions and 52 deletions
|
@ -1639,29 +1639,6 @@ _on_data_channel_ready_state (GstWebRTCDataChannel * channel,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_link_data_channel_to_sctp (GstWebRTCBin * webrtc,
|
||||
GstWebRTCDataChannel * channel)
|
||||
{
|
||||
if (webrtc->priv->sctp_transport && !channel->sctp_transport) {
|
||||
gint id;
|
||||
|
||||
g_object_get (channel, "id", &id, NULL);
|
||||
|
||||
if (webrtc->priv->sctp_transport->association_established && id != -1) {
|
||||
gchar *pad_name;
|
||||
|
||||
gst_webrtc_data_channel_set_sctp_transport (channel,
|
||||
webrtc->priv->sctp_transport);
|
||||
pad_name = g_strdup_printf ("sink_%u", id);
|
||||
if (!gst_element_link_pads (channel->appsrc, "src",
|
||||
channel->sctp_transport->sctpenc, pad_name))
|
||||
g_warn_if_reached ();
|
||||
g_free (pad_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_on_sctpdec_pad_added (GstElement * sctpdec, GstPad * pad,
|
||||
GstWebRTCBin * webrtc)
|
||||
|
@ -1686,7 +1663,8 @@ _on_sctpdec_pad_added (GstElement * sctpdec, GstPad * pad,
|
|||
gst_element_sync_state_with_parent (channel->appsrc);
|
||||
gst_element_sync_state_with_parent (channel->appsink);
|
||||
|
||||
_link_data_channel_to_sctp (webrtc, channel);
|
||||
gst_webrtc_data_channel_link_to_sctp (channel,
|
||||
webrtc->priv->sctp_transport);
|
||||
|
||||
g_array_append_val (webrtc->priv->pending_data_channels, channel);
|
||||
}
|
||||
|
@ -1723,7 +1701,8 @@ _on_sctp_state_notify (GstWebRTCSCTPTransport * sctp, GParamSpec * pspec,
|
|||
g_array_index (webrtc->priv->data_channels, GstWebRTCDataChannel *,
|
||||
i);
|
||||
|
||||
_link_data_channel_to_sctp (webrtc, channel);
|
||||
gst_webrtc_data_channel_link_to_sctp (channel,
|
||||
webrtc->priv->sctp_transport);
|
||||
|
||||
if (!channel->negotiated && !channel->opened)
|
||||
gst_webrtc_data_channel_start_negotiation (channel);
|
||||
|
@ -1783,7 +1762,8 @@ _get_or_create_data_channel_transports (GstWebRTCBin * webrtc, guint session_id)
|
|||
g_array_index (webrtc->priv->data_channels, GstWebRTCDataChannel *,
|
||||
i);
|
||||
|
||||
_link_data_channel_to_sctp (webrtc, channel);
|
||||
gst_webrtc_data_channel_link_to_sctp (channel,
|
||||
webrtc->priv->sctp_transport);
|
||||
}
|
||||
|
||||
gst_element_sync_state_with_parent (GST_ELEMENT (stream->send_bin));
|
||||
|
@ -3741,7 +3721,8 @@ _update_data_channel_from_sdp_media (GstWebRTCBin * webrtc,
|
|||
|
||||
if (webrtc->priv->sctp_transport->association_established
|
||||
&& !channel->negotiated && !channel->opened) {
|
||||
_link_data_channel_to_sctp (webrtc, channel);
|
||||
gst_webrtc_data_channel_link_to_sctp (channel,
|
||||
webrtc->priv->sctp_transport);
|
||||
gst_webrtc_data_channel_start_negotiation (channel);
|
||||
}
|
||||
}
|
||||
|
@ -4607,7 +4588,7 @@ gst_webrtc_bin_create_data_channel (GstWebRTCBin * webrtc, const gchar * label,
|
|||
ret = gst_object_ref (ret);
|
||||
ret->webrtcbin = webrtc;
|
||||
g_array_append_val (webrtc->priv->data_channels, ret);
|
||||
_link_data_channel_to_sctp (webrtc, ret);
|
||||
gst_webrtc_data_channel_link_to_sctp (ret, webrtc->priv->sctp_transport);
|
||||
if (webrtc->priv->sctp_transport &&
|
||||
webrtc->priv->sctp_transport->association_established
|
||||
&& !ret->negotiated) {
|
||||
|
|
|
@ -916,30 +916,6 @@ _on_sctp_notify_state (GObject * sctp_transport, GParamSpec * pspec,
|
|||
GST_OBJECT_UNLOCK (channel);
|
||||
}
|
||||
|
||||
void
|
||||
gst_webrtc_data_channel_set_sctp_transport (GstWebRTCDataChannel * channel,
|
||||
GstWebRTCSCTPTransport * sctp)
|
||||
{
|
||||
g_return_if_fail (GST_IS_WEBRTC_DATA_CHANNEL (channel));
|
||||
g_return_if_fail (GST_IS_WEBRTC_SCTP_TRANSPORT (sctp));
|
||||
|
||||
GST_OBJECT_LOCK (channel);
|
||||
if (channel->sctp_transport)
|
||||
g_signal_handlers_disconnect_by_data (channel->sctp_transport, channel);
|
||||
|
||||
gst_object_replace ((GstObject **) & channel->sctp_transport,
|
||||
GST_OBJECT (sctp));
|
||||
|
||||
if (sctp) {
|
||||
g_signal_connect (sctp, "stream-reset", G_CALLBACK (_on_sctp_reset_stream),
|
||||
channel);
|
||||
g_signal_connect (sctp, "notify::state", G_CALLBACK (_on_sctp_notify_state),
|
||||
channel);
|
||||
_on_sctp_notify_state_unlocked (G_OBJECT (sctp), channel);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (channel);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_webrtc_data_channel_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
|
@ -1321,3 +1297,49 @@ static void
|
|||
gst_webrtc_data_channel_init (GstWebRTCDataChannel * channel)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_data_channel_set_sctp_transport (GstWebRTCDataChannel * channel,
|
||||
GstWebRTCSCTPTransport * sctp)
|
||||
{
|
||||
g_return_if_fail (GST_IS_WEBRTC_DATA_CHANNEL (channel));
|
||||
g_return_if_fail (GST_IS_WEBRTC_SCTP_TRANSPORT (sctp));
|
||||
|
||||
GST_OBJECT_LOCK (channel);
|
||||
if (channel->sctp_transport)
|
||||
g_signal_handlers_disconnect_by_data (channel->sctp_transport, channel);
|
||||
|
||||
gst_object_replace ((GstObject **) & channel->sctp_transport,
|
||||
GST_OBJECT (sctp));
|
||||
|
||||
if (sctp) {
|
||||
g_signal_connect (sctp, "stream-reset", G_CALLBACK (_on_sctp_reset_stream),
|
||||
channel);
|
||||
g_signal_connect (sctp, "notify::state", G_CALLBACK (_on_sctp_notify_state),
|
||||
channel);
|
||||
_on_sctp_notify_state_unlocked (G_OBJECT (sctp), channel);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (channel);
|
||||
}
|
||||
|
||||
void
|
||||
gst_webrtc_data_channel_link_to_sctp (GstWebRTCDataChannel * channel,
|
||||
GstWebRTCSCTPTransport * sctp_transport)
|
||||
{
|
||||
if (sctp_transport && !channel->sctp_transport) {
|
||||
gint id;
|
||||
|
||||
g_object_get (channel, "id", &id, NULL);
|
||||
|
||||
if (sctp_transport->association_established && id != -1) {
|
||||
gchar *pad_name;
|
||||
|
||||
_data_channel_set_sctp_transport (channel, sctp_transport);
|
||||
pad_name = g_strdup_printf ("sink_%u", id);
|
||||
if (!gst_element_link_pads (channel->appsrc, "src",
|
||||
channel->sctp_transport->sctpenc, pad_name))
|
||||
g_warn_if_reached ();
|
||||
g_free (pad_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue