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

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