00001
00002
00003 #ifndef _GSTREAMERMM_ELEMENT_H
00004 #define _GSTREAMERMM_ELEMENT_H
00005
00006
00007 #include <glibmm.h>
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00042
00043
00044 namespace Gst
00045 { class Element_Class; }
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
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 }
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 }
00106 #endif
00107
00108
00109 namespace Gst
00110 {
00111
00112
00113
00114
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 }
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 }
00151 #endif
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 }
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
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
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
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
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
00468
00469
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
00492
00493
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
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
01070
01071
01072
01073
01074
01077 virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
01078
01079
01080
01081
01082
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
01127 #ifdef GLIBMM_VFUNCS_ENABLED
01128 #endif //GLIBMM_VFUNCS_ENABLED
01129
01130 protected:
01131
01132 #ifdef GLIBMM_VFUNCS_ENABLED
01133 #endif //GLIBMM_VFUNCS_ENABLED
01134
01135
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
01184
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
01239
01240 gobject_ = 0;
01241 }
01242
01243 #endif
01244
01245 }
01246
01247
01248 namespace Glib
01249 {
01258 Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01259 }
01260
01261
01262 #endif
01263