mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
b1dd20d57a
wasapi2 plugin should be preferred than old wasapi plugin if available because: * wasapi2 supports automatic stream routing, and it's highly recommended feature for application by MS. See also https://docs.microsoft.com/en-us/windows/win32/coreaudio/automatic-stream-routing * This implementation must be various COM threading issue free by design since wasapi2 plugin spawns a new dedicated COM thread and all COM objects' life-cycles are managed correctly. There are unsolved COM issues around old wasapi plugin. Such issues are very tricky to be solved unless old wasapi plugin's threading model is re-designed. Note that, in case of UWP, wasapi2 plugin's rank is primary + 1 already Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2314>
80 lines
2.2 KiB
C
80 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)
|
|
{
|
|
GstRank 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", 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", "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)
|