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); }
// // 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; }
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++; }
/* * setup_log_capture: * * Installs own logging handlers to capture and channelize all diagnostic output * during testing. */ void setup_log_capture (void) { (void) g_log_set_default_handler (check_log_handler, NULL); (void) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("buzztrax", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GStreamer", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_set_printerr_handler (check_print_handler); #ifndef GST_DISABLE_GST_DEBUG // gst_init() will add the log handler unconditionally: // - if we do this before gst_init() we don't actually remove the def log // handler // - if we do this after gst_init() we get debug output from gst_init() itself // on the default handler // - we want a flag to tell gst to not register the default handler // gst_debug_set_active() is not the same // A workaround for now is to set GST_DEBUG_FILE=/dev/null which our handler // is not using and doing the // gst_debug_remove_log_function (gst_debug_log_default); // after gst_init() from bt_check_init(). gst_debug_add_log_function (check_gst_log_handler, NULL, NULL); #endif }
gint log_set_log_handler (Log *log) { gchar *dir; dir = g_strdup_printf ("%s", log->log_path); if (g_mkdir_with_parents (dirname (dir), 0755) != 0) { GST_ERROR ("Can't open or create log directory: %s.", dirname (dir)); return 1; } log->func = log_func; log->log_hd = fopen (log->log_path, "ae"); if (log->log_hd == NULL) { GST_ERROR ("open log file error: %s", g_strerror (errno)); return 1; } setvbuf (log->log_hd, NULL, _IOLBF, 0); if (log->access_path != NULL) { log->access_hd = fopen (log->access_path, "ae"); if (log->log_hd == NULL) { GST_ERROR ("open access file error: %s", g_strerror (errno)); return 1; } setvbuf (log->access_hd, NULL, _IOLBF, 0); } if (log->log_hd == NULL) { GST_ERROR ("Error open log file %s, %s.", log->log_path, g_strerror (errno)); return -1; } else { gst_debug_add_log_function (log_func, log, NULL); return 0; } g_free (dir); }
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; }
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; }
/** * owr_init: * * Initializes the OpenWebRTC library. Creates a new #GMainContext and starts * the main loop used in the OpenWebRTC library. Either this function or * owr_init_with_main_context() must be called before doing anything else. */ void owr_init() { gboolean owr_main_context_is_external; GstBus *bus; g_return_if_fail(!owr_initialized); #ifdef __ANDROID__ g_set_print_handler((GPrintFunc)g_print_android_handler); g_set_printerr_handler((GPrintFunc)g_printerr_android_handler); g_log_set_default_handler((GLogFunc)g_log_android_handler, NULL); gst_debug_add_log_function((GstLogFunction)gst_log_android_handler, NULL, NULL); #endif /* Hack to make sure that all symbols that we need are included in the resulting library/binary */ _owr_require_symbols(); gst_init(NULL, NULL); owr_initialized = TRUE; GST_PLUGIN_STATIC_REGISTER(alaw); GST_PLUGIN_STATIC_REGISTER(app); GST_PLUGIN_STATIC_REGISTER(audioconvert); GST_PLUGIN_STATIC_REGISTER(audioresample); GST_PLUGIN_STATIC_REGISTER(audiotestsrc); GST_PLUGIN_STATIC_REGISTER(coreelements); GST_PLUGIN_STATIC_REGISTER(erdtls); GST_PLUGIN_STATIC_REGISTER(mulaw); GST_PLUGIN_STATIC_REGISTER(opengl); GST_PLUGIN_STATIC_REGISTER(openh264); GST_PLUGIN_STATIC_REGISTER(opus); GST_PLUGIN_STATIC_REGISTER(rtp); GST_PLUGIN_STATIC_REGISTER(rtpmanager); GST_PLUGIN_STATIC_REGISTER(srtp); GST_PLUGIN_STATIC_REGISTER(videoconvert); GST_PLUGIN_STATIC_REGISTER(videocrop); GST_PLUGIN_STATIC_REGISTER(videofilter); GST_PLUGIN_STATIC_REGISTER(videoparsersbad); GST_PLUGIN_STATIC_REGISTER(videorate); GST_PLUGIN_STATIC_REGISTER(videorepair); GST_PLUGIN_STATIC_REGISTER(videoscale); GST_PLUGIN_STATIC_REGISTER(videotestsrc); GST_PLUGIN_STATIC_REGISTER(volume); GST_PLUGIN_STATIC_REGISTER(vpx); #ifdef __APPLE__ #if !TARGET_IPHONE_SIMULATOR GST_PLUGIN_STATIC_REGISTER(applemedia); GST_PLUGIN_STATIC_REGISTER(osxaudio); #endif #elif defined(__ANDROID__) GST_PLUGIN_STATIC_REGISTER(androidvideosource); GST_PLUGIN_STATIC_REGISTER(opensles); #elif defined(__linux__) GST_PLUGIN_STATIC_REGISTER(pulseaudio); GST_PLUGIN_STATIC_REGISTER(video4linux2); #endif #if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR) GST_PLUGIN_STATIC_REGISTER(ercolorspace); #endif gst_element_register(NULL, "nicesrc", GST_RANK_NONE, GST_TYPE_NICE_SRC); gst_element_register(NULL, "nicesink", GST_RANK_NONE, GST_TYPE_NICE_SINK); owr_main_context_is_external = !!owr_main_context; if (!owr_main_context_is_external) owr_main_context = g_main_context_new(); owr_pipeline = gst_pipeline_new("OpenWebRTC"); bus = gst_pipeline_get_bus(GST_PIPELINE(owr_pipeline)); g_main_context_push_thread_default(owr_main_context); bus_watch_id = gst_bus_add_watch(bus, (GstBusFunc)bus_call, NULL); g_main_context_pop_thread_default(owr_main_context); gst_object_unref(bus); gst_element_set_state(owr_pipeline, GST_STATE_PLAYING); #ifdef OWR_DEBUG g_signal_connect(owr_pipeline, "deep-notify", G_CALLBACK(gst_object_default_deep_notify), NULL); #endif if (owr_main_context_is_external) return; owr_main_loop = g_main_loop_new(owr_main_context, FALSE); owr_main_thread = g_thread_new("owr_main_loop", owr_run, NULL); }