コード例 #1
0
ファイル: category.c プロジェクト: WangCrystal/gstreamer
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;
}
コード例 #2
0
ファイル: player.cpp プロジェクト: shil99/study
GstDriver::GstDriver(MediaPlayerHWInterface* parent):
{
    init_gstreamer();
    {
        // set debug
        property_get("persist.gst.debug", debug, "0");
      	gst_debug_remove_log_function(debug_log);
    	gst_debug_add_log_function(debug_log, this);
	    gst_debug_remove_log_function(gst_debug_log_default);

        gst_init_check (&argc, &argv, &err);
    }
コード例 #3
0
//
// STARTUP
///////////////////////////////////////////////////////////////////////////////
// (static) super-initialization - called once at application startup
bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
{
	static bool done_init = false;
	if (!done_init)
	{
		// Init the glib type system - we need it.
		g_type_init();

		set_gst_plugin_path();

		// Protect against GStreamer resetting the locale, yuck.
		static std::string saved_locale;
		saved_locale = setlocale(LC_ALL, NULL);
		if (0 == gst_init_check(NULL, NULL, NULL))
		{
		    LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
			setlocale(LC_ALL, saved_locale.c_str() );
			return false;
		}
		setlocale(LC_ALL, saved_locale.c_str() );

		// Set up logging facilities
		gst_debug_remove_log_function( gst_debug_log_default );
		gst_debug_add_log_function( gstreamer_log, NULL );

		// Init our custom plugins - only really need do this once.
		gst_slvideo_init_class();


		// List the plugins GStreamer can find
		LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
		GList *list;
		GstRegistry *registry = gst_registry_get_default();
		std::string loaded = "";
		for (list = gst_registry_get_plugin_list(registry);
		     list != NULL;
		     list = g_list_next(list))
		{	 
			GstPlugin *list_plugin = (GstPlugin *)list->data;
			(bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
			LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
		}
		gst_plugin_list_free(list);


		done_init = true;
	}
	return true;
}
コード例 #4
0
// must be called after gst_init(), see comment in setup_log_capture()
void
bt_check_init (void)
{
  _priv_bt_info_start_time = gst_util_get_timestamp ();

  // disable logging from gstreamer itself
  gst_debug_remove_log_function (gst_debug_log_default);
  // set e.g. GST_DEBUG="bt-core:DEBUG" if more details are needed
  if (gst_debug_get_default_threshold () < GST_LEVEL_INFO) {
    gst_debug_set_default_threshold (GST_LEVEL_INFO);
  }
  // register our plugins
  extern gboolean bt_test_plugin_init (GstPlugin * plugin);
  gst_plugin_register_static (GST_VERSION_MAJOR,
      GST_VERSION_MINOR,
      "bt-test",
      "buzztrax test plugin - several unit test support elements",
      bt_test_plugin_init,
      VERSION, "LGPL", PACKAGE, PACKAGE_NAME, "http://www.buzztrax.org");

  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "bt-check", 0,
      "music production environment / unit tests");

  const gchar *checks = g_getenv ("BT_CHECKS");
  if (BT_IS_STRING (checks)) {
    // we're leaking this
    funcs = g_strsplit (checks, ",", -1);
  }
#ifdef HAVE_SETRLIMIT
  // only fork mode limit cpu/mem usage
  const gchar *mode = g_getenv ("CK_FORK");
  if (!mode || strcmp (mode, "no")) {
    struct rlimit rl;

    rl.rlim_max = RLIM_INFINITY;
    // limit cpu in seconds
    rl.rlim_cur = 20;
    if (setrlimit (RLIMIT_CPU, &rl) < 0)
      perror ("setrlimit(RLIMIT_CPU) failed");
    // limit process’s data size in bytes
    // if we get failing tests and "mmap() failed: Cannot allocate memory"
    // this limit needs to be increased
    rl.rlim_cur = 515 * 1024 * 1024;    // 0.5GB
    if (setrlimit (RLIMIT_DATA, &rl) < 0)
      perror ("setrlimit(RLIMIT_DATA) failed");
  }
#endif
}
コード例 #5
0
ファイル: main.c プロジェクト: euanmcleod/gstreamill
static gint init_log (gchar *log_path)
{
        gint ret;

        _log = log_new ("log_path", log_path, NULL);

        ret = log_set_log_handler (_log);
        if (ret != 0) {
                return ret;
        }

        /* remove gstInfo default handler. */
        gst_debug_remove_log_function (gst_debug_log_default);

        return 0;
}
コード例 #6
0
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++;
}
コード例 #7
0
ファイル: main.cpp プロジェクト: Glebka/jenkins-vr
int main()
{
	gst_init( NULL, NULL );

   GST_DEBUG_CATEGORY_INIT (app_debug, "JENKINS-VR", 0, "JENKINS-VR");
   FILE* mLogFile = g_fopen( "logfile.txt", "w" );

   if ( mLogFile )
   {
      bool result = true;
      gst_debug_remove_log_function( NULL );
      gst_debug_add_log_function( gst_debug_log_default, mLogFile, NULL );
      gst_debug_set_threshold_from_string( "GST_TRACER:7,GST_BUFFER*:7,GST_EVENT:7,GST_MESSAGE:7,JENKINS-VR:7,pocketsphinx:7,CGstPlayerPipeline:7,CGstRecognizerPipeline:7", true );
   }

   CLogger::setConsoleLogLevel( LogLevel::LEVEL_DEBUG );
   CLogger::fatal() << "Hello fatal! " << "This is on the same line.";
   CLogger::error() << "Hello error! " << "This is on the same line.";
   CLogger::warning() << "Hello warning! " << "This is on the same line.";
   CLogger::info() << "Hello info! " << "This is on the same line.";
   CLogger::debug() << "Hello debug! " << "This is on the same line.";
	return 0;
}
コード例 #8
0
//static
bool
MediaPluginGStreamer010::startup()
{
	// first - check if GStreamer is explicitly disabled
	if (NULL != getenv("LL_DISABLE_GSTREAMER"))
		return false;

	// only do global GStreamer initialization once.
	if (!mDoneInit)
	{
#if !GLIB_CHECK_VERSION(2, 36, 0)
#if !GLIB_CHECK_VERSION(2, 32, 0)
		if (!g_thread_supported()) g_thread_init(NULL);
#endif
		// Init the glib type system - we need it.
		g_type_init();
#endif
		set_gst_plugin_path();


/*
		// Get symbols!
#if LL_DARWIN
		if (! grab_gst_syms("libgstreamer-0.10.dylib",
				    "libgstvideo-0.10.dylib") )
#elseif LL_WINDOWS
		if (! grab_gst_syms("libgstreamer-0.10.dll",
				    "libgstvideo-0.10.dll") )
#else // linux or other ELFy unixoid
		if (! grab_gst_syms("libgstreamer-0.10.so.0",
				    "libgstvideo-0.10.so.0") )
#endif
		{
			WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled.");
			return false;
		}
*/
// 		if (gst_segtrap_set_enabled)
// 		{
			gst_segtrap_set_enabled(FALSE);
// 		}
// 		else
// 		{
// 			WARNMSG("gst_segtrap_set_enabled() is not available; plugin crashes won't be caught.");
// 		}
/*
#if LL_LINUX
		// Gstreamer tries a fork during init, waitpid-ing on it,
		// which conflicts with any installed SIGCHLD handler...
		struct sigaction tmpact, oldact;
		if (gst_registry_fork_set_enabled) {
			// if we can disable SIGCHLD-using forking behaviour,
			// do it.
			gst_registry_fork_set_enabled(false);
		}
		else {
			// else temporarily install default SIGCHLD handler
			// while GStreamer initialises
			tmpact.sa_handler = SIG_DFL;
			sigemptyset( &tmpact.sa_mask );
			tmpact.sa_flags = SA_SIGINFO;
			sigaction(SIGCHLD, &tmpact, &oldact);
		}
#endif // LL_LINUX
*/
		// Protect against GStreamer resetting the locale, yuck.
		static std::string saved_locale;
		saved_locale = setlocale(LC_ALL, NULL);

		// finally, try to initialize GStreamer!
		GError *err = NULL;
		gboolean init_gst_success = gst_init_check(NULL, NULL, &err);

		// restore old locale
		setlocale(LC_ALL, saved_locale.c_str() );
/*
#if LL_LINUX
		// restore old SIGCHLD handler
		if (!gst_registry_fork_set_enabled)
			sigaction(SIGCHLD, &oldact, NULL);
#endif // LL_LINUX
*/
		if (!init_gst_success) // fail
		{
			if (err)
			{
				WARNMSG("GST init failed: %s", err->message);
				g_error_free(err);
			}
			else
			{
				WARNMSG("GST init failed for unspecified reason.");
			}
			return false;
		}

		// Set up logging facilities
		gst_debug_remove_log_function( gst_debug_log_default );
//		gst_debug_add_log_function( gstreamer_log, NULL );

		// Init our custom plugins - only really need do this once.
		gst_slvideo_init_class();
/*
		// List the plugins GStreamer can find
		LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
		GList *list;
		GstRegistry *registry = gst_registry_get_default();
		std::string loaded = "";
		for (list = gst_registry_get_plugin_list(registry);
		     list != NULL;
		     list = g_list_next(list))
		{	 
			GstPlugin *list_plugin = (GstPlugin *)list->data;
			(bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
			LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
		}
		gst_plugin_list_free(list);
*/
		mDoneInit = true;
	}

	return true;
}
コード例 #9
0
ファイル: output.c プロジェクト: WangCrystal/gstreamer
gint
main (gint argc, gchar * argv[])
{

  gst_init (&argc, &argv);

  GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0,
      "default category for this test");
  GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0,
      "second category for this test");
