Beispiel #1
0
gint
main (gint argc, gchar * argv[])
{
  GSList *before, *after;

  unsetenv ("GST_DEBUG");
  gst_init (&argc, &argv);

  before = gst_debug_get_all_categories ();
  GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
      "default category for this test");
  GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
      GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
      "static category for this test");
  after = gst_debug_get_all_categories ();

  g_print ("removing default log function\n");
#ifdef GST_DISABLE_GST_DEBUG
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 0);
#else
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
  g_print
      ("checking, if the two new categories are put into the category list correctly...\n");
  g_assert (g_slist_length (after) - g_slist_length (before) == 2);
  /* check the _get stuff */
  g_print
      ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
  g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
  g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
  g_assert (strcmp (gst_debug_category_get_description (cat),
          "default category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat) ==
      gst_debug_get_default_threshold ());
  g_assert (strcmp (gst_debug_category_get_name (cat_static),
          "cat_static") == 0);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
  g_assert (strcmp (gst_debug_category_get_description (cat_static),
          "static category for this test") == 0);
  g_assert (gst_debug_category_get_threshold (cat_static) ==
      gst_debug_get_default_threshold ());
  /* check if setting levels for names work */
  g_print
      ("checking if changing threshold for names affects existing categories...\n");
  gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat_static) ==
      gst_debug_get_default_threshold ());
  gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
  g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
#endif

  g_print ("everything ok.\n");
  return 0;
}
void
gst_debugserver_log_send_debug_categories (GstDebugserverTcp * tcp_server,
    TcpClient * client)
{
  GstDebugger__GStreamerData gst_data = GST_DEBUGGER__GSTREAMER_DATA__INIT;
  GstDebugger__DebugCategories debug_categories =
      GST_DEBUGGER__DEBUG_CATEGORIES__INIT;
  gint categories_count, i = 0;

  gst_data.info_type_case =
      GST_DEBUGGER__GSTREAMER_DATA__INFO_TYPE_DEBUG_CATEGORIES;

  GSList *tmp, *all_categories = gst_debug_get_all_categories ();

  tmp = all_categories = g_slist_sort (all_categories, sort_by_category_name);
  categories_count = g_slist_length (all_categories);

  debug_categories.n_category = categories_count;
  debug_categories.category =
      (char **) g_malloc (sizeof (char *) * categories_count);

  while (tmp) {
    GstDebugCategory *cat = (GstDebugCategory *) tmp->data;
    debug_categories.category[i++] = (char *) gst_debug_category_get_name (cat);
    tmp = g_slist_next (tmp);
  }
  g_slist_free (all_categories);

  gst_data.debug_categories = &debug_categories;

  gst_debugserver_tcp_send_packet (tcp_server, client, &gst_data);

  g_free (debug_categories.category);
}
Beispiel #3
0
static void
gst_debug_help (void)
{
  GSList *list, *walk;
  GList *list2, *g;

  /* Need to ensure the registry is loaded to get debug categories */
  if (!init_post (NULL, NULL, NULL, NULL))
    exit (1);

  list2 = gst_registry_plugin_filter (gst_registry_get (),
      select_all, FALSE, NULL);

  /* FIXME this is gross.  why don't debug have categories PluginFeatures? */
  for (g = list2; g; g = g_list_next (g)) {
    GstPlugin *plugin = GST_PLUGIN_CAST (g->data);

    gst_plugin_load (plugin);
  }
  g_list_free (list2);

  list = gst_debug_get_all_categories ();
  walk = list = g_slist_sort (list, sort_by_category_name);

  g_print ("\n");
  g_print ("name                  level    description\n");
  g_print ("---------------------+--------+--------------------------------\n");

  while (walk) {
    gboolean on_unix;
    GstDebugCategory *cat = (GstDebugCategory *) walk->data;
    GstDebugColorMode coloring = gst_debug_get_color_mode ();
#ifdef G_OS_UNIX
    on_unix = TRUE;
#else
    on_unix = FALSE;
#endif

    if (GST_DEBUG_COLOR_MODE_UNIX == coloring
        || (on_unix && GST_DEBUG_COLOR_MODE_ON == coloring)) {
      gchar *color = gst_debug_construct_term_color (cat->color);

      g_print ("%s%-20s\033[00m  %1d %s  %s%s\033[00m\n",
          color,
          gst_debug_category_get_name (cat),
          gst_debug_category_get_threshold (cat),
          gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
          color, gst_debug_category_get_description (cat));
      g_free (color);
    } else if (GST_DEBUG_COLOR_MODE_ON == coloring && !on_unix) {
#ifdef G_OS_WIN32
      gint color = gst_debug_construct_win_color (cat->color);
      const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;

      SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), color);
      g_print ("%-20s", gst_debug_category_get_name (cat));
      SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear);
      g_print (" %1d %s ", gst_debug_category_get_threshold (cat),
          gst_debug_level_get_name (gst_debug_category_get_threshold (cat)));
      SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), color);
      g_print ("%s", gst_debug_category_get_description (cat));
      SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear);
      g_print ("\n");
#endif /* G_OS_WIN32 */
    } else {
      g_print ("%-20s  %1d %s  %s\n", gst_debug_category_get_name (cat),
          gst_debug_category_get_threshold (cat),
          gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
          gst_debug_category_get_description (cat));
    }
    walk = g_slist_next (walk);
  }
  g_slist_free (list);
  g_print ("\n");
}