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
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
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
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
00474
00475
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
00498
00499
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
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
00639
00640
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
01119
01120
01121
01122
01123
01126 virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
01127
01128
01129
01130
01131
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
01176 #ifdef GLIBMM_VFUNCS_ENABLED
01177 #endif //GLIBMM_VFUNCS_ENABLED
01178
01179 protected:
01180
01181 #ifdef GLIBMM_VFUNCS_ENABLED
01182 #endif //GLIBMM_VFUNCS_ENABLED
01183
01184
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
01233
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
01288
01289 gobject_ = 0;
01290 }
01291
01292 #endif
01293
01294 }
01295
01296
01297 namespace Glib
01298 {
01307 Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01308 }
01309
01310
01311 #endif
01312