2 * Copyright (C) 2008 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
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.
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.
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.
20 #ifndef __GST_WASAPI_UTIL_H__
21 #define __GST_WASAPI_UTIL_H__
24 #include <gst/audio/audio.h>
25 #include <gst/audio/gstaudiosrc.h>
26 #include <gst/audio/gstaudiosink.h>
31 #include <mmdeviceapi.h>
32 #include <audioclient.h>
34 #include "gstaudioclient3.h"
36 /* Static Caps shared between source, sink, and device provider */
37 #define GST_WASAPI_STATIC_CAPS "audio/x-raw, " \
38 "format = (string) " GST_AUDIO_FORMATS_ALL ", " \
39 "layout = (string) interleaved, " \
40 "rate = " GST_AUDIO_RATE_RANGE ", " \
41 "channels = " GST_AUDIO_CHANNELS_RANGE
43 /* Standard error path */
44 #define HR_FAILED_AND(hr,func,and) \
47 gchar *msg = gst_wasapi_util_hresult_to_string (hr); \
48 GST_ERROR_OBJECT (self, #func " failed: %s", msg); \
54 #define HR_FAILED_RET(hr,func,ret) HR_FAILED_AND(hr,func,return ret)
56 #define HR_FAILED_GOTO(hr,func,where) HR_FAILED_AND(hr,func,res = FALSE; goto where)
58 /* Device role enum property */
61 GST_WASAPI_DEVICE_ROLE_CONSOLE,
62 GST_WASAPI_DEVICE_ROLE_MULTIMEDIA,
63 GST_WASAPI_DEVICE_ROLE_COMMS
64 } GstWasapiDeviceRole;
65 #define GST_WASAPI_DEVICE_TYPE_ROLE (gst_wasapi_device_role_get_type())
66 GType gst_wasapi_device_role_get_type (void);
70 gboolean gst_wasapi_util_have_audioclient3 (void);
72 gint gst_wasapi_device_role_to_erole (gint role);
74 gint gst_wasapi_erole_to_device_role (gint erole);
76 gchar *gst_wasapi_util_hresult_to_string (HRESULT hr);
78 gboolean gst_wasapi_util_get_devices (GstElement * element, gboolean active,
81 gboolean gst_wasapi_util_get_device_client (GstElement * element,
82 gboolean capture, gint role, const wchar_t * device_strid,
83 IMMDevice ** ret_device, IAudioClient ** ret_client);
85 gboolean gst_wasapi_util_get_device_format (GstElement * element,
86 gint device_mode, IMMDevice * device, IAudioClient * client,
87 WAVEFORMATEX ** ret_format);
89 gboolean gst_wasapi_util_get_render_client (GstElement * element,
90 IAudioClient * client, IAudioRenderClient ** ret_render_client);
92 gboolean gst_wasapi_util_get_capture_client (GstElement * element,
93 IAudioClient * client, IAudioCaptureClient ** ret_capture_client);
95 gboolean gst_wasapi_util_get_clock (GstElement * element,
96 IAudioClient * client, IAudioClock ** ret_clock);
98 gboolean gst_wasapi_util_parse_waveformatex (WAVEFORMATEXTENSIBLE * format,
99 GstCaps * template_caps, GstCaps ** out_caps,
100 GstAudioChannelPosition ** out_positions);
102 void gst_wasapi_util_get_best_buffer_sizes (GstAudioRingBufferSpec * spec,
103 gboolean exclusive, REFERENCE_TIME default_period,
104 REFERENCE_TIME min_period, REFERENCE_TIME * ret_period,
105 REFERENCE_TIME * ret_buffer_duration);
107 gboolean gst_wasapi_util_initialize_audioclient (GstElement * element,
108 GstAudioRingBufferSpec * spec, IAudioClient * client,
109 WAVEFORMATEX * format, guint sharemode, gboolean low_latency,
110 guint * ret_devicep_frames);
112 gboolean gst_wasapi_util_initialize_audioclient3 (GstElement * element,
113 GstAudioRingBufferSpec * spec, IAudioClient3 * client,
114 WAVEFORMATEX * format, gboolean low_latency, guint * ret_devicep_frames);
116 HANDLE gst_wasapi_util_set_thread_characteristics (void);
118 void gst_wasapi_util_revert_thread_characteristics (HANDLE handle);
120 #endif /* __GST_WASAPI_UTIL_H__ */