Beispiel #1
0
int
main (int argc, char *argv[])
{
  GstElementFactory *factory;
  GOptionEntry options[] = {
    GST_TOOLS_GOPTION_VERSION,
    {NULL}
  };
  GOptionContext *ctx;
  GError *err = NULL;

  setlocale (LC_ALL, "");

#if !GLIB_CHECK_VERSION (2, 31, 0)
  g_thread_init (NULL);
#endif

  gst_tools_set_prgname ("gst-xmlinspect");

  ctx = g_option_context_new ("[ELEMENT-NAME]");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    exit (1);
  }
  g_option_context_free (ctx);

  gst_tools_print_version ("gst-xmlinspect");

  /* if no arguments, print out all elements */
  if (argc == 1) {
    GList *features, *f;

    features = gst_registry_get_feature_list (gst_registry_get_default (),
        GST_TYPE_ELEMENT_FACTORY);

    PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");

    for (f = features; f != NULL; f = f->next)
      print_element_info (GST_ELEMENT_FACTORY (f->data));

    gst_plugin_feature_list_free (features);
    return 0;
  }

  /* else we try to get a factory */
  factory = gst_element_factory_find (argv[1]);

  /* if there's a factory, print out the info */
  if (factory) {
    PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
    return print_element_info (factory);
  }

  /* otherwise, error out */
  g_printerr ("no such element '%s'\n", argv[1]);
  return -1;
}
Beispiel #2
0
int
main (int argc, char *argv[])
{
  gchar **filenames = NULL;
  guint num, i;
  GError *err = NULL;
  GOptionContext *ctx;
  GOptionEntry options[] = {
    GST_TOOLS_GOPTION_VERSION,
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
    {NULL}
  };

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

#if !GLIB_CHECK_VERSION (2, 31, 0)
  g_thread_init (NULL);
#endif

  gst_tools_set_prgname ("gst-typefind");

  ctx = g_option_context_new ("FILES");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
    exit (1);
  }
  g_option_context_free (ctx);

  gst_tools_print_version ("gst-typefind");

  if (filenames == NULL || *filenames == NULL) {
    g_print ("Please give a filename to typefind\n\n");
    return 1;
  }

  num = g_strv_length (filenames);

  for (i = 0; i < num; ++i) {
    typefind_file (filenames[i]);
  }

  g_strfreev (filenames);

  return 0;
}
Beispiel #3
0
int
main (int argc, char *argv[])
{
  gboolean print_all = FALSE;
  gboolean do_print_blacklist = FALSE;
  gboolean plugin_name = FALSE;
  gboolean print_aii = FALSE;
  gboolean uri_handlers = FALSE;
#ifndef GST_DISABLE_OPTION_PARSING
  GOptionEntry options[] = {
    {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
        N_("Print all elements"), NULL},
    {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
        N_("Print list of blacklisted files"), NULL},
    {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
        N_("Print a machine-parsable list of features the specified plugin "
              "or all plugins provide.\n                                       "
              "Useful in connection with external automatic plugin "
              "installation mechanisms"), NULL},
    {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
        N_("List the plugin contents"), NULL},
    {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
          N_
          ("Print supported URI schemes, with the elements that implement them"),
        NULL},
    GST_TOOLS_GOPTION_VERSION,
    {NULL}
  };
  GOptionContext *ctx;
  GError *err = NULL;
#endif

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  g_thread_init (NULL);

  gst_tools_set_prgname ("gst-inspect");

#ifndef GST_DISABLE_OPTION_PARSING
  ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    exit (1);
  }
  g_option_context_free (ctx);
#else
  gst_init (&argc, &argv);
#endif

  gst_tools_print_version ("gst-inspect");

  if (print_all && argc > 1) {
    g_print ("-a requires no extra arguments\n");
    return 1;
  }

  if (uri_handlers && argc > 1) {
    g_print ("-u requires no extra arguments\n");
    exit (1);
  }

  /* if no arguments, print out list of elements */
  if (uri_handlers) {
    print_all_uri_handlers ();
  } else if (argc == 1 || print_all) {
    if (do_print_blacklist)
      print_blacklist ();
    else {
      if (print_aii)
        print_all_plugin_automatic_install_info ();
      else
        print_element_list (print_all);
    }
  } else {
    /* else we try to get a factory */
    GstElementFactory *factory;
    GstPlugin *plugin;
    const char *arg = argv[argc - 1];
    int retval;

    if (!plugin_name) {
      factory = gst_element_factory_find (arg);

      /* if there's a factory, print out the info */
      if (factory) {
        retval = print_element_info (factory, print_all);
        gst_object_unref (factory);
      } else {
        retval = print_element_features (arg);
      }
    } else {
      retval = -1;
    }

    /* otherwise check if it's a plugin */
    if (retval) {
      plugin = gst_default_registry_find_plugin (arg);

      /* if there is such a plugin, print out info */
      if (plugin) {
        if (print_aii) {
          print_plugin_automatic_install_info (plugin);
        } else {
          print_plugin_info (plugin);
          print_plugin_features (plugin);
        }
      } else {
        GError *error = NULL;

        if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
          plugin = gst_plugin_load_file (arg, &error);

          if (plugin) {
            if (print_aii) {
              print_plugin_automatic_install_info (plugin);
            } else {
              print_plugin_info (plugin);
              print_plugin_features (plugin);
            }
          } else {
            g_print (_("Could not load plugin file: %s\n"), error->message);
            g_error_free (error);
            return -1;
          }
        } else {
          g_print (_("No such element or plugin '%s'\n"), arg);
          return -1;
        }
      }
    }
  }

  return 0;
}