New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -120,16 +120,15 @@ static inline void update_window_params(struct display_capture *dc)
|
|||
if (!requires_window(dc->crop))
|
||||
return;
|
||||
|
||||
NSArray *arr = (NSArray*)CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
dc->window.window_id);
|
||||
|
||||
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionIncludingWindow, dc->window.window_id);
|
||||
|
||||
if (arr.count) {
|
||||
NSDictionary *dict = arr[0];
|
||||
NSDictionary *ref = dict[(NSString*)kCGWindowBounds];
|
||||
NSDictionary *ref = dict[(NSString *)kCGWindowBounds];
|
||||
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)ref,
|
||||
&dc->window_rect);
|
||||
dc->on_screen = dict[(NSString*)kCGWindowIsOnscreen] != nil;
|
||||
&dc->window_rect);
|
||||
dc->on_screen = dict[(NSString *)kCGWindowIsOnscreen] != nil;
|
||||
dc->window_rect =
|
||||
[dc->screen convertRectToBacking:dc->window_rect];
|
||||
|
||||
|
|
@ -144,8 +143,10 @@ static inline void update_window_params(struct display_capture *dc)
|
|||
}
|
||||
|
||||
static inline void display_stream_update(struct display_capture *dc,
|
||||
CGDisplayStreamFrameStatus status, uint64_t display_time,
|
||||
IOSurfaceRef frame_surface, CGDisplayStreamUpdateRef update_ref)
|
||||
CGDisplayStreamFrameStatus status,
|
||||
uint64_t display_time,
|
||||
IOSurfaceRef frame_surface,
|
||||
CGDisplayStreamUpdateRef update_ref)
|
||||
{
|
||||
UNUSED_PARAMETER(display_time);
|
||||
UNUSED_PARAMETER(update_ref);
|
||||
|
|
@ -176,8 +177,7 @@ static inline void display_stream_update(struct display_capture *dc,
|
|||
size_t dropped_frames = CGDisplayStreamUpdateGetDropCount(update_ref);
|
||||
if (dropped_frames > 0)
|
||||
blog(LOG_INFO, "%s: Dropped %zu frames",
|
||||
obs_source_get_name(dc->source),
|
||||
dropped_frames);
|
||||
obs_source_get_name(dc->source), dropped_frames);
|
||||
}
|
||||
|
||||
static bool init_display_stream(struct display_capture *dc)
|
||||
|
|
@ -192,38 +192,34 @@ static bool init_display_stream(struct display_capture *dc)
|
|||
NSNumber *screen_num = dc->screen.deviceDescription[@"NSScreenNumber"];
|
||||
CGDirectDisplayID disp_id = (CGDirectDisplayID)screen_num.pointerValue;
|
||||
|
||||
NSDictionary *rect_dict = CFBridgingRelease(
|
||||
CGRectCreateDictionaryRepresentation(
|
||||
CGRectMake(0, 0,
|
||||
dc->screen.frame.size.width,
|
||||
dc->screen.frame.size.height)));
|
||||
NSDictionary *rect_dict =
|
||||
CFBridgingRelease(CGRectCreateDictionaryRepresentation(
|
||||
CGRectMake(0, 0, dc->screen.frame.size.width,
|
||||
dc->screen.frame.size.height)));
|
||||
|
||||
CFBooleanRef show_cursor_cf =
|
||||
dc->hide_cursor ? kCFBooleanFalse : kCFBooleanTrue;
|
||||
CFBooleanRef show_cursor_cf = dc->hide_cursor ? kCFBooleanFalse
|
||||
: kCFBooleanTrue;
|
||||
|
||||
NSDictionary *dict = @{
|
||||
(__bridge NSString*)kCGDisplayStreamSourceRect: rect_dict,
|
||||
(__bridge NSString*)kCGDisplayStreamQueueDepth: @5,
|
||||
(__bridge NSString*)kCGDisplayStreamShowCursor:
|
||||
(id)show_cursor_cf,
|
||||
(__bridge NSString *)kCGDisplayStreamSourceRect: rect_dict,
|
||||
(__bridge NSString *)kCGDisplayStreamQueueDepth: @5,
|
||||
(__bridge NSString *)
|
||||
kCGDisplayStreamShowCursor: (id)show_cursor_cf,
|
||||
};
|
||||
|
||||
os_event_init(&dc->disp_finished, OS_EVENT_TYPE_MANUAL);
|
||||
|
||||
const CGSize *size = &dc->frame.size;
|
||||
dc->disp = CGDisplayStreamCreateWithDispatchQueue(disp_id,
|
||||
size->width, size->height, 'BGRA',
|
||||
(__bridge CFDictionaryRef)dict,
|
||||
dispatch_queue_create(NULL, NULL),
|
||||
^(CGDisplayStreamFrameStatus status,
|
||||
uint64_t displayTime,
|
||||
IOSurfaceRef frameSurface,
|
||||
CGDisplayStreamUpdateRef updateRef)
|
||||
{
|
||||
display_stream_update(dc, status, displayTime,
|
||||
frameSurface, updateRef);
|
||||
}
|
||||
);
|
||||
dc->disp = CGDisplayStreamCreateWithDispatchQueue(
|
||||
disp_id, size->width, size->height, 'BGRA',
|
||||
(__bridge CFDictionaryRef)dict,
|
||||
dispatch_queue_create(NULL, NULL),
|
||||
^(CGDisplayStreamFrameStatus status, uint64_t displayTime,
|
||||
IOSurfaceRef frameSurface,
|
||||
CGDisplayStreamUpdateRef updateRef) {
|
||||
display_stream_update(dc, status, displayTime,
|
||||
frameSurface, updateRef);
|
||||
});
|
||||
|
||||
return !CGDisplayStreamStart(dc->disp);
|
||||
}
|
||||
|
|
@ -252,8 +248,7 @@ bool init_vertbuf(struct display_capture *dc)
|
|||
|
||||
void load_crop(struct display_capture *dc, obs_data_t *settings);
|
||||
|
||||
static void *display_capture_create(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
static void *display_capture_create(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
UNUSED_PARAMETER(source);
|
||||
UNUSED_PARAMETER(settings);
|
||||
|
|
@ -303,25 +298,24 @@ fail:
|
|||
}
|
||||
|
||||
static void build_sprite(struct gs_vb_data *data, float fcx, float fcy,
|
||||
float start_u, float end_u, float start_v, float end_v)
|
||||
float start_u, float end_u, float start_v, float end_v)
|
||||
{
|
||||
struct vec2 *tvarray = data->tvarray[0].array;
|
||||
|
||||
vec3_set(data->points+1, fcx, 0.0f, 0.0f);
|
||||
vec3_set(data->points+2, 0.0f, fcy, 0.0f);
|
||||
vec3_set(data->points+3, fcx, fcy, 0.0f);
|
||||
vec2_set(tvarray, start_u, start_v);
|
||||
vec2_set(tvarray+1, end_u, start_v);
|
||||
vec2_set(tvarray+2, start_u, end_v);
|
||||
vec2_set(tvarray+3, end_u, end_v);
|
||||
vec3_set(data->points + 1, fcx, 0.0f, 0.0f);
|
||||
vec3_set(data->points + 2, 0.0f, fcy, 0.0f);
|
||||
vec3_set(data->points + 3, fcx, fcy, 0.0f);
|
||||
vec2_set(tvarray, start_u, start_v);
|
||||
vec2_set(tvarray + 1, end_u, start_v);
|
||||
vec2_set(tvarray + 2, start_u, end_v);
|
||||
vec2_set(tvarray + 3, end_u, end_v);
|
||||
}
|
||||
|
||||
static inline void build_sprite_rect(struct gs_vb_data *data,
|
||||
float origin_x, float origin_y, float end_x, float end_y)
|
||||
static inline void build_sprite_rect(struct gs_vb_data *data, float origin_x,
|
||||
float origin_y, float end_x, float end_y)
|
||||
{
|
||||
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
||||
origin_x, end_x,
|
||||
origin_y, end_y);
|
||||
origin_x, end_x, origin_y, end_y);
|
||||
}
|
||||
|
||||
static void display_capture_video_tick(void *data, float seconds)
|
||||
|
|
@ -348,8 +342,8 @@ static void display_capture_video_tick(void *data, float seconds)
|
|||
if (requires_window(dc->crop) && !dc->on_screen)
|
||||
goto cleanup;
|
||||
|
||||
CGPoint origin = { 0.f };
|
||||
CGPoint end = { 0.f };
|
||||
CGPoint origin = {0.f};
|
||||
CGPoint end = {0.f};
|
||||
|
||||
switch (dc->crop) {
|
||||
float x, y;
|
||||
|
|
@ -379,10 +373,9 @@ static void display_capture_video_tick(void *data, float seconds)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
obs_enter_graphics();
|
||||
build_sprite_rect(gs_vertexbuffer_get_data(dc->vertbuf),
|
||||
origin.x, origin.y, end.x, end.y);
|
||||
build_sprite_rect(gs_vertexbuffer_get_data(dc->vertbuf), origin.x,
|
||||
origin.y, end.x, end.y);
|
||||
|
||||
if (dc->tex)
|
||||
gs_texture_rebind_iosurface(dc->tex, dc->prev);
|
||||
|
|
@ -412,7 +405,7 @@ static void display_capture_video_render(void *data, gs_effect_t *effect)
|
|||
gs_load_samplerstate(dc->sampler, 0);
|
||||
gs_technique_t *tech = gs_effect_get_technique(dc->effect, "Draw");
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(dc->effect, "image"),
|
||||
dc->tex);
|
||||
dc->tex);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
|
|
@ -428,9 +421,9 @@ static const char *display_capture_getname(void *unused)
|
|||
return obs_module_text("DisplayCapture");
|
||||
}
|
||||
|
||||
#define CROPPED_LENGTH(rect, origin_, length) \
|
||||
fabs((rect ## .size. ## length - dc->crop_rect.size. ## length) - \
|
||||
(rect ## .origin. ## origin_ + dc->crop_rect.origin. ## origin_))
|
||||
#define CROPPED_LENGTH(rect, origin_, length) \
|
||||
fabs((rect##.size.##length - dc->crop_rect.size.##length) - \
|
||||
(rect##.origin.##origin_ + dc->crop_rect.origin.##origin_))
|
||||
|
||||
static uint32_t display_capture_getwidth(void *data)
|
||||
{
|
||||
|
|
@ -502,20 +495,20 @@ void load_crop(struct display_capture *dc, obs_data_t *settings)
|
|||
|
||||
#define CROP_VAR_NAME(var, mode) (mode "." #var)
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
dc->crop_rect.var = obs_data_get_double(settings, \
|
||||
CROP_VAR_NAME(var, mode));
|
||||
dc->crop_rect.var = \
|
||||
obs_data_get_double(settings, CROP_VAR_NAME(var, mode));
|
||||
switch (dc->crop) {
|
||||
case CROP_MANUAL:
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
break;
|
||||
|
||||
case CROP_TO_WINDOW_AND_MANUAL:
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
break;
|
||||
|
||||
|
|
@ -552,7 +545,7 @@ static void display_capture_update(void *data, obs_data_t *settings)
|
|||
}
|
||||
|
||||
static bool switch_crop_mode(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
|
||||
|
|
@ -561,20 +554,20 @@ static bool switch_crop_mode(obs_properties_t *props, obs_property_t *p,
|
|||
|
||||
const char *name;
|
||||
bool visible;
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
name = CROP_VAR_NAME(var, mode); \
|
||||
obs_property_set_visible(obs_properties_get(props, name), visible);
|
||||
|
||||
visible = crop == CROP_MANUAL;
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
|
||||
visible = crop == CROP_TO_WINDOW_AND_MANUAL;
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
#undef LOAD_CROP_VAR
|
||||
|
||||
|
|
@ -582,15 +575,12 @@ static bool switch_crop_mode(obs_properties_t *props, obs_property_t *p,
|
|||
return true;
|
||||
}
|
||||
|
||||
static const char *crop_names[] = {
|
||||
"CropMode.None",
|
||||
"CropMode.Manual",
|
||||
"CropMode.ToWindow",
|
||||
"CropMode.ToWindowAndManual"
|
||||
};
|
||||
static const char *crop_names[] = {"CropMode.None", "CropMode.Manual",
|
||||
"CropMode.ToWindow",
|
||||
"CropMode.ToWindowAndManual"};
|
||||
|
||||
#ifndef COUNTOF
|
||||
#define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
|
||||
#define COUNTOF(x) (sizeof(x) / sizeof(x[0]))
|
||||
#endif
|
||||
static obs_properties_t *display_capture_properties(void *unused)
|
||||
{
|
||||
|
|
@ -598,9 +588,9 @@ static obs_properties_t *display_capture_properties(void *unused)
|
|||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
||||
obs_property_t *list = obs_properties_add_list(props,
|
||||
"display", obs_module_text("DisplayCapture.Display"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *list = obs_properties_add_list(
|
||||
props, "display", obs_module_text("DisplayCapture.Display"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
||||
for (unsigned i = 0; i < [NSScreen screens].count; i++) {
|
||||
char buf[10];
|
||||
|
|
@ -609,11 +599,11 @@ static obs_properties_t *display_capture_properties(void *unused)
|
|||
}
|
||||
|
||||
obs_properties_add_bool(props, "show_cursor",
|
||||
obs_module_text("DisplayCapture.ShowCursor"));
|
||||
obs_module_text("DisplayCapture.ShowCursor"));
|
||||
|
||||
obs_property_t *crop = obs_properties_add_list(props, "crop_mode",
|
||||
obs_module_text("CropMode"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *crop = obs_properties_add_list(
|
||||
props, "crop_mode", obs_module_text("CropMode"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_set_modified_callback(crop, switch_crop_mode);
|
||||
|
||||
for (unsigned i = 0; i < COUNTOF(crop_names); i++) {
|
||||
|
|
@ -627,22 +617,22 @@ static obs_properties_t *display_capture_properties(void *unused)
|
|||
obs_property_t *p;
|
||||
const char *name;
|
||||
float min;
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
name = CROP_VAR_NAME(var, mode); \
|
||||
p = obs_properties_add_float(props, name, \
|
||||
obs_module_text("Crop."#var), min, 4096.f, .5f); \
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
name = CROP_VAR_NAME(var, mode); \
|
||||
p = obs_properties_add_float( \
|
||||
props, name, obs_module_text("Crop." #var), min, 4096.f, .5f); \
|
||||
obs_property_set_visible(p, false);
|
||||
|
||||
min = 0.f;
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
|
||||
min = -4096.f;
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
#undef LOAD_CROP_VAR
|
||||
|
||||
|
|
@ -650,22 +640,22 @@ static obs_properties_t *display_capture_properties(void *unused)
|
|||
}
|
||||
|
||||
struct obs_source_info display_capture_info = {
|
||||
.id = "display_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = display_capture_getname,
|
||||
.id = "display_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = display_capture_getname,
|
||||
|
||||
.create = display_capture_create,
|
||||
.destroy = display_capture_destroy,
|
||||
.create = display_capture_create,
|
||||
.destroy = display_capture_destroy,
|
||||
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.video_tick = display_capture_video_tick,
|
||||
.video_render = display_capture_video_render,
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.video_tick = display_capture_video_tick,
|
||||
.video_render = display_capture_video_render,
|
||||
|
||||
.get_width = display_capture_getwidth,
|
||||
.get_height = display_capture_getheight,
|
||||
.get_width = display_capture_getwidth,
|
||||
.get_height = display_capture_getheight,
|
||||
|
||||
.get_defaults = display_capture_defaults,
|
||||
.get_defaults = display_capture_defaults,
|
||||
.get_properties = display_capture_properties,
|
||||
.update = display_capture_update,
|
||||
.update = display_capture_update,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue