ringbuffer.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _GSTREAMERMM_RINGBUFFER_H
00004 #define _GSTREAMERMM_RINGBUFFER_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 /* gstreamermm - a C++ wrapper for gstreamer
00010  *
00011  * Copyright 2008-2009 The gstreamermm Development Team
00012  *
00013  * This library is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2.1 of the License, or (at your option) any later version.
00017  *
00018  * This library is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with this library; if not, write to the Free
00025  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00026  */
00027 
00028 #include <gst/audio/gstringbuffer.h>
00029 #include <gstreamermm/caps.h>
00030 #include <gstreamermm/object.h>
00031 #include <gstreamermm/format.h>
00032 
00033 
00034 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00035 typedef struct _GstRingBuffer GstRingBuffer;
00036 typedef struct _GstRingBufferClass GstRingBufferClass;
00037 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00038 
00039 
00040 namespace Gst
00041 { class RingBuffer_Class; } // namespace Gst
00042 namespace Gst
00043 {
00044 
00050 enum RingBufferSegState
00051 {
00052   SEGSTATE_INVALID,
00053   SEGSTATE_EMPTY,
00054   SEGSTATE_FILLED,
00055   SEGSTATE_PARTIAL
00056 };
00057 
00058 } // namespace Gst
00059 
00060 
00061 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00062 namespace Glib
00063 {
00064 
00065 template <>
00066 class Value<Gst::RingBufferSegState> : public Glib::Value_Enum<Gst::RingBufferSegState>
00067 {
00068 public:
00069   static GType value_type() G_GNUC_CONST;
00070 };
00071 
00072 } // namespace Glib
00073 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00074 
00075 
00076 namespace Gst
00077 {
00078 
00082 enum RingBufferState
00083 {
00084   RING_BUFFER_STATE_STOPPED,
00085   RING_BUFFER_STATE_PAUSED,
00086   RING_BUFFER_STATE_STARTED
00087 };
00088 
00089 } // namespace Gst
00090 
00091 
00092 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00093 namespace Glib
00094 {
00095 
00096 template <>
00097 class Value<Gst::RingBufferState> : public Glib::Value_Enum<Gst::RingBufferState>
00098 {
00099 public:
00100   static GType value_type() G_GNUC_CONST;
00101 };
00102 
00103 } // namespace Glib
00104 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00105 
00106 
00107 namespace Gst
00108 {
00109 
00113 enum BufferFormat
00114 {
00115   UNKNOWN,
00116   S8,
00117   U8,
00118   S16_LE,
00119   S16_BE,
00120   U16_LE,
00121   U16_BE,
00122   S24_LE,
00123   S24_BE,
00124   U24_LE,
00125   U24_BE,
00126   S32_LE,
00127   S32_BE,
00128   U32_LE,
00129   U32_BE,
00130   S24_3LE,
00131   S24_3BE,
00132   U24_3LE,
00133   U24_3BE,
00134   S20_3LE,
00135   S20_3BE,
00136   U20_3LE,
00137   U20_3BE,
00138   S18_3LE,
00139   S18_3BE,
00140   U18_3LE,
00141   U18_3BE,
00142   FLOAT32_LE,
00143   FLOAT32_BE,
00144   FLOAT64_LE,
00145   FLOAT64_BE,
00146   MU_LAW,
00147   A_LAW,
00148   IMA_ADPCM,
00149   MPEG,
00150   GSM,
00151   IEC958,
00152   AC3,
00153   EAC3,
00154   DTS
00155 };
00156 
00157 } // namespace Gst
00158 
00159 
00160 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00161 namespace Glib
00162 {
00163 
00164 template <>
00165 class Value<Gst::BufferFormat> : public Glib::Value_Enum<Gst::BufferFormat>
00166 {
00167 public:
00168   static GType value_type() G_GNUC_CONST;
00169 };
00170 
00171 } // namespace Glib
00172 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00173 
00174 
00175 namespace Gst
00176 {
00177 
00181 enum BufferFormatType
00182 {
00183   BUFTYPE_LINEAR,
00184   BUFTYPE_FLOAT,
00185   BUFTYPE_MU_LAW,
00186   BUFTYPE_A_LAW,
00187   BUFTYPE_IMA_ADPCM,
00188   BUFTYPE_MPEG,
00189   BUFTYPE_GSM,
00190   BUFTYPE_IEC958,
00191   BUFTYPE_AC3,
00192   BUFTYPE_EAC3,
00193   BUFTYPE_DTS
00194 };
00195 
00196 } // namespace Gst
00197 
00198 
00199 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00200 namespace Glib
00201 {
00202 
00203 template <>
00204 class Value<Gst::BufferFormatType> : public Glib::Value_Enum<Gst::BufferFormatType>
00205 {
00206 public:
00207   static GType value_type() G_GNUC_CONST;
00208 };
00209 
00210 } // namespace Glib
00211 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00212 
00213 
00214 namespace Gst
00215 {
00216 
00217 
00221 class RingBufferSpec
00222 {
00223   public:
00224 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00225   typedef RingBufferSpec CppObjectType;
00226   typedef GstRingBufferSpec BaseObjectType;
00227 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00228 
00229 private:
00230 
00231 public:
00233   RingBufferSpec(const GstRingBufferSpec* castitem);
00234 
00236   Glib::RefPtr<Gst::Caps> caps;
00237 
00240   Gst::BufferFormatType type;
00241 
00244   Gst::BufferFormat format;
00245 
00248   bool          sign;
00249 
00252   bool          bigend;
00253 
00256   int           width;
00257 
00260   int           depth;
00261 
00264   int           rate;
00265 
00268   int           channels;
00269 
00272   guint64       latency_time;
00273 
00276   guint64       buffer_time;
00277 
00280   int           segsize;
00281 
00284   int           segtotal;
00285 
00288   int           bytes_per_sample;
00289 
00292   guint8        silence_sample[32];
00293 
00297   int           seglatency;
00298 
00299 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00300   void copy_fields_from(const GstRingBufferSpec& spec);
00301   void copy_fields_to(GstRingBufferSpec& spec) const;
00302 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00303 
00304 
00305 };
00306 
00320 class RingBuffer : public Gst::Object 
00321 {
00322   
00323 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00324 
00325 public:
00326   typedef RingBuffer CppObjectType;
00327   typedef RingBuffer_Class CppClassType;
00328   typedef GstRingBuffer BaseObjectType;
00329   typedef GstRingBufferClass BaseClassType;
00330 
00331 private:  friend class RingBuffer_Class;
00332   static CppClassType ringbuffer_class_;
00333 
00334 private:
00335   // noncopyable
00336   RingBuffer(const RingBuffer&);
00337   RingBuffer& operator=(const RingBuffer&);
00338 
00339 protected:
00340   explicit RingBuffer(const Glib::ConstructParams& construct_params);
00341   explicit RingBuffer(GstRingBuffer* castitem);
00342 
00343 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00344 
00345 public:
00346   virtual ~RingBuffer();
00347 
00348 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00349   static GType get_type()      G_GNUC_CONST;
00350   static GType get_base_type() G_GNUC_CONST;
00351 #endif
00352 
00354   GstRingBuffer*       gobj()       { return reinterpret_cast<GstRingBuffer*>(gobject_); }
00355 
00357   const GstRingBuffer* gobj() const { return reinterpret_cast<GstRingBuffer*>(gobject_); }
00358 
00360   GstRingBuffer* gobj_copy();
00361 
00362 private:
00363 
00364   
00365 public:
00372   typedef sigc::slot<void, guint8*, guint> SlotFill;
00373 
00374   //TODO: _MEMBER_GET(cond, cond, Glib::Cond, GCond*)
00375 
00383   void set_fill_slot(const SlotFill& slot);
00384   
00385 
00394   bool acquire(const Gst::RingBufferSpec& spec);
00395   
00396 
00402   bool release();
00403   
00409   bool is_acquired() const;
00410   
00420   bool activate(bool active);
00421   
00429   bool is_active() const;
00430   
00436   bool start();
00437   
00443   bool pause();
00444   
00450   bool stop();
00451   
00466   guint get_delay() const;
00467   
00475   guint64 get_samples_done() const;
00476   
00487   void set_sample(guint64 sample);
00488   
00499   guint commit(guint64 sample, guchar* data, guint len);
00500   
00531   guint commit(guint64& sample, guchar* data, int in_samples, int out_samples, int& accum);
00532   
00543   bool convert(Gst::Format src_fmt, gint64 src_val, Gst::Format dest_fmt, gint64& dest_val) const;
00544   
00553   bool prepare_read(int& segment, guint8*& readptr, int& len);
00554   
00570   guint read(guint64 sample, guchar* data, guint len);
00571   
00578   void clear(int segment);
00579   
00584   void clear_all();
00585   
00592   void advance(guint advance);
00593   
00600   bool close_device();
00601   
00609   bool open_device();
00610   
00616   bool device_is_open() const;
00617   
00626   void set_may_start(bool allowed);
00627 
00634   static bool parse_caps(Gst::RingBufferSpec& spec, const Glib::RefPtr<Gst::Caps>& caps);
00635 
00636   
00642   void set_flushing(bool flushing);
00643 
00644   //TODO: Wrap vfuncs.
00645 
00646 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00647 private:
00648   SlotFill* slot;
00649   bool _slot_set;
00650 #endif
00651 
00652 
00653 public:
00654 
00655 public:
00656   //C++ methods used to invoke GTK+ virtual functions:
00657 #ifdef GLIBMM_VFUNCS_ENABLED
00658 #endif //GLIBMM_VFUNCS_ENABLED
00659 
00660 protected:
00661   //GTK+ Virtual Functions (override these to change behaviour):
00662 #ifdef GLIBMM_VFUNCS_ENABLED
00663 #endif //GLIBMM_VFUNCS_ENABLED
00664 
00665   //Default Signal Handlers::
00666 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00667 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00668 
00669 
00670 };
00671 
00672 } // namespace Gst
00673 
00674 
00675 namespace Glib
00676 {
00685   Glib::RefPtr<Gst::RingBuffer> wrap(GstRingBuffer* object, bool take_copy = false);
00686 }
00687 
00688 
00689 #endif /* _GSTREAMERMM_RINGBUFFER_H */
00690 

Generated on Wed Aug 19 15:53:28 2009 for gstreamermm by  doxygen 1.5.4