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
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>
00038
00039
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041 typedef struct _GstElement GstElement;
00042 typedef struct _GstElementClass GstElementClass;
00043 #endif
00044
00045
00046 namespace Gst
00047 { class Element_Class; }
00048 namespace Gst
00049 {
00050
00067 class Bus;
00068 class Caps;
00069 class Clock;
00070 class ElementFactory;
00071 class Event;
00072 class Index;
00073 class Interface;
00074 class Message;
00075 class Pad;
00076 class PadTemplate;
00077 class Query;
00078 class TagList;
00079
00080
00081 template <class CppType>
00082 class Iterator;
00083
00089 enum ElementFlags
00090 {
00091 ELEMENT_LOCKED_STATE = GST_OBJECT_FLAG_LAST << 0,
00092 ELEMENT_IS_SINK = GST_OBJECT_FLAG_LAST << 1,
00093 ELEMENT_UNPARENTING = GST_OBJECT_FLAG_LAST << 2,
00094 ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST << 16
00095 };
00096
00097 }
00098
00099
00100 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00101 namespace Glib
00102 {
00103
00104 template <>
00105 class Value<Gst::ElementFlags> : public Glib::Value_Enum<Gst::ElementFlags>
00106 {
00107 public:
00108 static GType value_type() G_GNUC_CONST;
00109 };
00110
00111 }
00112 #endif
00113
00114
00115 namespace Gst
00116 {
00117
00118
00119
00120
00121 enum StateChange
00122 {
00123 STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
00124 STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
00125 STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
00126 STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
00127 STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
00128 STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL
00129 };
00130
00134 enum StateChangeReturn
00135 {
00136 STATE_CHANGE_FAILURE,
00137 STATE_CHANGE_SUCCESS,
00138 STATE_CHANGE_ASYNC,
00139 STATE_CHANGE_NO_PREROLL
00140 };
00141
00142 }
00143
00144
00145 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00146 namespace Glib
00147 {
00148
00149 template <>
00150 class Value<Gst::StateChangeReturn> : public Glib::Value_Enum<Gst::StateChangeReturn>
00151 {
00152 public:
00153 static GType value_type() G_GNUC_CONST;
00154 };
00155
00156 }
00157 #endif
00158
00159
00160 namespace Gst
00161 {
00162
00163
00164 namespace Enums
00165 {
00166
00172 Glib::ustring get_name(State state);
00173
00179 Glib::ustring get_name(StateChangeReturn state_ret);
00180
00181 }
00182
00224 class Element : public Gst::Object
00225 {
00226
00227 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00228
00229 public:
00230 typedef Element CppObjectType;
00231 typedef Element_Class CppClassType;
00232 typedef GstElement BaseObjectType;
00233 typedef GstElementClass BaseClassType;
00234
00235 private: friend class Element_Class;
00236 static CppClassType element_class_;
00237
00238 private:
00239
00240 Element(const Element&);
00241 Element& operator=(const Element&);
00242
00243 protected:
00244 explicit Element(const Glib::ConstructParams& construct_params);
00245 explicit Element(GstElement* castitem);
00246
00247 #endif
00248
00249 public:
00250 virtual ~Element();
00251
00252 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00253 static GType get_type() G_GNUC_CONST;
00254 static GType get_base_type() G_GNUC_CONST;
00255 #endif
00256
00258 GstElement* gobj() { return reinterpret_cast<GstElement*>(gobject_); }
00259
00261 const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
00262
00264 GstElement* gobj_copy();
00265
00266 private:
00267
00268
00269 protected:
00270
00271 Element();
00272
00273 public:
00285 Glib::RefPtr<Gst::Element> link(const Glib::RefPtr<Gst::Element>& dest);
00286
00287
00305 bool add_pad(const Glib::RefPtr<Gst::Pad>& pad);
00306
00311 void create_all_pads();
00312
00313
00314 Glib::RefPtr<Gst::Pad> create_compatible_pad(const Glib::RefPtr<Gst::Pad>& pad, const Glib::RefPtr<Gst::Caps>& caps);
00315
00316
00317
00318 Glib::RefPtr<Gst::PadTemplate> get_compatible_pad_template(const Glib::RefPtr<Gst::PadTemplate>& padtemplate);
00319
00320
00321
00322
00329 Glib::RefPtr<Gst::Pad> get_request_pad(const Glib::ustring& name);
00330
00339 Glib::RefPtr<Gst::Pad> get_static_pad(const Glib::ustring& name);
00340
00341
00352 void no_more_pads();
00353
00360 void release_request_pad(const Glib::RefPtr<Gst::Pad>& pad);
00361
00384 bool remove_pad(const Glib::RefPtr<Gst::Pad>& pad);
00385
00392 Gst::Iterator<Gst::Pad> iterate_pads();
00393
00399 Gst::Iterator<Gst::Pad> iterate_sink_pads();
00400
00406 Gst::Iterator<Gst::Pad> iterate_src_pads();
00407
00415 void unlink(const Glib::RefPtr<Gst::Element>& other_element);
00416
00417
00418
00419
00430 bool link_pads(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& others_padname);
00431
00432
00438 void unlink_pads(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& other_padname);
00439
00440
00441
00452 bool link_pads_filtered(const Glib::ustring& padname, const Glib::RefPtr<Gst::Element>& other_element, const Glib::ustring& others_padname, const Glib::RefPtr<Gst::Caps>& filter);
00453
00454
00455
00468 bool link_filtered(const Glib::RefPtr<Gst::Element>& other_element, const Glib::RefPtr<Gst::Caps>& filter);
00469
00470
00476 void set_base_time(ClockTime time);
00477
00483 ClockTime get_base_time() const;
00484
00491 void set_bus(const Glib::RefPtr<Gst::Bus>& bus);
00492
00498 Glib::RefPtr<Gst::Bus> get_bus();
00499
00505 Glib::RefPtr<const Gst::Bus> get_bus() const;
00506
00513 void set_index(const Glib::RefPtr<Gst::Index>& index);
00514
00515
00516
00523 Glib::RefPtr<Gst::Index> get_index();
00524
00531 Glib::RefPtr<const Gst::Index > get_index() const;
00532
00533
00538 Glib::RefPtr<Gst::ElementFactory> get_factory();
00539
00544 Glib::RefPtr<const Gst::ElementFactory> get_factory() const;
00545
00546
00552 bool is_indexable() const;
00553
00559 bool requires_clock() const;
00560
00571 bool set_clock(const Glib::RefPtr<Gst::Clock>& clock);
00572
00579 Glib::RefPtr<Gst::Clock> get_clock();
00580
00587 Glib::RefPtr<const Gst::Clock> get_clock() const;
00588
00598 bool provides_clock() const;
00599
00608 Glib::RefPtr<Gst::Clock> provide_clock();
00609
00618 Glib::RefPtr<const Gst::Clock> provide_clock() const;
00619
00634 StateChangeReturn set_state(State state);
00635
00659 StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
00660
00669 bool set_locked_state(gboolean locked_state);
00670
00680 bool is_locked_state() const;
00681
00690 void abort_state();
00691
00708 StateChangeReturn continue_state(StateChangeReturn prestate_value);
00709
00731 void lost_state();
00732
00739 bool sync_state_with_parent();
00740
00748 StateChangeReturn change_state(StateChange transition);
00749
00757 void found_tags(const Gst::TagList& list);
00758
00767 void found_tags_for_pad(const Glib::RefPtr<Gst::Pad>& pad, const Gst::TagList& list);
00768
00769
00770
00788 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);
00789
00799 bool post_message(const Glib::RefPtr<Gst::Message>& message);
00800
00801
00810 Glib::ArrayHandle<QueryType> get_query_types() const;
00811
00812
00823 bool query(const Glib::RefPtr<Gst::Query>& query);
00824
00832 bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const;
00833
00840 bool query_position(Format& format, gint64& position) const;
00841
00848 bool query_position(Format& format) const;
00849
00850
00857 bool query_duration(Format& format, gint64& duration) const;
00858
00865 bool query_duration(Format& format) const;
00866
00867
00894 bool seek(Format format, SeekFlags flags, gint64 position);
00895
00910 bool seek(double rate, Format format, SeekFlags flags, SeekType current_type, gint64 current_position, SeekType stop_type, gint64 stop_position);
00911
00921 bool send_event(const Glib::RefPtr<Gst::Event>& event);
00922
00923
00929 bool implements_interface(GType iface_type);
00930
00937 Glib::SignalProxy0< void > signal_no_more_pads();
00938
00939
00946 Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_added();
00947
00948
00955 Glib::SignalProxy1< void,const Glib::RefPtr<Gst::Pad>& > signal_pad_removed();
00956
00957
00960 #ifdef GLIBMM_VFUNCS_ENABLED
00961 virtual Glib::RefPtr<Gst::Pad> request_new_pad_vfunc(const Glib::RefPtr<Gst::PadTemplate>& templ, const Glib::ustring& name);
00962 #endif //GLIBMM_VFUNCS_ENABLED
00963
00964
00967 #ifdef GLIBMM_VFUNCS_ENABLED
00968 virtual void release_pad_vfunc(const Glib::RefPtr<Gst::Pad>& pad);
00969 #endif //GLIBMM_VFUNCS_ENABLED
00970
00971
00974 #ifdef GLIBMM_VFUNCS_ENABLED
00975 virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout);
00976 #endif //GLIBMM_VFUNCS_ENABLED
00977
00978
00981 #ifdef GLIBMM_VFUNCS_ENABLED
00982 virtual StateChangeReturn set_state_vfunc(State state);
00983 #endif //GLIBMM_VFUNCS_ENABLED
00984
00985
00988 #ifdef GLIBMM_VFUNCS_ENABLED
00989 virtual StateChangeReturn change_state_vfunc(StateChange transition);
00990 #endif //GLIBMM_VFUNCS_ENABLED
00991
00992
00995 #ifdef GLIBMM_VFUNCS_ENABLED
00996 virtual void set_bus_vfunc(const Glib::RefPtr<Gst::Bus>& bus);
00997 #endif //GLIBMM_VFUNCS_ENABLED
00998
00999
01002 #ifdef GLIBMM_VFUNCS_ENABLED
01003 virtual Glib::RefPtr<Gst::Clock> provide_clock_vfunc();
01004 #endif //GLIBMM_VFUNCS_ENABLED
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01029 #ifdef GLIBMM_VFUNCS_ENABLED
01030 virtual Glib::RefPtr<Gst::Index> get_index_vfunc();
01031 #endif //GLIBMM_VFUNCS_ENABLED
01032
01033
01036 #ifdef GLIBMM_VFUNCS_ENABLED
01037 virtual void set_index_vfunc(const Glib::RefPtr<Gst::Index>& index);
01038 #endif //GLIBMM_VFUNCS_ENABLED
01039
01040
01043 #ifdef GLIBMM_VFUNCS_ENABLED
01044 virtual bool send_event_vfunc(const Glib::RefPtr<Gst::Event>& event);
01045 #endif //GLIBMM_VFUNCS_ENABLED
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01060 #ifdef GLIBMM_VFUNCS_ENABLED
01061 virtual bool query_vfunc(const Glib::RefPtr<Gst::Query>& query);
01062 #endif //GLIBMM_VFUNCS_ENABLED
01063
01064
01065 public:
01066
01067 public:
01068
01069 #ifdef GLIBMM_VFUNCS_ENABLED
01070 #endif //GLIBMM_VFUNCS_ENABLED
01071
01072 protected:
01073
01074 #ifdef GLIBMM_VFUNCS_ENABLED
01075 #endif //GLIBMM_VFUNCS_ENABLED
01076
01077
01078 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01079 virtual void on_no_more_pads();
01080 virtual void on_pad_added(const Glib::RefPtr<Gst::Pad>& new_pad);
01081 virtual void on_pad_removed(const Glib::RefPtr<Gst::Pad>& old_pad);
01082 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01083
01084
01085 };
01086
01119 template <class T_Interface>
01120 class ElementInterfaced
01121 : public Element,
01122 public T_Interface
01123 {
01124 public:
01125
01126
01127 GstElement* gobj();
01128 const GstElement* gobj() const;
01129 GstElement* gobj_copy();
01130
01131 ~ElementInterfaced();
01132
01133 protected:
01134 ElementInterfaced(const ElementInterfaced&);
01135 ElementInterfaced& operator=(const ElementInterfaced&);
01136
01137 protected:
01138 ElementInterfaced(GstElement* castitem);
01139
01140 private:
01141 friend class Gst::Interface;
01142 };
01143
01144 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01145
01146 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
01147
01148 template <class T_Interface>
01149 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
01150 {
01151 gobject_ = (GObject*)castitem;
01152 if (gobject_) {
01153 gst_object_ref(Element::gobj());
01154 g_object_weak_ref(gobject_,
01155 &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
01156 }
01157 }
01158
01159 template <class T_Interface>
01160 GstElement* ElementInterfaced<T_Interface>::gobj()
01161 {
01162 return Element::gobj();
01163 }
01164
01165 template <class T_Interface>
01166 const GstElement* ElementInterfaced<T_Interface>::gobj() const
01167 {
01168 return Element::gobj();
01169 }
01170
01171 template <class T_Interface>
01172 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
01173 {
01174 return Element::gobj_copy();
01175 }
01176
01177 template <class T_Interface>
01178 ElementInterfaced<T_Interface>::~ElementInterfaced()
01179 {
01180
01181
01182 gobject_ = 0;
01183 }
01184
01185 #endif
01186
01187 }
01188
01189
01190 namespace Glib
01191 {
01200 Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01201 }
01202
01203
01204 #endif
01205