windows: Enable wasapi on windows
This commit is contained in:
parent
c438592ab0
commit
2eb0052663
|
@ -13,6 +13,7 @@ endif ()
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON)
|
option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON)
|
||||||
|
option(WITH_WASAPI "Use wasapi instead of directsound on windows" ON)
|
||||||
|
|
||||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/19804
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/19804
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -16,3 +16,4 @@ option('plugin-rtp-vp9', type: 'feature', value: 'disabled', description: 'VP9 c
|
||||||
option('plugin-rtp-webrtc-audio-processing', type: 'feature', description: 'Voice preprocessing')
|
option('plugin-rtp-webrtc-audio-processing', type: 'feature', description: 'Voice preprocessing')
|
||||||
|
|
||||||
option('use-soup2', type: 'boolean', value: false, description: 'Use libsoup version 2 instead of 3')
|
option('use-soup2', type: 'boolean', value: false, description: 'Use libsoup version 2 instead of 3')
|
||||||
|
option('with-wasapi', type: 'boolean', value: true, description: 'Use wasapi insted of directsound on windows')
|
||||||
|
|
|
@ -58,6 +58,10 @@ if(RTP_ENABLE_MSDK)
|
||||||
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_MSDK)
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_MSDK)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WIN32 AND WITH_WASAPI)
|
||||||
|
list(APPEND RTP_DEFINITIONS WITH_WASAPI)
|
||||||
|
endif()
|
||||||
|
|
||||||
vala_precompile(RTP_VALA_C
|
vala_precompile(RTP_VALA_C
|
||||||
SOURCES
|
SOURCES
|
||||||
src/codec_util.vala
|
src/codec_util.vala
|
||||||
|
|
|
@ -55,5 +55,8 @@ endif
|
||||||
if get_option('plugin-rtp-vp9').allowed()
|
if get_option('plugin-rtp-vp9').allowed()
|
||||||
vala_args += ['-D', 'ENABLE_VP9']
|
vala_args += ['-D', 'ENABLE_VP9']
|
||||||
endif
|
endif
|
||||||
|
if host_machine.system() == 'windows' and get_option('with-wasapi')
|
||||||
|
vala_args += ['-D', 'WITH_WASAPI']
|
||||||
|
endif
|
||||||
lib_rtp = shared_library('rtp', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, kwargs: install_options)
|
lib_rtp = shared_library('rtp', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, kwargs: install_options)
|
||||||
dep_rtp = declare_dependency(link_with: lib_rtp, include_directories: include_directories('.'))
|
dep_rtp = declare_dependency(link_with: lib_rtp, include_directories: include_directories('.'))
|
||||||
|
|
|
@ -42,6 +42,19 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
if (pause_count < 0) warning("Pause count below zero!");
|
if (pause_count < 0) warning("Pause count below zero!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool is_skipped(Gst.Device device) {
|
||||||
|
bool is_noprops = device.properties == null;
|
||||||
|
#if WITH_WASAPI
|
||||||
|
bool is_disabled_sound = device.properties.get_string("device.api") == "directsound";
|
||||||
|
#else
|
||||||
|
bool is_disabled_sound = device.properties.get_string("device.api") == "wasapi";
|
||||||
|
#endif
|
||||||
|
bool is_proplist = device.properties.has_name("pipewire-proplist") && device.has_classes("Audio");
|
||||||
|
bool is_monitor = device.properties.get_string("device.class") == "monitor";
|
||||||
|
bool is_in_devices = devices.any_match((it) => it.matches(device));
|
||||||
|
return is_noprops || is_disabled_sound || is_proplist || is_monitor || is_in_devices;
|
||||||
|
}
|
||||||
|
|
||||||
private void init_device_monitor() {
|
private void init_device_monitor() {
|
||||||
if (device_monitor != null) return;
|
if (device_monitor != null) return;
|
||||||
device_monitor = new Gst.DeviceMonitor();
|
device_monitor = new Gst.DeviceMonitor();
|
||||||
|
@ -49,11 +62,8 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
device_monitor.get_bus().add_watch(Priority.DEFAULT, on_device_monitor_message);
|
device_monitor.get_bus().add_watch(Priority.DEFAULT, on_device_monitor_message);
|
||||||
device_monitor.start();
|
device_monitor.start();
|
||||||
foreach (Gst.Device device in device_monitor.get_devices()) {
|
foreach (Gst.Device device in device_monitor.get_devices()) {
|
||||||
if (device.properties == null) continue;
|
if (is_skipped(device)) continue;
|
||||||
if (device.properties.get_string("device.api") == "wasapi") continue;
|
debug(@"(Init) Add name=$(device.name) device=$(device.display_name)");
|
||||||
if (device.properties.has_name("pipewire-proplist") && device.has_classes("Audio")) continue;
|
|
||||||
if (device.properties.get_string("device.class") == "monitor") continue;
|
|
||||||
if (devices.any_match((it) => it.matches(device))) continue;
|
|
||||||
devices.add(new Device(this, device));
|
devices.add(new Device(this, device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,20 +237,23 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case Gst.MessageType.DEVICE_ADDED:
|
case Gst.MessageType.DEVICE_ADDED:
|
||||||
message.parse_device_added(out gst_device);
|
message.parse_device_added(out gst_device);
|
||||||
if (devices.any_match((it) => it.matches(gst_device))) return Source.CONTINUE;
|
if (is_skipped(gst_device)) return Source.CONTINUE;
|
||||||
device = new Device(this, gst_device);
|
device = new Device(this, gst_device);
|
||||||
|
debug(@"(Notify) Add name=$(gst_device.name) device=$(gst_device.display_name)");
|
||||||
devices.add(device);
|
devices.add(device);
|
||||||
break;
|
break;
|
||||||
#if GST_1_16
|
#if GST_1_16
|
||||||
case Gst.MessageType.DEVICE_CHANGED:
|
case Gst.MessageType.DEVICE_CHANGED:
|
||||||
message.parse_device_changed(out gst_device, out old_gst_device);
|
message.parse_device_changed(out gst_device, out old_gst_device);
|
||||||
device = devices.first_match((it) => it.matches(old_gst_device));
|
device = devices.first_match((it) => it.matches(old_gst_device));
|
||||||
|
debug(@"(Notify) Change name=$(gst_device.name) device=$(gst_device.display_name)");
|
||||||
if (device != null) device.update(gst_device);
|
if (device != null) device.update(gst_device);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case Gst.MessageType.DEVICE_REMOVED:
|
case Gst.MessageType.DEVICE_REMOVED:
|
||||||
message.parse_device_removed(out gst_device);
|
message.parse_device_removed(out gst_device);
|
||||||
device = devices.first_match((it) => it.matches(gst_device));
|
device = devices.first_match((it) => it.matches(gst_device));
|
||||||
|
debug(@"(Notify) Remove name=$(gst_device.name) device=$(gst_device.display_name)");
|
||||||
if (device != null) devices.remove(device);
|
if (device != null) devices.remove(device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue