- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# 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/error.h>
    00033 #include <gstreamermm/event.h>
    00034 #include <gstreamermm/message.h>
    00035 #include <gstreamermm/query.h>
    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
    00250
    00251   static GType get_base_type() G_GNUC_CONST;
    00252 #endif
    00253
    00255   GstElement*       gobj()       { return reinterpret_cast<GstElement*>(gobject_); }
    00256
    00258   const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
    00259
    00261   GstElement* gobj_copy();
    00262
    00263 private:
    00264
    00265
    00266 protected:
    00267   //Needed for ElementInterfaced derived class
    00268   Element();
    00269
    00270 public:
    00284   Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest);
    00285
    00286
    00304   bool add_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00305
    00310   void create_all_pads();
    00311
    00312
    00321   Glib::RefPtr<Gst::Pad> create_compatible_pad(const Glib::RefPtr<const Gst::Pad>& pad, const Glib::RefPtr<const Gst::Caps>& caps);
    00322
    00329   Glib::RefPtr<Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& compattempl);
    00330
    00337   Glib::RefPtr<const Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& compattempl) const;
    00338
    00339   //TODO: The documentation says "The pad should be released with gst_element_release_request_pad().", which is odd. murrayc
    00340
    00347   Glib::RefPtr<Gst::Pad> get_request_pad(const Glib::ustring& name);
    00348
    00349
    00358   Glib::RefPtr<Gst::Pad> get_static_pad(const Glib::ustring& name);
    00359
    00368   Glib::RefPtr<const Gst::Pad> get_static_pad(const Glib::ustring& name) const;
    00369
    00370
    00381   void no_more_pads();
    00382
    00393   void release_request_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00394
    00417   bool remove_pad(const Glib::RefPtr<Gst::Pad>& pad);
    00418
    00425   Gst::Iterator<Gst::Pad> iterate_pads();
    00426
    00433   Gst::Iterator<const Gst::Pad> iterate_pads() const;
    00434
    00440   Gst::Iterator<Gst::Pad> iterate_sink_pads();
    00441
    00447   Gst::Iterator<const Gst::Pad> iterate_sink_pads() const;
    00448
    00454   Gst::Iterator<Gst::Pad> iterate_src_pads();
    00455
    00461   Gst::Iterator<const Gst::Pad> iterate_src_pads() const;
    00462
    00470   void unlink(const Glib::RefPtr<Gst::Element>& dest);
    00471
    00472
    00473   //This is not like link() because link() was written to return the
    00474   //destination element as a convenience for further linking to compensate for
    00475   //C API's convenience function gst_element_link_many().
    00476
    00487   bool link_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname);
    00488
    00489
    00495   void unlink_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname);
    00496
    00497   //This is not like link() because link() was written to return the
    00498   //destination element as a convenience for further linking to compensate for
    00499   //C API's convenience function gst_element_link_many().
    00500
    00511   bool link_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname, const Glib::RefPtr<Gst::Caps>& filter);
    00512
    00527   Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest, const Glib::RefPtr<Gst::Caps>& filter);
    00528
    00529
    00535   void set_base_time(ClockTime time);
    00536
    00542   ClockTime get_base_time() const;
    00543
    00560   void set_start_time(Gst::ClockTime time);
    00561
    00567   Gst::ClockTime get_start_time() const;
    00568
    00575   void set_bus(const Glib::RefPtr<Gst::Bus>& bus);
    00576
    00582   Glib::RefPtr<Gst::Bus> get_bus();
    00583
    00589   Glib::RefPtr<const Gst::Bus> get_bus() const;
    00590
    00597   void set_index(const Glib::RefPtr<Gst::Index>& index);
    00598
    00599   //Note: gst_element_get_index provides a reference.
    00600
    00607   Glib::RefPtr<Gst::Index> get_index();
    00608
    00615   Glib::RefPtr<const Gst::Index > get_index() const;
    00616
    00617
    00622   Glib::RefPtr<Gst::ElementFactory> get_factory();
    00623
    00628   Glib::RefPtr<const Gst::ElementFactory> get_factory() const;
    00629
    00630
    00636   bool is_indexable() const;
    00637
    00638   // We don't wrap the gst_element_get_name(), gst_element_set_name(),
    00639   // gst_element_get_parent(), and gst_element_set_parent() macros because they
    00640   // just calls the base (GstObject) class's functions anyway.
    00641
    00642
    00648   bool requires_clock() const;
    00649
    00660   bool set_clock(const Glib::RefPtr<Gst::Clock>& clock);
    00661
    00668   Glib::RefPtr<Gst::Clock> get_clock();
    00669
    00676   Glib::RefPtr<const Gst::Clock> get_clock() const;
    00677
    00687   bool provides_clock() const;
    00688
    00697   Glib::RefPtr<Gst::Clock> provide_clock();
    00698
    00707   Glib::RefPtr<const Gst::Clock> provide_clock() const;
    00708
    00726   StateChangeReturn set_state(State state);
    00727
    00751   StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
    00752
    00761   bool set_locked_state(gboolean locked_state);
    00762
    00772   bool is_locked_state() const;
    00773
    00782   void abort_state();
    00783
    00800   StateChangeReturn continue_state(StateChangeReturn ret);
    00801
    00810   void lost_state();
    00811
    00836   void lost_state(bool new_base_time);
    00837
    00844   bool sync_state_with_parent();
    00845
    00853   StateChangeReturn change_state(StateChange transition);
    00854
    00862   void found_tags(Gst::TagList& list);
    00863
    00872   void found_tags_for_pad(const Glib::RefPtr<Gst::Pad>& pad, Gst::TagList& list);
    00873
    00892   void post_message(int code, int line, MessageType type = Gst::MESSAGE_INFO,
    00893     const Glib::QueryQuark& domain = get_core_error_quark(),
    00894     const Glib::ustring& text = Glib::ustring(),
    00895     const Glib::ustring& debug = Glib::ustring(),
    00896     const Glib::ustring& file = Glib::ustring(),
    00897     const Glib::ustring& function = Glib::ustring());
    00898
    00899
    00909   bool post_message(const Glib::RefPtr<Gst::Message>& message);
    00910
    00911
    00920   Glib::ArrayHandle<QueryType> get_query_types() const;
    00921
    00922
    00933   bool query(const Glib::RefPtr<Gst::Query>& query) const;
    00934
    00942   bool query_convert(Format src_format, gint64 src_val, Format& dest_format, gint64& dest_val) const;
    00943
    00950   bool query_position(Format& format, gint64& cur) const;
    00951
    00958   bool query_position(Format& format) const;
    00959
    00960
    00967   bool query_duration(Format& format, gint64& duration) const;
    00968
    00975   bool query_duration(Format& format) const;
    00976
    00977
    01004   bool seek(Format format, SeekFlags seek_flags, gint64 seek_pos);
    01005
    01020   bool seek(double rate, Format format, SeekFlags flags, SeekType cur_type, gint64 cur, SeekType stop_type, gint64 stop);
    01021
    01031   bool send_event(const Glib::RefPtr<Gst::Event>& event);
    01032
    01033
    01039   bool implements_interface(GType iface_type) const;
    01040
    01047   Glib::SignalProxy0< void > signal_no_more_pads();
    01048
    01049
    01056   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_added();
    01057
    01058
    01065   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_removed();
    01066
    01067
    01070   #ifdef GLIBMM_VFUNCS_ENABLED
    01071   virtual Glib::RefPtr<Gst::Pad> request_new_pad_vfunc(const Glib::RefPtr<const Gst::PadTemplate>& templ, const Glib::ustring& name);
    01072 #endif //GLIBMM_VFUNCS_ENABLED
    01073
    01074
    01077   #ifdef GLIBMM_VFUNCS_ENABLED
    01078   virtual void release_pad_vfunc(const Glib::RefPtr<Gst::Pad>& pad);
    01079 #endif //GLIBMM_VFUNCS_ENABLED
    01080
    01081
    01084   #ifdef GLIBMM_VFUNCS_ENABLED
    01085   virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout) const;
    01086 #endif //GLIBMM_VFUNCS_ENABLED
    01087
    01088
    01091   #ifdef GLIBMM_VFUNCS_ENABLED
    01092   virtual StateChangeReturn set_state_vfunc(State state);
    01093 #endif //GLIBMM_VFUNCS_ENABLED
    01094
    01095
    01098   #ifdef GLIBMM_VFUNCS_ENABLED
    01099   virtual StateChangeReturn change_state_vfunc(StateChange transition);
    01100 #endif //GLIBMM_VFUNCS_ENABLED
    01101
    01102
    01105   #ifdef GLIBMM_VFUNCS_ENABLED
    01106   virtual void set_bus_vfunc(const Glib::RefPtr<Gst::Bus>& bus);
    01107 #endif //GLIBMM_VFUNCS_ENABLED
    01108
    01109
    01112   #ifdef GLIBMM_VFUNCS_ENABLED
    01113   virtual Glib::RefPtr<Gst::Clock> provide_clock_vfunc();
    01114 #endif //GLIBMM_VFUNCS_ENABLED
    01115
    01116
    01117 #ifdef GLIBMM_VFUNCS_ENABLED
    01118   // This vfunc is hand-coded because it is necessary for the callback to
    01119   // return true instead of false (as would happen with the default gmmproc
    01120   // callback) because GstElement does not set its set_clock() vfunc
    01121   // by default and yet gst_element_set_clock() returns true when GstElement's
    01122   // set_clock() vfunc is not set (it's a strange thing, but look at
    01123   // gst_element_class_init() and gst_element_set_clock() for insight).
    01126   virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
    01127
    01128   // This vfunc is handwritten because the default gmmproc code produces a
    01129   // compile error related to tyring to use Glib::ArrayHandle<>'s default
    01130   // constructor when returning a default value at the end of both the callback
    01131   // and the vfunc.
    01134    virtual Glib::ArrayHandle<QueryType> get_query_types_vfunc() const;
    01135 #endif //GLIBMM_VFUNCS_ENABLED
    01136
    01139   #ifdef GLIBMM_VFUNCS_ENABLED
    01140   virtual Glib::RefPtr<Gst::Index> get_index_vfunc() const;
    01141 #endif //GLIBMM_VFUNCS_ENABLED
    01142
    01143
    01146   #ifdef GLIBMM_VFUNCS_ENABLED
    01147   virtual void set_index_vfunc(const Glib::RefPtr<Gst::Index>& index);
    01148 #endif //GLIBMM_VFUNCS_ENABLED
    01149
    01150
    01153   #ifdef GLIBMM_VFUNCS_ENABLED
    01154   virtual bool send_event_vfunc(const Glib::RefPtr<Gst::Event>& event);
    01155 #endif //GLIBMM_VFUNCS_ENABLED
    01156
    01157
    01160   #ifdef GLIBMM_VFUNCS_ENABLED
    01161   virtual bool query_vfunc(const Glib::RefPtr<Gst::Query>& query) const;
    01162 #endif //GLIBMM_VFUNCS_ENABLED
    01163
    01164
    01165 protected:
    01166
    01167
    01168 private:
    01169   void handle_error(const Glib::ustring& message);
    01170
    01171
    01172 public:
    01173
    01174 public:
    01175   //C++ methods used to invoke GTK+ virtual functions:
    01176 #ifdef GLIBMM_VFUNCS_ENABLED
    01177 #endif //GLIBMM_VFUNCS_ENABLED
    01178
    01179 protected:
    01180   //GTK+ Virtual Functions (override these to change behaviour):
    01181 #ifdef GLIBMM_VFUNCS_ENABLED
    01182 #endif //GLIBMM_VFUNCS_ENABLED
    01183
    01184   //Default Signal Handlers::
    01185 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    01186   virtual void on_no_more_pads();
    01187   virtual void on_pad_added(const Glib::RefPtr<Gst::Pad>& new_pad);
    01188   virtual void on_pad_removed(const Glib::RefPtr<Gst::Pad>& old_pad);
    01189 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    01190
    01191
    01192 };
    01193
    01226 template <class T_Interface>
    01227 class ElementInterfaced
    01228 : public Element,
    01229   public T_Interface
    01230 {
    01231 public:
    01232   // Make calls involving underlying gobject unambiguous (specifically, gobj()
    01233   // is ambiguous when called from an ElementInterfaced<..> class
    01234   GstElement* gobj();
    01235   const GstElement* gobj() const;
    01236   GstElement* gobj_copy();
    01237
    01238   ~ElementInterfaced();
    01239
    01240 protected:
    01241   ElementInterfaced(const ElementInterfaced&);
    01242   ElementInterfaced& operator=(const ElementInterfaced&);
    01243
    01244 protected:
    01245   ElementInterfaced(GstElement* castitem);
    01246
    01247 private:
    01248   friend class Gst::Interface;
    01249 };
    01250
    01251 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    01252
    01253 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
    01254
    01255 template <class T_Interface>
    01256 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
    01257 {
    01258   gobject_ = (GObject*)castitem;
    01259   if(gobject_) {
    01260     gst_object_ref(Element::gobj());
    01261     g_object_weak_ref(gobject_,
    01262       &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
    01263   }
    01264 }
    01265
    01266 template <class T_Interface>
    01267 GstElement* ElementInterfaced<T_Interface>::gobj()
    01268 {
    01269   return Element::gobj();
    01270 }
    01271
    01272 template <class T_Interface>
    01273 const GstElement* ElementInterfaced<T_Interface>::gobj() const
    01274 {
    01275   return Element::gobj();
    01276 }
    01277
    01278 template <class T_Interface>
    01279 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
    01280 {
    01281   return Element::gobj_copy();
    01282 }
    01283
    01284 template <class T_Interface>
    01285 ElementInterfaced<T_Interface>::~ElementInterfaced()
    01286 {
    01287   // Set the gobject_ to null so that when this is deleted, the gobject doesn't
    01288   // go with it and other elements "wrapping" the gobject are not affected
    01289   gobject_ = 0;
    01290 }
    01291
    01292 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    01293
    01294 } // namespace Gst
    01295
    01296
    01297 namespace Glib
    01298 {
    01307   Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
    01308 }
    01309
    01310
    01311 #endif /* _GSTREAMERMM_ELEMENT_H */
    01312