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
|
|
@ -21,61 +21,59 @@ struct window_capture {
|
|||
|
||||
DARRAY(uint8_t) buffer;
|
||||
|
||||
pthread_t capture_thread;
|
||||
pthread_t capture_thread;
|
||||
os_event_t *capture_event;
|
||||
os_event_t *stop_event;
|
||||
};
|
||||
|
||||
static CGImageRef get_image(struct window_capture *wc)
|
||||
{
|
||||
NSArray *arr = (NSArray*)CGWindowListCreate(
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id);
|
||||
NSArray *arr = (NSArray *)CGWindowListCreate(
|
||||
kCGWindowListOptionIncludingWindow, wc->window.window_id);
|
||||
[arr autorelease];
|
||||
|
||||
if (arr.count)
|
||||
return CGWindowListCreateImage(CGRectNull,
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
return CGWindowListCreateImage(
|
||||
CGRectNull, kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
|
||||
if (!find_window(&wc->window, NULL, false))
|
||||
return NULL;
|
||||
|
||||
return CGWindowListCreateImage(CGRectNull,
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
}
|
||||
|
||||
static inline void capture_frame(struct window_capture *wc)
|
||||
{
|
||||
uint64_t ts = os_gettime_ns();
|
||||
uint64_t ts = os_gettime_ns();
|
||||
CGImageRef img = get_image(wc);
|
||||
if (!img)
|
||||
return;
|
||||
|
||||
size_t width = CGImageGetWidth(img);
|
||||
size_t width = CGImageGetWidth(img);
|
||||
size_t height = CGImageGetHeight(img);
|
||||
|
||||
CGRect rect = {{0, 0}, {width, height}};
|
||||
da_reserve(wc->buffer, width * height * 4);
|
||||
uint8_t *data = wc->buffer.array;
|
||||
|
||||
CGContextRef cg_context = CGBitmapContextCreate(data, width, height,
|
||||
8, width * 4, wc->color_space,
|
||||
kCGBitmapByteOrder32Host |
|
||||
kCGImageAlphaPremultipliedFirst);
|
||||
CGContextRef cg_context = CGBitmapContextCreate(
|
||||
data, width, height, 8, width * 4, wc->color_space,
|
||||
kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
||||
CGContextSetBlendMode(cg_context, kCGBlendModeCopy);
|
||||
CGContextDrawImage(cg_context, rect, img);
|
||||
CGContextRelease(cg_context);
|
||||
CGImageRelease(img);
|
||||
|
||||
struct obs_source_frame frame = {
|
||||
.format = VIDEO_FORMAT_BGRA,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.data[0] = data,
|
||||
.format = VIDEO_FORMAT_BGRA,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.data[0] = data,
|
||||
.linesize[0] = width * 4,
|
||||
.timestamp = ts,
|
||||
.timestamp = ts,
|
||||
};
|
||||
|
||||
obs_source_output_video(wc->source, &frame);
|
||||
|
|
@ -99,7 +97,7 @@ static void *capture_thread(void *data)
|
|||
}
|
||||
|
||||
static inline void *window_capture_create_internal(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
obs_source_t *source)
|
||||
{
|
||||
struct window_capture *wc = bzalloc(sizeof(struct window_capture));
|
||||
|
||||
|
|
@ -111,8 +109,9 @@ static inline void *window_capture_create_internal(obs_data_t *settings,
|
|||
|
||||
init_window(&wc->window, settings);
|
||||
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow") ?
|
||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow")
|
||||
? kCGWindowImageDefault
|
||||
: kCGWindowImageBoundsIgnoreFraming;
|
||||
|
||||
os_event_init(&wc->capture_event, OS_EVENT_TYPE_AUTO);
|
||||
os_event_init(&wc->stop_event, OS_EVENT_TYPE_MANUAL);
|
||||
|
|
@ -135,7 +134,7 @@ static void window_capture_destroy(void *data)
|
|||
|
||||
os_event_signal(cap->stop_event);
|
||||
os_event_signal(cap->capture_event);
|
||||
|
||||
|
||||
pthread_join(cap->capture_thread, NULL);
|
||||
|
||||
CGColorSpaceRelease(cap->color_space);
|
||||
|
|
@ -165,26 +164,28 @@ static obs_properties_t *window_capture_properties(void *unused)
|
|||
add_window_properties(props);
|
||||
|
||||
obs_properties_add_bool(props, "show_shadow",
|
||||
obs_module_text("WindowCapture.ShowShadow"));
|
||||
obs_module_text("WindowCapture.ShowShadow"));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
static inline void window_capture_update_internal(struct window_capture *wc,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow") ?
|
||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow")
|
||||
? kCGWindowImageDefault
|
||||
: kCGWindowImageBoundsIgnoreFraming;
|
||||
|
||||
update_window(&wc->window, settings);
|
||||
|
||||
if (wc->window.window_name.length) {
|
||||
blog(LOG_INFO, "[window-capture: '%s'] update settings:\n"
|
||||
"\twindow: %s\n"
|
||||
"\towner: %s",
|
||||
obs_source_get_name(wc->source),
|
||||
[wc->window.window_name UTF8String],
|
||||
[wc->window.owner_name UTF8String]);
|
||||
blog(LOG_INFO,
|
||||
"[window-capture: '%s'] update settings:\n"
|
||||
"\twindow: %s\n"
|
||||
"\towner: %s",
|
||||
obs_source_get_name(wc->source),
|
||||
[wc->window.window_name UTF8String],
|
||||
[wc->window.owner_name UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ static const char *window_capture_getname(void *unused)
|
|||
}
|
||||
|
||||
static inline void window_capture_tick_internal(struct window_capture *wc,
|
||||
float seconds)
|
||||
float seconds)
|
||||
{
|
||||
UNUSED_PARAMETER(seconds);
|
||||
os_event_signal(wc->capture_event);
|
||||
|
|
@ -221,17 +222,17 @@ static void window_capture_tick(void *data, float seconds)
|
|||
}
|
||||
|
||||
struct obs_source_info window_capture_info = {
|
||||
.id = "window_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = window_capture_getname,
|
||||
.id = "window_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = window_capture_getname,
|
||||
|
||||
.create = window_capture_create,
|
||||
.destroy = window_capture_destroy,
|
||||
.create = window_capture_create,
|
||||
.destroy = window_capture_destroy,
|
||||
|
||||
.output_flags = OBS_SOURCE_ASYNC_VIDEO,
|
||||
.video_tick = window_capture_tick,
|
||||
.output_flags = OBS_SOURCE_ASYNC_VIDEO,
|
||||
.video_tick = window_capture_tick,
|
||||
|
||||
.get_defaults = window_capture_defaults,
|
||||
.get_defaults = window_capture_defaults,
|
||||
.get_properties = window_capture_properties,
|
||||
.update = window_capture_update,
|
||||
.update = window_capture_update,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue