2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gst.c: Initialization and non-pipeline operations
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 #include "gst_private.h"
29 #include "gstplugin.h"
30 #include "gstbuffer.h"
32 #include "gstpipeline.h"
33 #include "gstthread.h"
40 extern gint _gst_trace_on;
43 static gboolean gst_init_check (int *argc, gchar ***argv);
47 * @argc: pointer to application's argc
48 * @argv: pointer to application's argv
50 * Initializes the GStreamer library, setting up internal path lists,
51 * registering built-in elements, and loading standard plugins.
54 gst_init (int *argc, char **argv[])
58 GST_INFO (GST_CAT_GST_INIT, "Initializing GStreamer Core Library");
60 if (!g_thread_supported ()) g_thread_init (NULL);
62 _gst_progname = g_strdup(*argv[0]);
66 if (!gst_init_check (argc,argv)) {
70 _gst_cpu_initialize ();
71 _gst_type_initialize ();
72 _gst_plugin_initialize ();
73 _gst_buffer_initialize ();
75 /* register some standard builtin types */
76 gst_elementfactory_new ("bin", gst_bin_get_type (), &gst_bin_details);
77 gst_elementfactory_new ("pipeline", gst_pipeline_get_type (), &gst_pipeline_details);
78 gst_elementfactory_new ("thread", gst_thread_get_type (), &gst_thread_details);
82 gst_trace = gst_trace_new ("gst.trace",1024);
83 gst_trace_set_default (gst_trace);
87 /* returns FALSE if the program can be aborted */
89 gst_init_check (int *argc,
93 gboolean showhelp = FALSE;
98 for (i=1; i< *argc; i++) {
99 if (!strncmp ("--gst-info-mask=", (*argv)[i], 16)) {
102 // handle either 0xHEX or dec
103 if (*((*argv)[i]+17) == 'x') {
104 sscanf ((*argv)[i]+18, "%08x", &val);
106 sscanf ((*argv)[i]+16, "%d", &val);
109 gst_info_set_categories (val);
113 else if (!strncmp ("--gst-debug-mask=", (*argv)[i], 17)) {
116 // handle either 0xHEX or dec
117 if (*((*argv)[i]+18) == 'x') {
118 sscanf ((*argv)[i]+19, "%08x", &val);
120 sscanf ((*argv)[i]+17, "%d", &val);
123 gst_debug_set_categories (val);
127 else if (!strncmp ("--help", (*argv)[i], 6)) {
132 for (i = 1; i < *argc; i++) {
133 for (k = i; k < *argc; k++)
134 if ((*argv)[k] != NULL)
139 for (j = i + k; j < *argc; j++)
140 (*argv)[j-k] = (*argv)[j];
149 g_print ("usage %s [OPTION...]\n", (*argv)[0]);
151 g_print ("\nGStreamer options\n");
152 g_print (" --gst-info-mask=FLAGS Gst info flags to set (current %08x)\n", gst_info_get_categories());
153 g_print (" --gst-debug-mask=FLAGS Gst debugging flags to set\n");
155 g_print ("\nGStreamer info/debug FLAGS (to be OR'ed)\n");
157 for (i = 0; i<GST_CAT_MAX_CATEGORY; i++) {
158 g_print (" 0x%08x %s %s\n", 1<<i,
159 (gst_info_get_categories() & (1<<i)?"(enabled)":" "),
160 gst_get_category_name (i));
172 * Enter the main GStreamer processing loop
183 * Exits the main GStreamer processing loop