if (!channel) {
channel = g_object_new (WEBRTC_TYPE_DATA_CHANNEL, NULL);
channel->parent.id = stream_id;
- channel->webrtcbin = webrtc;
+ webrtc_data_channel_set_webrtcbin (channel, webrtc);
g_signal_emit (webrtc, gst_webrtc_bin_signals[PREPARE_DATA_CHANNEL_SIGNAL],
0, channel, FALSE);
gst_element_sync_state_with_parent (ret->sink_bin);
ret = gst_object_ref (ret);
- ret->webrtcbin = webrtc;
+ webrtc_data_channel_set_webrtcbin (ret, webrtc);
g_ptr_array_add (webrtc->priv->data_channels, ret);
DC_UNLOCK (webrtc);
struct task
{
+ GstWebRTCBin *webrtcbin;
GstWebRTCDataChannel *channel;
ChannelTask func;
gpointer user_data;
static void
_free_task (struct task *task)
{
+ g_object_unref (task->webrtcbin);
gst_object_unref (task->channel);
if (task->notify)
_channel_enqueue_task (WebRTCDataChannel * channel, ChannelTask func,
gpointer user_data, GDestroyNotify notify)
{
- struct task *task = g_new0 (struct task, 1);
+ GstWebRTCBin *webrtcbin = NULL;
+ struct task *task = NULL;
+ webrtcbin = g_weak_ref_get (&channel->webrtcbin_weak);
+ if (!webrtcbin)
+ return;
+
+ task = g_new0 (struct task, 1);
+
+ task->webrtcbin = webrtcbin;
task->channel = gst_object_ref (channel);
task->func = func;
task->user_data = user_data;
task->notify = notify;
- gst_webrtc_bin_enqueue_task (channel->webrtcbin,
+ gst_webrtc_bin_enqueue_task (task->webrtcbin,
(GstWebRTCBinFunc) _execute_task, task, (GDestroyNotify) _free_task,
NULL);
}
g_clear_object (&channel->appsrc);
g_clear_object (&channel->appsink);
+ g_weak_ref_clear (&channel->webrtcbin_weak);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
G_LOCK (outstanding_channels_lock);
outstanding_channels = g_list_prepend (outstanding_channels, channel);
G_UNLOCK (outstanding_channels_lock);
+
+ g_weak_ref_init (&channel->webrtcbin_weak, NULL);
}
static void
}
}
}
+
+void
+webrtc_data_channel_set_webrtcbin (WebRTCDataChannel * channel,
+ GstWebRTCBin * webrtcbin)
+{
+ g_weak_ref_set (&channel->webrtcbin_weak, webrtcbin);
+}
GstElement *sink_bin;
GstElement *appsink;
- GstWebRTCBin *webrtcbin;
+ GWeakRef webrtcbin_weak;
gboolean opened;
gulong src_probe;
GError *stored_error;
void webrtc_data_channel_link_to_sctp (WebRTCDataChannel *channel,
WebRTCSCTPTransport *sctp_transport);
+G_GNUC_INTERNAL
+void webrtc_data_channel_set_webrtcbin (WebRTCDataChannel *channel,
+ GstWebRTCBin *webrtcbin);
+
G_DECLARE_FINAL_TYPE (WebRTCErrorIgnoreBin, webrtc_error_ignore_bin, WEBRTC, ERROR_IGNORE_BIN, GstBin);
G_END_DECLS