/src/gstreamer/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils.c
Line | Count | Source |
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 <glib/gi18n-lib.h> |
63 | | |
64 | | #ifndef GST_DISABLE_GST_DEBUG |
65 | | #define GST_CAT_DEFAULT gst_pb_utils_ensure_debug_category() |
66 | | |
67 | | static GstDebugCategory * |
68 | | gst_pb_utils_ensure_debug_category (void) |
69 | 0 | { |
70 | 0 | static gsize cat_gonce = 0; |
71 | |
|
72 | 0 | if (g_once_init_enter (&cat_gonce)) { |
73 | 0 | GstDebugCategory *cat = NULL; |
74 | |
|
75 | 0 | GST_DEBUG_CATEGORY_INIT (cat, "pbutils", 0, "GStreamer Plugins Base utils"); |
76 | |
|
77 | 0 | g_once_init_leave (&cat_gonce, (gsize) cat); |
78 | 0 | } |
79 | |
|
80 | 0 | return (GstDebugCategory *) cat_gonce; |
81 | 0 | } |
82 | | #endif /* GST_DISABLE_GST_DEBUG */ |
83 | | |
84 | | static gpointer |
85 | | _init_locale_text_domain (gpointer data) |
86 | 4 | { |
87 | | #ifdef ENABLE_NLS |
88 | | GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, |
89 | | LOCALEDIR); |
90 | | bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); |
91 | | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
92 | | #endif |
93 | | |
94 | 4 | return NULL; |
95 | 4 | } |
96 | | |
97 | | void |
98 | | gst_pb_utils_init_locale_text_domain (void) |
99 | 13 | { |
100 | 13 | static GOnce locale_init_once = G_ONCE_INIT; |
101 | | |
102 | 13 | g_once (&locale_init_once, _init_locale_text_domain, NULL); |
103 | 13 | } |
104 | | |
105 | | /** |
106 | | * gst_pb_utils_init: |
107 | | * |
108 | | * Initialises the base utils support library. This function is not |
109 | | * thread-safe. Applications should call it after calling gst_init(), |
110 | | * plugins should call it from their plugin_init function. |
111 | | * |
112 | | * This function may be called multiple times. It will do nothing if the |
113 | | * library has already been initialised. |
114 | | */ |
115 | | void |
116 | | gst_pb_utils_init (void) |
117 | 4 | { |
118 | 4 | static gboolean inited; /* FALSE */ |
119 | | |
120 | 4 | if (inited) { |
121 | 0 | GST_LOG ("already initialised"); |
122 | 0 | return; |
123 | 0 | } |
124 | 4 | gst_pb_utils_init_locale_text_domain (); |
125 | | |
126 | 4 | inited = TRUE; |
127 | 4 | } |