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
00038
00039 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00040 typedef struct _GstElement GstElement;
00041 typedef struct _GstElementClass GstElementClass;
00042 #endif
00043
00044
00045 namespace Gst
00046 { class Element_Class; }
00047 namespace Gst
00048 {
00049
00050 class Bus;
00051 class Caps;
00052 class Clock;
00053 class ElementFactory;
00054 class Event;
00055 class Index;
00056 class Interface;
00057 class Message;
00058 class Pad;
00059 class PadTemplate;
00060 class Query;
00061 class TagList;
00062
00068 enum ElementFlags
00069 {
00070 ELEMENT_LOCKED_STATE = GST_OBJECT_FLAG_LAST << 0,
00071 ELEMENT_IS_SINK = GST_OBJECT_FLAG_LAST << 1,
00072 ELEMENT_UNPARENTING = GST_OBJECT_FLAG_LAST << 2,
00073 ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST << 16
00074 };
00075
00076 }
00077
00078
00079 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00080 namespace Glib
00081 {
00082
00083 template <>
00084 class Value<Gst::ElementFlags> : public Glib::Value_Enum<Gst::ElementFlags>
00085 {
00086 public:
00087 static GType value_type() G_GNUC_CONST;
00088 };
00089
00090 }
00091 #endif
00092
00093
00094 namespace Gst
00095 {
00096
00097
00098 enum StateChange
00099 {
00100 STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
00101 STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
00102 STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
00103 STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
00104 STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
00105 STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL
00106 };
00107
00111 enum StateChangeReturn
00112 {
00113 STATE_CHANGE_FAILURE,
00114 STATE_CHANGE_SUCCESS,
00115 STATE_CHANGE_ASYNC,
00116 STATE_CHANGE_NO_PREROLL
00117 };
00118
00119 }
00120
00121
00122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00123 namespace Glib
00124 {
00125
00126 template <>
00127 class Value<Gst::StateChangeReturn> : public Glib::Value_Enum<Gst::StateChangeReturn>
00128 {
00129 public:
00130 static GType value_type() G_GNUC_CONST;
00131 };
00132
00133 }
00134 #endif
00135
00136
00137 namespace Gst
00138 {
00139
00140
00146 Glib::ustring get_name(State s);
00147
00153 Glib::ustring get_name(StateChangeReturn s);
00154
00195 class Element : public Gst::Object
00196 {
00197
00198 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00199
00200 public:
00201 typedef Element CppObjectType;
00202 typedef Element_Class CppClassType;
00203 typedef GstElement BaseObjectType;
00204 typedef GstElementClass BaseClassType;
00205
00206 private: friend class Element_Class;
00207 static CppClassType element_class_;
00208
00209 private:
00210
00211 Element(const Element&);
00212 Element& operator=(const Element&);
00213
00214 protected:
00215 explicit Element(const Glib::ConstructParams& construct_params);
00216 explicit Element(GstElement* castitem);
00217
00218 #endif
00219
00220 public:
00221 virtual ~Element();
00222
00223 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00224 static GType get_type() G_GNUC_CONST;
00225 static GType get_base_type() G_GNUC_CONST;
00226 #endif
00227
00229 GstElement* gobj() { return reinterpret_cast<GstElement*>(gobject_); }
00230
00232 const GstElement* gobj() const { return reinterpret_cast<GstElement*>(gobject_); }
00233
00235 GstElement* gobj_copy();
00236
00237 private:
00238
00239
00240 protected:
00241
00242 Element();
00243
00244 public:
00245 Glib::RefPtr<Element> link(const Glib::RefPtr<Element>& other_element);
00246
00264 bool add_pad(const Glib::RefPtr<Pad>& pad);
00265
00276 Glib::RefPtr<Pad> get_pad(const Glib::ustring& name);
00277
00282 void create_all_pads();
00283
00284 Glib::RefPtr<Pad> get_compatible_pad(const Glib::RefPtr<Pad>& pad, const Glib::RefPtr<Caps>& caps);
00285 Glib::RefPtr<PadTemplate> get_compatible_pad_template(const Glib::RefPtr<PadTemplate>& padtemplate);
00286
00287
00294 Glib::RefPtr<Pad> get_request_pad(const Glib::ustring& name);
00295
00304 Glib::RefPtr<Pad> get_static_pad(const Glib::ustring& name);
00305
00316 void no_more_pads();
00317
00324 void release_request_pad(const Glib::RefPtr<Pad>& pad);
00325
00348 bool remove_pad(const Glib::RefPtr<Pad>& pad);
00349
00350
00358 void unlink(const Glib::RefPtr<Element>& other_element);
00359
00360
00371 bool link_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname);
00372
00373
00379 void unlink_pads(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& other_padname);
00380
00381
00392 bool link_pads_filtered(const Glib::ustring& padname, const Glib::RefPtr<Element>& other_element, const Glib::ustring& others_padname, const Glib::RefPtr<Caps>& filter);
00393
00394
00407 bool link_filtered(const Glib::RefPtr<Element>& other_element, const Glib::RefPtr<Caps>& filter);
00408
00414 void set_base_time(ClockTime time);
00415
00421 ClockTime get_base_time() const;
00422
00429 void set_bus(const Glib::RefPtr<Bus>& bus);
00430
00436 Glib::RefPtr<Bus> get_bus();
00437
00443 Glib::RefPtr<const Bus> get_bus() const;
00444
00451 void set_index(const Glib::RefPtr<Index>& index);
00452
00453
00454
00461 Glib::RefPtr<Index> get_index();
00462
00469 Glib::RefPtr<Index const> get_index() const;
00470
00471
00476 Glib::RefPtr<ElementFactory> get_factory();
00477
00483 bool is_indexable() const;
00484
00490 bool requires_clock() const;
00491
00502 bool set_clock(const Glib::RefPtr<Clock>& clock);
00503
00510 Glib::RefPtr<Clock> get_clock();
00511
00518 Glib::RefPtr<const Clock> get_clock() const;
00519
00529 bool provides_clock() const;
00530
00539 Glib::RefPtr<Clock> provide_clock();
00540
00549 Glib::RefPtr<const Clock> provide_clock() const;
00550
00565 StateChangeReturn set_state(State state);
00566
00590 StateChangeReturn get_state(State& state, State& pending, ClockTime timeout) const;
00591
00600 bool set_locked_state(gboolean locked_state);
00601
00611 bool is_locked_state() const;
00612
00621 void abort_state();
00622
00639 StateChangeReturn continue_state(StateChangeReturn prestate_value);
00640
00662 void lost_state();
00663
00670 bool sync_state_with_parent();
00671
00679 StateChangeReturn change_state(StateChange transition);
00680
00688 void found_tags(TagList& list);
00689
00698 void found_tags_for_pad(const Glib::RefPtr<Pad>& pad, TagList& list);
00699
00700
00701
00719 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);
00720
00730 bool post_message(const Glib::RefPtr<Message>& message);
00731
00732
00741 Glib::ArrayHandle<QueryType> get_query_types() const;
00742
00743
00754 bool query(const Glib::RefPtr<Query>& query);
00755
00763 bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const;
00764
00771 bool query_position(Format& format, gint64& position) const;
00772
00779 bool query_position(Format& format) const;
00780
00781
00788 bool query_duration(Format& format, gint64& duration) const;
00789
00796 bool query_duration(Format& format) const;
00797
00798
00825 bool seek(Format format, SeekFlags flags, gint64 position);
00826
00841 bool seek(double rate, Format format, SeekFlags flags, SeekType current_type, gint64 current_position, SeekType stop_type, gint64 stop_position);
00842
00852 bool send_event(const Glib::RefPtr<Event>& event);
00853
00854
00860 bool implements_interface(GType iface_type);
00861
00862
00869 Glib::SignalProxy0< void > signal_no_more_pads();
00870
00871
00878 Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_added();
00879
00880
00887 Glib::SignalProxy1< void,const Glib::RefPtr<Pad>& > signal_pad_removed();
00888
00889
00892 #ifdef GLIBMM_VFUNCS_ENABLED
00893 virtual Glib::RefPtr<Pad> request_new_pad_vfunc(const Glib::RefPtr<PadTemplate>& templ, const Glib::ustring& name);
00894 #endif //GLIBMM_VFUNCS_ENABLED
00895
00896
00899 #ifdef GLIBMM_VFUNCS_ENABLED
00900 virtual void release_pad_vfunc(const Glib::RefPtr<Pad>& pad);
00901 #endif //GLIBMM_VFUNCS_ENABLED
00902
00903
00906 #ifdef GLIBMM_VFUNCS_ENABLED
00907 virtual StateChangeReturn get_state_vfunc(State& state, State& pending, ClockTime timeout);
00908 #endif //GLIBMM_VFUNCS_ENABLED
00909
00910
00913 #ifdef GLIBMM_VFUNCS_ENABLED
00914 virtual StateChangeReturn set_state_vfunc(State state);
00915 #endif //GLIBMM_VFUNCS_ENABLED
00916
00917
00920 #ifdef GLIBMM_VFUNCS_ENABLED
00921 virtual StateChangeReturn change_state_vfunc(StateChange transition);
00922 #endif //GLIBMM_VFUNCS_ENABLED
00923
00924
00927 #ifdef GLIBMM_VFUNCS_ENABLED
00928 virtual void set_bus_vfunc(const Glib::RefPtr<Bus>& bus);
00929 #endif //GLIBMM_VFUNCS_ENABLED
00930
00931
00934 #ifdef GLIBMM_VFUNCS_ENABLED
00935 virtual Glib::RefPtr<Clock> provide_clock_vfunc();
00936 #endif //GLIBMM_VFUNCS_ENABLED
00937
00938
00941 #ifdef GLIBMM_VFUNCS_ENABLED
00942 virtual bool set_clock_vfunc(const Glib::RefPtr<Clock>& clock);
00943 #endif //GLIBMM_VFUNCS_ENABLED
00944
00945
00948 #ifdef GLIBMM_VFUNCS_ENABLED
00949 virtual Glib::RefPtr<Index> get_index_vfunc();
00950 #endif //GLIBMM_VFUNCS_ENABLED
00951
00952
00955 #ifdef GLIBMM_VFUNCS_ENABLED
00956 virtual void set_index_vfunc(const Glib::RefPtr<Index>& index);
00957 #endif //GLIBMM_VFUNCS_ENABLED
00958
00959
00962 #ifdef GLIBMM_VFUNCS_ENABLED
00963 virtual bool send_event_vfunc(const Glib::RefPtr<Event>& event);
00964 #endif //GLIBMM_VFUNCS_ENABLED
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00978 #ifdef GLIBMM_VFUNCS_ENABLED
00979 virtual bool query_vfunc(const Glib::RefPtr<Query>& query);
00980 #endif //GLIBMM_VFUNCS_ENABLED
00981
00982
00983 public:
00984
00985 public:
00986
00987 #ifdef GLIBMM_VFUNCS_ENABLED
00988 #endif //GLIBMM_VFUNCS_ENABLED
00989
00990 protected:
00991
00992 #ifdef GLIBMM_VFUNCS_ENABLED
00993 #endif //GLIBMM_VFUNCS_ENABLED
00994
00995
00996 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00997 virtual void on_no_more_pads();
00998 virtual void on_pad_added(const Glib::RefPtr<Pad>& new_pad);
00999 virtual void on_pad_removed(const Glib::RefPtr<Pad>& old_pad);
01000 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
01001
01002
01003 };
01004
01036 template <class T_Interface>
01037 class ElementInterfaced
01038 : public Element,
01039 public T_Interface
01040 {
01041 public:
01042
01043
01044 GstElement* gobj();
01045 const GstElement* gobj() const;
01046 GstElement* gobj_copy();
01047
01048 ~ElementInterfaced();
01049
01050 protected:
01051 ElementInterfaced(const ElementInterfaced&);
01052 ElementInterfaced& operator=(const ElementInterfaced&);
01053
01054 protected:
01055 ElementInterfaced(GstElement* castitem);
01056
01057 private:
01058 friend class Gst::Interface;
01059 };
01060
01061 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01062
01063 void ElementInterfaced_WeakNotify_gstreamermm_callback(void* data, GObject* where_the_object_was);
01064
01065 template <class T_Interface>
01066 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
01067 {
01068 gobject_ = (GObject*)castitem;
01069 if (gobject_) {
01070 gst_object_ref(Element::gobj());
01071 g_object_weak_ref(gobject_,
01072 &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
01073 }
01074 }
01075
01076 template <class T_Interface>
01077 GstElement* ElementInterfaced<T_Interface>::gobj()
01078 {
01079 return Element::gobj();
01080 }
01081
01082 template <class T_Interface>
01083 const GstElement* ElementInterfaced<T_Interface>::gobj() const
01084 {
01085 return Element::gobj();
01086 }
01087
01088 template <class T_Interface>
01089 GstElement* ElementInterfaced<T_Interface>::gobj_copy()
01090 {
01091 return Element::gobj_copy();
01092 }
01093
01094 template <class T_Interface>
01095 ElementInterfaced<T_Interface>::~ElementInterfaced()
01096 {
01097
01098
01099 gobject_ = 0;
01100 }
01101
01102 #endif
01103
01104 }
01105
01106
01107 namespace Glib
01108 {
01117 Glib::RefPtr<Gst::Element> wrap(GstElement* object, bool take_copy = false);
01118 }
01119
01120
01121 #endif
01122