1 /* GStreamer 2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> 3 * 2005 Wim Taymans <wim@fluendo.com> 4 * 5 * gstaudiosrc.h: 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public 18 * License along with this library; if not, write to the 19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef __GST_AUDIO_AUDIO_H__ 24 #include <gst/audio/audio.h> 25 #endif 26 27 #ifndef __GST_AUDIO_SRC_H__ 28 #define __GST_AUDIO_SRC_H__ 29 30 #include <gst/gst.h> 31 #include <gst/audio/gstaudiobasesrc.h> 32 33 G_BEGIN_DECLS 34 35 #define GST_TYPE_AUDIO_SRC (gst_audio_src_get_type()) 36 #define GST_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SRC,GstAudioSrc)) 37 #define GST_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SRC,GstAudioSrcClass)) 38 #define GST_AUDIO_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_SRC,GstAudioSrcClass)) 39 #define GST_IS_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SRC)) 40 #define GST_IS_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SRC)) 41 42 typedef struct _GstAudioSrc GstAudioSrc; 43 typedef struct _GstAudioSrcClass GstAudioSrcClass; 44 45 /** 46 * GstAudioSrc: 47 * 48 * Base class for simple audio sources. 49 */ 50 struct _GstAudioSrc { 51 GstAudioBaseSrc element; 52 53 /*< private >*/ /* with LOCK */ 54 GThread *thread; 55 56 /*< private >*/ 57 gpointer _gst_reserved[GST_PADDING]; 58 }; 59 60 /** 61 * GstAudioSrcClass: 62 * @parent_class: the parent class. 63 * @open: open the device with the specified caps 64 * @prepare: configure device with format 65 * @unprepare: undo the configuration 66 * @close: close the device 67 * @read: read samples from the audio device 68 * @delay: the number of frames queued in the device 69 * @reset: unblock a read to the device and reset. 70 * 71 * #GstAudioSrc class. Override the vmethod to implement 72 * functionality. 73 */ 74 struct _GstAudioSrcClass { 75 GstAudioBaseSrcClass parent_class; 76 77 /* vtable */ 78 79 /* open the device with given specs */ 80 gboolean (*open) (GstAudioSrc *src); 81 /* prepare resources and state to operate with the given specs */ 82 gboolean (*prepare) (GstAudioSrc *src, GstAudioRingBufferSpec *spec); 83 /* undo anything that was done in prepare() */ 84 gboolean (*unprepare) (GstAudioSrc *src); 85 /* close the device */ 86 gboolean (*close) (GstAudioSrc *src); 87 /* read samples from the device */ 88 guint (*read) (GstAudioSrc *src, gpointer data, guint length, 89 GstClockTime *timestamp); 90 /* get number of frames queued in the device */ 91 guint (*delay) (GstAudioSrc *src); 92 /* reset the audio device, unblock from a write */ 93 void (*reset) (GstAudioSrc *src); 94 95 /*< private >*/ 96 gpointer _gst_reserved[GST_PADDING]; 97 }; 98 99 GST_AUDIO_API 100 GType gst_audio_src_get_type(void); 101 102 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioSrc, gst_object_unref) 103 104 G_END_DECLS 105 106 #endif /* __GST_AUDIO_SRC_H__ */ 107