| 1 | /* gstreamermm - a C++ wrapper for gstreamer |
| 2 | * |
| 3 | * Copyright 2008 The gstreamermm Development Team |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free |
| 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #include <gstreamermm/init.h> |
| 21 | #include <gstreamermm/wrap_init.h> |
| 22 | #include <glibmm/init.h> |
| 23 | #include <gst/gst.h> |
| 24 | |
| 25 | namespace Gst |
| 26 | { |
| 27 | |
| 28 | static void initialize_wrap_system() |
| 29 | { |
| 30 | static bool s_init = false; |
| 31 | if(!s_init) |
| 32 | { |
| 33 | //For Glib::wrap(), for Glib::Object-derived classes. |
| 34 | Gst::wrap_init(); |
| 35 | s_init = true; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void init(int& argc, char**& argv) |
| 40 | { |
| 41 | static bool s_init = false; |
| 42 | if(!s_init) |
| 43 | { |
| 44 | Glib::init(); |
| 45 | gst_init(&argc, &argv); |
| 46 | initialize_wrap_system(); |
| 47 | s_init = true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void init() |
| 52 | { |
| 53 | static bool s_init = false; |
| 54 | if(!s_init) |
| 55 | { |
| 56 | Glib::init(); |
| 57 | gst_init(nullptr, nullptr); |
| 58 | initialize_wrap_system(); |
| 59 | s_init = true; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | bool init_check(int& argc, char**& argv) |
| 64 | { |
| 65 | static bool s_init = false; |
| 66 | static bool result = false; |
| 67 | |
| 68 | if(!s_init) |
| 69 | { |
| 70 | Glib::init(); |
| 71 | |
| 72 | GError* gerror = nullptr; |
| 73 | result = gst_init_check(&argc, &argv, &gerror); |
| 74 | |
| 75 | if(gerror) |
| 76 | ::Glib::Error::throw_exception(gerror); |
| 77 | |
| 78 | initialize_wrap_system(); |
| 79 | s_init = true; |
| 80 | } |
| 81 | |
| 82 | return result; |
| 83 | } |
| 84 | |
| 85 | bool init_check() |
| 86 | { |
| 87 | static bool s_init = false; |
| 88 | static bool result = false; |
| 89 | |
| 90 | if(!s_init) |
| 91 | { |
| 92 | Glib::init(); |
| 93 | |
| 94 | GError* gerror = nullptr; |
| 95 | result = gst_init_check(nullptr, nullptr, &gerror); |
| 96 | |
| 97 | if(gerror) |
| 98 | ::Glib::Error::throw_exception(gerror); |
| 99 | |
| 100 | initialize_wrap_system(); |
| 101 | s_init = true; |
| 102 | } |
| 103 | |
| 104 | return result; |
| 105 | } |
| 106 | |
| 107 | bool is_initialized() |
| 108 | { |
| 109 | return static_cast<bool>(gst_is_initialized()); |
| 110 | } |
| 111 | |
| 112 | void deinit() |
| 113 | { |
| 114 | gst_deinit(); |
| 115 | } |
| 116 | |
| 117 | Glib::OptionGroup get_option_group() |
| 118 | { |
| 119 | return Glib::OptionGroup(gst_init_get_option_group()); |
| 120 | } |
| 121 | |
| 122 | void version(guint& major, guint& minor, guint& micro, guint& nano) |
| 123 | { |
| 124 | gst_version(&major, &minor, µ, &nano); |
| 125 | } |
| 126 | |
| 127 | Glib::ustring version_string() |
| 128 | { |
| 129 | return Glib::ustring(gst_version_string()); |
| 130 | } |
| 131 | |
| 132 | bool segtrap_is_enabled() |
| 133 | { |
| 134 | return gst_segtrap_is_enabled(); |
| 135 | } |
| 136 | |
| 137 | void segtrap_set_enabled(bool enabled) |
| 138 | { |
| 139 | gst_segtrap_set_enabled(enabled); |
| 140 | } |
| 141 | |
| 142 | bool registry_fork_is_enabled() |
| 143 | { |
| 144 | return gst_registry_fork_is_enabled(); |
| 145 | } |
| 146 | |
| 147 | void registry_fork_set_enabled(bool enabled) |
| 148 | { |
| 149 | gst_registry_fork_set_enabled(enabled); |
| 150 | } |
| 151 | |
| 152 | bool update_registry() |
| 153 | { |
| 154 | return gst_update_registry(); |
| 155 | } |
| 156 | |
| 157 | } |