| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008-2016 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 <gst/gst.h> |
| 21 |
#include <gstreamermm/object.h> |
| 22 |
#include <glibmm/arrayhandle.h> |
| 23 |
|
| 24 |
_DEFS(gstreamermm,gst) |
| 25 |
|
| 26 |
namespace Gst |
| 27 |
{ |
| 28 |
|
| 29 |
_WRAP_ENUM(PluginDependencyFlags, GstPluginDependencyFlags) |
| 30 |
_WRAP_ENUM(PluginFlags, GstPluginFlags) |
| 31 |
|
| 32 |
/** The plugin loading errors. |
| 33 |
* |
| 34 |
* - MODULE - The plugin could not be loaded |
| 35 |
* - DEPENDENCIES - The plugin has unresolved dependencies |
| 36 |
* - NAME_MISMATCH - The plugin has already be loaded from a different file |
| 37 |
*/ |
| 38 |
_WRAP_GERROR(PluginError, GstPluginError, GST_PLUGIN_ERROR) |
| 39 |
|
| 40 |
class Structure; |
| 41 |
|
| 42 |
/** A container for features loaded from a shared object module. |
| 43 |
* GStreamer is extensible, so Gst::Element instances can be loaded at runtime. |
| 44 |
* A plugin system can provide one or more of the basic GStreamer |
| 45 |
* Gst::PluginFeature subclasses. |
| 46 |
* |
| 47 |
* A plugin should export a symbol gst_plugin_desc that is a struct of type |
| 48 |
* PluginDesc. the plugin loader will check the version of the core library |
| 49 |
* the plugin was linked against and will create a new Gst::Plugin. It will |
| 50 |
* then call the PluginInitFunc function that was provided in the |
| 51 |
* gst_plugin_desc. |
| 52 |
* |
| 53 |
* Once you have a handle to a Gst::Plugin (e.g. from the RegistryPool), you |
| 54 |
* can add any object that subclasses Gst::PluginFeature. |
| 55 |
* |
| 56 |
* Usually plugins are always automaticlly loaded so you don't need to call |
| 57 |
* gst_plugin_load() explicitly to bring it into memory. There are options to |
| 58 |
* statically link plugins to an app or even use GStreamer without a plugin |
| 59 |
* repository in which case load() can be needed to bring the plugin |
| 60 |
* into memory. |
| 61 |
* |
| 62 |
* Last reviewed on 2016-06-06 (1.8.0) |
| 63 |
*/ |
| 64 |
class Plugin : public Object |
| 65 |
{ |
| 66 |
_CLASS_GOBJECT(Plugin, GstPlugin, GST_PLUGIN, Object, GstObject) |
| 67 |
|
| 68 |
public: |
| 69 |
/** For example, |
| 70 |
* bool on_plugin_init(const Glib::RefPtr<Gst::Plugin>& plugin);. |
| 71 |
* The init function should return true if plugin was initialized |
| 72 |
* successfully, false otherwise. |
| 73 |
*/ |
| 74 |
typedef sigc::slot< bool, const Glib::RefPtr<Gst::Plugin>& > SlotInit; |
| 75 |
|
| 76 |
/** For example, |
| 77 |
* bool on_plugin_filter(const Glib::RefPtr<Gst::Plugin>& plugin);. |
| 78 |
* The filter function should return true if plugin is a match, false |
| 79 |
* otherwise. |
| 80 |
*/ |
| 81 |
typedef sigc::slot< bool, const Glib::RefPtr<Gst::Plugin>& > SlotFilter; |
| 82 |
|
| 83 |
_WRAP_METHOD(static Glib::QueryQuark error_quark(), gst_plugin_error_quark) |
| 84 |
_WRAP_METHOD(Glib::ustring get_name() const, gst_plugin_get_name) |
| 85 |
_WRAP_METHOD(Glib::ustring get_description() const, gst_plugin_get_description) |
| 86 |
_WRAP_METHOD(Glib::ustring get_filename() const, gst_plugin_get_filename) |
| 87 |
_WRAP_METHOD(Glib::ustring get_license() const, gst_plugin_get_license) |
| 88 |
_WRAP_METHOD(Glib::ustring get_package() const, gst_plugin_get_package) |
| 89 |
_WRAP_METHOD(Glib::ustring get_origin() const, gst_plugin_get_origin) |
| 90 |
_WRAP_METHOD(Glib::ustring get_source() const, gst_plugin_get_source) |
| 91 |
_WRAP_METHOD(Glib::ustring get_version() const, gst_plugin_get_version) |
| 92 |
_WRAP_METHOD(Glib::ustring get_release_date_string() const, gst_plugin_get_release_date_string) |
| 93 |
|
| 94 |
_WRAP_METHOD(bool is_loaded() const, gst_plugin_is_loaded) |
| 95 |
|
| 96 |
// A copy is taken so that the original is not freed by the wrapper. |
| 97 |
#m4 _CONVERSION(`const GstStructure*',`Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)') |
| 98 |
_WRAP_METHOD(Gst::Structure get_cache_data() const, gst_plugin_get_cache_data) |
| 99 |
|
| 100 |
_WRAP_METHOD(void set_cache_data(Gst::Structure& cache_data), gst_plugin_set_cache_data) |
| 101 |
|
| 102 |
/** @throw Gst::PluginError. |
| 103 |
*/ |
| 104 |
_WRAP_METHOD(static Glib::RefPtr<Gst::Plugin> load_file(const Glib::ustring& filename), gst_plugin_load_file, errthrow) |
| 105 |
|
| 106 |
_WRAP_METHOD(Glib::RefPtr<Gst::Plugin> load(), gst_plugin_load) |
| 107 |
_WRAP_METHOD(static Glib::RefPtr<Gst::Plugin> load_by_name(const Glib::ustring& name), gst_plugin_load_by_name) |
| 108 |
|
| 109 |
// Don't wrap gst_plugin_list_free because Glib::ListHandle<> already takes |
| 110 |
// care of freeing. |
| 111 |
_IGNORE(gst_plugin_list_free) |
| 112 |
|
| 113 |
static bool register_static(int major_version, int minor_version, |
| 114 |
const Glib::ustring& name, const Glib::ustring& description, |
| 115 |
const SlotInit& init_slot, const Glib::ustring& version, |
| 116 |
const Glib::ustring& license, const Glib::ustring& source, |
| 117 |
const Glib::ustring& package, const Glib::ustring& origin); |
| 118 |
|
| 119 |
_WRAP_METHOD(void add_dependency(const Glib::StringArrayHandle& env_vars, |
| 120 |
const Glib::StringArrayHandle& paths, |
| 121 |
const Glib::StringArrayHandle& names, |
| 122 |
Gst::PluginDependencyFlags flags), gst_plugin_add_dependency) |
| 123 |
|
| 124 |
_WRAP_METHOD(void add_dependency(const Glib::ustring& env_vars, |
| 125 |
const Glib::ustring& paths, |
| 126 |
const Glib::ustring& names, |
| 127 |
Gst::PluginDependencyFlags flags), gst_plugin_add_dependency_simple) |
| 128 |
}; |
| 129 |
|
| 130 |
} // namespace Gst |