1 /* GStreamer
2 * Copyright (C) 2018 Nirbheek Chauhan <nirbheek@centricular.com>
3 * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "gstwasapi2device.h"
26 #include "gstwasapi2client.h"
27 #include "gstwasapi2util.h"
28 #include <gst/winrt/gstwinrt.h>
29
30 GST_DEBUG_CATEGORY_EXTERN (gst_wasapi2_debug);
31 #define GST_CAT_DEFAULT gst_wasapi2_debug
32
33 enum
34 {
35 PROP_0,
36 PROP_DEVICE,
37 };
38
39 struct _GstWasapi2Device
40 {
41 GstDevice parent;
42
43 gchar *device_id;
44 const gchar *factory_name;
45 GstWasapi2ClientDeviceClass device_class;
46 };
47
48 G_DEFINE_TYPE (GstWasapi2Device, gst_wasapi2_device, GST_TYPE_DEVICE);
49
50 static void gst_wasapi2_device_get_property (GObject * object,
51 guint prop_id, GValue * value, GParamSpec * pspec);
52 static void gst_wasapi2_device_set_property (GObject * object,
53 guint prop_id, const GValue * value, GParamSpec * pspec);
54 static void gst_wasapi2_device_finalize (GObject * object);
55 static GstElement *gst_wasapi2_device_create_element (GstDevice * device,
56 const gchar * name);
57
58 static void
gst_wasapi2_device_class_init(GstWasapi2DeviceClass * klass)59 gst_wasapi2_device_class_init (GstWasapi2DeviceClass * klass)
60 {
61 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
62 GstDeviceClass *dev_class = GST_DEVICE_CLASS (klass);
63
64 dev_class->create_element = gst_wasapi2_device_create_element;
65
66 gobject_class->get_property = gst_wasapi2_device_get_property;
67 gobject_class->set_property = gst_wasapi2_device_set_property;
68 gobject_class->finalize = gst_wasapi2_device_finalize;
69
70 g_object_class_install_property (gobject_class, PROP_DEVICE,
71 g_param_spec_string ("device", "Device",
72 "WASAPI playback device as a GUID string", NULL,
73 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
74 }
75
76 static void
gst_wasapi2_device_init(GstWasapi2Device * self)77 gst_wasapi2_device_init (GstWasapi2Device * self)
78 {
79 }
80
81 static void
gst_wasapi2_device_finalize(GObject * object)82 gst_wasapi2_device_finalize (GObject * object)
83 {
84 GstWasapi2Device *self = GST_WASAPI2_DEVICE (object);
85
86 g_free (self->device_id);
87
88 G_OBJECT_CLASS (gst_wasapi2_device_parent_class)->finalize (object);
89 }
90
91 static GstElement *
gst_wasapi2_device_create_element(GstDevice * device,const gchar * name)92 gst_wasapi2_device_create_element (GstDevice * device, const gchar * name)
93 {
94 GstWasapi2Device *self = GST_WASAPI2_DEVICE (device);
95 GstElement *elem;
96
97 elem = gst_element_factory_make (self->factory_name, name);
98
99 g_object_set (elem, "device", self->device_id, NULL);
100
101 if (self->device_class == GST_WASAPI2_CLIENT_DEVICE_CLASS_LOOPBACK_CAPTURE)
102 g_object_set (elem, "loopback", TRUE, NULL);
103
104 return elem;
105 }
106
107 static void
gst_wasapi2_device_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)108 gst_wasapi2_device_get_property (GObject * object, guint prop_id,
109 GValue * value, GParamSpec * pspec)
110 {
111 GstWasapi2Device *self = GST_WASAPI2_DEVICE (object);
112
113 switch (prop_id) {
114 case PROP_DEVICE:
115 g_value_set_string (value, self->device_id);
116 break;
117 default:
118 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
119 break;
120 }
121 }
122
123 static void
gst_wasapi2_device_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)124 gst_wasapi2_device_set_property (GObject * object, guint prop_id,
125 const GValue * value, GParamSpec * pspec)
126 {
127 GstWasapi2Device *self = GST_WASAPI2_DEVICE (object);
128
129 switch (prop_id) {
130 case PROP_DEVICE:
131 self->device_id = g_value_dup_string (value);
132 break;
133 default:
134 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
135 break;
136 }
137 }
138
139 typedef struct _GstWasapi2DeviceProvider
140 {
141 GstDeviceProvider parent;
142
143 GstWinRTDeviceWatcher *watcher;
144
145 GMutex lock;
146 GCond cond;
147
148 gboolean enum_completed;
149 } GstWasapi2DeviceProvider;
150
151 typedef struct _GstWasapi2DeviceProviderClass
152 {
153 GstDeviceProviderClass parent_class;
154
155 GstWinRTDeviceClass winrt_device_class;
156 } GstWasapi2DeviceProviderClass;
157
158 static GstDeviceProviderClass *parent_class = NULL;
159
160 #define GST_WASAPI2_DEVICE_PROVIDER(object) \
161 ((GstWasapi2DeviceProvider *) (object))
162 #define GST_WASAPI2_DEVICE_PROVIDER_GET_CLASS(object) \
163 (G_TYPE_INSTANCE_GET_CLASS ((object),G_TYPE_FROM_INSTANCE (object),GstWasapi2DeviceProviderClass))
164
165 static void gst_wasapi2_device_provider_dispose (GObject * object);
166 static void gst_wasapi2_device_provider_finalize (GObject * object);
167
168 static GList *gst_wasapi2_device_provider_probe (GstDeviceProvider * provider);
169 static gboolean
170 gst_wasapi2_device_provider_start (GstDeviceProvider * provider);
171 static void gst_wasapi2_device_provider_stop (GstDeviceProvider * provider);
172
173 static void
174 gst_wasapi2_device_provider_device_added (GstWinRTDeviceWatcher * watcher,
175 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformation * info,
176 gpointer user_data);
177 static void
178 gst_wasapi2_device_provider_device_updated (GstWinRTDeviceWatcher * watcher,
179 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
180 info_update, gpointer user_data);
181 static void gst_wasapi2_device_provider_device_removed (GstWinRTDeviceWatcher *
182 watcher,
183 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
184 info_update, gpointer user_data);
185 static void
186 gst_wasapi2_device_provider_device_enum_completed (GstWinRTDeviceWatcher *
187 watcher, gpointer user_data);
188
189 static void
gst_wasapi2_device_provider_class_init(GstWasapi2DeviceProviderClass * klass,gpointer data)190 gst_wasapi2_device_provider_class_init (GstWasapi2DeviceProviderClass * klass,
191 gpointer data)
192 {
193 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
194 GstDeviceProviderClass *provider_class = GST_DEVICE_PROVIDER_CLASS (klass);
195
196 gobject_class->dispose = gst_wasapi2_device_provider_dispose;
197 gobject_class->finalize = gst_wasapi2_device_provider_finalize;
198
199 provider_class->probe = GST_DEBUG_FUNCPTR (gst_wasapi2_device_provider_probe);
200 provider_class->start = GST_DEBUG_FUNCPTR (gst_wasapi2_device_provider_start);
201 provider_class->stop = GST_DEBUG_FUNCPTR (gst_wasapi2_device_provider_stop);
202
203 parent_class = (GstDeviceProviderClass *) g_type_class_peek_parent (klass);
204
205 klass->winrt_device_class = (GstWinRTDeviceClass) GPOINTER_TO_INT (data);
206 if (klass->winrt_device_class == GST_WINRT_DEVICE_CLASS_AUDIO_CAPTURE) {
207 gst_device_provider_class_set_static_metadata (provider_class,
208 "WASAPI (Windows Audio Session API) Capture Device Provider",
209 "Source/Audio", "List WASAPI source devices",
210 "Nirbheek Chauhan <nirbheek@centricular.com>, "
211 "Seungha Yang <seungha@centricular.com>");
212 } else {
213 gst_device_provider_class_set_static_metadata (provider_class,
214 "WASAPI (Windows Audio Session API) Render and Loopback Capture Device Provider",
215 "Source/Sink/Audio", "List WASAPI loop back source and sink devices",
216 "Nirbheek Chauhan <nirbheek@centricular.com>, "
217 "Seungha Yang <seungha@centricular.com>");
218 }
219 }
220
221 static void
gst_wasapi2_device_provider_init(GstWasapi2DeviceProvider * self)222 gst_wasapi2_device_provider_init (GstWasapi2DeviceProvider * self)
223 {
224 GstWasapi2DeviceProviderClass *klass =
225 GST_WASAPI2_DEVICE_PROVIDER_GET_CLASS (self);
226 GstWinRTDeviceWatcherCallbacks callbacks;
227
228 g_mutex_init (&self->lock);
229 g_cond_init (&self->cond);
230
231 callbacks.added = gst_wasapi2_device_provider_device_added;
232 callbacks.updated = gst_wasapi2_device_provider_device_updated;
233 callbacks.removed = gst_wasapi2_device_provider_device_removed;
234 callbacks.enumeration_completed =
235 gst_wasapi2_device_provider_device_enum_completed;
236
237 self->watcher =
238 gst_winrt_device_watcher_new (klass->winrt_device_class,
239 &callbacks, self);
240 }
241
242 static void
gst_wasapi2_device_provider_dispose(GObject * object)243 gst_wasapi2_device_provider_dispose (GObject * object)
244 {
245 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (object);
246
247 gst_clear_object (&self->watcher);
248
249 G_OBJECT_CLASS (parent_class)->dispose (object);
250 }
251
252 static void
gst_wasapi2_device_provider_finalize(GObject * object)253 gst_wasapi2_device_provider_finalize (GObject * object)
254 {
255 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (object);
256
257 g_mutex_clear (&self->lock);
258 g_cond_clear (&self->cond);
259
260 G_OBJECT_CLASS (parent_class)->finalize (object);
261 }
262
263 static void
gst_wasapi2_device_provider_probe_internal(GstWasapi2DeviceProvider * self,GstWasapi2ClientDeviceClass client_class,GList ** devices)264 gst_wasapi2_device_provider_probe_internal (GstWasapi2DeviceProvider * self,
265 GstWasapi2ClientDeviceClass client_class, GList ** devices)
266 {
267 gint i;
268 const gchar *device_class, *factory_name;
269
270 if (client_class == GST_WASAPI2_CLIENT_DEVICE_CLASS_RENDER) {
271 device_class = "Audio/Sink";
272 factory_name = "wasapi2sink";
273 } else {
274 device_class = "Audio/Source";
275 factory_name = "wasapi2src";
276 }
277
278 for (i = 0;; i++) {
279 GstWasapi2Client *client = NULL;
280 GstDevice *device;
281 GstStructure *props = NULL;
282 GstCaps *caps = NULL;
283 gchar *device_id = NULL;
284 gchar *device_name = NULL;
285
286 client = gst_wasapi2_client_new (client_class, i, NULL, NULL);
287
288 if (!client)
289 return;
290
291 caps = gst_wasapi2_client_get_caps (client);
292 if (!caps) {
293 GST_WARNING_OBJECT (self, "Couldn't get caps from client %d", i);
294 /* this might be a case where device activation is not finished yet */
295 caps = gst_caps_from_string (GST_WASAPI2_STATIC_CAPS);
296 }
297
298 g_object_get (client,
299 "device", &device_id, "device-name", &device_name, NULL);
300 if (!device_id) {
301 GST_WARNING_OBJECT (self, "Couldn't get device name from client %d", i);
302 goto next;
303 }
304
305 if (!device_name) {
306 GST_WARNING_OBJECT (self, "Couldn't get device name from client %d", i);
307 goto next;
308 }
309
310 props = gst_structure_new ("wasapi2-proplist",
311 "device.api", G_TYPE_STRING, "wasapi2",
312 "device.id", G_TYPE_STRING, device_id,
313 "device.default", G_TYPE_BOOLEAN, i == 0,
314 "wasapi2.device.description", G_TYPE_STRING, device_name, NULL);
315 switch (client_class) {
316 case GST_WASAPI2_CLIENT_DEVICE_CLASS_CAPTURE:
317 gst_structure_set (props,
318 "wasapi2.device.loopback", G_TYPE_BOOLEAN, FALSE, NULL);
319 break;
320 case GST_WASAPI2_CLIENT_DEVICE_CLASS_LOOPBACK_CAPTURE:
321 gst_structure_set (props,
322 "wasapi2.device.loopback", G_TYPE_BOOLEAN, TRUE, NULL);
323 break;
324 default:
325 break;
326 }
327
328 device = g_object_new (GST_TYPE_WASAPI2_DEVICE, "device", device_id,
329 "display-name", device_name, "caps", caps,
330 "device-class", device_class, "properties", props, NULL);
331 GST_WASAPI2_DEVICE (device)->factory_name = factory_name;
332 GST_WASAPI2_DEVICE (device)->device_class = client_class;
333
334 *devices = g_list_append (*devices, device);
335
336 next:
337 gst_clear_object (&client);
338 gst_clear_caps (&caps);
339 g_free (device_id);
340 g_free (device_name);
341 if (props)
342 gst_structure_free (props);
343 }
344
345 return;
346 }
347
348 static GList *
gst_wasapi2_device_provider_probe(GstDeviceProvider * provider)349 gst_wasapi2_device_provider_probe (GstDeviceProvider * provider)
350 {
351 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (provider);
352 GstWasapi2DeviceProviderClass *klass =
353 GST_WASAPI2_DEVICE_PROVIDER_GET_CLASS (self);
354 GList *devices = NULL;
355
356 if (klass->winrt_device_class == GST_WINRT_DEVICE_CLASS_AUDIO_CAPTURE) {
357 gst_wasapi2_device_provider_probe_internal (self,
358 GST_WASAPI2_CLIENT_DEVICE_CLASS_CAPTURE, &devices);
359 } else {
360 gst_wasapi2_device_provider_probe_internal (self,
361 GST_WASAPI2_CLIENT_DEVICE_CLASS_LOOPBACK_CAPTURE, &devices);
362 gst_wasapi2_device_provider_probe_internal (self,
363 GST_WASAPI2_CLIENT_DEVICE_CLASS_RENDER, &devices);
364 }
365
366 return devices;
367 }
368
369 static gboolean
gst_wasapi2_device_provider_start(GstDeviceProvider * provider)370 gst_wasapi2_device_provider_start (GstDeviceProvider * provider)
371 {
372 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (provider);
373 GList *devices = NULL;
374 GList *iter;
375
376 if (!self->watcher) {
377 GST_ERROR_OBJECT (self, "DeviceWatcher object wasn't configured");
378 return FALSE;
379 }
380
381 self->enum_completed = FALSE;
382
383 if (!gst_winrt_device_watcher_start (self->watcher))
384 return FALSE;
385
386 /* Wait for initial enumeration to be completed */
387 g_mutex_lock (&self->lock);
388 while (!self->enum_completed)
389 g_cond_wait (&self->cond, &self->lock);
390
391 devices = gst_wasapi2_device_provider_probe (provider);
392 if (devices) {
393 for (iter = devices; iter; iter = g_list_next (iter)) {
394 gst_device_provider_device_add (provider, GST_DEVICE (iter->data));
395 }
396
397 g_list_free (devices);
398 }
399 g_mutex_unlock (&self->lock);
400
401 return TRUE;
402 }
403
404 static void
gst_wasapi2_device_provider_stop(GstDeviceProvider * provider)405 gst_wasapi2_device_provider_stop (GstDeviceProvider * provider)
406 {
407 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (provider);
408
409 if (self->watcher)
410 gst_winrt_device_watcher_stop (self->watcher);
411 }
412
413 static gboolean
gst_wasapi2_device_is_in_list(GList * list,GstDevice * device)414 gst_wasapi2_device_is_in_list (GList * list, GstDevice * device)
415 {
416 GList *iter;
417 GstStructure *s;
418 const gchar *device_id;
419 gboolean found = FALSE;
420
421 s = gst_device_get_properties (device);
422 g_assert (s);
423
424 device_id = gst_structure_get_string (s, "device.id");
425 g_assert (device_id);
426
427 for (iter = list; iter; iter = g_list_next (iter)) {
428 GstStructure *other_s;
429 const gchar *other_id;
430
431 other_s = gst_device_get_properties (GST_DEVICE (iter->data));
432 g_assert (other_s);
433
434 other_id = gst_structure_get_string (other_s, "device.id");
435 g_assert (other_id);
436
437 if (g_ascii_strcasecmp (device_id, other_id) == 0) {
438 found = TRUE;
439 }
440
441 gst_structure_free (other_s);
442 if (found)
443 break;
444 }
445
446 gst_structure_free (s);
447
448 return found;
449 }
450
451 static void
gst_wasapi2_device_provider_update_devices(GstWasapi2DeviceProvider * self)452 gst_wasapi2_device_provider_update_devices (GstWasapi2DeviceProvider * self)
453 {
454 GstDeviceProvider *provider = GST_DEVICE_PROVIDER_CAST (self);
455 GList *prev_devices = NULL;
456 GList *new_devices = NULL;
457 GList *to_add = NULL;
458 GList *to_remove = NULL;
459 GList *iter;
460
461 GST_OBJECT_LOCK (self);
462 prev_devices = g_list_copy_deep (provider->devices,
463 (GCopyFunc) gst_object_ref, NULL);
464 GST_OBJECT_UNLOCK (self);
465
466 new_devices = gst_wasapi2_device_provider_probe (provider);
467
468 /* Ownership of GstDevice for gst_device_provider_device_add()
469 * and gst_device_provider_device_remove() is a bit complicated.
470 * Remove floating reference here for things to be clear */
471 for (iter = new_devices; iter; iter = g_list_next (iter))
472 gst_object_ref_sink (iter->data);
473
474 /* Check newly added devices */
475 for (iter = new_devices; iter; iter = g_list_next (iter)) {
476 if (!gst_wasapi2_device_is_in_list (prev_devices, GST_DEVICE (iter->data))) {
477 to_add = g_list_prepend (to_add, gst_object_ref (iter->data));
478 }
479 }
480
481 /* Check removed device */
482 for (iter = prev_devices; iter; iter = g_list_next (iter)) {
483 if (!gst_wasapi2_device_is_in_list (new_devices, GST_DEVICE (iter->data))) {
484 to_remove = g_list_prepend (to_remove, gst_object_ref (iter->data));
485 }
486 }
487
488 for (iter = to_remove; iter; iter = g_list_next (iter))
489 gst_device_provider_device_remove (provider, GST_DEVICE (iter->data));
490
491 for (iter = to_add; iter; iter = g_list_next (iter))
492 gst_device_provider_device_add (provider, GST_DEVICE (iter->data));
493
494 if (prev_devices)
495 g_list_free_full (prev_devices, (GDestroyNotify) gst_object_unref);
496
497 if (to_add)
498 g_list_free_full (to_add, (GDestroyNotify) gst_object_unref);
499
500 if (to_remove)
501 g_list_free_full (to_remove, (GDestroyNotify) gst_object_unref);
502 }
503
504 static void
gst_wasapi2_device_provider_device_added(GstWinRTDeviceWatcher * watcher,__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformation * info,gpointer user_data)505 gst_wasapi2_device_provider_device_added (GstWinRTDeviceWatcher * watcher,
506 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformation * info,
507 gpointer user_data)
508 {
509 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (user_data);
510
511 if (self->enum_completed)
512 gst_wasapi2_device_provider_update_devices (self);
513 }
514
515 static void
gst_wasapi2_device_provider_device_removed(GstWinRTDeviceWatcher * watcher,__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate * info_update,gpointer user_data)516 gst_wasapi2_device_provider_device_removed (GstWinRTDeviceWatcher * watcher,
517 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
518 info_update, gpointer user_data)
519 {
520 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (user_data);
521
522 if (self->enum_completed)
523 gst_wasapi2_device_provider_update_devices (self);
524 }
525
526 static void
gst_wasapi2_device_provider_device_updated(GstWinRTDeviceWatcher * watcher,__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate * info,gpointer user_data)527 gst_wasapi2_device_provider_device_updated (GstWinRTDeviceWatcher * watcher,
528 __x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate * info,
529 gpointer user_data)
530 {
531 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (user_data);
532
533 gst_wasapi2_device_provider_update_devices (self);
534 }
535
536 static void
gst_wasapi2_device_provider_device_enum_completed(GstWinRTDeviceWatcher * watcher,gpointer user_data)537 gst_wasapi2_device_provider_device_enum_completed (GstWinRTDeviceWatcher *
538 watcher, gpointer user_data)
539 {
540 GstWasapi2DeviceProvider *self = GST_WASAPI2_DEVICE_PROVIDER (user_data);
541
542 g_mutex_lock (&self->lock);
543 GST_DEBUG_OBJECT (self, "Enumeration completed");
544 self->enum_completed = TRUE;
545 g_cond_signal (&self->cond);
546 g_mutex_unlock (&self->lock);
547 }
548
549 static void
gst_wasapi2_device_provider_register_internal(GstPlugin * plugin,guint rank,GstWinRTDeviceClass winrt_device_class)550 gst_wasapi2_device_provider_register_internal (GstPlugin * plugin,
551 guint rank, GstWinRTDeviceClass winrt_device_class)
552 {
553 GType type;
554 const gchar *type_name = NULL;
555 const gchar *feature_name = NULL;
556 GTypeInfo type_info = {
557 sizeof (GstWasapi2DeviceProviderClass),
558 NULL,
559 NULL,
560 (GClassInitFunc) gst_wasapi2_device_provider_class_init,
561 NULL,
562 NULL,
563 sizeof (GstWasapi2DeviceProvider),
564 0,
565 (GInstanceInitFunc) gst_wasapi2_device_provider_init,
566 };
567
568 type_info.class_data = GINT_TO_POINTER (winrt_device_class);
569
570 if (winrt_device_class == GST_WINRT_DEVICE_CLASS_AUDIO_CAPTURE) {
571 type_name = "GstWasapi2CaputreDeviceProvider";
572 feature_name = "wasapi2capturedeviceprovider";
573 } else if (winrt_device_class == GST_WINRT_DEVICE_CLASS_AUDIO_RENDER) {
574 type_name = "GstWasapi2RenderDeviceProvider";
575 feature_name = "wasapi2renderdeviceprovider";
576 } else {
577 g_assert_not_reached ();
578 return;
579 }
580
581 type = g_type_register_static (GST_TYPE_DEVICE_PROVIDER,
582 type_name, &type_info, (GTypeFlags) 0);
583
584 if (!gst_device_provider_register (plugin, feature_name, rank, type))
585 GST_WARNING ("Failed to register provider '%s'", type_name);
586 }
587
588 void
gst_wasapi2_device_provider_register(GstPlugin * plugin,guint rank)589 gst_wasapi2_device_provider_register (GstPlugin * plugin, guint rank)
590 {
591 gst_wasapi2_device_provider_register_internal (plugin, rank,
592 GST_WINRT_DEVICE_CLASS_AUDIO_CAPTURE);
593 gst_wasapi2_device_provider_register_internal (plugin, rank,
594 GST_WINRT_DEVICE_CLASS_AUDIO_RENDER);
595 }
596