1 /* GStreamer base utils library
2 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * SECTION:gstpbutils
22 * @title: Pbutils
23 * @short_description: General Application and Plugin Utility Library
24 *
25 * libgstpbutils is a general utility library for plugins and applications.
26 * It currently provides the
27 * following:
28 *
29 * * human-readable description strings of codecs, elements, sources, decoders,
30 * encoders, or sinks from decoder/encoder caps, element names, or protocol
31 * names.
32 *
33 * * support for applications to initiate installation of missing plugins (if
34 * this is supported by the distribution or operating system used)
35 *
36 * * API for GStreamer elements to create missing-plugin messages in order to
37 * communicate to the application that a certain type of plugin is missing
38 * (decoder, encoder, URI protocol source, URI protocol sink, named element)
39 *
40 * * API for applications to recognise and handle missing-plugin messages
41 *
42 * ## Linking to this library
43 *
44 * You should obtain the required CFLAGS and LIBS using pkg-config on the
45 * gstreamer-plugins-base-1.0 module. You will then also need to add
46 * '-lgstreamer-pbutils-1.0' manually to your LIBS line.
47 *
48 * ## Library initialisation
49 *
50 * Before using any of its functions, applications and plugins must call
51 * gst_pb_utils_init() to initialise the library.
52 *
53 */
54
55 #ifdef HAVE_CONFIG_H
56 # include "config.h"
57 #endif
58
59 #include "pbutils.h"
60 #include "pbutils-private.h"
61
62 #include "gst/gst-i18n-plugin.h"
63
64 static gpointer
_init_locale_text_domain(gpointer data)65 _init_locale_text_domain (gpointer data)
66 {
67 #ifdef ENABLE_NLS
68 GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
69 LOCALEDIR);
70 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
71 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
72 #endif
73
74 return NULL;
75 }
76
77 void
gst_pb_utils_init_locale_text_domain(void)78 gst_pb_utils_init_locale_text_domain (void)
79 {
80 static GOnce locale_init_once = G_ONCE_INIT;
81
82 g_once (&locale_init_once, _init_locale_text_domain, NULL);
83 }
84
85 /**
86 * gst_pb_utils_init:
87 *
88 * Initialises the base utils support library. This function is not
89 * thread-safe. Applications should call it after calling gst_init(),
90 * plugins should call it from their plugin_init function.
91 *
92 * This function may be called multiple times. It will do nothing if the
93 * library has already been initialised.
94 */
95 void
gst_pb_utils_init(void)96 gst_pb_utils_init (void)
97 {
98 static gboolean inited; /* FALSE */
99
100 if (inited) {
101 GST_LOG ("already initialised");
102 return;
103 }
104 gst_pb_utils_init_locale_text_domain ();
105
106 inited = TRUE;
107 }
108