- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# 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
    00351
    00352   static GType get_base_type() G_GNUC_CONST;
    00353 #endif
    00354
    00356   GstRingBuffer*       gobj()       { return reinterpret_cast<GstRingBuffer*>(gobject_); }
    00357
    00359   const GstRingBuffer* gobj() const { return reinterpret_cast<GstRingBuffer*>(gobject_); }
    00360
    00362   GstRingBuffer* gobj_copy();
    00363
    00364 private:
    00365
    00366
    00367 public:
    00374   typedef sigc::slot<void, guint8*, guint> SlotFill;
    00375
    00376   //TODO: _MEMBER_GET(cond, cond, Glib::Cond, GCond*)
    00377
    00385   void set_fill_slot(const SlotFill& slot);
    00386
    00387
    00396   bool acquire(const Gst::RingBufferSpec& spec);
    00397
    00398
    00404   bool release();
    00405
    00411   bool is_acquired() const;
    00412
    00422   bool activate(bool active);
    00423
    00431   bool is_active() const;
    00432
    00438   bool start();
    00439
    00445   bool pause();
    00446
    00452   bool stop();
    00453
    00468   guint get_delay() const;
    00469
    00477   guint64 get_samples_done() const;
    00478
    00489   void set_sample(guint64 sample);
    00490
    00501   guint commit(guint64 sample, guchar* data, guint len);
    00502
    00533   guint commit(guint64& sample, guchar* data, int in_samples, int out_samples, int& accum);
    00534
    00545   bool convert(Gst::Format src_fmt, gint64 src_val, Gst::Format dest_fmt, gint64& dest_val) const;
    00546
    00555   bool prepare_read(int& segment, guint8*& readptr, int& len);
    00556
    00572   guint read(guint64 sample, guchar* data, guint len);
    00573
    00580   void clear(int segment);
    00581
    00586   void clear_all();
    00587
    00594   void advance(guint advance);
    00595
    00602   bool close_device();
    00603
    00611   bool open_device();
    00612
    00618   bool device_is_open() const;
    00619
    00628   void set_may_start(bool allowed);
    00629
    00636   static bool parse_caps(Gst::RingBufferSpec& spec, const Glib::RefPtr<Gst::Caps>& caps);
    00637
    00638
    00644   void set_flushing(bool flushing);
    00645
    00646   //TODO: Wrap vfuncs.
    00647
    00648 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00649 private:
    00650   SlotFill* slot;
    00651   bool _slot_set;
    00652 #endif
    00653
    00654
    00655 public:
    00656
    00657 public:
    00658   //C++ methods used to invoke GTK+ virtual functions:
    00659 #ifdef GLIBMM_VFUNCS_ENABLED
    00660 #endif //GLIBMM_VFUNCS_ENABLED
    00661
    00662 protected:
    00663   //GTK+ Virtual Functions (override these to change behaviour):
    00664 #ifdef GLIBMM_VFUNCS_ENABLED
    00665 #endif //GLIBMM_VFUNCS_ENABLED
    00666
    00667   //Default Signal Handlers::
    00668 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    00669 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
    00670
    00671
    00672 };
    00673
    00674 } // namespace Gst
    00675
    00676
    00677 namespace Glib
    00678 {
    00687   Glib::RefPtr<Gst::RingBuffer> wrap(GstRingBuffer* object, bool take_copy = false);
    00688 }
    00689
    00690
    00691 #endif /* _GSTREAMERMM_RINGBUFFER_H */
    00692