gst-indent

This commit is contained in:
Costa Shulyupin 2020-04-14 13:49:55 +03:00 committed by Sebastian Dröge
parent ca96b6de86
commit 2557eab9d5

View File

@ -18,7 +18,8 @@
#include <string.h> #include <string.h>
enum AppState { enum AppState
{
APP_STATE_UNKNOWN = 0, APP_STATE_UNKNOWN = 0,
APP_STATE_ERROR = 1, /* generic error */ APP_STATE_ERROR = 1, /* generic error */
SERVER_CONNECTING = 1000, SERVER_CONNECTING = 1000,
@ -49,12 +50,14 @@ static const gchar *server_url = "wss://webrtc.nirbheek.in:8443";
static gboolean disable_ssl = FALSE; static gboolean disable_ssl = FALSE;
static gboolean remote_is_offerer = FALSE; static gboolean remote_is_offerer = FALSE;
static GOptionEntry entries[] = static GOptionEntry entries[] = {
{ {"peer-id", 0, 0, G_OPTION_ARG_STRING, &peer_id,
{ "peer-id", 0, 0, G_OPTION_ARG_STRING, &peer_id, "String ID of the peer to connect to", "ID" }, "String ID of the peer to connect to", "ID"},
{ "server", 0, 0, G_OPTION_ARG_STRING, &server_url, "Signalling server to connect to", "URL" }, {"server", 0, 0, G_OPTION_ARG_STRING, &server_url,
"Signalling server to connect to", "URL"},
{"disable-ssl", 0, 0, G_OPTION_ARG_NONE, &disable_ssl, "Disable ssl", NULL}, {"disable-ssl", 0, 0, G_OPTION_ARG_NONE, &disable_ssl, "Disable ssl", NULL},
{ "remote-offerer", 0, 0, G_OPTION_ARG_NONE, &remote_is_offerer, "Request that the peer generate the offer and we'll answer", NULL }, {"remote-offerer", 0, 0, G_OPTION_ARG_NONE, &remote_is_offerer,
"Request that the peer generate the offer and we'll answer", NULL},
{NULL}, {NULL},
}; };
@ -221,7 +224,8 @@ send_sdp_to_peer (GstWebRTCSessionDescription *desc)
JsonObject *msg, *sdp; JsonObject *msg, *sdp;
if (app_state < PEER_CALL_NEGOTIATING) { if (app_state < PEER_CALL_NEGOTIATING) {
cleanup_and_quit_loop ("Can't send SDP to peer, not in call", APP_STATE_ERROR); cleanup_and_quit_loop ("Can't send SDP to peer, not in call",
APP_STATE_ERROR);
return; return;
} }
@ -231,12 +235,10 @@ send_sdp_to_peer (GstWebRTCSessionDescription *desc)
if (desc->type == GST_WEBRTC_SDP_TYPE_OFFER) { if (desc->type == GST_WEBRTC_SDP_TYPE_OFFER) {
g_print ("Sending offer:\n%s\n", text); g_print ("Sending offer:\n%s\n", text);
json_object_set_string_member (sdp, "type", "offer"); json_object_set_string_member (sdp, "type", "offer");
} } else if (desc->type == GST_WEBRTC_SDP_TYPE_ANSWER) {
else if (desc->type == GST_WEBRTC_SDP_TYPE_ANSWER) {
g_print ("Sending answer:\n%s\n", text); g_print ("Sending answer:\n%s\n", text);
json_object_set_string_member (sdp, "type", "answer"); json_object_set_string_member (sdp, "type", "answer");
} } else {
else {
g_assert_not_reached (); g_assert_not_reached ();
} }
@ -288,7 +290,8 @@ on_negotiation_needed (GstElement * element, gpointer user_data)
g_free (msg); g_free (msg);
} else { } else {
GstPromise *promise; GstPromise *promise;
promise = gst_promise_new_with_change_func (on_offer_created, user_data, NULL);; promise =
gst_promise_new_with_change_func (on_offer_created, user_data, NULL);;
g_signal_emit_by_name (webrtc1, "create-offer", NULL, promise); g_signal_emit_by_name (webrtc1, "create-offer", NULL, promise);
} }
} }
@ -328,18 +331,19 @@ data_channel_on_message_string (GObject * dc, gchar *str, gpointer user_data)
static void static void
connect_data_channel_signals (GObject * data_channel) connect_data_channel_signals (GObject * data_channel)
{ {
g_signal_connect (data_channel, "on-error", G_CALLBACK (data_channel_on_error), g_signal_connect (data_channel, "on-error",
NULL); G_CALLBACK (data_channel_on_error), NULL);
g_signal_connect (data_channel, "on-open", G_CALLBACK (data_channel_on_open), g_signal_connect (data_channel, "on-open", G_CALLBACK (data_channel_on_open),
NULL); NULL);
g_signal_connect (data_channel, "on-close", G_CALLBACK (data_channel_on_close), g_signal_connect (data_channel, "on-close",
NULL); G_CALLBACK (data_channel_on_close), NULL);
g_signal_connect (data_channel, "on-message-string", G_CALLBACK (data_channel_on_message_string), g_signal_connect (data_channel, "on-message-string",
NULL); G_CALLBACK (data_channel_on_message_string), NULL);
} }
static void static void
on_data_channel (GstElement * webrtc, GObject * data_channel, gpointer user_data) on_data_channel (GstElement * webrtc, GObject * data_channel,
gpointer user_data)
{ {
connect_data_channel_signals (data_channel); connect_data_channel_signals (data_channel);
receive_channel = data_channel; receive_channel = data_channel;
@ -352,8 +356,7 @@ on_ice_gathering_state_notify (GstElement * webrtcbin, GParamSpec * pspec,
GstWebRTCICEGatheringState ice_gather_state; GstWebRTCICEGatheringState ice_gather_state;
const gchar *new_state = "unknown"; const gchar *new_state = "unknown";
g_object_get (webrtcbin, "ice-gathering-state", &ice_gather_state, g_object_get (webrtcbin, "ice-gathering-state", &ice_gather_state, NULL);
NULL);
switch (ice_gather_state) { switch (ice_gather_state) {
case GST_WEBRTC_ICE_GATHERING_STATE_NEW: case GST_WEBRTC_ICE_GATHERING_STATE_NEW:
new_state = "new"; new_state = "new";
@ -375,12 +378,12 @@ start_pipeline (void)
GError *error = NULL; GError *error = NULL;
pipe1 = pipe1 =
gst_parse_launch ("webrtcbin bundle-policy=max-bundle name=sendrecv " STUN_SERVER gst_parse_launch ("webrtcbin bundle-policy=max-bundle name=sendrecv "
STUN_SERVER
"videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! " "videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! "
"queue ! " RTP_CAPS_VP8 "96 ! sendrecv. " "queue ! " RTP_CAPS_VP8 "96 ! sendrecv. "
"audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! " "audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! "
"queue ! " RTP_CAPS_OPUS "97 ! sendrecv. ", "queue ! " RTP_CAPS_OPUS "97 ! sendrecv. ", &error);
&error);
if (error) { if (error) {
g_printerr ("Failed to parse launch: %s\n", error->message); g_printerr ("Failed to parse launch: %s\n", error->message);
@ -525,15 +528,13 @@ 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 ();
g_signal_emit_by_name (webrtc1, "set-remote-description", offer, g_signal_emit_by_name (webrtc1, "set-remote-description", offer, promise);
promise);
gst_promise_interrupt (promise); gst_promise_interrupt (promise);
gst_promise_unref (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, promise = gst_promise_new_with_change_func (on_answer_created, NULL, NULL);
NULL);
g_signal_emit_by_name (webrtc1, "create-answer", NULL, promise); g_signal_emit_by_name (webrtc1, "create-answer", NULL, promise);
} }
@ -669,8 +670,7 @@ on_server_message (SoupWebsocketConnection * conn, SoupWebsocketDataType type,
gst_promise_unref (promise); gst_promise_unref (promise);
} }
app_state = PEER_CALL_STARTED; app_state = PEER_CALL_STARTED;
} } else {
else {
g_print ("Received offer:\n%s\n", text); g_print ("Received offer:\n%s\n", text);
on_offer_received (sdp); on_offer_received (sdp);
} }
@ -732,7 +732,8 @@ connect_to_websocket_server_async (void)
SoupSession *session; SoupSession *session;
const char *https_aliases[] = { "wss", NULL }; const char *https_aliases[] = { "wss", NULL };
session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, !disable_ssl, session =
soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, !disable_ssl,
SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
//SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt", //SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt",
SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL); SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);
@ -759,7 +760,8 @@ check_plugins (void)
GstPlugin *plugin; GstPlugin *plugin;
GstRegistry *registry; GstRegistry *registry;
const gchar *needed[] = { "opus", "vpx", "nice", "webrtc", "dtls", "srtp", const gchar *needed[] = { "opus", "vpx", "nice", "webrtc", "dtls", "srtp",
"rtpmanager", "videotestsrc", "audiotestsrc", NULL}; "rtpmanager", "videotestsrc", "audiotestsrc", NULL
};
registry = gst_registry_get (); registry = gst_registry_get ();
ret = TRUE; ret = TRUE;