Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / wasapi2 / plugin.c
1 /* GStreamer
2  * Copyright (C) 2020 Seungha Yang <seungha@centricular.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 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <winapifamily.h>
25
26 #include "gstwasapi2sink.h"
27 #include "gstwasapi2src.h"
28 #include "gstwasapi2device.h"
29 #include "gstwasapi2util.h"
30 #include <mfapi.h>
31
32 GST_DEBUG_CATEGORY (gst_wasapi2_debug);
33 GST_DEBUG_CATEGORY (gst_wasapi2_client_debug);
34
35 static void
36 plugin_deinit (gpointer data)
37 {
38   MFShutdown ();
39 }
40
41 static gboolean
42 plugin_init (GstPlugin * plugin)
43 {
44   GstRank rank = GST_RANK_PRIMARY + 1;
45   HRESULT hr;
46
47   /**
48    * plugin-wasapi2:
49    *
50    * Since: 1.18
51    */
52
53   hr = MFStartup (MF_VERSION, MFSTARTUP_NOSOCKET);
54   if (!gst_wasapi2_result (hr)) {
55     GST_WARNING ("MFStartup failure, hr: 0x%x", hr);
56     return TRUE;
57   }
58
59   GST_DEBUG_CATEGORY_INIT (gst_wasapi2_debug, "wasapi2", 0, "wasapi2");
60   GST_DEBUG_CATEGORY_INIT (gst_wasapi2_client_debug, "wasapi2client",
61       0, "wasapi2client");
62
63   gst_element_register (plugin, "wasapi2sink", rank, GST_TYPE_WASAPI2_SINK);
64   gst_element_register (plugin, "wasapi2src", rank, GST_TYPE_WASAPI2_SRC);
65
66   gst_device_provider_register (plugin, "wasapi2deviceprovider",
67       rank, GST_TYPE_WASAPI2_DEVICE_PROVIDER);
68
69   g_object_set_data_full (G_OBJECT (plugin),
70       "plugin-wasapi2-shutdown", "shutdown-data",
71       (GDestroyNotify) plugin_deinit);
72
73   return TRUE;
74 }
75
76 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
77     GST_VERSION_MINOR,
78     wasapi2,
79     "Windows audio session API plugin",
80     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)