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   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:
00282   Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest);
00283   
00284 
00302   bool add_pad(const Glib::RefPtr<Gst::Pad>& pad);
00303   
00308   void create_all_pads();
00309 
00310   
00319   Glib::RefPtr<Gst::Pad> create_compatible_pad(const Glib::RefPtr<const Gst::Pad>& pad, const Glib::RefPtr<const Gst::Caps>& caps);
00320   
00327   Glib::RefPtr<Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& compattempl);
00328   
00335   Glib::RefPtr<const Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<const Gst::PadTemplate>& compattempl) const;
00336 
00337   //TODO: The documentation says "The pad should be released with gst_element_release_request_pad().", which is odd. murrayc
00338   
00345   Glib::RefPtr<Gst::Pad> get_request_pad(const Glib::ustring& name);
00346 
00347   
00356   Glib::RefPtr<Gst::Pad> get_static_pad(const Glib::ustring& name);
00357   
00366   Glib::RefPtr<const Gst::Pad> get_static_pad(const Glib::ustring& name) const;
00367   
00368 
00379   void no_more_pads();
00380   
00387   void release_request_pad(const Glib::RefPtr<Gst::Pad>& pad);
00388   
00411   bool remove_pad(const Glib::RefPtr<Gst::Pad>& pad);
00412   
00419   Gst::Iterator<Gst::Pad> iterate_pads();
00420   
00427   Gst::Iterator<const Gst::Pad> iterate_pads() const;
00428   
00434   Gst::Iterator<Gst::Pad> iterate_sink_pads();
00435   
00441   Gst::Iterator<const Gst::Pad> iterate_sink_pads() const;
00442   
00448   Gst::Iterator<Gst::Pad> iterate_src_pads();
00449   
00455   Gst::Iterator<const Gst::Pad> iterate_src_pads() const;
00456   
00464   void unlink(const Glib::RefPtr<Gst::Element>& dest);
00465   
00466 
00467   //This is not like link() because link() was written to return the
00468   //destination element as a convenience for further linking to compensate for
00469   //C API's convenience function gst_element_link_many().
00470   
00481   bool link_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname);
00482 
00483   
00489   void unlink_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname);
00490 
00491   //This is not like link() because link() was written to return the
00492   //destination element as a convenience for further linking to compensate for
00493   //C API's convenience function gst_element_link_many().
00494   
00505   bool link_pads(const Glib::ustring& srcpadname, const Glib::RefPtr<Gst::Element>& dest, const Glib::ustring& destpadname, const Glib::RefPtr<Gst::Caps>& filter);
00506 
00521   Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest, const Glib::RefPtr<Gst::Caps>& filter);
00522   
00523 
00529   void set_base_time(ClockTime time);
00530   
00536   ClockTime get_base_time() const;
00537   
00544   void set_bus(const Glib::RefPtr<Gst::Bus>& bus);
00545   
00551   Glib::RefPtr<Gst::Bus> get_bus();
00552   
00558   Glib::RefPtr<const Gst::Bus> get_bus() const;
00559   
00566   void set_index(const Glib::RefPtr<Gst::Index>& index);
00567 
00568   //Note: gst_element_get_index provides a reference.
00569   
00576   Glib::RefPtr<Gst::Index> get_index();
00577   
00584   Glib::RefPtr<const Gst::Index > get_index() const;
00585 
00586   
00591   Glib::RefPtr<Gst::ElementFactory> get_factory();
00592   
00597   Glib::RefPtr<const Gst::ElementFactory> get_factory() const;
00598 
00599   
00605   bool is_indexable() const;
00606   
00612   bool requires_clock() const;
00613   
00624   bool set_clock(const Glib::RefPtr<Gst::Clock>& clock);
00625   
00632   Glib::RefPtr<Gst::Clock> get_clock();
00633   
00640   Glib::RefPtr<const Gst::Clock> get_clock() const;
00641   
00651   bool provides_clock() const;
00652   
00661   Glib::RefPtr<Gst::Clock> provide_clock();
00662   
00671   Glib::RefPtr<const Gst::Clock> provide_clock() const;
00672   
00690   StateChangeReturn set_state(State state);
00691   
00715   StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
00716   
00725   bool set_locked_state(gboolean locked_state);
00726   
00736   bool is_locked_state() const;
00737   
00746   void abort_state();
00747   
00764   StateChangeReturn continue_state(StateChangeReturn ret);
00765   
00787   void lost_state();
00788   
00795   bool sync_state_with_parent();
00796   
00804   StateChangeReturn change_state(StateChange transition);
00805   
00813   void found_tags(Gst::TagList& list);
00814   
00823   void found_tags_for_pad(const Glib::RefPtr<Gst::Pad>& pad, Gst::TagList& list);
00824 
00843   void post_message(int code, int line, MessageType type = Gst::MESSAGE_INFO,
00844     const Glib::QueryQuark& domain = get_core_error_quark(),
00845     const Glib::ustring& text = Glib::ustring(),
00846     const Glib::ustring& debug = Glib::ustring(),
00847     const Glib::ustring& file = Glib::ustring(),
00848     const Glib::ustring& function = Glib::ustring());
00849   
00850 
00860   bool post_message(const Glib::RefPtr<Gst::Message>& message);
00861 
00862  
00871   Glib::ArrayHandle<QueryType> get_query_types() const;
00872 
00873   
00884   bool query(const Glib::RefPtr<Gst::Query>& query) const;
00885   
00893   bool query_convert(Format src_format, gint64 src_val, Format& dest_format, gint64& dest_val) const;
00894   
00901   bool query_position(Format& format, gint64& cur) const;
00902 
00909   bool query_position(Format& format) const;
00910 
00911   
00918   bool query_duration(Format& format, gint64& duration) const;
00919 
00926   bool query_duration(Format& format) const;
00927 
00928   
00955   bool seek(Format format, SeekFlags seek_flags, gint64 seek_pos);
00956   
00971   bool seek(double rate, Format format, SeekFlags flags, SeekType cur_type, gint64 cur, SeekType stop_type, gint64 stop);
00972 
00982   bool send_event(const Glib::RefPtr<Gst::Event>& event);
00983   
00984 
00990   bool implements_interface(GType iface_type) const;
00991 
00998   Glib::SignalProxy0< void > signal_no_more_pads();
00999 
01000 
01007   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_added();
01008 
01009 
01016   Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_removed();
01017 
01018 
01021   #ifdef GLIBMM_VFUNCS_ENABLED
01022   virtual Glib::RefPtr<Gst::Pad> request_new_pad_vfunc(const Glib::RefPtr<const Gst::PadTemplate>& templ, const Glib::ustring& name);
01023 #endif //GLIBMM_VFUNCS_ENABLED
01024 
01025 
01028   #ifdef GLIBMM_VFUNCS_ENABLED
01029   virtual void release_pad_vfunc(const Glib::RefPtr<Gst::Pad>& pad);
01030 #endif //GLIBMM_VFUNCS_ENABLED
01031 
01032 
01035   #ifdef GLIBMM_VFUNCS_ENABLED
01036   virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout) const;
01037 #endif //GLIBMM_VFUNCS_ENABLED
01038 
01039 
01042   #ifdef GLIBMM_VFUNCS_ENABLED
01043   virtual StateChangeReturn set_state_vfunc(State state);
01044 #endif //GLIBMM_VFUNCS_ENABLED
01045 
01046 
01049   #ifdef GLIBMM_VFUNCS_ENABLED
01050   virtual StateChangeReturn change_state_vfunc(StateChange transition);
01051 #endif //GLIBMM_VFUNCS_ENABLED
01052 
01053 
01056   #ifdef GLIBMM_VFUNCS_ENABLED
01057   virtual void set_bus_vfunc(const Glib::RefPtr<Gst::Bus>& bus);
01058 #endif //GLIBMM_VFUNCS_ENABLED
01059 
01060 
01063   #ifdef GLIBMM_VFUNCS_ENABLED
01064   virtual Glib::RefPtr<Gst::Clock> provide_clock_vfunc();
01065 #endif //GLIBMM_VFUNCS_ENABLED
01066 
01067 
01068 #ifdef GLIBMM_VFUNCS_ENABLED
01069   // This vfunc is hand-coded because it is necessary for the callback to
01070   // return true instead of false (as would happen with the default gmmproc
01071   // callback) because GstElement does not set its set_clock() vfunc
01072   // by default and yet gst_element_set_clock() returns true when GstElement's
01073   // set_clock() vfunc is not set (it's a strange thing, but look at
01074   // gst_element_class_init() and gst_element_set_clock() for insight).
01077   virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
01078 
01079   // This vfunc is handwritten because the default gmmproc code produces a
01080   // compile error related to tyring to use Glib::ArrayHandle<>'s default
01081   // constructor when returning a default value at the end of both the callback
01082   // and the vfunc.
01085    virtual Glib::ArrayHandle<QueryType> get_query_types_vfunc() const;
01086 #endif //GLIBMM_VFUNCS_ENABLED
01087 
01090   #ifdef GLIBMM_VFUNCS_ENABLED
01091   virtual Glib::RefPtr<Gst::Index> get_index_vfunc() const;
01092 #endif //GLIBMM_VFUNCS_ENABLED
01093 
01094 
01097   #ifdef GLIBMM_VFUNCS_ENABLED
01098   virtual void set_index_vfunc(const Glib::RefPtr<Gst::Index>& index);
01099 #endif //GLIBMM_VFUNCS_ENABLED
01100 
01101 
01104   #ifdef GLIBMM_VFUNCS_ENABLED
01105   virtual bool send_event_vfunc(const Glib::RefPtr<Gst::Event>& event);
01106 #endif //GLIBMM_VFUNCS_ENABLED
01107 
01108 
01111   #ifdef GLIBMM_VFUNCS_ENABLED
01112   virtual bool query_vfunc(const Glib::RefPtr<Gst::Query>& query) const;
01113 #endif //GLIBMM_VFUNCS_ENABLED
01114 
01115 
01116 protected:
01117 
01118   
01119 private:
01120   void handle_error(const Glib::ustring& message);
01121   
01122 
01123 public:
01124 
01125 public:
01126   //C++ methods used to invoke GTK+ virtual functions:
01127 #ifdef GLIBMM_VFUNCS_ENABLED
01128 #endif //GLIBMM_VFUNCS_ENABLED
01129 
01130 protected:
01131   //GTK+ Virtual Functions (override these to change behaviour):
01132 #ifdef GLIBMM_VFUNCS_ENABLED
01133 #endif //GLIBMM_VFUNCS_ENABLED
01134 
01135   //Default Signal Handlers::
01136 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01137   virtual void on_no_more_pads();
01138   virtual void on_pad_added(const Glib::RefPtr<Gst::Pad>& new_pad);
01139   virtual void on_pad_removed(const Glib::RefPtr<Gst::Pad>& old_pad);
01140 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01141 
01142 
01143 };
01144 
01177 template <class T_Interface>
01178 class ElementInterfaced
01179 : public Element,
01180   public T_Interface
01181 {
01182 public:
01183   // Make calls involving underlying gobject unambiguous (specifically, gobj()
01184   // is ambiguous when called from an ElementInterfaced<..> class
01185   GstElement* gobj();
01186   const GstElement* gobj() const;
01187   GstElement* gobj_copy();
01188 
01189   ~ElementInterfaced();
01190 
01191 protected:
01192   ElementInterfaced(const ElementInterfaced&);
01193   ElementInterfaced& operator=(const ElementInterfaced&);
01194 
01195 protected:
01196   ElementInterfaced(GstElement* castitem);
01197 
01198 private:
01199   friend class Gst::Interface;
01200 };
01201 
01202 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01203 
01204 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
01205 
01206 template <class T_Interface>
01207 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
01208 {
01209   gobject_ = (GObject*)castitem;
01210   if(gobject_) {
01211     gst_object_ref(Element::gobj());
01212     g_object_weak_ref(gobject_,
01213       &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
01214   }
01215 }
01216 
01217 template <class T_Interface>
01218 GstElement* ElementInterfaced<T_Interface>::gobj()
01219 {
01220   return Element::gobj();
01221 }
01222 
01223 template <class T_Interface>
01224 const GstElement* ElementInterfaced<T_Interface>::gobj() const
01225 {
01226   return Element::gobj();
01227 }
01228 
01229 template <class T_Interface>
01230 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
01231 {
01232   return Element::gobj_copy();
01233 }
01234 
01235 template <class T_Interface>
01236 ElementInterfaced<T_Interface>::~ElementInterfaced()
01237 {
01238   // Set the gobject_ to null so that when this is deleted, the gobject doesn't
01239   // go with it and other elements "wrapping" the gobject are not affected
01240   gobject_ = 0;
01241 }
01242 
01243 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01244 
01245 } // namespace Gst
01246 
01247 
01248 namespace Glib
01249 {
01258   Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01259 }
01260 
01261 
01262 #endif /* _GSTREAMERMM_ELEMENT_H */
01263 

Generated on Wed Aug 19 15:53:18 2009 for gstreamermm by  doxygen 1.5.4