Seungha Yang ba41200c96 wasapi2: Implement IMMDeviceEnumerator based enumerator
... and merge wasapi2{capture,render}deviceprovider into single
wasapi2deviceprovider since we can enumerate input/output audio
devices at once using IMMDeviceEnumerator

This is a preparation for complete porting to Win32 API

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9307>
2025-07-02 18:18:18 +00:00

81 lines
2.2 KiB
C++

/* GStreamer
* Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <winapifamily.h>
#include "gstwasapi2sink.h"
#include "gstwasapi2src.h"
#include "gstwasapi2device.h"
#include "gstwasapi2util.h"
#include <mfapi.h>
GST_DEBUG_CATEGORY (gst_wasapi2_debug);
GST_DEBUG_CATEGORY (gst_wasapi2_client_debug);
static void
plugin_deinit (gpointer data)
{
MFShutdown ();
}
static gboolean
plugin_init (GstPlugin * plugin)
{
guint rank = GST_RANK_PRIMARY + 1;
HRESULT hr;
/**
* plugin-wasapi2:
*
* Since: 1.18
*/
hr = MFStartup (MF_VERSION, MFSTARTUP_NOSOCKET);
if (!gst_wasapi2_result (hr)) {
GST_WARNING ("MFStartup failure, hr: 0x%x", (guint) hr);
return TRUE;
}
GST_DEBUG_CATEGORY_INIT (gst_wasapi2_debug, "wasapi2", 0, "wasapi2");
GST_DEBUG_CATEGORY_INIT (gst_wasapi2_client_debug, "wasapi2client",
0, "wasapi2client");
gst_element_register (plugin, "wasapi2sink", rank, GST_TYPE_WASAPI2_SINK);
gst_element_register (plugin, "wasapi2src", rank, GST_TYPE_WASAPI2_SRC);
gst_device_provider_register (plugin, "wasapi2deviceprovider", rank,
GST_TYPE_WASAPI2_DEVICE_PROVIDER);
g_object_set_data_full (G_OBJECT (plugin),
"plugin-wasapi2-shutdown", (gpointer) "shutdown-data",
(GDestroyNotify) plugin_deinit);
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
wasapi2,
"Windows audio session API plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)