| 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/pad.h> |
| 22 |
#include <gstreamermm/pluginfeature.h> |
| 23 |
#include <gstreamermm/urihandler.h> |
| 24 |
|
| 25 |
_DEFS(gstreamermm,gst) |
| 26 |
|
| 27 |
namespace Gst |
| 28 |
{ |
| 29 |
|
| 30 |
enum ElementFactoryListType |
| 31 |
{ |
| 32 |
ELEMENT_FACTORY_TYPE_ANY, |
| 33 |
ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS, |
| 34 |
ELEMENT_FACTORY_TYPE_AUDIO_ENCODER, |
| 35 |
ELEMENT_FACTORY_TYPE_DECODABLE, |
| 36 |
ELEMENT_FACTORY_TYPE_DECODER, |
| 37 |
ELEMENT_FACTORY_TYPE_DEMUXER, |
| 38 |
ELEMENT_FACTORY_TYPE_DEPAYLOADER, |
| 39 |
ELEMENT_FACTORY_TYPE_ENCODER, |
| 40 |
ELEMENT_FACTORY_TYPE_FORMATTER, |
| 41 |
ELEMENT_FACTORY_TYPE_MAX_ELEMENTS, |
| 42 |
ELEMENT_FACTORY_TYPE_MEDIA_AUDIO, |
| 43 |
ELEMENT_FACTORY_TYPE_MEDIA_IMAGE, |
| 44 |
ELEMENT_FACTORY_TYPE_MEDIA_METADATA, |
| 45 |
ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE, |
| 46 |
ELEMENT_FACTORY_TYPE_MEDIA_VIDEO, |
| 47 |
ELEMENT_FACTORY_TYPE_MEDIA_ANY, |
| 48 |
ELEMENT_FACTORY_TYPE_MUXER, |
| 49 |
ELEMENT_FACTORY_TYPE_PARSER, |
| 50 |
ELEMENT_FACTORY_TYPE_PAYLOADER, |
| 51 |
ELEMENT_FACTORY_TYPE_SINK, |
| 52 |
ELEMENT_FACTORY_TYPE_SRC, |
| 53 |
ELEMENT_FACTORY_TYPE_VIDEO_ENCODER |
| 54 |
}; |
| 55 |
|
| 56 |
class ArrayHandler; |
| 57 |
class Caps; |
| 58 |
class Element; |
| 59 |
class StaticPadTemplate; |
| 60 |
struct StaticPadTemplateTraits; |
| 61 |
class Plugin; |
| 62 |
|
| 63 |
/** Create Gst::Element 's from a factory |
| 64 |
* |
| 65 |
* Gst::ElementFactory is used to create instances of elements. A |
| 66 |
* Gst::ElementFactory can be added to a Gst::Plugin as it is also a |
| 67 |
* Gst::PluginFeature. |
| 68 |
* |
| 69 |
* Use the find() and create() |
| 70 |
* functions to create element instances or use create_element() as a |
| 71 |
* convenient shortcut. |
| 72 |
* |
| 73 |
* The following code example shows you how to create a 'filesrc' element. |
| 74 |
* |
| 75 |
* @code |
| 76 |
* #include <gstreamermm.h> |
| 77 |
* #include <iostream> |
| 78 |
* |
| 79 |
* int main (int argc, char *argc[]) |
| 80 |
* { |
| 81 |
* Glib::RefPtr<Gst::Element> src; |
| 82 |
* Glib::RefPtr<Gst::ElementFactory> srcfactory; |
| 83 |
* |
| 84 |
* Gst::init(&argc,&argv); |
| 85 |
* |
| 86 |
* srcfactory = Gst::ElementFactory::find("filesrc"); |
| 87 |
* |
| 88 |
* if(!srcfactory) |
| 89 |
* { |
| 90 |
* std::cout << "Could not find factory 'filesrc'" << std::endl; |
| 91 |
* exit(1); |
| 92 |
* } |
| 93 |
* |
| 94 |
* src = srcfactory->create("src"); |
| 95 |
* |
| 96 |
* if(!src) |
| 97 |
* { |
| 98 |
* std::cout << "Could not create element 'src'" << std::endl; |
| 99 |
* exit(1); |
| 100 |
* } |
| 101 |
* ... |
| 102 |
* } |
| 103 |
* @endcode |
| 104 |
* |
| 105 |
* Last reviewed on 2016-05-21 (1.8.0). |
| 106 |
* |
| 107 |
*/ |
| 108 |
class ElementFactory : public PluginFeature |
| 109 |
{ |
| 110 |
_CLASS_GOBJECT(ElementFactory, GstElementFactory, GST_ELEMENT_FACTORY, PluginFeature, GstPluginFeature) |
| 111 |
|
| 112 |
public: |
| 113 |
_WRAP_METHOD(static bool register_element(const Glib::RefPtr<Gst::Plugin>& plugin, const Glib::ustring& name, guint rank, GType type), gst_element_register) |
| 114 |
|
| 115 |
_WRAP_METHOD(static Glib::RefPtr<Gst::ElementFactory> find(const Glib::ustring& name), gst_element_factory_find) |
| 116 |
|
| 117 |
_WRAP_METHOD(Glib::RefPtr<Gst::Element> create(const Glib::ustring& name{?}), gst_element_factory_create) |
| 118 |
|
| 119 |
_WRAP_METHOD(static Glib::RefPtr<Gst::Element> create_element(const Glib::ustring& factory_name, const Glib::ustring& name{?}), gst_element_factory_make) |
| 120 |
|
| 121 |
_WRAP_METHOD(bool can_sink_all_caps(const Glib::RefPtr<const Gst::Caps>& caps) const, gst_element_factory_can_sink_all_caps) |
| 122 |
_WRAP_METHOD(bool can_src_all_caps(const Glib::RefPtr<const Gst::Caps>& caps) const, gst_element_factory_can_src_all_caps) |
| 123 |
_WRAP_METHOD(bool can_sink_any_caps(const Glib::RefPtr<const Gst::Caps>& caps) const, gst_element_factory_can_sink_any_caps) |
| 124 |
_WRAP_METHOD(bool can_src_any_caps(const Glib::RefPtr<const Gst::Caps>& caps) const, gst_element_factory_can_src_any_caps) |
| 125 |
|
| 126 |
_WRAP_METHOD(GType get_element_type() const, gst_element_factory_get_element_type) |
| 127 |
|
| 128 |
#m4 _CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_DEEP)') |
| 129 |
_WRAP_METHOD(std::vector<Glib::ustring> get_metadata_keys() const, gst_element_factory_get_metadata_keys) |
| 130 |
_WRAP_METHOD(Glib::ustring get_metadata(const Glib::ustring& key) const, gst_element_factory_get_metadata) |
| 131 |
|
| 132 |
_WRAP_METHOD(guint get_num_pad_templates() const, gst_element_factory_get_num_pad_templates) |
| 133 |
_WRAP_METHOD(URIType get_uri_type() const, gst_element_factory_get_uri_type) |
| 134 |
|
| 135 |
#m4 _CONVERSION(`const gchar* const*',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_DEEP)') |
| 136 |
_WRAP_METHOD(std::vector<Glib::ustring> get_uri_protocols() const, gst_element_factory_get_uri_protocols) |
| 137 |
|
| 138 |
_WRAP_METHOD(bool has_interface(const Glib::ustring& name) const, gst_element_factory_has_interface) |
| 139 |
|
| 140 |
#m4 _CONVERSION(`const GList*', `std::vector< Gst::StaticPadTemplate >', `Glib::ListHandler< Gst::StaticPadTemplate, StaticPadTemplateTraits >::list_to_vector(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)') |
| 141 |
_WRAP_METHOD(std::vector< Gst::StaticPadTemplate > get_static_pad_templates() const, gst_element_factory_get_static_pad_templates) |
| 142 |
|
| 143 |
#m4 _CONVERSION(`GList*', `std::vector< Glib::RefPtr<Gst::ElementFactory> >', `Glib::ListHandler< Glib::RefPtr<Gst::ElementFactory> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)') |
| 144 |
#m4 _CONVERSION(`const std::vector< Glib::RefPtr<Gst::ElementFactory> >&', `GList*', `Glib::ListHandler< Glib::RefPtr<Gst::ElementFactory> >::vector_to_list($3).data()') |
| 145 |
_WRAP_METHOD(static std::vector< Glib::RefPtr<Gst::ElementFactory> > filter(const std::vector< Glib::RefPtr<Gst::ElementFactory> >& list, const Glib::RefPtr<const Gst::Caps>& caps, PadDirection direction, bool subsetonly), gst_element_factory_list_filter) |
| 146 |
|
| 147 |
#m4 _CONVERSION(`ElementFactoryListType', `GstElementFactoryListType', `_list_types[$3]') |
| 148 |
|
| 149 |
_WRAP_METHOD(static std::vector< Glib::RefPtr<Gst::ElementFactory> > get_elements(ElementFactoryListType type, Rank minrank), gst_element_factory_list_get_elements) |
| 150 |
_WRAP_METHOD(bool is_type(ElementFactoryListType type) const, gst_element_factory_list_is_type) |
| 151 |
}; |
| 152 |
|
| 153 |
/*! A gstreamermm Gst::ElementFactory example. |
| 154 |
* @example basics/element_factory.cc |
| 155 |
*/ |
| 156 |
|
| 157 |
} // namespace Gst |