gstreamermm: element.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files

# element.h

Go to the documentation of this file.

    00001 // -*- c++ -*-
    00002 // Generated by gtkmmproc -- DO NOT MODIFY!
    00003 #ifndef _GSTREAMERMM_ELEMENT_H
    00004 #define _GSTREAMERMM_ELEMENT_H
    00005
    00006
    00007 #include <glibmm.h>
    00008
    00009 /* gstreamermm - a C++ wrapper for gstreamer
    00010  *
    00011  * Copyright 2008 The gstreamermm Development Team
    00012  *
    00013  * This library is free software; you can redistribute it and/or
    00014  * modify it under the terms of the GNU Lesser General Public
    00015  * License as published by the Free Software Foundation; either
    00016  * version 2.1 of the License, or (at your option) any later version.
    00017  *
    00018  * This library is distributed in the hope that it will be useful,
    00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00021  * Lesser General Public License for more details.
    00022  *
    00023  * You should have received a copy of the GNU Lesser General Public
    00024  * License along with this library; if not, write to the Free
    00025  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00026  */
    00027
    00028 #include <gst/gstelement.h>
    00029 #include <gstreamermm/object.h>
    00030 #include <gstreamermm/clock.h>
    00031 #include <gstreamermm/enums.h>
    00032 #include <gstreamermm/event.h>
    00033 #include <gstreamermm/message.h>
    00034 #include <gstreamermm/query.h>
    00035 #include <stdexcept> //Because link() throws std::runtime_error
    00036
    00037
    00038 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00039 typedef struct _GstElement GstElement;
    00040 typedef struct _GstElementClass GstElementClass;
    00041 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00042
    00043
    00044 namespace Gst
    00045 { class Element_Class; } // namespace Gst
    00046 namespace Gst
    00047 {
    00048
    00061 class Bus;
    00062 class Caps;
    00063 class Clock;
    00064 class ElementFactory;
    00065 class Event;
    00066 class Index;
    00067 class Interface;
    00068 class Message;
    00069 class Pad;
    00070 class PadTemplate;
    00071 class Query;
    00072 class TagList;
    00073
    00074 //Gst::Iterator<> forward declaration.
    00075 template <class CppType>
    00076 class Iterator;
    00077
    00083 enum ElementFlags
    00084 {
    00085   ELEMENT_LOCKED_STATE = GST_OBJECT_FLAG_LAST << 0,
    00086   ELEMENT_IS_SINK = GST_OBJECT_FLAG_LAST << 1,
    00087   ELEMENT_UNPARENTING = GST_OBJECT_FLAG_LAST << 2,
    00088   ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST << 16
    00089 };
    00090
    00091 } // namespace Gst
    00092
    00093
    00094 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00095 namespace Glib
    00096 {
    00097
    00098 template <>
    00099 class Value<Gst::ElementFlags> : public Glib::Value_Enum<Gst::ElementFlags>
    00100 {
    00101 public:
    00102   static GType value_type() G_GNUC_CONST;
    00103 };
    00104
    00105 } // namespace Glib
    00106 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00107
    00108
    00109 namespace Gst
    00110 {
    00111
    00112
    00113 //TODO: Fix gmmproc so that definition in gst_enums.defs does not cause errors
    00114 //and this can be wrapped with _WRAP_ENUM.
    00115 enum StateChange
    00116 {
    00117   STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
    00118   STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
    00119   STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
    00120   STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
    00121   STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
    00122   STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL
    00123 };
    00124
    00128 enum StateChangeReturn
    00129 {
    00130   STATE_CHANGE_FAILURE,
    00131   STATE_CHANGE_SUCCESS,
    00132   STATE_CHANGE_ASYNC,
    00133   STATE_CHANGE_NO_PREROLL
    00134 };
    00135
    00136 } // namespace Gst
    00137
    00138
    00139 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00140 namespace Glib
    00141 {
    00142
    00143 template <>
    00144 class Value<Gst::StateChangeReturn> : public Glib::Value_Enum<Gst::StateChangeReturn>
    00145 {
    00146 public:
    00147   static GType value_type() G_GNUC_CONST;
    00148 };
    00149
    00150 } // namespace Glib
    00151 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00152
    00153
    00154 namespace Gst
    00155 {
    00156
    00157
    00158 namespace Enums
    00159 {
    00160
    00166 Glib::ustring get_name(State state);
    00167
    00173 Glib::ustring get_name(StateChangeReturn state_ret);
    00174
    00175 } //namespace Enums
    00176
    00219 class Element : public Gst::Object
    00220 {
    00221
    00222 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00223
    00224 public:
    00225   typedef Element CppObjectType;
    00226   typedef Element_Class CppClassType;
    00227   typedef GstElement BaseObjectType;
    00228   typedef GstElementClass BaseClassType;
    00229
    00230 private:  friend class Element_Class;
    00231   static CppClassType element_class_;
    00232
    00233 private:
    00234   // noncopyable
    00235   Element(const Element&);
    00236   Element& operator=(const Element&);
    00237
    00238 protected:
    00239   explicit Element(const Glib::ConstructParams& construct_params);
    00240   explicit Element(GstElement* castitem);
    00241
    00242 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00243
    00244 public:
    00245   virtual ~Element();
    00246
    00247 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00248   static GType get_type()      G_GNUC_CONST;
    00249   static GType get_base_type() G_GNUC_CONST;
    00250 #endif
    00251
    00253   GstElement*       gobj()       { return reinterpret_cast<GstElement*>(gobject_); }
    00254
    00256   const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
    00257
    00259   GstElement* gobj_copy();
    00260
    00261 private:
    00262
    00263
    00264 protected:
    00265   //Needed for ElementInterfaced derived class
    00266   Element();
    00267
    00268 public:
    00280   Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest);
    00281
    00282
    00300   bool add_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00301
    00306   void create_all_pads();
    00307
    00308
    00317   Glib::RefPtr<Gst::Pad> create_compatible_pad(const Glib::RefPtr<const Gst::Pad>& pad, const Glib::RefPtr<const Gst::Caps>& caps);
    00318
    00325   Glib::RefPtr<Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& padtemplate);
    00326
    00333   Glib::RefPtr<const Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& padtemplate) const;
    00334
    00335   //TODO: The documentation says "The pad should be released with gst_element_release_request_pad().", which is odd. murrayc
    00336
    00343   Glib::RefPtr<Gst::Pad> get_request_pad(const Glib::ustring& name);
    00344
    00345
    00354   Glib::RefPtr<Gst::Pad> get_static_pad(const Glib::ustring& name);
    00355
    00364   Glib::RefPtr<const Gst::Pad> get_static_pad(const Glib::ustring& name) const;
    00365
    00366
    00377   void no_more_pads();
    00378
    00385   void release_request_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00386
    00409   bool remove_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00410
    00417   Gst::Iterator<Gst::Pad> iterate_pads();
    00418
    00425   Gst::Iterator<const Gst::Pad> iterate_pads() const;
    00426
    00432   Gst::Iterator<Gst::Pad> iterate_sink_pads();
    00433
    00439   Gst::Iterator<const Gst::Pad> iterate_sink_pads() const;
    00440
    00446   Gst::Iterator<Gst::Pad> iterate_src_pads();
    00447
    00453   Gst::Iterator<const Gst::Pad> iterate_src_pads() const;
    00454
    00462   void unlink(const Glib::RefPtr<Gst::Element>& other_element);
    00463
    00464
    00465   //TODO: Make this like link()?
    00466
    00477   bool link_pads(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& others_padname);
    00478
    00479
    00485   void unlink_pads(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& other_padname);
    00486
    00487   //TODO: Make this like link()?
    00488
    00499   bool link_pads_filtered(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& others_padname, const Glib::RefPtr<Gst::Caps>& filter);
    00500
    00501   //TODO: Make this like link()?
    00502
    00515   bool link_filtered(const Glib::RefPtr<Gst::Element>& other_element, const Glib::RefPtr<Gst::Caps>& filter);
    00516
    00517
    00523   void set_base_time(ClockTime time);
    00524
    00530   ClockTime get_base_time() const;
    00531
    00538   void set_bus(const Glib::RefPtr<Gst::Bus>& bus);
    00539
    00545   Glib::RefPtr<Gst::Bus> get_bus();
    00546
    00552   Glib::RefPtr<const Gst::Bus> get_bus() const;
    00553
    00560   void set_index(const Glib::RefPtr<Gst::Index>& index);
    00561
    00562   //Note: gst_element_get_index provides a reference.
    00563
    00570   Glib::RefPtr<Gst::Index> get_index();
    00571
    00578   Glib::RefPtr<const Gst::Index > get_index() const;
    00579
    00580
    00585   Glib::RefPtr<Gst::ElementFactory> get_factory();
    00586
    00591   Glib::RefPtr<const Gst::ElementFactory> get_factory() const;
    00592
    00593
    00599   bool is_indexable() const;
    00600
    00606   bool requires_clock() const;
    00607
    00618   bool set_clock(const Glib::RefPtr<Gst::Clock>& clock);
    00619
    00626   Glib::RefPtr<Gst::Clock> get_clock();
    00627
    00634   Glib::RefPtr<const Gst::Clock> get_clock() const;
    00635
    00645   bool provides_clock() const;
    00646
    00655   Glib::RefPtr<Gst::Clock> provide_clock();
    00656
    00665   Glib::RefPtr<const Gst::Clock> provide_clock() const;
    00666
    00681   StateChangeReturn set_state(State state);
    00682
    00706   StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
    00707
    00716   bool set_locked_state(gboolean locked_state);
    00717
    00727   bool is_locked_state() const;
    00728
    00737   void abort_state();
    00738
    00755   StateChangeReturn continue_state(StateChangeReturn prestate_value);
    00756
    00778   void lost_state();
    00779
    00786   bool sync_state_with_parent();
    00787
    00795   StateChangeReturn change_state(StateChange transition);
    00796
    00804   void found_tags(Gst::TagList& list);
    00805
    00814   void found_tags_for_pad(const Glib::RefPtr<Gst::Pad>& pad, Gst::TagList& list);
    00815
    00816   //TODO: Change the parameter order?
    00817
    00835   void post_message(MessageType message_type, const Glib::QueryQuark& domain, int code, const Glib::ustring& message, const Glib::ustring& debug, const Glib::ustring& filename, const Glib::ustring& function_name, int line_number);
    00836
    00846   bool post_message(const Glib::RefPtr<Gst::Message>& message);
    00847
    00848
    00857   Glib::ArrayHandle<QueryType> get_query_types() const;
    00858
    00859
    00870   bool query(const Glib::RefPtr<Gst::Query>& query) const;
    00871
    00879   bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const;
    00880
    00887   bool query_position(Format& format, gint64& position) const;
    00888
    00895   bool query_position(Format& format) const;
    00896
    00897
    00904   bool query_duration(Format& format, gint64& duration) const;
    00905
    00912   bool query_duration(Format& format) const;
    00913
    00914
    00941   bool seek(Format format, SeekFlags flags, gint64 position);
    00942
    00957   bool seek(double rate, Format format, SeekFlags flags, SeekType current_type, gint64 current_position, SeekType stop_type, gint64 stop_position);
    00958
    00968   bool send_event(const Glib::RefPtr<Gst::Event>& event);
    00969
    00970
    00976   bool implements_interface(GType iface_type) const;
    00977
    00984   Glib::SignalProxy0< void > signal_no_more_pads();
    00985
    00986
    00993   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_added();
    00994
    00995
    01002   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_removed();
    01003
    01004
    01007   #ifdef GLIBMM_VFUNCS_ENABLED
    01008   virtual Glib::RefPtr<Gst::Pad> request_new_pad_vfunc(const Glib::RefPtr<const Gst::PadTemplate>& templ, const Glib::ustring& name);
    01009 #endif //GLIBMM_VFUNCS_ENABLED
    01010
    01011
    01014   #ifdef GLIBMM_VFUNCS_ENABLED
    01015   virtual void release_pad_vfunc(const Glib::RefPtr<Gst::Pad>& pad);
    01016 #endif //GLIBMM_VFUNCS_ENABLED
    01017
    01018
    01021   #ifdef GLIBMM_VFUNCS_ENABLED
    01022   virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout) const;
    01023 #endif //GLIBMM_VFUNCS_ENABLED
    01024
    01025
    01028   #ifdef GLIBMM_VFUNCS_ENABLED
    01029   virtual StateChangeReturn set_state_vfunc(State state);
    01030 #endif //GLIBMM_VFUNCS_ENABLED
    01031
    01032
    01035   #ifdef GLIBMM_VFUNCS_ENABLED
    01036   virtual StateChangeReturn change_state_vfunc(StateChange transition);
    01037 #endif //GLIBMM_VFUNCS_ENABLED
    01038
    01039
    01042   #ifdef GLIBMM_VFUNCS_ENABLED
    01043   virtual void set_bus_vfunc(const Glib::RefPtr<Gst::Bus>& bus);
    01044 #endif //GLIBMM_VFUNCS_ENABLED
    01045
    01046
    01049   #ifdef GLIBMM_VFUNCS_ENABLED
    01050   virtual Glib::RefPtr<Gst::Clock> provide_clock_vfunc();
    01051 #endif //GLIBMM_VFUNCS_ENABLED
    01052
    01053
    01054   //TODO: Wrapping this vfunc causes problems for generated plug-ins because
    01055   //the underlying C base class (GstElement) does not have a default set_clock
    01056   //(gst_element_set_clock_func) implementation and when a pipeline tries to
    01057   //set a clock for our derived gtkmm wrapper (in gst_bin_set_clock_func by
    01058   //calling gst_element_set_clock on all its children),
    01059   //set_clock_vfunc_callback returns false because when it tries to call the
    01060   //(*base->set_clock)() function, there is none (for a GstElement) and the
    01061   //callback winds up typedefing RType to gboolean and returning RType() which
    01062   //is false thus triggering a failure when setting the clock for one of our
    01063   //gtkmm plug-in wrappers. I think the reason that there is no default
    01064   //set_clock() implementation in GStreamer is that it depends on if an element
    01065   //requires a clock (see gst_element_requires_clock) so a possible fix would
    01066   //be to add an optional parameter to _WRAP_VFUNC parameter specifying what to
    01067   //return in that last vfunc callback return statement.  This would also fix
    01068   //bug #530416 so I may submit a patch for this in hopes that it fixes both
    01069   //problems.
    01070   // /** Set the Gst::Clock on the element.
    01071   //  */
    01072   //_WRAP_VFUNC(bool set_clock(const Glib::RefPtr<Gst::Clock>& clock), "set_clock")
    01073
    01076   #ifdef GLIBMM_VFUNCS_ENABLED
    01077   virtual Glib::RefPtr<Gst::Index> get_index_vfunc() const;
    01078 #endif //GLIBMM_VFUNCS_ENABLED
    01079
    01080
    01083   #ifdef GLIBMM_VFUNCS_ENABLED
    01084   virtual void set_index_vfunc(const Glib::RefPtr<Gst::Index>& index);
    01085 #endif //GLIBMM_VFUNCS_ENABLED
    01086
    01087
    01090   #ifdef GLIBMM_VFUNCS_ENABLED
    01091   virtual bool send_event_vfunc(const Glib::RefPtr<Gst::Event>& event);
    01092 #endif //GLIBMM_VFUNCS_ENABLED
    01093
    01094
    01095   //TODO: This vfunc can't be wrapped without getting a compile error in the
    01096   //generated code.  The compile error comes about because the code assumes
    01097   //that Glib::ArrayHandle<> has a default constructor but it does not.  The
    01098   //way the code is generated will have to be tweaked.
    01099   //
    01100 //#m4 __CONVERSION(`Glib::ArrayHandle<QueryType>',`const GstQueryType*',`(GstQueryType*)(($3).data())')
    01101   // /** Get the supported Gst::QueryType of this element.
    01102   //  */
    01103   // _WRAP_VFUNC(Glib::ArrayHandle<QueryType> get_query_types() const, "get_query_types")
    01104
    01105
    01108   #ifdef GLIBMM_VFUNCS_ENABLED
    01109   virtual bool query_vfunc(const Glib::RefPtr<Gst::Query>& query) const;
    01110 #endif //GLIBMM_VFUNCS_ENABLED
    01111
    01112
    01113 public:
    01114
    01115 public:
    01116   //C++ methods used to invoke GTK+ virtual functions:
    01117 #ifdef GLIBMM_VFUNCS_ENABLED
    01118 #endif //GLIBMM_VFUNCS_ENABLED
    01119
    01120 protected:
    01121   //GTK+ Virtual Functions (override these to change behaviour):
    01122 #ifdef GLIBMM_VFUNCS_ENABLED
    01123 #endif //GLIBMM_VFUNCS_ENABLED
    01124
    01125   //Default Signal Handlers::
    01126 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    01127   virtual void on_no_more_pads();
    01128   virtual void on_pad_added(const Glib::RefPtr<Gst::Pad>& new_pad);
    01129   virtual void on_pad_removed(const Glib::RefPtr<Gst::Pad>& old_pad);
    01130 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    01131
    01132
    01133 };
    01134
    01167 template <class T_Interface>
    01168 class ElementInterfaced
    01169 : public Element,
    01170   public T_Interface
    01171 {
    01172 public:
    01173   // Make calls involving underlying gobject unambiguous (specifically, gobj()
    01174   // is ambiguous when called from an ElementInterfaced<..> class
    01175   GstElement* gobj();
    01176   const GstElement* gobj() const;
    01177   GstElement* gobj_copy();
    01178
    01179   ~ElementInterfaced();
    01180
    01181 protected:
    01182   ElementInterfaced(const ElementInterfaced&);
    01183   ElementInterfaced& operator=(const ElementInterfaced&);
    01184
    01185 protected:
    01186   ElementInterfaced(GstElement* castitem);
    01187
    01188 private:
    01189   friend class Gst::Interface;
    01190 };
    01191
    01192 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01193
    01194 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
    01195
    01196 template <class T_Interface>
    01197 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
    01198 {
    01199   gobject_ = (GObject*)castitem;
    01200   if (gobject_) {
    01201     gst_object_ref(Element::gobj());
    01202     g_object_weak_ref(gobject_,
    01203       &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
    01204   }
    01205 }
    01206
    01207 template <class T_Interface>
    01208 GstElement* ElementInterfaced<T_Interface>::gobj()
    01209 {
    01210   return Element::gobj();
    01211 }
    01212
    01213 template <class T_Interface>
    01214 const GstElement* ElementInterfaced<T_Interface>::gobj() const
    01215 {
    01216   return Element::gobj();
    01217 }
    01218
    01219 template <class T_Interface>
    01220 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
    01221 {
    01222   return Element::gobj_copy();
    01223 }
    01224
    01225 template <class T_Interface>
    01226 ElementInterfaced<T_Interface>::~ElementInterfaced()
    01227 {
    01228   // Set the gobject_ to NULL so that when this is deleted, the gobject doesn't
    01229   // go with it and other elements "wrapping" the gobject are not affected
    01230   gobject_ = 0;
    01231 }
    01232
    01233 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    01234
    01235 } // namespace Gst
    01236
    01237
    01238 namespace Glib
    01239 {
    01248   Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
    01249 }
    01250
    01251
    01252 #endif /* _GSTREAMERMM_ELEMENT_H */
    01253