Check for all necessary plugins at startup
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 9 Mar 2018 20:24:48 +0000 (01:54 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Fri, 9 Mar 2018 20:24:48 +0000 (01:54 +0530)
People seem to be having problems ensuring that they have all the
right plugins built, so make it a bit easier for them.

webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c
webrtc/sendrecv/gst/webrtc-sendrecv.c

index 00bcae4..4a99eb8 100644 (file)
@@ -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;
index 28f9660..fcad886 100644 (file)
@@ -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;