#ifndef GST_DISABLE_GST_DEBUG
  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
#endif
  gst_debug_add_log_function (check_message, NULL);

  count = 0;
  GST_ERROR ("This is an error.");
  ++count;
  GST_WARNING ("This is a warning.");
  ++count;
  GST_INFO ("This is an info message.");
  ++count;
  GST_DEBUG ("This is a debug message.");
  ++count;
  GST_LOG ("This is a log message.");
  ++count;
  GST_CAT_ERROR (cat2, "This is an error with category.");
  ++count;
  GST_CAT_WARNING (cat2, "This is a warning with category.");
  ++count;
  GST_CAT_INFO (cat2, "This is an info message with category.");
  ++count;
  GST_CAT_DEBUG (cat2, "This is a debug message with category.");
  ++count;
  GST_CAT_LOG (cat2, "This is a log message with category.");
  count = -1;
  pipeline = gst_element_factory_make ("pipeline", "testelement");
  count = 10;
  GST_ERROR_OBJECT (pipeline, "This is an error with object.");
  ++count;
  GST_WARNING_OBJECT (pipeline, "This is a warning with object.");
  ++count;
  GST_INFO_OBJECT (pipeline, "This is an info message with object.");
  ++count;
  GST_DEBUG_OBJECT (pipeline, "This is a debug message with object.");
  ++count;
  GST_LOG_OBJECT (pipeline, "This is a log message with object.");
  ++count;
  GST_CAT_ERROR_OBJECT (cat2, pipeline,
      "This is an error with category and object.");
  ++count;
  GST_CAT_WARNING_OBJECT (cat2, pipeline,
      "This is a warning with category and object.");
  ++count;
  GST_CAT_INFO_OBJECT (cat2, pipeline,
      "This is an info message with category and object.");
  ++count;
  GST_CAT_DEBUG_OBJECT (cat2, pipeline,
      "This is a debug message with category and object.");
  ++count;
  GST_CAT_LOG_OBJECT (cat2, pipeline,
      "This is a log message with category and object.");
  count = -1;

#ifndef GST_DISABLE_GST_DEBUG
  g_assert (gst_debug_remove_log_function (check_message) == 1);
#endif

  return 0;
}