/* * this bit handles: * - initalization of threads if we use them * - log handler * - initial output * - initializes gst_format * - registers a bunch of types for gst_objects * * - we don't have cases yet where this fails, but in the future * we might and then it's nice to be able to return that */ static gboolean init_post (GOptionContext * context, GOptionGroup * group, gpointer data, GError ** error) { GLogLevelFlags llf; if (gst_initialized) { GST_DEBUG ("already initialized"); return TRUE; } llf = G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL; g_log_set_handler (g_log_domain_gstreamer, llf, debug_log_handler, NULL); #ifndef GST_DISABLE_TRACE _priv_gst_alloc_trace_initialize (); #endif _priv_gst_mini_object_initialize (); _priv_gst_quarks_initialize (); _priv_gst_allocator_initialize (); _priv_gst_memory_initialize (); _priv_gst_format_initialize (); _priv_gst_query_initialize (); _priv_gst_structure_initialize (); _priv_gst_caps_initialize (); _priv_gst_caps_features_initialize (); _priv_gst_meta_initialize (); _priv_gst_message_initialize (); g_type_class_ref (gst_object_get_type ()); g_type_class_ref (gst_pad_get_type ()); g_type_class_ref (gst_element_factory_get_type ()); g_type_class_ref (gst_element_get_type ()); g_type_class_ref (gst_tracer_factory_get_type ()); g_type_class_ref (gst_type_find_factory_get_type ()); g_type_class_ref (gst_bin_get_type ()); g_type_class_ref (gst_bus_get_type ()); g_type_class_ref (gst_task_get_type ()); g_type_class_ref (gst_clock_get_type ()); g_type_class_ref (gst_debug_color_mode_get_type ()); gst_uri_handler_get_type (); g_type_class_ref (gst_object_flags_get_type ()); g_type_class_ref (gst_bin_flags_get_type ()); g_type_class_ref (gst_buffer_flags_get_type ()); g_type_class_ref (gst_buffer_copy_flags_get_type ()); g_type_class_ref (gst_bus_flags_get_type ()); g_type_class_ref (gst_bus_sync_reply_get_type ()); g_type_class_ref (gst_caps_flags_get_type ()); g_type_class_ref (gst_clock_return_get_type ()); g_type_class_ref (gst_clock_entry_type_get_type ()); g_type_class_ref (gst_clock_flags_get_type ()); g_type_class_ref (gst_clock_type_get_type ()); g_type_class_ref (gst_debug_graph_details_get_type ()); g_type_class_ref (gst_state_get_type ()); g_type_class_ref (gst_state_change_return_get_type ()); g_type_class_ref (gst_state_change_get_type ()); g_type_class_ref (gst_element_flags_get_type ()); g_type_class_ref (gst_core_error_get_type ()); g_type_class_ref (gst_library_error_get_type ()); g_type_class_ref (gst_resource_error_get_type ()); g_type_class_ref (gst_stream_error_get_type ()); g_type_class_ref (gst_event_type_flags_get_type ()); g_type_class_ref (gst_event_type_get_type ()); g_type_class_ref (gst_seek_type_get_type ()); g_type_class_ref (gst_seek_flags_get_type ()); g_type_class_ref (gst_qos_type_get_type ()); g_type_class_ref (gst_format_get_type ()); g_type_class_ref (gst_debug_level_get_type ()); g_type_class_ref (gst_debug_color_flags_get_type ()); g_type_class_ref (gst_iterator_result_get_type ()); g_type_class_ref (gst_iterator_item_get_type ()); g_type_class_ref (gst_message_type_get_type ()); g_type_class_ref (gst_mini_object_flags_get_type ()); g_type_class_ref (gst_pad_link_return_get_type ()); g_type_class_ref (gst_pad_link_check_get_type ()); g_type_class_ref (gst_flow_return_get_type ()); g_type_class_ref (gst_pad_mode_get_type ()); g_type_class_ref (gst_pad_direction_get_type ()); g_type_class_ref (gst_pad_flags_get_type ()); g_type_class_ref (gst_pad_presence_get_type ()); g_type_class_ref (gst_pad_template_flags_get_type ()); g_type_class_ref (gst_pipeline_flags_get_type ()); g_type_class_ref (gst_plugin_error_get_type ()); g_type_class_ref (gst_plugin_flags_get_type ()); g_type_class_ref (gst_plugin_dependency_flags_get_type ()); g_type_class_ref (gst_rank_get_type ()); g_type_class_ref (gst_query_type_flags_get_type ()); g_type_class_ref (gst_query_type_get_type ()); g_type_class_ref (gst_buffering_mode_get_type ()); g_type_class_ref (gst_stream_status_type_get_type ()); g_type_class_ref (gst_structure_change_type_get_type ()); g_type_class_ref (gst_tag_merge_mode_get_type ()); g_type_class_ref (gst_tag_flag_get_type ()); g_type_class_ref (gst_tag_scope_get_type ()); g_type_class_ref (gst_task_pool_get_type ()); g_type_class_ref (gst_task_state_get_type ()); g_type_class_ref (gst_toc_entry_type_get_type ()); g_type_class_ref (gst_type_find_probability_get_type ()); g_type_class_ref (gst_uri_error_get_type ()); g_type_class_ref (gst_uri_type_get_type ()); g_type_class_ref (gst_parse_error_get_type ()); g_type_class_ref (gst_parse_flags_get_type ()); g_type_class_ref (gst_search_mode_get_type ()); g_type_class_ref (gst_progress_type_get_type ()); g_type_class_ref (gst_buffer_pool_acquire_flags_get_type ()); g_type_class_ref (gst_memory_flags_get_type ()); g_type_class_ref (gst_map_flags_get_type ()); g_type_class_ref (gst_caps_intersect_mode_get_type ()); g_type_class_ref (gst_pad_probe_type_get_type ()); g_type_class_ref (gst_pad_probe_return_get_type ()); g_type_class_ref (gst_segment_flags_get_type ()); g_type_class_ref (gst_scheduling_flags_get_type ()); g_type_class_ref (gst_meta_flags_get_type ()); g_type_class_ref (gst_toc_entry_type_get_type ()); g_type_class_ref (gst_toc_scope_get_type ()); g_type_class_ref (gst_toc_loop_type_get_type ()); g_type_class_ref (gst_control_binding_get_type ()); g_type_class_ref (gst_control_source_get_type ()); g_type_class_ref (gst_lock_flags_get_type ()); g_type_class_ref (gst_allocator_flags_get_type ()); g_type_class_ref (gst_stream_flags_get_type ()); _priv_gst_event_initialize (); _priv_gst_buffer_initialize (); _priv_gst_buffer_list_initialize (); _priv_gst_sample_initialize (); _priv_gst_context_initialize (); _priv_gst_date_time_initialize (); _priv_gst_tag_initialize (); _priv_gst_toc_initialize (); _priv_gst_value_initialize (); g_type_class_ref (gst_param_spec_fraction_get_type ()); gst_parse_context_get_type (); _priv_gst_plugin_initialize (); /* register core plugins */ gst_plugin_register_static (GST_VERSION_MAJOR, GST_VERSION_MINOR, "staticelements", "core elements linked into the GStreamer library", gst_register_core_elements, VERSION, GST_LICENSE, PACKAGE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); /* * Any errors happening below this point are non-fatal, we therefore mark * gstreamer as being initialized, since it is the case from a plugin point of * view. * * If anything fails, it will be put back to %FALSE in gst_init_check(). * This allows some special plugins that would call gst_init() to not cause a * looping effect (i.e. initializing GStreamer twice). */ gst_initialized = TRUE; if (!gst_update_registry ()) return FALSE; GST_INFO ("GLib runtime version: %d.%d.%d", glib_major_version, glib_minor_version, glib_micro_version); GST_INFO ("GLib headers version: %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); GST_INFO ("initialized GStreamer successfully"); #ifndef GST_DISABLE_GST_DEBUG _priv_gst_tracing_init (); #endif return TRUE; }
/** * gst_deinit: * * Clean up any resources created by GStreamer in gst_init(). * * It is normally not needed to call this function in a normal application * as the resources will automatically be freed when the program terminates. * This function is therefore mostly used by testsuites and other memory * profiling tools. * * After this call GStreamer (including this method) should not be used anymore. */ void gst_deinit (void) { GstBinClass *bin_class; GstClock *clock; GST_INFO ("deinitializing GStreamer"); if (gst_deinitialized) { GST_DEBUG ("already deinitialized"); return; } #ifndef GST_DISABLE_GST_DEBUG _priv_gst_tracing_deinit (); #endif g_thread_pool_set_max_unused_threads (0); bin_class = GST_BIN_CLASS (g_type_class_peek (gst_bin_get_type ())); if (bin_class->pool != NULL) { g_thread_pool_free (bin_class->pool, FALSE, TRUE); bin_class->pool = NULL; } gst_task_cleanup_all (); g_slist_foreach (_priv_gst_preload_plugins, (GFunc) g_free, NULL); g_slist_free (_priv_gst_preload_plugins); _priv_gst_preload_plugins = NULL; #ifndef GST_DISABLE_REGISTRY g_list_foreach (_priv_gst_plugin_paths, (GFunc) g_free, NULL); g_list_free (_priv_gst_plugin_paths); _priv_gst_plugin_paths = NULL; #endif clock = gst_system_clock_obtain (); gst_object_unref (clock); gst_object_unref (clock); _priv_gst_registry_cleanup (); #ifndef GST_DISABLE_TRACE _priv_gst_alloc_trace_deinit (); #endif g_type_class_unref (g_type_class_peek (gst_object_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_get_type ())); g_type_class_unref (g_type_class_peek (gst_tracer_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_type_find_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_bin_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_get_type ())); g_type_class_unref (g_type_class_peek (gst_task_get_type ())); g_type_class_unref (g_type_class_peek (gst_object_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_bin_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_copy_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_sync_reply_get_type ())); g_type_class_unref (g_type_class_peek (gst_caps_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_entry_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_graph_details_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_change_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_change_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_core_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_library_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_dependency_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_parse_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_resource_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_search_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_stream_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_stream_status_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_structure_change_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_event_type_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_event_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_seek_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_seek_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_qos_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_format_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_level_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_color_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_iterator_result_get_type ())); g_type_class_unref (g_type_class_peek (gst_iterator_item_get_type ())); g_type_class_unref (g_type_class_peek (gst_message_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_meta_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_mini_object_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_link_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_link_check_get_type ())); g_type_class_unref (g_type_class_peek (gst_flow_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_direction_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_presence_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_template_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pipeline_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_rank_get_type ())); g_type_class_unref (g_type_class_peek (gst_query_type_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_query_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffering_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_tag_merge_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_tag_flag_get_type ())); g_type_class_unref (g_type_class_peek (gst_tag_scope_get_type ())); g_type_class_unref (g_type_class_peek (gst_task_state_get_type ())); g_type_class_unref (g_type_class_peek (gst_toc_entry_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_toc_scope_get_type ())); g_type_class_unref (g_type_class_peek (gst_type_find_probability_get_type ())); g_type_class_unref (g_type_class_peek (gst_uri_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_uri_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_parse_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_param_spec_fraction_get_type ())); g_type_class_unref (g_type_class_peek (gst_progress_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_pool_acquire_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_memory_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_map_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_caps_intersect_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_probe_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_probe_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_segment_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_scheduling_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_control_binding_get_type ())); g_type_class_unref (g_type_class_peek (gst_control_source_get_type ())); g_type_class_unref (g_type_class_peek (gst_toc_entry_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_toc_loop_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_lock_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_allocator_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_stream_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_color_mode_get_type ())); gst_deinitialized = TRUE; GST_INFO ("deinitialized GStreamer"); }
/** * gst_deinit: * * Clean up any resources created by GStreamer in gst_init(). * * It is normally not needed to call this function in a normal application * as the resources will automatically be freed when the program terminates. * This function is therefore mostly used by testsuites and other memory * profiling tools. * * After this call GStreamer (including this method) should not be used anymore. */ void gst_deinit (void) { GstClock *clock; GST_INFO ("deinitializing GStreamer"); if (gst_deinitialized) { GST_DEBUG ("already deinitialized"); return; } g_slist_foreach (_priv_gst_preload_plugins, (GFunc) g_free, NULL); g_slist_free (_priv_gst_preload_plugins); _priv_gst_preload_plugins = NULL; #ifndef GST_DISABLE_REGISTRY g_list_foreach (_priv_gst_plugin_paths, (GFunc) g_free, NULL); g_list_free (_priv_gst_plugin_paths); _priv_gst_plugin_paths = NULL; #endif clock = gst_system_clock_obtain (); gst_object_unref (clock); gst_object_unref (clock); _priv_gst_registry_cleanup (); g_type_class_unref (g_type_class_peek (gst_object_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_get_type ())); g_type_class_unref (g_type_class_peek (gst_type_find_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_bin_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_get_type ())); g_type_class_unref (g_type_class_peek (gst_task_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_factory_get_type ())); g_type_class_unref (g_type_class_peek (gst_object_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_bin_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_flag_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_copy_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffer_list_item_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_bus_sync_reply_get_type ())); g_type_class_unref (g_type_class_peek (gst_caps_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_entry_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_clock_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_graph_details_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_change_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_state_change_get_type ())); g_type_class_unref (g_type_class_peek (gst_element_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_core_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_library_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_dependency_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_parse_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_resource_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_search_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_stream_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_stream_status_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_structure_change_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_event_type_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_event_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_seek_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_seek_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_qos_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_format_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_certainty_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_entry_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_lookup_method_get_type ())); g_type_class_unref (g_type_class_peek (gst_assoc_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_resolver_method_get_type ())); g_type_class_unref (g_type_class_peek (gst_index_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_level_get_type ())); g_type_class_unref (g_type_class_peek (gst_debug_color_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_iterator_result_get_type ())); g_type_class_unref (g_type_class_peek (gst_iterator_item_get_type ())); g_type_class_unref (g_type_class_peek (gst_message_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_mini_object_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_link_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_link_check_get_type ())); g_type_class_unref (g_type_class_peek (gst_flow_return_get_type ())); g_type_class_unref (g_type_class_peek (gst_activate_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_direction_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_presence_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_template_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_pipeline_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_plugin_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_rank_get_type ())); g_type_class_unref (g_type_class_peek (gst_query_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_buffering_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_tag_merge_mode_get_type ())); g_type_class_unref (g_type_class_peek (gst_tag_flag_get_type ())); g_type_class_unref (g_type_class_peek (gst_task_state_get_type ())); g_type_class_unref (g_type_class_peek (gst_alloc_trace_flags_get_type ())); g_type_class_unref (g_type_class_peek (gst_type_find_probability_get_type ())); g_type_class_unref (g_type_class_peek (gst_uri_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_parse_error_get_type ())); g_type_class_unref (g_type_class_peek (gst_param_spec_fraction_get_type ())); g_type_class_unref (g_type_class_peek (gst_progress_type_get_type ())); g_type_class_unref (g_type_class_peek (gst_caps_intersect_mode_get_type ())); gst_deinitialized = TRUE; GST_INFO ("deinitialized GStreamer"); }