Add source properties window (very preliminary)
- Add a properties window for sources so that you can now actually edit the settings for sources. Also, display the source by itself in the window (Note: not working on mac, and possibly not working on linux). When changing the settings for a source, it will call obs_source_update on that source when you have modified any values automatically. - Add a properties 'widget', eventually I want to turn this in to a regular nice properties view like you'd see in the designer, but right now it just uses a form layout in a QScrollArea with regular controls to display the properties. It's clunky but works for the time being. - Make it so that swap chains and the main graphics subsystem will automatically use at least one backbuffer if none was specified - Fix bug where displays weren't added to the main display array - Make it so that you can get the properties of a source via the actual pointer of a source/encoder/output in addition to being able to look up properties via identifier. - When registering source types, check for required functions (wasn't doing it before). getheight/getwidth should not be optional if it's a video source as well. - Add an RAII OBSObj wrapper to obs.hpp for non-reference-counted libobs pointers - Add an RAII OBSSignal wrapper to obs.hpp for libobs signals to automatically disconnect them on destruction - Move the "scale and center" calculation in window-basic-main.cpp to its own function and in its own source file - Add an 'update' callback to WASAPI audio sources
This commit is contained in:
parent
6c904650b3
commit
d9251f9e87
26 changed files with 991 additions and 74 deletions
|
|
@ -44,6 +44,8 @@ class WASAPISource {
|
|||
|
||||
bool ProcessCaptureData();
|
||||
|
||||
inline void Start();
|
||||
inline void Stop();
|
||||
void Reconnect();
|
||||
|
||||
bool InitDevice(IMMDeviceEnumerator *enumerator);
|
||||
|
|
@ -55,11 +57,13 @@ class WASAPISource {
|
|||
|
||||
bool TryInitialize();
|
||||
|
||||
void UpdateSettings(obs_data_t settings);
|
||||
|
||||
public:
|
||||
WASAPISource(obs_data_t settings, obs_source_t source_, bool input);
|
||||
inline ~WASAPISource();
|
||||
|
||||
void UpdateSettings(obs_data_t settings);
|
||||
void Update(obs_data_t settings);
|
||||
};
|
||||
|
||||
WASAPISource::WASAPISource(obs_data_t settings, obs_source_t source_,
|
||||
|
|
@ -81,6 +85,11 @@ WASAPISource::WASAPISource(obs_data_t settings, obs_source_t source_,
|
|||
if (!receiveSignal.Valid())
|
||||
throw "Could not create receive signal";
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
inline void WASAPISource::Start()
|
||||
{
|
||||
if (!TryInitialize()) {
|
||||
blog(LOG_INFO, "[WASAPISource::WASAPISource] "
|
||||
"Device '%s' not found. Waiting for device",
|
||||
|
|
@ -89,18 +98,25 @@ WASAPISource::WASAPISource(obs_data_t settings, obs_source_t source_,
|
|||
}
|
||||
}
|
||||
|
||||
inline WASAPISource::~WASAPISource()
|
||||
inline void WASAPISource::Stop()
|
||||
{
|
||||
if (active)
|
||||
blog(LOG_INFO, "WASAPI: Device '%s' Terminated",
|
||||
device_name.c_str());
|
||||
|
||||
SetEvent(stopSignal);
|
||||
|
||||
if (active)
|
||||
if (active) {
|
||||
blog(LOG_INFO, "WASAPI: Device '%s' Terminated",
|
||||
device_name.c_str());
|
||||
WaitForSingleObject(captureThread, INFINITE);
|
||||
}
|
||||
|
||||
if (reconnecting)
|
||||
WaitForSingleObject(reconnectThread, INFINITE);
|
||||
|
||||
ResetEvent(stopSignal);
|
||||
}
|
||||
|
||||
inline WASAPISource::~WASAPISource()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
void WASAPISource::UpdateSettings(obs_data_t settings)
|
||||
|
|
@ -110,6 +126,20 @@ void WASAPISource::UpdateSettings(obs_data_t settings)
|
|||
isDefaultDevice = _strcmpi(device_id.c_str(), "default") == 0;
|
||||
}
|
||||
|
||||
void WASAPISource::Update(obs_data_t settings)
|
||||
{
|
||||
string newDevice = obs_data_getstring(settings, "device_id");
|
||||
bool restart = newDevice.compare(device_id) != 0;
|
||||
|
||||
if (restart)
|
||||
Stop();
|
||||
|
||||
UpdateSettings(settings);
|
||||
|
||||
if (restart)
|
||||
Start();
|
||||
}
|
||||
|
||||
bool WASAPISource::InitDevice(IMMDeviceEnumerator *enumerator)
|
||||
{
|
||||
HRESULT res;
|
||||
|
|
@ -431,6 +461,11 @@ static void DestroyWASAPISource(void *obj)
|
|||
delete static_cast<WASAPISource*>(obj);
|
||||
}
|
||||
|
||||
static void UpdateWASAPISource(void *obj, obs_data_t settings)
|
||||
{
|
||||
static_cast<WASAPISource*>(obj)->Update(settings);
|
||||
}
|
||||
|
||||
static obs_properties_t GetWASAPIProperties(const char *locale, bool input)
|
||||
{
|
||||
obs_properties_t props = obs_properties_create();
|
||||
|
|
@ -477,6 +512,7 @@ void RegisterWASAPIInput()
|
|||
info.getname = GetWASAPIInputName;
|
||||
info.create = CreateWASAPIInput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.defaults = GetWASAPIDefaults;
|
||||
info.properties = GetWASAPIPropertiesInput;
|
||||
obs_register_source(&info);
|
||||
|
|
@ -491,6 +527,7 @@ void RegisterWASAPIOutput()
|
|||
info.getname = GetWASAPIOutputName;
|
||||
info.create = CreateWASAPIOutput;
|
||||
info.destroy = DestroyWASAPISource;
|
||||
info.update = UpdateWASAPISource;
|
||||
info.defaults = GetWASAPIDefaults;
|
||||
info.properties = GetWASAPIPropertiesOutput;
|
||||
obs_register_source(&info);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue