|
@@ -2,6 +2,11 @@
|
|
|
#include "dc-capture.h"
|
|
|
|
|
|
#define TEXT_MONITOR_CAPTURE obs_module_text("MonitorCapture")
|
|
|
+#define TEXT_CAPTURE_CURSOR obs_module_text("CaptureCursor")
|
|
|
+#define TEXT_COMPATIBILITY obs_module_text("Compatibility")
|
|
|
+#define TEXT_MONITOR obs_module_text("Monitor")
|
|
|
+#define TEXT_PRIMARY_MONITOR obs_module_text("PrimaryMonitor")
|
|
|
+
|
|
|
struct monitor_capture {
|
|
|
obs_source_t *source;
|
|
|
|
|
@@ -75,6 +80,7 @@ static void update_monitor(struct monitor_capture *capture,
|
|
|
static inline void update_settings(struct monitor_capture *capture,
|
|
|
obs_data_t *settings)
|
|
|
{
|
|
|
+ capture->monitor = (int)obs_data_get_int(settings, "monitor");
|
|
|
capture->capture_cursor = obs_data_get_bool(settings, "capture_cursor");
|
|
|
capture->compatibility = obs_data_get_bool(settings, "compatibility");
|
|
|
|
|
@@ -110,6 +116,12 @@ static void monitor_capture_defaults(obs_data_t *settings)
|
|
|
obs_data_set_default_bool(settings, "compatibility", false);
|
|
|
}
|
|
|
|
|
|
+static void monitor_capture_update(void *data, obs_data_t *settings)
|
|
|
+{
|
|
|
+ struct monitor_capture *mc = data;
|
|
|
+ update_settings(mc, settings);
|
|
|
+}
|
|
|
+
|
|
|
static void *monitor_capture_create(obs_data_t *settings, obs_source_t *source)
|
|
|
{
|
|
|
struct monitor_capture *capture;
|
|
@@ -158,16 +170,85 @@ static uint32_t monitor_capture_height(void *data)
|
|
|
return capture->data.height;
|
|
|
}
|
|
|
|
|
|
+static BOOL CALLBACK enum_monitor_props(HMONITOR handle, HDC hdc, LPRECT rect,
|
|
|
+ LPARAM param)
|
|
|
+{
|
|
|
+ UNUSED_PARAMETER(hdc);
|
|
|
+ UNUSED_PARAMETER(rect);
|
|
|
+
|
|
|
+ obs_property_t *monitor_list = (obs_property_t*)param;
|
|
|
+ MONITORINFO mi;
|
|
|
+ size_t monitor_id = 0;
|
|
|
+ struct dstr monitor_desc = { 0 };
|
|
|
+ struct dstr resolution = { 0 };
|
|
|
+ struct dstr format_string = { 0 };
|
|
|
+
|
|
|
+ monitor_id = obs_property_list_item_count(monitor_list);
|
|
|
+
|
|
|
+ mi.cbSize = sizeof(mi);
|
|
|
+ GetMonitorInfo(handle, &mi);
|
|
|
+
|
|
|
+ dstr_catf(&resolution,
|
|
|
+ "%dx%d @ %d,%d",
|
|
|
+ mi.rcMonitor.right - mi.rcMonitor.left,
|
|
|
+ mi.rcMonitor.bottom - mi.rcMonitor.top,
|
|
|
+ mi.rcMonitor.left,
|
|
|
+ mi.rcMonitor.top);
|
|
|
+
|
|
|
+ dstr_copy(&format_string, "%s %d: %s");
|
|
|
+ if (mi.dwFlags == MONITORINFOF_PRIMARY) {
|
|
|
+ dstr_catf(&format_string, " (%s)", TEXT_PRIMARY_MONITOR);
|
|
|
+ }
|
|
|
+
|
|
|
+ dstr_catf(&monitor_desc,
|
|
|
+ format_string.array,
|
|
|
+ TEXT_MONITOR,
|
|
|
+ monitor_id,
|
|
|
+ resolution.array);
|
|
|
+
|
|
|
+ obs_property_list_add_int(monitor_list,
|
|
|
+ monitor_desc.array, (int)monitor_id);
|
|
|
+
|
|
|
+ dstr_free(&monitor_desc);
|
|
|
+ dstr_free(&resolution);
|
|
|
+ dstr_free(&format_string);
|
|
|
+
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+static obs_properties_t *monitor_capture_properties(void *unused)
|
|
|
+{
|
|
|
+ UNUSED_PARAMETER(unused);
|
|
|
+
|
|
|
+ obs_properties_t *props = obs_properties_create();
|
|
|
+
|
|
|
+ obs_property_t *monitors = obs_properties_add_list(props,
|
|
|
+ "monitor", TEXT_MONITOR,
|
|
|
+ OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
|
|
+
|
|
|
+ obs_property_t *compatmode = obs_properties_add_bool(props,
|
|
|
+ "compatibility", TEXT_COMPATIBILITY);
|
|
|
+
|
|
|
+ obs_property_t *capture_cursor = obs_properties_add_bool(props,
|
|
|
+ "capture_cursor", TEXT_CAPTURE_CURSOR);
|
|
|
+
|
|
|
+ EnumDisplayMonitors(NULL, NULL, enum_monitor_props, (LPARAM)monitors);
|
|
|
+
|
|
|
+ return props;
|
|
|
+}
|
|
|
+
|
|
|
struct obs_source_info monitor_capture_info = {
|
|
|
- .id = "monitor_capture",
|
|
|
- .type = OBS_SOURCE_TYPE_INPUT,
|
|
|
- .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW,
|
|
|
- .get_name = monitor_capture_getname,
|
|
|
- .create = monitor_capture_create,
|
|
|
- .destroy = monitor_capture_destroy,
|
|
|
- .video_render = monitor_capture_render,
|
|
|
- .video_tick = monitor_capture_tick,
|
|
|
- .get_width = monitor_capture_width,
|
|
|
- .get_height = monitor_capture_height,
|
|
|
- .get_defaults = monitor_capture_defaults
|
|
|
+ .id = "monitor_capture",
|
|
|
+ .type = OBS_SOURCE_TYPE_INPUT,
|
|
|
+ .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW,
|
|
|
+ .get_name = monitor_capture_getname,
|
|
|
+ .create = monitor_capture_create,
|
|
|
+ .destroy = monitor_capture_destroy,
|
|
|
+ .video_render = monitor_capture_render,
|
|
|
+ .video_tick = monitor_capture_tick,
|
|
|
+ .update = monitor_capture_update,
|
|
|
+ .get_width = monitor_capture_width,
|
|
|
+ .get_height = monitor_capture_height,
|
|
|
+ .get_defaults = monitor_capture_defaults,
|
|
|
+ .get_properties = monitor_capture_properties
|
|
|
};
|