From 55e86469d9aab4adf24dee86e3e4c06b623bcea1 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 10 Mar 2018 01:54:48 +0530 Subject: [PATCH] Check for all necessary plugins at startup People seem to be having problems ensuring that they have all the right plugins built, so make it a bit easier for them. --- .../multiparty-sendrecv/gst/mp-webrtc-sendrecv.c | 27 ++++++++++++++++++++++ webrtc/sendrecv/gst/webrtc-sendrecv.c | 27 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c b/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c index 00bcae4..4a99eb8 100644 --- a/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c +++ b/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c @@ -893,6 +893,30 @@ connect_to_websocket_server_async (void) app_state = SERVER_CONNECTING; } +static gboolean +check_plugins (void) +{ + int i; + gboolean ret; + GstPlugin *plugin; + GstRegistry *registry; + const gchar *needed[] = { "opus", "nice", "webrtc", "dtls", "srtp" + "rtpmanager", "audiotestsrc", NULL}; + + registry = gst_registry_get (); + ret = TRUE; + for (i = 0; i < g_strv_length ((gchar **) needed); i++) { + plugin = gst_registry_find_plugin (registry, needed[i]); + if (!plugin) { + g_print ("Required gstreamer plugin '%s' not found\n", needed[i]); + ret = FALSE; + continue; + } + gst_object_unref (plugin); + } + return ret; +} + int main (int argc, char *argv[]) { @@ -908,6 +932,9 @@ main (int argc, char *argv[]) return -1; } + if (!check_plugins ()) + return -1; + if (!room_id) { g_printerr ("--room-id is a required argument\n"); return -1; diff --git a/webrtc/sendrecv/gst/webrtc-sendrecv.c b/webrtc/sendrecv/gst/webrtc-sendrecv.c index 28f9660..fcad886 100644 --- a/webrtc/sendrecv/gst/webrtc-sendrecv.c +++ b/webrtc/sendrecv/gst/webrtc-sendrecv.c @@ -568,6 +568,30 @@ connect_to_websocket_server_async (void) app_state = SERVER_CONNECTING; } +static gboolean +check_plugins (void) +{ + int i; + gboolean ret; + GstPlugin *plugin; + GstRegistry *registry; + const gchar *needed[] = { "opus", "vpx", "nice", "webrtc", "dtls", "srtp", + "rtpmanager", "videotestsrc", "audiotestsrc", NULL}; + + registry = gst_registry_get (); + ret = TRUE; + for (i = 0; i < g_strv_length ((gchar **) needed); i++) { + plugin = gst_registry_find_plugin (registry, needed[i]); + if (!plugin) { + g_print ("Required gstreamer plugin '%s' not found\n", needed[i]); + ret = FALSE; + continue; + } + gst_object_unref (plugin); + } + return ret; +} + int main (int argc, char *argv[]) { @@ -583,6 +607,9 @@ main (int argc, char *argv[]) return -1; } + if (!check_plugins ()) + return -1; + if (!peer_id) { g_printerr ("--peer-id is a required argument\n"); return -1; -- 2.7.4