sendrecv: wait until the offer is set before creating answer

Pragmatically, an answer cannot be created until the offer is created as
the answer creation needs information from the offer.  Practically, due
to implementation details, the answer was always queued after the set of
the offer and so the call flow did not matter.

The current code also hid a bug in webrtcbin where ice candidates would be
generated before the answer had been created which is against the JSEP
specification.

Change to the correct call flow for exemplary effect.
This commit is contained in:
Matthew Waters 2020-05-01 18:52:33 +10:00 committed by Matthew Waters
parent 615813ef93
commit 3a86a37c03

View file

@ -517,7 +517,15 @@ on_answer_created (GstPromise * promise, gpointer user_data)
}
static void
on_offer_received (GstSDPMessage * sdp)
on_offer_set (GstPromise * promise, gpointer user_data)
{
gst_promise_unref (promise);
promise = gst_promise_new_with_change_func (on_answer_created, NULL, NULL);
g_signal_emit_by_name (webrtc1, "create-answer", NULL, promise);
}
static void
on_offer_received (GstSDPMessage *sdp)
{
GstWebRTCSessionDescription *offer = NULL;
GstPromise *promise;
@ -527,15 +535,11 @@ on_offer_received (GstSDPMessage * sdp)
/* Set remote description on our pipeline */
{
promise = gst_promise_new ();
g_signal_emit_by_name (webrtc1, "set-remote-description", offer, promise);
gst_promise_interrupt (promise);
gst_promise_unref (promise);
promise = gst_promise_new_with_change_func (on_offer_set, NULL, NULL);
g_signal_emit_by_name (webrtc1, "set-remote-description", offer,
promise);
}
gst_webrtc_session_description_free (offer);
promise = gst_promise_new_with_change_func (on_answer_created, NULL, NULL);
g_signal_emit_by_name (webrtc1, "create-answer", NULL, promise);
}
/* One mega message handler for our asynchronous calling mechanism */