Allow devices with properties and use has_classes
This commit is contained in:
parent
96fbbdd8bb
commit
d7118c1b93
|
@ -17,19 +17,19 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
||||||
return plugin.pipe;
|
return plugin.pipe;
|
||||||
}}
|
}}
|
||||||
public string? media { get {
|
public string? media { get {
|
||||||
if (device.device_class.has_prefix("Audio/")) {
|
if (device.has_classes("Audio")) {
|
||||||
return "audio";
|
return "audio";
|
||||||
} else if (device.device_class.has_prefix("Video/")) {
|
} else if (device.has_classes("Video")) {
|
||||||
return "video";
|
return "video";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
public bool is_source { get {
|
public bool is_source { get {
|
||||||
return device.device_class.has_suffix("/Source");
|
return device.has_classes("Source");
|
||||||
}}
|
}}
|
||||||
public bool is_sink { get {
|
public bool is_sink { get {
|
||||||
return device.device_class.has_suffix("/Sink");
|
return device.has_classes("Sink");
|
||||||
}}
|
}}
|
||||||
|
|
||||||
private Gst.Element element;
|
private Gst.Element element;
|
||||||
|
|
|
@ -48,11 +48,13 @@ 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.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) continue;
|
if (device.properties != null) {
|
||||||
if (device.properties.get_string("device.api") == "wasapi") continue;
|
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) continue;
|
||||||
if (device.properties.get_string("device.class") == "monitor") continue;
|
if (device.properties.get_string("device.api") == "wasapi") continue;
|
||||||
if (devices.any_match((it) => it.matches(device))) continue;
|
if (device.properties.get_string("device.class") == "monitor") continue;
|
||||||
devices.add(new Device(this, device));
|
if (devices.any_match((it) => it.matches(device))) continue;
|
||||||
|
devices.add(new Device(this, device));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe = new Gst.Pipeline(null);
|
pipe = new Gst.Pipeline(null);
|
||||||
|
@ -186,6 +188,7 @@ 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 device);
|
message.parse_device_added(out device);
|
||||||
|
if (device.properties == null) return Source.CONTINUE;
|
||||||
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
||||||
|
@ -195,6 +198,7 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
#if GST_1_16
|
#if GST_1_16
|
||||||
case Gst.MessageType.DEVICE_CHANGED:
|
case Gst.MessageType.DEVICE_CHANGED:
|
||||||
message.parse_device_changed(out device, out old_device);
|
message.parse_device_changed(out device, out old_device);
|
||||||
|
if (device.properties == null) return Source.CONTINUE;
|
||||||
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
||||||
|
@ -204,6 +208,7 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
#endif
|
#endif
|
||||||
case Gst.MessageType.DEVICE_REMOVED:
|
case Gst.MessageType.DEVICE_REMOVED:
|
||||||
message.parse_device_removed(out device);
|
message.parse_device_removed(out device);
|
||||||
|
if (device.properties == null) return Source.CONTINUE;
|
||||||
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
if (device.properties.has_name("pipewire-proplist") && device.device_class.has_prefix("Audio/")) return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
if (device.properties.get_string("device.api") == "wasapi") return Source.CONTINUE;
|
||||||
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
if (device.properties.get_string("device.class") == "monitor") return Source.CONTINUE;
|
||||||
|
@ -212,19 +217,22 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
switch (device.device_class) {
|
string type = null;
|
||||||
case "Audio/Source":
|
if (device.has_classes("Audio")) {
|
||||||
devices_changed("audio", false);
|
type = "audio";
|
||||||
break;
|
} else if (device.has_classes("Video")) {
|
||||||
case "Audio/Sink":
|
type = "video";
|
||||||
devices_changed("audio", true);
|
}
|
||||||
break;
|
|
||||||
case "Video/Source":
|
bool? is_sink = null;
|
||||||
devices_changed("video", false);
|
if (device.has_classes("Source")) {
|
||||||
break;
|
is_sink = false;
|
||||||
case "Video/Sink":
|
} else if (device.has_classes("Sink")) {
|
||||||
devices_changed("video", true);
|
is_sink = true;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
if (type != null && is_sink != null) {
|
||||||
|
devices_changed(type, is_sink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Source.CONTINUE;
|
return Source.CONTINUE;
|
||||||
|
|
Loading…
Reference in a new issue