5 // Aaron Bockover <abockover@novell.com>
7 // Copyright (C) 2005-2008 Novell, Inc.
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #include <gst/pbutils/pbutils.h>
41 #include "banshee-gst.h"
43 static gboolean gstreamer_initialized
= FALSE
;
44 static gboolean banshee_debugging
;
45 static BansheeLogHandler banshee_log_handler
= NULL
;
46 static gint banshee_version
= -1;
49 gstreamer_initialize (gboolean debugging
, BansheeLogHandler log_handler
)
51 if (gstreamer_initialized
) {
55 banshee_debugging
= debugging
;
56 banshee_log_handler
= log_handler
;
58 gst_init (NULL
, NULL
);
62 gstreamer_initialized
= TRUE
;
66 gstreamer_test_pipeline (gchar
*pipeline
)
68 GstElement
*element
= NULL
;
71 element
= gst_parse_launch (pipeline
, &error
);
73 if (element
!= NULL
) {
74 gst_object_unref (GST_OBJECT (element
));
81 gstreamer_version_string ()
83 return g_strdup_printf ("%i.%i.%i.%i", GST_VERSION_MAJOR
, GST_VERSION_MINOR
, GST_VERSION_MICRO
, GST_VERSION_NANO
);
87 banshee_is_debugging ()
89 return banshee_debugging
;
93 banshee_get_version_number ()
95 guint16 major
= 0, minor
= 0, micro
= 0;
97 if (banshee_version
>= 0) {
98 return (guint
)banshee_version
;
101 if (sscanf (VERSION
, "%" G_GUINT16_FORMAT
".%" G_GUINT16_FORMAT
".%" G_GUINT16_FORMAT
,
102 &major
, &minor
, µ
) == 3) {
103 banshee_version
= ((guint8
)major
<< 16) | ((guint8
)minor
<< 8) | ((guint8
)micro
);
104 // major = (banshee_version >> 16)
105 // minor = (banshee_version >> 8) & 0x00FF
106 // micro = banshee_version & 0x0000FF
111 return (guint
)banshee_version
;
115 banshee_log (BansheeLogType type
, const gchar
*component
, const gchar
*message
)
117 if (banshee_log_handler
== NULL
) {
119 case BANSHEE_LOG_TYPE_WARNING
: g_warning ("%s: %s", component
, message
); break;
120 case BANSHEE_LOG_TYPE_ERROR
: g_error ("%s: %s", component
, message
); break;
121 default: g_debug ("%s: %s", component
, message
); break;
126 (banshee_log_handler
) (type
, component
, message
);
130 banshee_log_debug (const gchar
*component
, const gchar
*format
, ...)
135 if (!banshee_debugging
) {
139 va_start (args
, format
);
140 message
= g_strdup_vprintf (format
, args
);
143 banshee_log (BANSHEE_LOG_TYPE_DEBUG
, component
, message
);