EXPORT_API void gub_ref(const char *gst_debug_string)
{
    gub_log("GST ref (%d -> %d)", gub_ref_count, gub_ref_count + 1);
    if (gub_ref_count == 0) {
        GError *err = 0;
        gchar *version = NULL;

        if (!gst_init_check(0, 0, &err)) {
            gub_log("Failed to initialize GStreamer: %s", err ? err->message : "<No error message>");
            return;
        }

        /* get time we started for debugging messages */
        _priv_gst_info_start_time = gst_util_get_timestamp();

        gst_debug_remove_log_function(gst_debug_log_default);
        gst_debug_add_log_function((GstLogFunction)gst_debug_gub, NULL, NULL);
        if (gst_debug_string) {
            gub_log("Setting debug level to %s", gst_debug_string);
            gst_debug_set_active(TRUE);
            gst_debug_set_threshold_from_string(gst_debug_string, TRUE);
        } else {
            gst_debug_set_active(FALSE);
        }

#if defined (__ANDROID__)
        gst_android_register_static_plugins();
        gst_android_load_gio_modules();
#endif

        gub_main_loop_thread = g_thread_new("GstUnityBridge Main Thread", gub_main_loop_func, NULL);
        if (!gub_main_loop_thread) {
            gub_log("Failed to create GLib main thread: %s", err ? err->message : "<No error message>");
            return;
        }

        version = gst_version_string();
        gub_log("%s initialized", version);
        g_free(version);
    }

    gub_ref_count++;
}
Example #2
0
static void init_gst()
{
    static bool gst_inited = false;
    if (gst_inited)
        return;

    ALOGI("%s, %lu, begin", __func__, time(0));
    gint level = 0xff;
    g_set_print_handler(print_func); // g_print
    g_set_printerr_handler(print_func); // g_printerr
    g_log_set_handler("k2player", (GLogLevelFlags)level, log_func, NULL);
    g_log_set_default_handler(log_func, NULL);

    if (!g_thread_supported ()) {
        g_thread_init (NULL);
    }

    gst_debug_set_active(true);
#if 0
    GST_DEBUG_CATEGORY_STATIC (my_category);// define category (statically)
    #define GST_CAT_DEFAULT my_category     // set as default
    GST_DEBUG_CATEGORY_INIT (my_category, "my category", 0, "This is my very own");
    gst_debug_category_set_threshold(my_category, GST_LEVEL_TRACE);
#endif

    ALOGI("%s, %lu, gst_init", __func__, time(0));
    int argc = 1;
    char *argvs[] = {(char *)"k2player", NULL};
    char **argv = argvs;
    gst_init (&argc, &argv);

    ALOGI("%s, %lu, gst_static_init", __func__, time(0));
    gst_static_plugins();

    gst_inited = true;
    ALOGI("%s, %lu, end", __func__, time(0));
}
Example #3
0
static gboolean
parse_one_option (gint opt, const gchar * arg, GError ** err)
{
  switch (opt) {
    case ARG_VERSION:
      g_print ("GStreamer Core Library version %s\n", PACKAGE_VERSION);
      exit (0);
    case ARG_FATAL_WARNINGS:{
      GLogLevelFlags fatal_mask;

      fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
      fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
      g_log_set_always_fatal (fatal_mask);
      break;
    }
#ifndef GST_DISABLE_GST_DEBUG
    case ARG_DEBUG_LEVEL:{
      GstDebugLevel tmp = GST_LEVEL_NONE;

      tmp = (GstDebugLevel) strtol (arg, NULL, 0);
      if (((guint) tmp) < GST_LEVEL_COUNT) {
        gst_debug_set_default_threshold (tmp);
      }
      break;
    }
    case ARG_DEBUG:
      gst_debug_set_threshold_from_string (arg, FALSE);
      break;
    case ARG_DEBUG_NO_COLOR:
      gst_debug_set_colored (FALSE);
      break;
    case ARG_DEBUG_COLOR_MODE:
      gst_debug_set_color_mode_from_string (arg);
      break;
    case ARG_DEBUG_DISABLE:
      gst_debug_set_active (FALSE);
      break;
    case ARG_DEBUG_HELP:
      gst_debug_help ();
      exit (0);
#endif
    case ARG_PLUGIN_SPEW:
      break;
    case ARG_PLUGIN_PATH:
#ifndef GST_DISABLE_REGISTRY
      split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func, NULL);
#endif /* GST_DISABLE_REGISTRY */
      break;
    case ARG_PLUGIN_LOAD:
      split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL);
      break;
    case ARG_SEGTRAP_DISABLE:
      _gst_disable_segtrap = TRUE;
      break;
    case ARG_REGISTRY_UPDATE_DISABLE:
#ifndef GST_DISABLE_REGISTRY
      _priv_gst_disable_registry_update = TRUE;
#endif
      break;
    case ARG_REGISTRY_FORK_DISABLE:
      gst_registry_fork_set_enabled (FALSE);
      break;
    default:
      g_set_error (err, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
          _("Unknown option"));
      return FALSE;
  }

  return TRUE;
}