| 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 <gstreamermm/pad.h> |
| 23 |
|
| 24 |
_DEFS(gstreamermm,gst) |
| 25 |
|
| 26 |
namespace Gst |
| 27 |
{ |
| 28 |
|
| 29 |
_WRAP_ENUM(PadTemplateFlags, GstPadTemplateFlags) |
| 30 |
_WRAP_ENUM(PadPresence, GstPadPresence) |
| 31 |
|
| 32 |
class Caps; |
| 33 |
class Pad; |
| 34 |
|
| 35 |
/** A class that describes the media type of a pad. |
| 36 |
* Padtemplates describe the possible media types a pad or an elementfactory |
| 37 |
* can handle. This allows for both inspection of handled types before loading |
| 38 |
* the element plugin as well as identifying pads on elements that are not yet |
| 39 |
* created (request or sometimes pads). |
| 40 |
* |
| 41 |
* Gst::Pad and PadTemplates have Gst::Caps attached to it to describe the |
| 42 |
* media type they are capable of dealing with. get_caps() is used to get the |
| 43 |
* caps of a padtemplate. It's not possible to modify the caps of a padtemplate |
| 44 |
* after creation. |
| 45 |
* |
| 46 |
* PadTemplates have a Gst::PadPresence property which identifies the lifetime |
| 47 |
* of the pad and that can be retrieved with get_presence(). Also the direction |
| 48 |
* of the pad can be retrieved from the GstPadTemplate with get_direction(). |
| 49 |
* |
| 50 |
* The get_name_template() method is important for Gst::PAD_REQUEST pads |
| 51 |
* because it has to be used as the name in the |
| 52 |
* Gst::Element::get_request_pad() call to instantiate a pad from this |
| 53 |
* template. |
| 54 |
* |
| 55 |
* Padtemplates can be created with create(). |
| 56 |
|
| 57 |
* A padtemplate can be used to create a pad (see Gst::Pad::create() methods). |
| 58 |
* |
| 59 |
* Last reviewed on 2016-06-06 (1.8.0) |
| 60 |
*/ |
| 61 |
class PadTemplate : public Object |
| 62 |
{ |
| 63 |
_CLASS_GOBJECT(PadTemplate, GstPadTemplate, GST_PAD_TEMPLATE, Object, GstObject) |
| 64 |
|
| 65 |
protected: |
| 66 |
_WRAP_CTOR(PadTemplate(const Glib::ustring& name_template, PadDirection direction, PadPresence presence, const Glib::RefPtr<Gst::Caps>& caps), gst_pad_template_new) |
| 67 |
|
| 68 |
public: |
| 69 |
/** Creates a new pad template with a name according to the given template |
| 70 |
* and with the given arguments. This functions takes ownership of the |
| 71 |
* provided caps, so be sure to not use them afterwards. |
| 72 |
* |
| 73 |
* @param name_template The name template. |
| 74 |
* @param direction The Gst::PadDirection of the template. |
| 75 |
* @param presence The Gst::PadPresence of the pad. |
| 76 |
* @param caps A Gst::Caps set for the template. The caps are taken ownership |
| 77 |
* of. |
| 78 |
* @return A new Gst::PadTemplate. |
| 79 |
*/ |
| 80 |
_WRAP_CREATE(const Glib::ustring& name_template, PadDirection direction, PadPresence presence, const Glib::RefPtr<Gst::Caps>& caps) |
| 81 |
|
| 82 |
_WRAP_METHOD(Glib::RefPtr<Gst::Caps> get_caps(), gst_pad_template_get_caps) |
| 83 |
_WRAP_METHOD(Glib::RefPtr<const Gst::Caps> get_caps() const, gst_pad_template_get_caps, constversion) |
| 84 |
|
| 85 |
/** Get the nametemplate of the padtemplate. |
| 86 |
*/ |
| 87 |
_MEMBER_GET(name_template, name_template, Glib::ustring, gchar*) |
| 88 |
|
| 89 |
/** Get the Gst::PadDirection of the padtemplate. |
| 90 |
*/ |
| 91 |
_MEMBER_GET(direction, direction, PadDirection, GstPadDirection) |
| 92 |
|
| 93 |
/** Get the Gst::PadPresence of the padtemplate. |
| 94 |
*/ |
| 95 |
_MEMBER_GET(presence, presence, PadPresence, GstPadPresence) |
| 96 |
|
| 97 |
_WRAP_PROPERTY("caps", Glib::RefPtr<Gst::Caps>) |
| 98 |
_WRAP_PROPERTY("direction", Gst::PadDirection) |
| 99 |
_WRAP_PROPERTY("name-template", Glib::ustring) |
| 100 |
_WRAP_PROPERTY("presence", Gst::PadPresence) |
| 101 |
|
| 102 |
#m4 _CONVERSION(`GstPad*',`const Glib::RefPtr<Gst::Pad>&',`Glib::wrap($3, true)') |
| 103 |
_WRAP_SIGNAL(void pad_created(const Glib::RefPtr<Gst::Pad>& pad), "pad-created") |
| 104 |
|
| 105 |
//gst_pad_template_pad_created emits the "pad-created" signal. It seems |
| 106 |
//internal to C API (it is not found in API docs) so ignore it. |
| 107 |
_IGNORE(gst_pad_template_pad_created) |
| 108 |
}; |
| 109 |
|
| 110 |
|
| 111 |
class StaticPadTemplate |
| 112 |
{ |
| 113 |
_CLASS_BOXEDTYPE_STATIC(StaticPadTemplate, GstStaticPadTemplate) |
| 114 |
|
| 115 |
public: |
| 116 |
|
| 117 |
_WRAP_METHOD(Glib::RefPtr<Gst::Caps> get_caps(), gst_static_pad_template_get_caps) |
| 118 |
_WRAP_METHOD(Glib::RefPtr<const Gst::Caps> get_caps() const, gst_static_pad_template_get_caps, constversion) |
| 119 |
|
| 120 |
_WRAP_METHOD(Glib::RefPtr<Gst::PadTemplate> get(), gst_static_pad_template_get) |
| 121 |
|
| 122 |
/** Get the nametemplate of the padtemplate. |
| 123 |
*/ |
| 124 |
_MEMBER_GET(name_template, name_template, Glib::ustring, gchar*) |
| 125 |
|
| 126 |
/** Get the Gst::PadDirection of the padtemplate. |
| 127 |
*/ |
| 128 |
_MEMBER_GET(direction, direction, PadDirection, GstPadDirection) |
| 129 |
|
| 130 |
/** Get the Gst::PadPresence of the padtemplate. |
| 131 |
*/ |
| 132 |
_MEMBER_GET(presence, presence, PadPresence, GstPadPresence) |
| 133 |
|
| 134 |
}; |
| 135 |
|
| 136 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 137 |
struct StaticPadTemplateTraits |
| 138 |
{ |
| 139 |
typedef const Gst::StaticPadTemplate CppType; |
| 140 |
typedef const GstStaticPadTemplate * CType; |
| 141 |
typedef GstStaticPadTemplate * CTypeNonConst; |
| 142 |
|
| 143 |
static CType to_c_type (CppType& obj) { return obj.gobj(); } |
| 144 |
static CType to_c_type (CType ptr) { return ptr; } |
| 145 |
static CppType to_cpp_type (CType ptr) |
| 146 |
{ |
| 147 |
return CppType(const_cast<CTypeNonConst>(ptr)); |
| 148 |
} |
| 149 |
|
| 150 |
static void release_c_type (CType) |
| 151 |
{ |
| 152 |
} |
| 153 |
}; |
| 154 |
#endif //DOXYGEN_SHOULD_SKIP_THIS |
| 155 |
|
| 156 |
} //namespace Gst |