Improved Device support for V4L2 streams

Allow to reload list of devices, avoid timestamp warning in Loopback, clear UI menu.
This commit is contained in:
Bruno Herbelin
2023-03-26 17:36:18 +02:00
parent 85a25a0a39
commit c9cf6baf4b
4 changed files with 20 additions and 16 deletions

View File

@@ -203,7 +203,7 @@ void Device::remove(GstDevice *device)
g_free (device_name);
}
Device::Device(): monitor_initialized_(false), monitor_unplug_event_(false)
Device::Device(): monitor_(nullptr), monitor_initialized_(false), monitor_unplug_event_(false)
{
std::thread(launchMonitoring, this).detach();
}
@@ -212,6 +212,7 @@ void Device::launchMonitoring(Device *d)
{
// gstreamer monitoring of devices
d->monitor_ = gst_device_monitor_new ();
gst_device_monitor_set_show_all_devices(d->monitor_, true);
// watching all video stream sources
GstCaps *caps = gst_caps_new_empty_simple ("video/x-raw");
@@ -280,6 +281,15 @@ bool Device::initialized()
return Device::manager().monitor_initialized_;
}
void Device::reload()
{
if (monitor_ != nullptr) {
gst_device_monitor_stop(monitor_);
if ( !gst_device_monitor_start (monitor_) )
Log::Info("Device discovery start failed.");
}
}
int Device::numDevices()
{
access_.lock();