Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

webrtc-sendrecv.c: small cleanup #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions sendrecv/gst/webrtc-sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,15 @@ static void
on_offer_created (GstPromise * promise, gpointer user_data)
{
GstWebRTCSessionDescription *offer = NULL;
const GstStructure *reply;

g_assert_cmphex (app_state, ==, PEER_CALL_NEGOTIATING);

g_assert_cmphex (gst_promise_wait (promise), ==, GST_PROMISE_RESULT_REPLIED);
reply = gst_promise_get_reply (promise);
gst_structure_get (reply, "offer",
gst_structure_get (gst_promise_get_reply (promise), "offer",
GST_TYPE_WEBRTC_SESSION_DESCRIPTION, &offer, NULL);
gst_promise_unref (promise);

promise = gst_promise_new ();
g_signal_emit_by_name (webrtc1, "set-local-description", offer, promise);
gst_promise_interrupt (promise);
gst_promise_unref (promise);
g_signal_emit_by_name (webrtc1, "set-local-description", offer, NULL);

/* Send offer to peer */
send_sdp_to_peer (offer);
Expand All @@ -284,16 +279,11 @@ on_negotiation_needed (GstElement * element, gpointer user_data)
{
app_state = PEER_CALL_NEGOTIATING;

if (remote_is_offerer) {
gchar *msg = g_strdup_printf ("OFFER_REQUEST");
soup_websocket_connection_send_text (ws_conn, msg);
g_free (msg);
} else {
GstPromise *promise;
promise =
gst_promise_new_with_change_func (on_offer_created, user_data, NULL);;
g_signal_emit_by_name (webrtc1, "create-offer", NULL, promise);
}
if (remote_is_offerer)
soup_websocket_connection_send_text (ws_conn, "OFFER_REQUEST");
else
g_signal_emit_by_name (webrtc1, "create-offer", NULL,
gst_promise_new_with_change_func (on_offer_created, user_data, NULL));
}

#define STUN_SERVER " stun-server=stun://stun.l.google.com:19302 "
Expand Down Expand Up @@ -496,20 +486,15 @@ static void
on_answer_created (GstPromise * promise, gpointer user_data)
{
GstWebRTCSessionDescription *answer = NULL;
const GstStructure *reply;

g_assert_cmphex (app_state, ==, PEER_CALL_NEGOTIATING);

g_assert_cmphex (gst_promise_wait (promise), ==, GST_PROMISE_RESULT_REPLIED);
reply = gst_promise_get_reply (promise);
gst_structure_get (reply, "answer",
gst_structure_get (gst_promise_get_reply (promise), "answer",
GST_TYPE_WEBRTC_SESSION_DESCRIPTION, &answer, NULL);
gst_promise_unref (promise);

promise = gst_promise_new ();
g_signal_emit_by_name (webrtc1, "set-local-description", answer, promise);
gst_promise_interrupt (promise);
gst_promise_unref (promise);
g_signal_emit_by_name (webrtc1, "set-local-description", answer, NULL);

/* Send answer to peer */
send_sdp_to_peer (answer);
Expand All @@ -526,12 +511,7 @@ on_offer_received (GstSDPMessage * sdp)
g_assert_nonnull (offer);

/* 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);
}
g_signal_emit_by_name (webrtc1, "set-remote-description", offer, NULL);
gst_webrtc_session_description_free (offer);

promise = gst_promise_new_with_change_func (on_answer_created, NULL, NULL);
Expand Down