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 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00010 
00011 /* gstreamermm - a C++ wrapper for gstreamer
00012  *
00013  * Copyright 2008 The gstreamermm Development Team
00014  *
00015  * This library is free software; you can redistribute it and/or
00016  * modify it under the terms of the GNU Library General Public
00017  * License as published by the Free Software Foundation; either
00018  * version 2 of the License, or (at your option) any later version.
00019  *
00020  * This library is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023  * Library General Public License for more details.
00024  *
00025  * You should have received a copy of the GNU Library General Public
00026  * License along with this library; if not, write to the Free
00027  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00028  */
00029 
00030 #include <gst/gstelement.h>
00031 #include <gstreamermm/object.h>
00032 #include <gstreamermm/clock.h>
00033 #include <gstreamermm/enums.h>
00034 #include <gstreamermm/event.h>
00035 #include <gstreamermm/message.h>
00036 #include <gstreamermm/query.h>
00037 #include <stdexcept> //Because link() throws std::runtime_error
00038 
00039 
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041 typedef struct _GstElement GstElement;
00042 typedef struct _GstElementClass GstElementClass;
00043 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00044 
00045 
00046 namespace Gst
00047 { class Element_Class; } // namespace Gst
00048 namespace Gst
00049 {
00050 
00051 class Bus;
00052 class Caps;
00053 class Clock;
00054 class ElementFactory;
00055 class Event;
00056 class Index;
00057 class Interface;
00058 class Message;
00059 class Pad;
00060 class PadTemplate;
00061 class Query;
00062 class TagList;
00063 
00069 enum ElementFlags
00070 {
00071   ELEMENT_LOCKED_STATE = GST_OBJECT_FLAG_LAST << 0,
00072   ELEMENT_IS_SINK = GST_OBJECT_FLAG_LAST << 1,
00073   ELEMENT_UNPARENTING = GST_OBJECT_FLAG_LAST << 2,
00074   ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST << 16
00075 };
00076 
00077 } // namespace Gst
00078 
00079 
00080 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00081 namespace Glib
00082 {
00083 
00084 template <>
00085 class Value<Gst::ElementFlags> : public Glib::Value_Enum<Gst::ElementFlags>
00086 {
00087 public:
00088   static GType value_type() G_GNUC_CONST;
00089 };
00090 
00091 } // namespace Glib
00092 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00093 
00094 
00095 namespace Gst
00096 {
00097 
00098 
00099 //TODO: Fix gmmproc so that definition in gst_enums.defs does not cause errors
00100 //and this can be wrapped with _WRAP_ENUM.
00101 enum StateChange
00102 {
00103   STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
00104   STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
00105   STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
00106   STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
00107   STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
00108   STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL 
00109 };
00110 
00114 enum StateChangeReturn
00115 {
00116   STATE_CHANGE_FAILURE,
00117   STATE_CHANGE_SUCCESS,
00118   STATE_CHANGE_ASYNC,
00119   STATE_CHANGE_NO_PREROLL
00120 };
00121 
00122 } // namespace Gst
00123 
00124 
00125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00126 namespace Glib
00127 {
00128 
00129 template <>
00130 class Value<Gst::StateChangeReturn> : public Glib::Value_Enum<Gst::StateChangeReturn>
00131 {
00132 public:
00133   static GType value_type() G_GNUC_CONST;
00134 };
00135 
00136 } // namespace Glib
00137 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00138 
00139 
00140 namespace Gst
00141 {
00142 
00143 
00144 namespace Enums
00145 {
00146 
00152 Glib::ustring get_name(State s);
00153 
00159 Glib::ustring get_name(StateChangeReturn s);
00160 
00161 } //namespace Enums
00162 
00203 class Element : public Gst::Object
00204 {
00205   
00206 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00207 
00208 public:
00209   typedef Element CppObjectType;
00210   typedef Element_Class CppClassType;
00211   typedef GstElement BaseObjectType;
00212   typedef GstElementClass BaseClassType;
00213 
00214 private:  friend class Element_Class;
00215   static CppClassType element_class_;
00216 
00217 private:
00218   // noncopyable
00219   Element(const Element&);
00220   Element& operator=(const Element&);
00221 
00222 protected:
00223   explicit Element(const Glib::ConstructParams& construct_params);
00224   explicit Element(GstElement* castitem);
00225 
00226 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00227 
00228 public:
00229   virtual ~Element();
00230 
00231 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00232   static GType get_type()      G_GNUC_CONST;
00233   static GType get_base_type() G_GNUC_CONST;
00234 #endif
00235 
00237   GstElement*       gobj()       { return reinterpret_cast<GstElement*>(gobject_); }
00238 
00240   const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
00241 
00243   GstElement* gobj_copy();
00244 
00245 private:
00246 
00247 
00248 protected:
00249   //Needed for ElementInterfaced derived class
00250   Element();
00251 
00252 public:
00253 
00265   Glib::RefPtr<Element> link(const Glib::RefPtr<Element>& dest);
00266 
00267   
00285   bool add_pad(const Glib::RefPtr<Pad>& pad);
00286 
00287   //TODO: Remove this (and make sure it is really deprecated in the C API),
00288   //because the C API says it should not be used because it has unclear refcounting:
00289   //I asked for that in http://bugzilla.gnome.org/show_bug.cgi?id=533865
00290   
00302   Glib::RefPtr<Pad> get_pad(const Glib::ustring& name);
00303 
00304   
00309   void create_all_pads();
00310 
00311   //TODO: If these get* functions are creators, then maybe rename to create*()? murrayc
00312   //TODO: Can these be const?
00313   Glib::RefPtr<Pad> get_compatible_pad(const Glib::RefPtr<Pad>& pad, const Glib::RefPtr<Caps>& caps);
00314   Glib::RefPtr<PadTemplate> get_compatible_pad_template(const Glib::RefPtr<PadTemplate>& padtemplate);
00315 
00316   //TODO: The documentation says "The pad should be released with gst_element_release_request_pad().", which is odd. murrayc
00317   
00324   Glib::RefPtr<Pad> get_request_pad(const Glib::ustring& name);
00325   
00334   Glib::RefPtr<Pad> get_static_pad(const Glib::ustring& name);
00335 
00336   
00347   void no_more_pads();
00348   
00355   void release_request_pad(const Glib::RefPtr<Pad>& pad);
00356   
00379   bool remove_pad(const Glib::RefPtr<Pad>& pad);
00380  
00381   
00389   void unlink(const Glib::RefPtr<Element>& other_element);
00390 
00391   //TODO: Make this like link()?
00392   
00403   bool link_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname);
00404 
00405   
00411   void unlink_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& other_padname);
00412 
00413   //TODO: Make this like link()?
00414   
00425   bool link_pads_filtered(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname, const Glib::RefPtr<Caps>& filter);
00426 
00427   //TODO: Make this like link()?
00428 
00429   
00442   bool link_filtered(const Glib::RefPtr<Element>& other_element, const Glib::RefPtr<Caps>& filter);
00443   
00449   void set_base_time(ClockTime time);
00450   
00456   ClockTime get_base_time() const;
00457   
00464   void set_bus(const Glib::RefPtr<Bus>& bus);
00465   
00471   Glib::RefPtr<Bus> get_bus();
00472   
00478   Glib::RefPtr<const Bus> get_bus() const;
00479   
00486   void set_index(const Glib::RefPtr<Index>& index);
00487 
00488   //Note: gst_element_get_index provides a reference.
00489   
00496   Glib::RefPtr<Index> get_index();
00497   
00504   Glib::RefPtr<const Index > get_index() const;
00505 
00506 
00511   Glib::RefPtr<ElementFactory> get_factory();
00512   
00517   Glib::RefPtr<const ElementFactory> get_factory() const;
00518 
00519   
00525   bool is_indexable() const;
00526   
00532   bool requires_clock() const;
00533   
00544   bool set_clock(const Glib::RefPtr<Clock>& clock);
00545   
00552   Glib::RefPtr<Clock> get_clock();
00553   
00560   Glib::RefPtr<const Clock> get_clock() const;
00561   
00571   bool provides_clock() const;
00572   
00581   Glib::RefPtr<Clock> provide_clock();
00582   
00591   Glib::RefPtr<const Clock> provide_clock() const;
00592   
00607   StateChangeReturn set_state(State state);
00608   
00632   StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
00633   
00642   bool set_locked_state(gboolean locked_state);
00643   
00653   bool is_locked_state() const;
00654   
00663   void abort_state();
00664   
00681   StateChangeReturn continue_state(StateChangeReturn prestate_value);
00682   
00704   void lost_state();
00705   
00712   bool sync_state_with_parent();
00713   
00721   StateChangeReturn change_state(StateChange transition);
00722   
00730   void found_tags(const TagList& list); //TODO: Use return value instead?
00731   
00740   void found_tags_for_pad(const Glib::RefPtr<Pad>& pad, const TagList& list);
00741 
00742   //TODO: Change the parameter order?
00743   
00761   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);
00762   
00772   bool post_message(const Glib::RefPtr<Message>& message);
00773 
00774  
00783   Glib::ArrayHandle<QueryType> get_query_types() const;
00784 
00785   
00796   bool query(const Glib::RefPtr<Query>& query);
00797   
00805   bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const;
00806   
00813   bool query_position(Format& format, gint64& position) const;
00814 
00821   bool query_position(Format& format) const;
00822 
00823   
00830   bool query_duration(Format& format, gint64& duration) const;
00831 
00838   bool query_duration(Format& format) const;
00839 
00840   
00867   bool seek(Format format, SeekFlags flags, gint64 position);
00868   
00883   bool seek(double rate, Format format, SeekFlags flags, SeekType current_type, gint64 current_position, SeekType stop_type, gint64 stop_position);
00884 
00894   bool send_event(const Glib::RefPtr<Event>& event);
00895 
00896   
00902   bool implements_interface(GType iface_type);
00903 
00904   
00911   Glib::SignalProxy0< void > signal_no_more_pads();
00912 
00913 
00920   Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_added();
00921 
00922 
00929   Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_removed();
00930 
00931 
00934   #ifdef GLIBMM_VFUNCS_ENABLED
00935   virtual Glib::RefPtr<Pad> request_new_pad_vfunc(const Glib::RefPtr<PadTemplate>& templ, const Glib::ustring& name);
00936 #endif //GLIBMM_VFUNCS_ENABLED
00937 
00938 
00941   #ifdef GLIBMM_VFUNCS_ENABLED
00942   virtual void release_pad_vfunc(const Glib::RefPtr<Pad>& pad);
00943 #endif //GLIBMM_VFUNCS_ENABLED
00944 
00945 
00948   #ifdef GLIBMM_VFUNCS_ENABLED
00949   virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout);
00950 #endif //GLIBMM_VFUNCS_ENABLED
00951 
00952 
00955   #ifdef GLIBMM_VFUNCS_ENABLED
00956   virtual StateChangeReturn set_state_vfunc(State state);
00957 #endif //GLIBMM_VFUNCS_ENABLED
00958 
00959 
00962   #ifdef GLIBMM_VFUNCS_ENABLED
00963   virtual StateChangeReturn change_state_vfunc(StateChange transition);
00964 #endif //GLIBMM_VFUNCS_ENABLED
00965 
00966 
00969   #ifdef GLIBMM_VFUNCS_ENABLED
00970   virtual void set_bus_vfunc(const Glib::RefPtr<Bus>& bus);
00971 #endif //GLIBMM_VFUNCS_ENABLED
00972 
00973 
00976   #ifdef GLIBMM_VFUNCS_ENABLED
00977   virtual Glib::RefPtr<Clock> provide_clock_vfunc();
00978 #endif //GLIBMM_VFUNCS_ENABLED
00979 
00980 
00983   #ifdef GLIBMM_VFUNCS_ENABLED
00984   virtual bool set_clock_vfunc(const Glib::RefPtr<Clock>& clock);
00985 #endif //GLIBMM_VFUNCS_ENABLED
00986 
00987 
00990   #ifdef GLIBMM_VFUNCS_ENABLED
00991   virtual Glib::RefPtr<Index> get_index_vfunc();
00992 #endif //GLIBMM_VFUNCS_ENABLED
00993 
00994 
00997   #ifdef GLIBMM_VFUNCS_ENABLED
00998   virtual void set_index_vfunc(const Glib::RefPtr<Index>& index);
00999 #endif //GLIBMM_VFUNCS_ENABLED
01000 
01001 
01004   #ifdef GLIBMM_VFUNCS_ENABLED
01005   virtual bool send_event_vfunc(const Glib::RefPtr<Event>& event);
01006 #endif //GLIBMM_VFUNCS_ENABLED
01007 
01008 
01009   //TODO: This vfunc can't be wrapped without getting a compile error in the
01010   //generated code.  The compile error comes about because the code assumes
01011   //that Glib::ArrayHandle<> has a default constructor but it does not.  The
01012   //way the code is generated will have to be tweaked.
01013   //
01014 //#m4 __CONVERSION(`Glib::ArrayHandle<QueryType>',`const GstQueryType*',`(GstQueryType*)(($3).data())')
01015   // /** get the supported GstQueryType of this element
01016   // */
01017   // _WRAP_VFUNC(Glib::ArrayHandle<QueryType> get_query_types(), "get_query_types")
01018 
01021   #ifdef GLIBMM_VFUNCS_ENABLED
01022   virtual bool query_vfunc(const Glib::RefPtr<Query>& query);
01023 #endif //GLIBMM_VFUNCS_ENABLED
01024 
01025 
01026 public:
01027 
01028 public:
01029   //C++ methods used to invoke GTK+ virtual functions:
01030 #ifdef GLIBMM_VFUNCS_ENABLED
01031 #endif //GLIBMM_VFUNCS_ENABLED
01032 
01033 protected:
01034   //GTK+ Virtual Functions (override these to change behaviour):
01035 #ifdef GLIBMM_VFUNCS_ENABLED
01036 #endif //GLIBMM_VFUNCS_ENABLED
01037 
01038   //Default Signal Handlers::
01039 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01040   virtual void on_no_more_pads();
01041   virtual void on_pad_added(const Glib::RefPtr<Pad>& new_pad);
01042   virtual void on_pad_removed(const Glib::RefPtr<Pad>& old_pad);
01043 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01044 
01045 
01046 };
01047 
01079 template <class T_Interface>
01080 class ElementInterfaced
01081 : public Element,
01082   public T_Interface
01083 {
01084 public:
01085   // Make calls involving underlying gobject unambiguous (specifically, gobj()
01086   // is ambiguous when called from an ElementInterfaced<..> class
01087   GstElement* gobj();
01088   const GstElement* gobj() const;
01089   GstElement* gobj_copy();
01090 
01091   ~ElementInterfaced();
01092 
01093 protected:
01094   ElementInterfaced(const ElementInterfaced&);
01095   ElementInterfaced& operator=(const ElementInterfaced&);
01096 
01097 protected:
01098   ElementInterfaced(GstElement* castitem);
01099 
01100 private:
01101   friend class Gst::Interface;
01102 };
01103 
01104 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01105 
01106 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
01107 
01108 template <class T_Interface>
01109 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
01110 {
01111   gobject_ = (GObject*)castitem;
01112   if (gobject_) {
01113     gst_object_ref(Element::gobj());
01114     g_object_weak_ref(gobject_,
01115       &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
01116   }
01117 }
01118 
01119 template <class T_Interface>
01120 GstElement* ElementInterfaced<T_Interface>::gobj()
01121 {
01122   return Element::gobj();
01123 }
01124 
01125 template <class T_Interface>
01126 const GstElement* ElementInterfaced<T_Interface>::gobj() const
01127 {
01128   return Element::gobj();
01129 }
01130 
01131 template <class T_Interface>
01132 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
01133 {
01134   return Element::gobj_copy();
01135 }
01136 
01137 template <class T_Interface>
01138 ElementInterfaced<T_Interface>::~ElementInterfaced()
01139 {
01140   // Set the gobject_ to NULL so that when this is deleted, the gobject doesn't
01141   // go with it and other elements "wrapping" the gobject are not affected
01142   gobject_ = 0;
01143 }
01144 
01145 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01146 
01147 } // namespace Gst
01148 
01149 
01150 namespace Glib
01151 {
01160   Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01161 }
01162 
01163 
01164 #endif /* _GSTREAMERMM_ELEMENT_H */
01165 

Generated on Sun Jul 27 17:07:20 2008 for gstreamermm by  doxygen 1.5.4