| 1 | // -*- c++ -*- |
| 2 | |
| 3 | /* gstreamermm - a C++ wrapper for gstreamer |
| 4 | * |
| 5 | * Copyright 2008 The gstreamermm Development Team |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 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 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free |
| 19 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _GSTREAMERMM_INIT_H |
| 23 | #define _GSTREAMERMM_INIT_H |
| 24 | |
| 25 | #include <glibmm/error.h> |
| 26 | #include <glibmm/optiongroup.h> |
| 27 | |
| 28 | namespace Gst |
| 29 | { |
| 30 | |
| 31 | /** Initializes gstreamermm parsing command line arguments. |
| 32 | * |
| 33 | * Either this function or Gst::init_check() with command line parsing should |
| 34 | * be called to initialize gstreamermm before calling any other GLib functions. |
| 35 | * If this is not an option, your program must initialize the GLib thread |
| 36 | * system using Glib::thread_init() before any other GLib functions are called |
| 37 | * and use either Gst::init(), or Gst::init_check() without the command line |
| 38 | * arguments before calling any gstreamermm functions. |
| 39 | * |
| 40 | * Note: This function will terminate your program if it was unable to |
| 41 | * initialize GStreamer for some reason. If you want your program to fall back, |
| 42 | * use Gst::init_check() instead. |
| 43 | * |
| 44 | * WARNING: This function does not work in the same way as corresponding |
| 45 | * functions in other glib-style libraries, such as gtk_init(). In particular, |
| 46 | * unknown command line options cause this function to abort program execution. |
| 47 | * |
| 48 | * @param argc Reference to application's argc. |
| 49 | * @param argv Reference to application's argv. |
| 50 | */ |
| 51 | void init(int& argc, char**& argv); |
| 52 | |
| 53 | /** Initializes gstreamermm without parsing command line options. |
| 54 | * |
| 55 | * Either the Gst::init() or Gst::init_check() functions with command line |
| 56 | * parsing should be called to initialize gstreamermm before calling any other |
| 57 | * GLib functions. If this is not an option, your program must initialize the |
| 58 | * GLib thread system using Glib::thread_init() before any other GLib functions |
| 59 | * are called and use either this function or Gst::init_check() without the |
| 60 | * command line arguments before calling any gstreamermm functions. |
| 61 | * |
| 62 | * Note: This function will terminate your program if it was unable to |
| 63 | * initialize GStreamer for some reason. If you want your program to fall |
| 64 | * back, use Gst::init_check() instead. |
| 65 | */ |
| 66 | void init(); |
| 67 | |
| 68 | /** Initializes gstreamermm gracefully parsing command line arguments. |
| 69 | * |
| 70 | * Either this function or Gst::init() with command line parsing should be |
| 71 | * called to initialize gstreamermm before calling any other GLib functions. |
| 72 | * If this is not an option, your program must initialize the GLib thread |
| 73 | * system using Glib::thread_init() before any other GLib functions are called |
| 74 | * and use either Gst::init() or Gst::init_check() without the command line |
| 75 | * arguments before calling any gstreamermm functions. |
| 76 | * |
| 77 | * This function will return false if GStreamer could not be initialized for |
| 78 | * some reason. If you want your program to fail fatally, use Gst::init() |
| 79 | * instead. |
| 80 | * |
| 81 | * @param argc Reference to application's argc. |
| 82 | * @param argv Reference to application's argv. |
| 83 | * @return true if GStreamer could be initialized. |
| 84 | * @throw Glib::Error |
| 85 | */ |
| 86 | bool init_check(int& argc, char**& argv); |
| 87 | |
| 88 | /** Initializes gstreamermm gracefully without parsing command line arguments. |
| 89 | * |
| 90 | * Either the Gst::init() or Gst::init_check() functions with command line |
| 91 | * parsing should be called to initialize gstreamermm before calling any other |
| 92 | * GLib functions. If this is not an option, your program must initialize the |
| 93 | * GLib thread system using Glib::thread_init() before any other GLib functions |
| 94 | * are called and use either this function or Gst::init() without the command |
| 95 | * line arguments before calling any gstreamermm functions. |
| 96 | * |
| 97 | * This function will return false if GStreamer could not be initialized for |
| 98 | * some reason. If you want your program to fail fatally, use Gst::init() |
| 99 | * instead. |
| 100 | * |
| 101 | * @return true if GStreamer could be initialized. |
| 102 | * @throw Glib::Error |
| 103 | */ |
| 104 | bool init_check(); |
| 105 | |
| 106 | /** Use this function to check if GStreamer has been initialized. |
| 107 | * @return <tt>true</tt> if initialization has been done, <tt>false</tt> |
| 108 | * otherwise. |
| 109 | */ |
| 110 | bool is_initialized(void); |
| 111 | |
| 112 | /** Clean up any resources created by GStreamer upon initialization. |
| 113 | * |
| 114 | * It is normally not needed to call this function in a normal application as |
| 115 | * the resources will automatically be freed when the program terminates. |
| 116 | * This function is therefore mostly used by testsuites and other memory |
| 117 | * profiling tools. |
| 118 | * |
| 119 | * After this call GStreamer (including this method) should not be used |
| 120 | * anymore. |
| 121 | */ |
| 122 | void deinit(); |
| 123 | |
| 124 | /** Returns a Glib::OptionGroup with GStreamer's argument specifications. The |
| 125 | * group is set up to use standard GOption callbacks, so when using this group |
| 126 | * in combination with GOption parsing methods, all argument parsing and |
| 127 | * initialization is automated. |
| 128 | * |
| 129 | * This function is useful if you want to integrate GStreamer with other |
| 130 | * libraries that use GOption (see g_option_context_add_group() ). |
| 131 | * |
| 132 | * If you use this function, you should make sure you initialise the GLib |
| 133 | * threading system as one of the very first things in your program. |
| 134 | * |
| 135 | * @return A pointer to GStreamer's option group. |
| 136 | */ |
| 137 | Glib::OptionGroup get_option_group(); |
| 138 | |
| 139 | /** |
| 140 | * Gets the version number of the GStreamer library. |
| 141 | * |
| 142 | * @param major The major version number. |
| 143 | * @param minor The minor version number. |
| 144 | * @param micro The micro version number. |
| 145 | * @param nano The nano version number. |
| 146 | */ |
| 147 | void version(guint& major, guint& minor, guint& micro, guint& nano); |
| 148 | |
| 149 | /** |
| 150 | * This function returns a string that is useful for describing this version |
| 151 | * of GStreamer to the outside world: user agent strings, logging, ... |
| 152 | * |
| 153 | * @return A newly allocated string describing this version |
| 154 | * of GStreamer. |
| 155 | */ |
| 156 | Glib::ustring version_string(); |
| 157 | |
| 158 | /** |
| 159 | * Some functions in the GStreamer core might install a custom SIGSEGV handler |
| 160 | * to better catch and report errors to the application. Currently this feature |
| 161 | * is enabled by default when loading plugins. |
| 162 | * |
| 163 | * Applications might want to disable this behaviour with the |
| 164 | * gst_segtrap_set_enabled() function. This is typically done if the application |
| 165 | * wants to install its own handler without GStreamer interfering. |
| 166 | * |
| 167 | * @return <tt>true</tt> if GStreamer is allowed to install a custom SIGSEGV handler. |
| 168 | */ |
| 169 | bool segtrap_is_enabled(); |
| 170 | |
| 171 | /** |
| 172 | * Applications might want to disable/enable the SIGSEGV handling of |
| 173 | * the GStreamer core. See gst_segtrap_is_enabled() for more information. |
| 174 | * |
| 175 | * @param enabled Whether a custom SIGSEGV handler should be installed. |
| 176 | */ |
| 177 | void segtrap_set_enabled(bool enabled); |
| 178 | |
| 179 | /** |
| 180 | * By default GStreamer will perform scanning and rebuilding of the |
| 181 | * registry file using a helper child process. |
| 182 | * |
| 183 | * Applications might want to disable this behaviour with the |
| 184 | * gst_registry_fork_set_enabled() function, in which case new plugins |
| 185 | * are scanned (and loaded) into the application process. |
| 186 | * |
| 187 | * @return <tt>true</tt> if GStreamer will use the child helper process when |
| 188 | * rebuilding the registry. |
| 189 | */ |
| 190 | bool registry_fork_is_enabled(); |
| 191 | |
| 192 | /** |
| 193 | * Applications might want to disable/enable spawning of a child helper process |
| 194 | * when rebuilding the registry. See gst_registry_fork_is_enabled() for more |
| 195 | * information. |
| 196 | * |
| 197 | * @param enabled Whether rebuilding the registry can use a temporary child helper process. |
| 198 | */ |
| 199 | void registry_fork_set_enabled(bool enabled); |
| 200 | |
| 201 | /** |
| 202 | * Forces GStreamer to re-scan its plugin paths and update the default |
| 203 | * plugin registry. |
| 204 | * |
| 205 | * Applications will almost never need to call this function, it is only |
| 206 | * useful if the application knows new plugins have been installed (or old |
| 207 | * ones removed) since the start of the application (or, to be precise, the |
| 208 | * first call to gst_init()) and the application wants to make use of any |
| 209 | * newly-installed plugins without restarting the application. |
| 210 | * |
| 211 | * Applications should assume that the registry update is neither atomic nor |
| 212 | * thread-safe and should therefore not have any dynamic pipelines running |
| 213 | * (including the playbin and decodebin elements) and should also not create |
| 214 | * any elements or access the GStreamer registry while the update is in |
| 215 | * progress. |
| 216 | * |
| 217 | * Note that this function may block for a significant amount of time. |
| 218 | * |
| 219 | * @return <tt>true</tt> if the registry has been updated successfully (does not |
| 220 | * imply that there were changes), otherwise <tt>false</tt>. |
| 221 | */ |
| 222 | bool update_registry(); |
| 223 | |
| 224 | |
| 225 | /*! A gstreamermm init example. |
| 226 | * @example basics/init_gstreamermm.cc |
| 227 | */ |
| 228 | |
| 229 | }//end namespace Gst |
| 230 | |
| 231 | #endif //_GSTREAMERMM_INIT_H |