1 /* GStreamer 2 * Copyright (C) 2012 Fluendo S.A. <support@fluendo.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __OPENSLESRINGBUFFER_H__ 21 #define __OPENSLESRINGBUFFER_H__ 22 23 #include <gst/gst.h> 24 #include <gst/audio/audio.h> 25 #include "openslescommon.h" 26 27 #include <SLES/OpenSLES.h> 28 #include <SLES/OpenSLES_Android.h> 29 30 G_BEGIN_DECLS 31 32 #define MAX_NUMBER_OUTPUT_DEVICES 16 33 34 #define GST_TYPE_OPENSLES_RING_BUFFER \ 35 (gst_opensles_ringbuffer_get_type()) 36 #define GST_OPENSLES_RING_BUFFER(obj) \ 37 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENSLES_RING_BUFFER,GstOpenSLESRingBuffer)) 38 #define GST_OPENSLES_RING_BUFFER_CAST(obj) \ 39 ((GstOpenSLESRingBuffer*) obj) 40 #define GST_OPENSLES_RING_BUFFER_CLASS(klass) \ 41 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENSLES_RING_BUFFER,GstOpenSLESRingBufferClass)) 42 #define GST_OPENSLES_RING_BUFFER_GET_CLASS(obj) \ 43 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OPENSLES_RING_BUFFER,GstOpenSLESRingBufferClass)) 44 #define GST_IS_OPENSLES_RING_BUFFER(obj) \ 45 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENSLES_RING_BUFFER)) 46 #define GST_IS_OPENSLES_RING_BUFFER_CLASS(klass) \ 47 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENSLES_RING_BUFFER)) 48 49 typedef enum 50 { 51 RB_MODE_NONE = 0, 52 RB_MODE_SRC, 53 RB_MODE_SINK_PCM, 54 RB_MODE_SINK_COMPRESSED, 55 RB_MODE_LAST 56 } RingBufferMode; 57 58 typedef gboolean (*AcquireFunc) (GstAudioRingBuffer * rb, GstAudioRingBufferSpec * spec); 59 typedef gboolean (*StateFunc) (GstAudioRingBuffer * rb); 60 61 typedef struct _GstOpenSLESRingBuffer GstOpenSLESRingBuffer; 62 typedef struct _GstOpenSLESRingBufferClass GstOpenSLESRingBufferClass; 63 64 struct _GstOpenSLESRingBuffer 65 { 66 GstAudioRingBuffer object; 67 68 RingBufferMode mode; 69 70 /* engine interfaces */ 71 SLObjectItf engineObject; 72 SLEngineItf engineEngine; 73 74 /* outputMixObject */ 75 SLObjectItf outputMixObject; 76 77 /* player interfaces */ 78 SLObjectItf playerObject; 79 SLPlayItf playerPlay; 80 SLVolumeItf playerVolume; 81 gfloat volume; 82 gboolean mute; 83 gint is_prerolled; /* ATOMIC */ 84 GstOpenSLESStreamType stream_type; 85 86 /* recorder interfaces */ 87 SLObjectItf recorderObject; 88 SLRecordItf recorderRecord; 89 GstOpenSLESRecordingPreset preset; 90 91 /* buffer queue */ 92 SLAndroidSimpleBufferQueueItf bufferQueue; 93 guint data_segtotal; 94 guint8 * data; 95 guint data_size; 96 guint cursor; 97 gint segqueued; /* ATOMIC */ 98 gboolean is_queue_callback_registered; 99 100 /* vmethods */ 101 AcquireFunc acquire; 102 StateFunc start; 103 StateFunc pause; 104 StateFunc stop; 105 StateFunc change_volume; 106 StateFunc change_mute; 107 }; 108 109 struct _GstOpenSLESRingBufferClass 110 { 111 GstAudioRingBufferClass parent_class; 112 }; 113 114 GType gst_opensles_ringbuffer_get_type (void); 115 GstAudioRingBuffer *gst_opensles_ringbuffer_new (RingBufferMode mode); 116 void gst_opensles_ringbuffer_set_volume (GstAudioRingBuffer * rb, gfloat volume); 117 void gst_opensles_ringbuffer_set_mute (GstAudioRingBuffer * rb, gboolean mute); 118 119 G_END_DECLS 120 #endif /* __OPENSLESRINGBUFFER_H__ */ 121