1 /* 2 * GStreamer 3 * Copyright 2005 Thomas Vander Stichele <thomas@apestaart.org> 4 * Copyright 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net> 5 * Copyright 2005 Sébastien Moutte <sebastien@moutte.net> 6 * Copyright 2006 Joni Valtanen <joni.valtanen@movial.fi> 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 * DEALINGS IN THE SOFTWARE. 25 * 26 * Alternatively, the contents of this file may be used under the 27 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in 28 * which case the following provisions apply instead of the ones 29 * mentioned above: 30 * 31 * This library is free software; you can redistribute it and/or 32 * modify it under the terms of the GNU Library General Public 33 * License as published by the Free Software Foundation; either 34 * version 2 of the License, or (at your option) any later version. 35 * 36 * This library is distributed in the hope that it will be useful, 37 * but WITHOUT ANY WARRANTY; without even the implied warranty of 38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 * Library General Public License for more details. 40 * 41 * You should have received a copy of the GNU Library General Public 42 * License along with this library; if not, write to the 43 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 44 * Boston, MA 02110-1301, USA. 45 */ 46 47 #ifndef __GST_DIRECTSOUNDSRC_H__ 48 #define __GST_DIRECTSOUNDSRC_H__ 49 50 #include <gst/gst.h> 51 #include <gst/audio/audio.h> 52 #include <gst/audio/gstaudiosrc.h> 53 #include <windows.h> 54 #include <dsound.h> 55 #include <mmsystem.h> 56 57 /* add here some headers if needed */ 58 59 60 G_BEGIN_DECLS 61 62 /* #defines don't like whitespacey bits */ 63 #define GST_TYPE_DIRECTSOUND_SRC (gst_directsound_src_get_type()) 64 #define GST_DIRECTSOUND_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DIRECTSOUND_SRC,GstDirectSoundSrc)) 65 #define GST_DIRECTSOUND_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DIRECTSOUND_SRC,GstDirectSoundSrcClass)) 66 #define GST_IS_DIRECTSOUND_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DIRECTSOUND_SRC)) 67 #define GST_IS_DIRECTSOUND_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DIRECTSOUND_SRC)) 68 69 typedef struct _GstDirectSoundSrc GstDirectSoundSrc; 70 typedef struct _GstDirectSoundSrcClass GstDirectSoundSrcClass; 71 72 #define GST_DSOUND_LOCK(obj) (g_mutex_lock (&obj->dsound_lock)) 73 #define GST_DSOUND_UNLOCK(obj) (g_mutex_unlock (&obj->dsound_lock)) 74 75 struct _GstDirectSoundSrc 76 { 77 78 GstAudioSrc src; 79 80 LPDIRECTSOUNDCAPTURE pDSC; /* DirectSoundCapture*/ 81 LPDIRECTSOUNDCAPTUREBUFFER pDSBSecondary; /*Secondaty capturebuffer*/ 82 DWORD current_circular_offset; 83 84 guint buffer_size; 85 guint bytes_per_sample; 86 87 guint latency_time; 88 89 HMIXER mixer; 90 DWORD mixerline_cchannels; 91 gint control_id_volume; 92 gint control_id_mute; 93 glong dw_vol_max; 94 glong dw_vol_min; 95 96 glong volume; 97 gboolean mute; 98 99 GUID *device_guid; 100 101 char *device_name; 102 char *device_id; 103 104 GMutex dsound_lock; 105 106 GstClock *system_clock; 107 GstClockID *read_wait_clock_id; 108 gboolean reset_while_sleeping; 109 }; 110 111 struct _GstDirectSoundSrcClass 112 { 113 GstAudioSrcClass parent_class; 114 }; 115 116 GType gst_directsound_src_get_type (void); 117 118 #define GST_DIRECTSOUND_SRC_CAPS "audio/x-raw, " \ 119 "format = (string) { S16LE, S8 }, " \ 120 "layout = (string) interleaved, " \ 121 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]" 122 123 G_END_DECLS 124 125 #endif /* __GST_DIRECTSOUNDSRC_H__ */ 126