mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 11:49:59 +01:00
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:
@@ -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();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "GstToolkit.h"
|
||||
#include "StreamSource.h"
|
||||
|
||||
class DeviceSource : public StreamSource
|
||||
@@ -53,19 +52,6 @@ struct DeviceConfig {
|
||||
format = "";
|
||||
}
|
||||
|
||||
inline DeviceConfig& operator = (const DeviceConfig& b)
|
||||
{
|
||||
if (this != &b) {
|
||||
this->width = b.width;
|
||||
this->height = b.height;
|
||||
this->fps_numerator = b.fps_numerator;
|
||||
this->fps_denominator = b.fps_denominator;
|
||||
this->stream = b.stream;
|
||||
this->format = b.format;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator < (const DeviceConfig b) const
|
||||
{
|
||||
int formatscore = this->format.find("R") != std::string::npos ? 2 : 1; // best score for RGBx
|
||||
@@ -124,6 +110,7 @@ public:
|
||||
|
||||
int index (const std::string &device);
|
||||
bool exists (const std::string &device) ;
|
||||
void reload ();
|
||||
|
||||
static gboolean callback_device_monitor (GstBus *, GstMessage *, gpointer);
|
||||
static DeviceConfigSet getDeviceConfigs(const std::string &src_description);
|
||||
|
||||
@@ -86,7 +86,7 @@ std::string Loopback::init(GstCaps *caps)
|
||||
return std::string("Loopback : Invalid caps");
|
||||
|
||||
// create a gstreamer pipeline
|
||||
std::string description = "appsrc name=src ! videoconvert ! ";
|
||||
std::string description = "appsrc name=src ! videoconvert ! queue ! ";
|
||||
|
||||
// complement pipeline with sink
|
||||
description += Loopback::loopback_sink_ + " name=sink";
|
||||
|
||||
@@ -4377,6 +4377,10 @@ void OutputPreview::Render()
|
||||
ImGui::SetCursorPos(draw_pos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("No active streams", nullptr, false, false);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -7484,6 +7488,9 @@ void Navigator::RenderNewPannel()
|
||||
// Indication
|
||||
ImGui::SameLine();
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
if (ImGuiToolkit::IconButton(5,15,"Reload list"))
|
||||
Device::manager().reload();
|
||||
ImGui::SameLine();
|
||||
ImGuiToolkit::HelpToolTip("Create a source capturing video streams from connected devices or machines;\n"
|
||||
ICON_FA_CARET_RIGHT " webcams or frame grabbers\n"
|
||||
ICON_FA_CARET_RIGHT " screen capture\n"
|
||||
|
||||
Reference in New Issue
Block a user