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
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
00064
00065 template <class CppType>
00066 class Iterator;
00067
00073 enum ElementFlags
00074 {
00075 ELEMENT_LOCKED_STATE = GST_OBJECT_FLAG_LAST << 0,
00076 ELEMENT_IS_SINK = GST_OBJECT_FLAG_LAST << 1,
00077 ELEMENT_UNPARENTING = GST_OBJECT_FLAG_LAST << 2,
00078 ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST << 16
00079 };
00080
00081 }
00082
00083
00084 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00085 namespace Glib
00086 {
00087
00088 template <>
00089 class Value<Gst::ElementFlags> : public Glib::Value_Enum<Gst::ElementFlags>
00090 {
00091 public:
00092 static GType value_type() G_GNUC_CONST;
00093 };
00094
00095 }
00096 #endif
00097
00098
00099 namespace Gst
00100 {
00101
00102
00103
00104
00105 enum StateChange
00106 {
00107 STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
00108 STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
00109 STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
00110 STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
00111 STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
00112 STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL
00113 };
00114
00118 enum StateChangeReturn
00119 {
00120 STATE_CHANGE_FAILURE,
00121 STATE_CHANGE_SUCCESS,
00122 STATE_CHANGE_ASYNC,
00123 STATE_CHANGE_NO_PREROLL
00124 };
00125
00126 }
00127
00128
00129 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00130 namespace Glib
00131 {
00132
00133 template <>
00134 class Value<Gst::StateChangeReturn> : public Glib::Value_Enum<Gst::StateChangeReturn>
00135 {
00136 public:
00137 static GType value_type() G_GNUC_CONST;
00138 };
00139
00140 }
00141 #endif
00142
00143
00144 namespace Gst
00145 {
00146
00147
00148 namespace Enums
00149 {
00150
00156 Glib::ustring get_name(State s);
00157
00163 Glib::ustring get_name(StateChangeReturn s);
00164
00165 }
00166
00208 class Element : public Gst::Object
00209 {
00210
00211 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00212
00213 public:
00214 typedef Element CppObjectType;
00215 typedef Element_Class CppClassType;
00216 typedef GstElement BaseObjectType;
00217 typedef GstElementClass BaseClassType;
00218
00219 private: friend class Element_Class;
00220 static CppClassType element_class_;
00221
00222 private:
00223
00224 Element(const Element&);
00225 Element& operator=(const Element&);
00226
00227 protected:
00228 explicit Element(const Glib::ConstructParams& construct_params);
00229 explicit Element(GstElement* castitem);
00230
00231 #endif
00232
00233 public:
00234 virtual ~Element();
00235
00236 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00237 static GType get_type() G_GNUC_CONST;
00238 static GType get_base_type() G_GNUC_CONST;
00239 #endif
00240
00242 GstElement* gobj() { return reinterpret_cast<GstElement*>(gobject_); }
00243
00245 const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
00246
00248 GstElement* gobj_copy();
00249
00250 private:
00251
00252
00253 protected:
00254
00255 Element();
00256
00257 public:
00269 Glib::RefPtr<Element> link(const Glib::RefPtr<Element>& dest);
00270
00271
00289 bool add_pad(const Glib::RefPtr<Pad>& pad);
00290
00295 void create_all_pads();
00296
00297
00298 Glib::RefPtr<Pad> create_compatible_pad(const Glib::RefPtr<Pad>& pad, const Glib::RefPtr<Caps>& caps);
00299
00300
00301
00302 Glib::RefPtr<PadTemplate> get_compatible_pad_template(const Glib::RefPtr<PadTemplate>& padtemplate);
00303
00304
00305
00306
00313 Glib::RefPtr<Pad> get_request_pad(const Glib::ustring& name);
00314
00323 Glib::RefPtr<Pad> get_static_pad(const Glib::ustring& name);
00324
00325
00336 void no_more_pads();
00337
00344 void release_request_pad(const Glib::RefPtr<Pad>& pad);
00345
00368 bool remove_pad(const Glib::RefPtr<Pad>& pad);
00369
00376 Iterator<Pad> iterate_pads();
00377
00383 Iterator<Pad> iterate_sink_pads();
00384
00390 Iterator<Pad> iterate_src_pads();
00391
00399 void unlink(const Glib::RefPtr<Element>& other_element);
00400
00401
00402
00403
00414 bool link_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname);
00415
00416
00422 void unlink_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& other_padname);
00423
00424
00425
00436 bool link_pads_filtered(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname, const Glib::RefPtr<Caps>& filter);
00437
00438
00439
00452 bool link_filtered(const Glib::RefPtr<Element>& other_element, const Glib::RefPtr<Caps>& filter);
00453
00454
00460 void set_base_time(ClockTime time);
00461
00467 ClockTime get_base_time() const;
00468
00475 void set_bus(const Glib::RefPtr<Bus>& bus);
00476
00482 Glib::RefPtr<Bus> get_bus();
00483
00489 Glib::RefPtr<const Bus> get_bus() const;
00490
00497 void set_index(const Glib::RefPtr<Index>& index);
00498
00499
00500
00507 Glib::RefPtr<Index> get_index();
00508
00515 Glib::RefPtr<const Index > get_index() const;
00516
00517
00522 Glib::RefPtr<ElementFactory> get_factory();
00523
00528 Glib::RefPtr<const ElementFactory> get_factory() const;
00529
00530
00536 bool is_indexable() const;
00537
00543 bool requires_clock() const;
00544
00555 bool set_clock(const Glib::RefPtr<Clock>& clock);
00556
00563 Glib::RefPtr<Clock> get_clock();
00564
00571 Glib::RefPtr<const Clock> get_clock() const;
00572
00582 bool provides_clock() const;
00583
00592 Glib::RefPtr<Clock> provide_clock();
00593
00602 Glib::RefPtr<const Clock> provide_clock() const;
00603
00618 StateChangeReturn set_state(State state);
00619
00643 StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
00644
00653 bool set_locked_state(gboolean locked_state);
00654
00664 bool is_locked_state() const;
00665
00674 void abort_state();
00675
00692 StateChangeReturn continue_state(StateChangeReturn prestate_value);
00693
00715 void lost_state();
00716
00723 bool sync_state_with_parent();
00724
00732 StateChangeReturn change_state(StateChange transition);
00733
00741 void found_tags(const TagList& list);
00742
00751 void found_tags_for_pad(const Glib::RefPtr<Pad>& pad, const TagList& list);
00752
00753
00754
00772 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);
00773
00783 bool post_message(const Glib::RefPtr<Message>& message);
00784
00785
00794 Glib::ArrayHandle<QueryType> get_query_types() const;
00795
00796
00807 bool query(const Glib::RefPtr<Query>& query);
00808
00816 bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const;
00817
00824 bool query_position(Format& format, gint64& position) const;
00825
00832 bool query_position(Format& format) const;
00833
00834
00841 bool query_duration(Format& format, gint64& duration) const;
00842
00849 bool query_duration(Format& format) const;
00850
00851
00878 bool seek(Format format, SeekFlags flags, gint64 position);
00879
00894 bool seek(double rate, Format format, SeekFlags flags, SeekType current_type, gint64 current_position, SeekType stop_type, gint64 stop_position);
00895
00905 bool send_event(const Glib::RefPtr<Event>& event);
00906
00907
00913 bool implements_interface(GType iface_type);
00914
00921 Glib::SignalProxy0< void > signal_no_more_pads();
00922
00923
00930 Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_added();
00931
00932
00939 Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_removed();
00940
00941
00944 #ifdef GLIBMM_VFUNCS_ENABLED
00945 virtual Glib::RefPtr<Pad> request_new_pad_vfunc(const Glib::RefPtr<PadTemplate>& templ, const Glib::ustring& name);
00946 #endif //GLIBMM_VFUNCS_ENABLED
00947
00948
00951 #ifdef GLIBMM_VFUNCS_ENABLED
00952 virtual void release_pad_vfunc(const Glib::RefPtr<Pad>& pad);
00953 #endif //GLIBMM_VFUNCS_ENABLED
00954
00955
00958 #ifdef GLIBMM_VFUNCS_ENABLED
00959 virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout);
00960 #endif //GLIBMM_VFUNCS_ENABLED
00961
00962
00965 #ifdef GLIBMM_VFUNCS_ENABLED
00966 virtual StateChangeReturn set_state_vfunc(State state);
00967 #endif //GLIBMM_VFUNCS_ENABLED
00968
00969
00972 #ifdef GLIBMM_VFUNCS_ENABLED
00973 virtual StateChangeReturn change_state_vfunc(StateChange transition);
00974 #endif //GLIBMM_VFUNCS_ENABLED
00975
00976
00979 #ifdef GLIBMM_VFUNCS_ENABLED
00980 virtual void set_bus_vfunc(const Glib::RefPtr<Bus>& bus);
00981 #endif //GLIBMM_VFUNCS_ENABLED
00982
00983
00986 #ifdef GLIBMM_VFUNCS_ENABLED
00987 virtual Glib::RefPtr<Clock> provide_clock_vfunc();
00988 #endif //GLIBMM_VFUNCS_ENABLED
00989
00990
00993 #ifdef GLIBMM_VFUNCS_ENABLED
00994 virtual bool set_clock_vfunc(const Glib::RefPtr<Clock>& clock);
00995 #endif //GLIBMM_VFUNCS_ENABLED
00996
00997
01000 #ifdef GLIBMM_VFUNCS_ENABLED
01001 virtual Glib::RefPtr<Index> get_index_vfunc();
01002 #endif //GLIBMM_VFUNCS_ENABLED
01003
01004
01007 #ifdef GLIBMM_VFUNCS_ENABLED
01008 virtual void set_index_vfunc(const Glib::RefPtr<Index>& index);
01009 #endif //GLIBMM_VFUNCS_ENABLED
01010
01011
01014 #ifdef GLIBMM_VFUNCS_ENABLED
01015 virtual bool send_event_vfunc(const Glib::RefPtr<Event>& event);
01016 #endif //GLIBMM_VFUNCS_ENABLED
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01031 #ifdef GLIBMM_VFUNCS_ENABLED
01032 virtual bool query_vfunc(const Glib::RefPtr<Query>& query);
01033 #endif //GLIBMM_VFUNCS_ENABLED
01034
01035
01036 public:
01037
01038 public:
01039
01040 #ifdef GLIBMM_VFUNCS_ENABLED
01041 #endif //GLIBMM_VFUNCS_ENABLED
01042
01043 protected:
01044
01045 #ifdef GLIBMM_VFUNCS_ENABLED
01046 #endif //GLIBMM_VFUNCS_ENABLED
01047
01048
01049 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01050 virtual void on_no_more_pads();
01051 virtual void on_pad_added(const Glib::RefPtr<Pad>& new_pad);
01052 virtual void on_pad_removed(const Glib::RefPtr<Pad>& old_pad);
01053 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01054
01055
01056 };
01057
01090 template <class T_Interface>
01091 class ElementInterfaced
01092 : public Element,
01093 public T_Interface
01094 {
01095 public:
01096
01097
01098 GstElement* gobj();
01099 const GstElement* gobj() const;
01100 GstElement* gobj_copy();
01101
01102 ~ElementInterfaced();
01103
01104 protected:
01105 ElementInterfaced(const ElementInterfaced&);
01106 ElementInterfaced& operator=(const ElementInterfaced&);
01107
01108 protected:
01109 ElementInterfaced(GstElement* castitem);
01110
01111 private:
01112 friend class Gst::Interface;
01113 };
01114
01115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01116
01117 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
01118
01119 template <class T_Interface>
01120 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
01121 {
01122 gobject_ = (GObject*)castitem;
01123 if (gobject_) {
01124 gst_object_ref(Element::gobj());
01125 g_object_weak_ref(gobject_,
01126 &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
01127 }
01128 }
01129
01130 template <class T_Interface>
01131 GstElement* ElementInterfaced<T_Interface>::gobj()
01132 {
01133 return Element::gobj();
01134 }
01135
01136 template <class T_Interface>
01137 const GstElement* ElementInterfaced<T_Interface>::gobj() const
01138 {
01139 return Element::gobj();
01140 }
01141
01142 template <class T_Interface>
01143 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
01144 {
01145 return Element::gobj_copy();
01146 }
01147
01148 template <class T_Interface>
01149 ElementInterfaced<T_Interface>::~ElementInterfaced()
01150 {
01151
01152
01153 gobject_ = 0;
01154 }
01155
01156 #endif
01157
01158 }
01159
01160
01161 namespace Glib
01162 {
01171 Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01172 }
01173
01174
01175 #endif
01176