static gboolean
_execute_op (GstWebRTCBinTask * op)
{
+ GstStructure *s;
+
PC_LOCK (op->webrtc);
if (op->webrtc->priv->is_closed) {
PC_UNLOCK (op->webrtc);
goto out;
}
- op->op (op->webrtc, op->data);
+ s = op->op (op->webrtc, op->data);
PC_UNLOCK (op->webrtc);
+ if (op->promise)
+ gst_promise_reply (op->promise, s);
+ else if (s)
+ gst_structure_free (s);
+
out:
return G_SOURCE_REMOVE;
}
#undef STATE
}
-static void
+static GstStructure *
_update_ice_gathering_state_task (GstWebRTCBin * webrtc, gpointer data)
{
GstWebRTCICEGatheringState old_state = webrtc->ice_gathering_state;
g_object_notify (G_OBJECT (webrtc), "ice-gathering-state");
PC_LOCK (webrtc);
}
+
+ return NULL;
}
static void
NULL, NULL);
}
-static void
+static GstStructure *
_update_ice_connection_state_task (GstWebRTCBin * webrtc, gpointer data)
{
GstWebRTCICEConnectionState old_state = webrtc->ice_connection_state;
g_object_notify (G_OBJECT (webrtc), "ice-connection-state");
PC_LOCK (webrtc);
}
+
+ return NULL;
}
static void
NULL, NULL);
}
-static void
+static GstStructure *
_update_peer_connection_state_task (GstWebRTCBin * webrtc, gpointer data)
{
GstWebRTCPeerConnectionState old_state = webrtc->peer_connection_state;
g_object_notify (G_OBJECT (webrtc), "connection-state");
PC_LOCK (webrtc);
}
+
+ return NULL;
}
static void
return FALSE;
}
-static void
+static GstStructure *
_check_need_negotiation_task (GstWebRTCBin * webrtc, gpointer unused)
{
if (webrtc->priv->need_negotiation) {
0);
PC_LOCK (webrtc);
}
+
+ return NULL;
}
/* http://w3c.github.io/webrtc-pc/#dfn-update-the-negotiation-needed-flag */
static void _on_sctp_notify_dtls_state (GstWebRTCDTLSTransport * transport,
GParamSpec * pspec, GstWebRTCBin * webrtc);
-static void
+static GstStructure *
_sctp_check_dtls_state_task (GstWebRTCBin * webrtc, gpointer unused)
{
TransportStream *stream;
if (dtls_state != GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTED) {
GST_DEBUG_OBJECT (webrtc,
"Data channel DTLS connection is not ready yet: %d", dtls_state);
- return;
+ return NULL;
}
GST_DEBUG_OBJECT (webrtc, "Data channel DTLS connection is now ready");
/* Not locked state anymore so this was already taken care of before */
if (!gst_element_is_locked_state (sctp_transport->sctpdec))
- return;
+ return NULL;
/* Start up the SCTP elements now that the DTLS connection is established */
gst_element_set_locked_state (sctp_transport->sctpdec, FALSE);
g_signal_handlers_disconnect_by_func (transport, _on_sctp_notify_dtls_state,
webrtc);
+
+ return NULL;
}
static void
return ret;
cancel_offer:
- gst_sdp_message_uninit (ret);
+ gst_sdp_message_free (ret);
ret = NULL;
goto out;
}
struct create_sdp
{
GstStructure *options;
- GstPromise *promise;
GstWebRTCSDPType type;
};
-static void
+static GstStructure *
_create_sdp_task (GstWebRTCBin * webrtc, struct create_sdp *data)
{
GstWebRTCSessionDescription *desc = NULL;
}
out:
- PC_UNLOCK (webrtc);
- gst_promise_reply (data->promise, s);
- PC_LOCK (webrtc);
if (desc)
gst_webrtc_session_description_free (desc);
+
+ return s;
}
static void
{
if (data->options)
gst_structure_free (data->options);
- gst_promise_unref (data->promise);
g_free (data);
}
if (options)
data->options = gst_structure_copy (options);
- data->promise = gst_promise_ref (promise);
data->type = GST_WEBRTC_SDP_TYPE_OFFER;
if (!gst_webrtc_bin_enqueue_task (webrtc, (GstWebRTCBinFunc) _create_sdp_task,
if (options)
data->options = gst_structure_copy (options);
- data->promise = gst_promise_ref (promise);
data->type = GST_WEBRTC_SDP_TYPE_ANSWER;
if (!gst_webrtc_bin_enqueue_task (webrtc, (GstWebRTCBinFunc) _create_sdp_task,
struct set_description
{
- GstPromise *promise;
SDPSource source;
GstWebRTCSessionDescription *sdp;
};
}
/* http://w3c.github.io/webrtc-pc/#set-description */
-static void
+static GstStructure *
_set_description_task (GstWebRTCBin * webrtc, struct set_description *sd)
{
GstWebRTCSignalingState new_signaling_state = webrtc->signaling_state;
out:
g_strfreev (bundled);
- PC_UNLOCK (webrtc);
if (error) {
+ GstStructure *s = gst_structure_new ("application/x-gstwebrtcbin-error",
+ "error", G_TYPE_ERROR, error, NULL);
GST_WARNING_OBJECT (webrtc, "returning error: %s", error->message);
- gst_promise_reply (sd->promise,
- gst_structure_new ("application/x-gstwebrtcbin-error", "error",
- G_TYPE_ERROR, error, NULL));
g_clear_error (&error);
+ return s;
} else {
- gst_promise_reply (sd->promise, NULL);
+ return NULL;
}
- PC_LOCK (webrtc);
}
static void
_free_set_description_data (struct set_description *sd)
{
- if (sd->promise)
- gst_promise_unref (sd->promise);
if (sd->sdp)
gst_webrtc_session_description_free (sd->sdp);
g_free (sd);
goto bad_input;
sd = g_new0 (struct set_description, 1);
- if (promise != NULL)
- sd->promise = gst_promise_ref (promise);
sd->source = SDP_REMOTE;
sd->sdp = gst_webrtc_session_description_copy (remote_sdp);
goto bad_input;
sd = g_new0 (struct set_description, 1);
- if (promise != NULL)
- sd->promise = gst_promise_ref (promise);
sd->source = SDP_LOCAL;
sd->sdp = gst_webrtc_session_description_copy (local_sdp);
}
}
-static void
+static GstStructure *
_add_ice_candidate_task (GstWebRTCBin * webrtc, IceCandidateItem * item)
{
if (!webrtc->current_local_description || !webrtc->current_remote_description) {
} else {
_add_ice_candidate (webrtc, item, FALSE);
}
+
+ return NULL;
}
static void
(GDestroyNotify) _free_ice_candidate_item, NULL);
}
-static void
+static GstStructure *
_on_local_ice_candidate_task (GstWebRTCBin * webrtc)
{
gsize i;
if (webrtc->priv->pending_local_ice_candidates->len == 0) {
ICE_UNLOCK (webrtc);
GST_LOG_OBJECT (webrtc, "No ICE candidates to process right now");
- return; /* Nothing to process */
+ return NULL; /* Nothing to process */
}
/* Take the array so we can process it all and free it later
* without holding the lock
}
g_array_free (items, TRUE);
+
+ return NULL;
}
static void
}
/* https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-getstats() */
-static void
+static GstStructure *
_get_stats_task (GstWebRTCBin * webrtc, struct get_stats *stats)
{
- GstStructure *s;
/* Our selector is the pad,
* https://www.w3.org/TR/webrtc/#dfn-stats-selection-algorithm
*/
- s = gst_webrtc_bin_create_stats (webrtc, stats->pad);
-
- PC_UNLOCK (webrtc);
- gst_promise_reply (stats->promise, s);
- PC_LOCK (webrtc);
+ return gst_webrtc_bin_create_stats (webrtc, stats->pad);
}
static void