Apply clang-format to objective c code
parent
617086b040
commit
ad85a9fa25
|
@ -1,6 +1,5 @@
|
||||||
# please use clang-format version 8 or later
|
# please use clang-format version 8 or later
|
||||||
|
|
||||||
Language: Cpp
|
|
||||||
Standard: Cpp11
|
Standard: Cpp11
|
||||||
AccessModifierOffset: -8
|
AccessModifierOffset: -8
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
|
@ -104,3 +103,5 @@ TabWidth: 8
|
||||||
#TypenameMacros: # requires clang-format 9
|
#TypenameMacros: # requires clang-format 9
|
||||||
# - 'DARRAY'
|
# - 'DARRAY'
|
||||||
UseTab: ForContinuationAndIndentation
|
UseTab: ForContinuationAndIndentation
|
||||||
|
---
|
||||||
|
Language: ObjC
|
||||||
|
|
|
@ -150,12 +150,13 @@ void EnableOSXVSync(bool enable)
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
void *quartzCore = dlopen("/System/Library/Frameworks/"
|
void *quartzCore = dlopen("/System/Library/Frameworks/"
|
||||||
"QuartzCore.framework/QuartzCore", RTLD_LAZY);
|
"QuartzCore.framework/QuartzCore",
|
||||||
|
RTLD_LAZY);
|
||||||
if (quartzCore) {
|
if (quartzCore) {
|
||||||
set_debug_options = (set_int_t)dlsym(quartzCore,
|
set_debug_options = (set_int_t)dlsym(
|
||||||
"CGSSetDebugOptions");
|
quartzCore, "CGSSetDebugOptions");
|
||||||
deferred_updates = (set_int_t)dlsym(quartzCore,
|
deferred_updates = (set_int_t)dlsym(
|
||||||
"CGSDeferredUpdates");
|
quartzCore, "CGSDeferredUpdates");
|
||||||
|
|
||||||
valid = set_debug_options && deferred_updates;
|
valid = set_debug_options && deferred_updates;
|
||||||
}
|
}
|
||||||
|
@ -174,5 +175,6 @@ void EnableOSXDockIcon(bool enable)
|
||||||
if (enable)
|
if (enable)
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
else
|
else
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
|
[NSApp setActivationPolicy:
|
||||||
|
NSApplicationActivationPolicyProhibited];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,13 @@ static inline bool equali(NSString *a, NSString *b)
|
||||||
return a && b && [a caseInsensitiveCompare:b] == NSOrderedSame;
|
return a && b && [a caseInsensitiveCompare:b] == NSOrderedSame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface OBSSparkleUpdateDelegate :
|
@interface OBSSparkleUpdateDelegate
|
||||||
NSObject<SUUpdaterDelegate, SUVersionComparison>
|
: NSObject <SUUpdaterDelegate, SUVersionComparison> {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
@property (nonatomic) bool updateToUndeployed;
|
@property (nonatomic) bool updateToUndeployed;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation OBSSparkleUpdateDelegate
|
@implementation OBSSparkleUpdateDelegate {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize updateToUndeployed;
|
@synthesize updateToUndeployed;
|
||||||
|
@ -53,8 +51,8 @@ static inline bool equali(NSString *a, NSString *b)
|
||||||
dictionaryWithDictionary:item.propertiesDictionary];
|
dictionaryWithDictionary:item.propertiesDictionary];
|
||||||
NSString *build = [host objectForInfoDictionaryKey:@"CFBundleVersion"];
|
NSString *build = [host objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||||
NSString *url = dict[@"sparkle:releaseNotesLink"];
|
NSString *url = dict[@"sparkle:releaseNotesLink"];
|
||||||
dict[@"sparkle:releaseNotesLink"] = [url stringByAppendingFormat:@"#%@",
|
dict[@"sparkle:releaseNotesLink"] =
|
||||||
build];
|
[url stringByAppendingFormat:@"#%@", build];
|
||||||
|
|
||||||
return [[SUAppcastItem alloc] initWithDictionary:dict];
|
return [[SUAppcastItem alloc] initWithDictionary:dict];
|
||||||
}
|
}
|
||||||
|
@ -62,8 +60,8 @@ static inline bool equali(NSString *a, NSString *b)
|
||||||
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast
|
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast
|
||||||
forUpdater:(SUUpdater *)updater
|
forUpdater:(SUUpdater *)updater
|
||||||
{
|
{
|
||||||
SUAppcastItem *selected =
|
SUAppcastItem *selected = [self
|
||||||
[self bestValidUpdateWithDeltasInAppcast:appcast
|
bestValidUpdateWithDeltasInAppcast:appcast
|
||||||
forUpdater:updater];
|
forUpdater:updater];
|
||||||
|
|
||||||
NSBundle *host = updater.hostBundle;
|
NSBundle *host = updater.hostBundle;
|
||||||
|
@ -91,8 +89,8 @@ static inline bool equali(NSString *a, NSString *b)
|
||||||
return NSOrderedSame;
|
return NSOrderedSame;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <SUVersionComparison>)
|
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)__unused
|
||||||
versionComparatorForUpdater:(SUUpdater *)__unused updater
|
updater
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -141,4 +139,3 @@ void trigger_sparkle_update()
|
||||||
{
|
{
|
||||||
[updater checkForUpdates:nil];
|
[updater checkForUpdates:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,8 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
|
||||||
//#include "util/darray.h"
|
//#include "util/darray.h"
|
||||||
|
|
||||||
|
|
||||||
struct gl_windowinfo {
|
struct gl_windowinfo {
|
||||||
NSView *view;
|
NSView *view;
|
||||||
};
|
};
|
||||||
|
@ -38,8 +36,14 @@ static NSOpenGLContext *gl_context_create(void)
|
||||||
unsigned attrib_count = 0;
|
unsigned attrib_count = 0;
|
||||||
|
|
||||||
#define ADD_ATTR(x) \
|
#define ADD_ATTR(x) \
|
||||||
{ attributes[attrib_count++] = (NSOpenGLPixelFormatAttribute)x; }
|
{ \
|
||||||
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
attributes[attrib_count++] = (NSOpenGLPixelFormatAttribute)x; \
|
||||||
|
}
|
||||||
|
#define ADD_ATTR2(x, y) \
|
||||||
|
{ \
|
||||||
|
ADD_ATTR(x); \
|
||||||
|
ADD_ATTR(y); \
|
||||||
|
}
|
||||||
|
|
||||||
NSOpenGLPixelFormatAttribute attributes[40];
|
NSOpenGLPixelFormatAttribute attributes[40];
|
||||||
|
|
||||||
|
@ -182,8 +186,10 @@ void device_present(gs_device_t *device)
|
||||||
void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
|
void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
|
||||||
uint32_t *height)
|
uint32_t *height)
|
||||||
{
|
{
|
||||||
if(width) *width = swap->info.cx;
|
if (width)
|
||||||
if(height) *height = swap->info.cy;
|
*width = swap->info.cx;
|
||||||
|
if (height)
|
||||||
|
*height = swap->info.cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device,
|
gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device,
|
||||||
|
@ -221,15 +227,12 @@ gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device,
|
||||||
|
|
||||||
CGLError err = CGLTexImageIOSurface2D(
|
CGLError err = CGLTexImageIOSurface2D(
|
||||||
[[NSOpenGLContext currentContext] CGLContextObj],
|
[[NSOpenGLContext currentContext] CGLContextObj],
|
||||||
tex->base.gl_target,
|
tex->base.gl_target, tex->base.gl_internal_format, tex->width,
|
||||||
tex->base.gl_internal_format,
|
tex->height, tex->base.gl_format, tex->base.gl_type, ref, 0);
|
||||||
tex->width, tex->height,
|
|
||||||
tex->base.gl_format,
|
|
||||||
tex->base.gl_type,
|
|
||||||
ref, 0);
|
|
||||||
|
|
||||||
if (err != kCGLNoError) {
|
if (err != kCGLNoError) {
|
||||||
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
|
blog(LOG_ERROR,
|
||||||
|
"CGLTexImageIOSurface2D: %u, %s"
|
||||||
" (device_texture_create_from_iosurface)",
|
" (device_texture_create_from_iosurface)",
|
||||||
err, CGLErrorString(err));
|
err, CGLErrorString(err));
|
||||||
|
|
||||||
|
@ -237,8 +240,7 @@ gs_texture_t *device_texture_create_from_iosurface(gs_device_t *device,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl_tex_param_i(tex->base.gl_target,
|
if (!gl_tex_param_i(tex->base.gl_target, GL_TEXTURE_MAX_LEVEL, 0))
|
||||||
GL_TEXTURE_MAX_LEVEL, 0))
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!gl_bind_texture(tex->base.gl_target, 0))
|
if (!gl_bind_texture(tex->base.gl_target, 0))
|
||||||
|
@ -277,15 +279,12 @@ bool gs_texture_rebind_iosurface(gs_texture_t *texture, void *iosurf)
|
||||||
|
|
||||||
CGLError err = CGLTexImageIOSurface2D(
|
CGLError err = CGLTexImageIOSurface2D(
|
||||||
[[NSOpenGLContext currentContext] CGLContextObj],
|
[[NSOpenGLContext currentContext] CGLContextObj],
|
||||||
tex->base.gl_target,
|
tex->base.gl_target, tex->base.gl_internal_format, tex->width,
|
||||||
tex->base.gl_internal_format,
|
tex->height, tex->base.gl_format, tex->base.gl_type, ref, 0);
|
||||||
tex->width, tex->height,
|
|
||||||
tex->base.gl_format,
|
|
||||||
tex->base.gl_type,
|
|
||||||
ref, 0);
|
|
||||||
|
|
||||||
if (err != kCGLNoError) {
|
if (err != kCGLNoError) {
|
||||||
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
|
blog(LOG_ERROR,
|
||||||
|
"CGLTexImageIOSurface2D: %u, %s"
|
||||||
" (gs_texture_rebind_iosurface)",
|
" (gs_texture_rebind_iosurface)",
|
||||||
err, CGLErrorString(err));
|
err, CGLErrorString(err));
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ static double ns_time_compute_factor()
|
||||||
static uint64_t ns_time_full()
|
static uint64_t ns_time_full()
|
||||||
{
|
{
|
||||||
static double factor = 0.;
|
static double factor = 0.;
|
||||||
if (factor == 0.) factor = ns_time_compute_factor();
|
if (factor == 0.)
|
||||||
|
factor = ns_time_compute_factor();
|
||||||
return (uint64_t)(mach_absolute_time() * factor);
|
return (uint64_t)(mach_absolute_time() * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +73,8 @@ static time_func ns_time_select_func()
|
||||||
uint64_t os_gettime_ns(void)
|
uint64_t os_gettime_ns(void)
|
||||||
{
|
{
|
||||||
static time_func f = NULL;
|
static time_func f = NULL;
|
||||||
if (!f) f = ns_time_select_func();
|
if (!f)
|
||||||
|
f = ns_time_select_func();
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,8 +210,8 @@ static bool get_time_info(int64_t *cpu_time, int64_t *sys_time)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
count = TASK_BASIC_INFO_64_COUNT;
|
count = TASK_BASIC_INFO_64_COUNT;
|
||||||
kern_ret = task_info(task, TASK_BASIC_INFO_64,
|
kern_ret = task_info(task, TASK_BASIC_INFO_64, (task_info_t)&task_data,
|
||||||
(task_info_t)&task_data, &count);
|
&count);
|
||||||
if (kern_ret != KERN_SUCCESS)
|
if (kern_ret != KERN_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -302,11 +304,11 @@ os_inhibit_t *os_inhibit_sleep_create(const char *reason)
|
||||||
{
|
{
|
||||||
struct os_inhibit_info *info = bzalloc(sizeof(*info));
|
struct os_inhibit_info *info = bzalloc(sizeof(*info));
|
||||||
if (!reason)
|
if (!reason)
|
||||||
info->reason = CFStringCreateWithCString(kCFAllocatorDefault,
|
info->reason = CFStringCreateWithCString(
|
||||||
reason, kCFStringEncodingUTF8);
|
kCFAllocatorDefault, reason, kCFStringEncodingUTF8);
|
||||||
else
|
else
|
||||||
info->reason = CFStringCreateCopy(kCFAllocatorDefault,
|
info->reason =
|
||||||
CFSTR(""));
|
CFStringCreateCopy(kCFAllocatorDefault, CFSTR(""));
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -321,12 +323,11 @@ bool os_inhibit_sleep_set_active(os_inhibit_t *info, bool active)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
IOPMAssertionDeclareUserActivity(info->reason,
|
IOPMAssertionDeclareUserActivity(
|
||||||
kIOPMUserActiveLocal, &info->user_id);
|
info->reason, kIOPMUserActiveLocal, &info->user_id);
|
||||||
success = IOPMAssertionCreateWithName(
|
success = IOPMAssertionCreateWithName(
|
||||||
kIOPMAssertionTypeNoDisplaySleep,
|
kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn,
|
||||||
kIOPMAssertionLevelOn, info->reason,
|
info->reason, &info->sleep_id);
|
||||||
&info->sleep_id);
|
|
||||||
|
|
||||||
if (success != kIOReturnSuccess) {
|
if (success != kIOReturnSuccess) {
|
||||||
blog(LOG_WARNING, "Failed to disable sleep");
|
blog(LOG_WARNING, "Failed to disable sleep");
|
||||||
|
@ -364,13 +365,13 @@ static void os_get_cores_internal(void)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
size = sizeof(physical_cores);
|
size = sizeof(physical_cores);
|
||||||
ret = sysctlbyname("machdep.cpu.core_count", &physical_cores,
|
ret = sysctlbyname("machdep.cpu.core_count", &physical_cores, &size,
|
||||||
&size, NULL, 0);
|
NULL, 0);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = sysctlbyname("machdep.cpu.thread_count", &logical_cores,
|
ret = sysctlbyname("machdep.cpu.thread_count", &logical_cores, &size,
|
||||||
&size, NULL, 0);
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int os_get_physical_cores(void)
|
int os_get_physical_cores(void)
|
||||||
|
@ -390,8 +391,8 @@ int os_get_logical_cores(void)
|
||||||
static inline bool os_get_sys_memory_usage_internal(vm_statistics_t vmstat)
|
static inline bool os_get_sys_memory_usage_internal(vm_statistics_t vmstat)
|
||||||
{
|
{
|
||||||
mach_msg_type_number_t out_count = HOST_VM_INFO_COUNT;
|
mach_msg_type_number_t out_count = HOST_VM_INFO_COUNT;
|
||||||
if (host_statistics(mach_host_self(), HOST_VM_INFO,
|
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)vmstat,
|
||||||
(host_info_t)vmstat, &out_count) != KERN_SUCCESS)
|
&out_count) != KERN_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -409,8 +410,8 @@ uint64_t os_get_sys_free_size(void)
|
||||||
typedef task_basic_info_data_t mach_task_basic_info_data_t;
|
typedef task_basic_info_data_t mach_task_basic_info_data_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline bool os_get_proc_memory_usage_internal(
|
static inline bool
|
||||||
mach_task_basic_info_data_t *taskinfo)
|
os_get_proc_memory_usage_internal(mach_task_basic_info_data_t *taskinfo)
|
||||||
{
|
{
|
||||||
#ifdef MACH_TASK_BASIC_INFO
|
#ifdef MACH_TASK_BASIC_INFO
|
||||||
const task_flavor_t flavor = MACH_TASK_BASIC_INFO;
|
const task_flavor_t flavor = MACH_TASK_BASIC_INFO;
|
||||||
|
@ -419,8 +420,8 @@ static inline bool os_get_proc_memory_usage_internal(
|
||||||
const task_flavor_t flavor = TASK_BASIC_INFO;
|
const task_flavor_t flavor = TASK_BASIC_INFO;
|
||||||
mach_msg_type_number_t out_count = TASK_BASIC_INFO_COUNT;
|
mach_msg_type_number_t out_count = TASK_BASIC_INFO_COUNT;
|
||||||
#endif
|
#endif
|
||||||
if (task_info(mach_task_self(), flavor,
|
if (task_info(mach_task_self(), flavor, (task_info_t)taskinfo,
|
||||||
(task_info_t)taskinfo, &out_count) != KERN_SUCCESS)
|
&out_count) != KERN_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -461,8 +462,8 @@ char *cfstr_copy_cstr(CFStringRef cfstring, CFStringEncoding cfstring_encoding)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Try the quick way to obtain the buffer
|
// Try the quick way to obtain the buffer
|
||||||
const char *tmp_buffer = CFStringGetCStringPtr(cfstring,
|
const char *tmp_buffer =
|
||||||
cfstring_encoding);
|
CFStringGetCStringPtr(cfstring, cfstring_encoding);
|
||||||
|
|
||||||
if (tmp_buffer != NULL)
|
if (tmp_buffer != NULL)
|
||||||
return bstrdup(tmp_buffer);
|
return bstrdup(tmp_buffer);
|
||||||
|
@ -486,8 +487,8 @@ char *cfstr_copy_cstr(CFStringRef cfstring, CFStringEncoding cfstring_encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy CFString in requested encoding to buffer
|
// Copy CFString in requested encoding to buffer
|
||||||
Boolean success =
|
Boolean success = CFStringGetCString(cfstring, buffer, max_size,
|
||||||
CFStringGetCString(cfstring, buffer, max_size, cfstring_encoding);
|
cfstring_encoding);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
bfree(buffer);
|
bfree(buffer);
|
||||||
|
@ -500,15 +501,15 @@ char *cfstr_copy_cstr(CFStringRef cfstring, CFStringEncoding cfstring_encoding)
|
||||||
* Returns true on success or false on failure.
|
* Returns true on success or false on failure.
|
||||||
* In case of failure, the dstr capacity but not size is changed.
|
* In case of failure, the dstr capacity but not size is changed.
|
||||||
*/
|
*/
|
||||||
bool cfstr_copy_dstr(CFStringRef cfstring,
|
bool cfstr_copy_dstr(CFStringRef cfstring, CFStringEncoding cfstring_encoding,
|
||||||
CFStringEncoding cfstring_encoding, struct dstr *str)
|
struct dstr *str)
|
||||||
{
|
{
|
||||||
if (!cfstring)
|
if (!cfstring)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Try the quick way to obtain the buffer
|
// Try the quick way to obtain the buffer
|
||||||
const char *tmp_buffer = CFStringGetCStringPtr(cfstring,
|
const char *tmp_buffer =
|
||||||
cfstring_encoding);
|
CFStringGetCStringPtr(cfstring, cfstring_encoding);
|
||||||
|
|
||||||
if (tmp_buffer != NULL) {
|
if (tmp_buffer != NULL) {
|
||||||
dstr_copy(str, tmp_buffer);
|
dstr_copy(str, tmp_buffer);
|
||||||
|
@ -530,8 +531,8 @@ bool cfstr_copy_dstr(CFStringRef cfstring,
|
||||||
dstr_ensure_capacity(str, max_size);
|
dstr_ensure_capacity(str, max_size);
|
||||||
|
|
||||||
// Copy CFString in requested encoding to dstr buffer
|
// Copy CFString in requested encoding to dstr buffer
|
||||||
Boolean success = CFStringGetCString(
|
Boolean success = CFStringGetCString(cfstring, str->array, max_size,
|
||||||
cfstring, str->array, max_size, cfstring_encoding);
|
cfstring_encoding);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
dstr_resize(str, max_size);
|
dstr_resize(str, max_size);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -121,8 +121,7 @@ static inline void update_window_params(struct display_capture *dc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
|
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
|
||||||
kCGWindowListOptionIncludingWindow,
|
kCGWindowListOptionIncludingWindow, dc->window.window_id);
|
||||||
dc->window.window_id);
|
|
||||||
|
|
||||||
if (arr.count) {
|
if (arr.count) {
|
||||||
NSDictionary *dict = arr[0];
|
NSDictionary *dict = arr[0];
|
||||||
|
@ -144,8 +143,10 @@ static inline void update_window_params(struct display_capture *dc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void display_stream_update(struct display_capture *dc,
|
static inline void display_stream_update(struct display_capture *dc,
|
||||||
CGDisplayStreamFrameStatus status, uint64_t display_time,
|
CGDisplayStreamFrameStatus status,
|
||||||
IOSurfaceRef frame_surface, CGDisplayStreamUpdateRef update_ref)
|
uint64_t display_time,
|
||||||
|
IOSurfaceRef frame_surface,
|
||||||
|
CGDisplayStreamUpdateRef update_ref)
|
||||||
{
|
{
|
||||||
UNUSED_PARAMETER(display_time);
|
UNUSED_PARAMETER(display_time);
|
||||||
UNUSED_PARAMETER(update_ref);
|
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);
|
size_t dropped_frames = CGDisplayStreamUpdateGetDropCount(update_ref);
|
||||||
if (dropped_frames > 0)
|
if (dropped_frames > 0)
|
||||||
blog(LOG_INFO, "%s: Dropped %zu frames",
|
blog(LOG_INFO, "%s: Dropped %zu frames",
|
||||||
obs_source_get_name(dc->source),
|
obs_source_get_name(dc->source), dropped_frames);
|
||||||
dropped_frames);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool init_display_stream(struct display_capture *dc)
|
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"];
|
NSNumber *screen_num = dc->screen.deviceDescription[@"NSScreenNumber"];
|
||||||
CGDirectDisplayID disp_id = (CGDirectDisplayID)screen_num.pointerValue;
|
CGDirectDisplayID disp_id = (CGDirectDisplayID)screen_num.pointerValue;
|
||||||
|
|
||||||
NSDictionary *rect_dict = CFBridgingRelease(
|
NSDictionary *rect_dict =
|
||||||
CGRectCreateDictionaryRepresentation(
|
CFBridgingRelease(CGRectCreateDictionaryRepresentation(
|
||||||
CGRectMake(0, 0,
|
CGRectMake(0, 0, dc->screen.frame.size.width,
|
||||||
dc->screen.frame.size.width,
|
|
||||||
dc->screen.frame.size.height)));
|
dc->screen.frame.size.height)));
|
||||||
|
|
||||||
CFBooleanRef show_cursor_cf =
|
CFBooleanRef show_cursor_cf = dc->hide_cursor ? kCFBooleanFalse
|
||||||
dc->hide_cursor ? kCFBooleanFalse : kCFBooleanTrue;
|
: kCFBooleanTrue;
|
||||||
|
|
||||||
NSDictionary *dict = @{
|
NSDictionary *dict = @{
|
||||||
(__bridge NSString *)kCGDisplayStreamSourceRect: rect_dict,
|
(__bridge NSString *)kCGDisplayStreamSourceRect: rect_dict,
|
||||||
(__bridge NSString *)kCGDisplayStreamQueueDepth: @5,
|
(__bridge NSString *)kCGDisplayStreamQueueDepth: @5,
|
||||||
(__bridge NSString*)kCGDisplayStreamShowCursor:
|
(__bridge NSString *)
|
||||||
(id)show_cursor_cf,
|
kCGDisplayStreamShowCursor: (id)show_cursor_cf,
|
||||||
};
|
};
|
||||||
|
|
||||||
os_event_init(&dc->disp_finished, OS_EVENT_TYPE_MANUAL);
|
os_event_init(&dc->disp_finished, OS_EVENT_TYPE_MANUAL);
|
||||||
|
|
||||||
const CGSize *size = &dc->frame.size;
|
const CGSize *size = &dc->frame.size;
|
||||||
dc->disp = CGDisplayStreamCreateWithDispatchQueue(disp_id,
|
dc->disp = CGDisplayStreamCreateWithDispatchQueue(
|
||||||
size->width, size->height, 'BGRA',
|
disp_id, size->width, size->height, 'BGRA',
|
||||||
(__bridge CFDictionaryRef)dict,
|
(__bridge CFDictionaryRef)dict,
|
||||||
dispatch_queue_create(NULL, NULL),
|
dispatch_queue_create(NULL, NULL),
|
||||||
^(CGDisplayStreamFrameStatus status,
|
^(CGDisplayStreamFrameStatus status, uint64_t displayTime,
|
||||||
uint64_t displayTime,
|
|
||||||
IOSurfaceRef frameSurface,
|
IOSurfaceRef frameSurface,
|
||||||
CGDisplayStreamUpdateRef updateRef)
|
CGDisplayStreamUpdateRef updateRef) {
|
||||||
{
|
|
||||||
display_stream_update(dc, status, displayTime,
|
display_stream_update(dc, status, displayTime,
|
||||||
frameSurface, updateRef);
|
frameSurface, updateRef);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
return !CGDisplayStreamStart(dc->disp);
|
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);
|
void load_crop(struct display_capture *dc, obs_data_t *settings);
|
||||||
|
|
||||||
static void *display_capture_create(obs_data_t *settings,
|
static void *display_capture_create(obs_data_t *settings, obs_source_t *source)
|
||||||
obs_source_t *source)
|
|
||||||
{
|
{
|
||||||
UNUSED_PARAMETER(source);
|
UNUSED_PARAMETER(source);
|
||||||
UNUSED_PARAMETER(settings);
|
UNUSED_PARAMETER(settings);
|
||||||
|
@ -316,12 +311,11 @@ static void build_sprite(struct gs_vb_data *data, float fcx, float fcy,
|
||||||
vec2_set(tvarray + 3, end_u, end_v);
|
vec2_set(tvarray + 3, end_u, end_v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void build_sprite_rect(struct gs_vb_data *data,
|
static inline void build_sprite_rect(struct gs_vb_data *data, float origin_x,
|
||||||
float origin_x, float origin_y, float end_x, float end_y)
|
float origin_y, float end_x, float end_y)
|
||||||
{
|
{
|
||||||
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
||||||
origin_x, end_x,
|
origin_x, end_x, origin_y, end_y);
|
||||||
origin_y, end_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_capture_video_tick(void *data, float seconds)
|
static void display_capture_video_tick(void *data, float seconds)
|
||||||
|
@ -379,10 +373,9 @@ static void display_capture_video_tick(void *data, float seconds)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
obs_enter_graphics();
|
obs_enter_graphics();
|
||||||
build_sprite_rect(gs_vertexbuffer_get_data(dc->vertbuf),
|
build_sprite_rect(gs_vertexbuffer_get_data(dc->vertbuf), origin.x,
|
||||||
origin.x, origin.y, end.x, end.y);
|
origin.y, end.x, end.y);
|
||||||
|
|
||||||
if (dc->tex)
|
if (dc->tex)
|
||||||
gs_texture_rebind_iosurface(dc->tex, dc->prev);
|
gs_texture_rebind_iosurface(dc->tex, dc->prev);
|
||||||
|
@ -502,8 +495,8 @@ void load_crop(struct display_capture *dc, obs_data_t *settings)
|
||||||
|
|
||||||
#define CROP_VAR_NAME(var, mode) (mode "." #var)
|
#define CROP_VAR_NAME(var, mode) (mode "." #var)
|
||||||
#define LOAD_CROP_VAR(var, mode) \
|
#define LOAD_CROP_VAR(var, mode) \
|
||||||
dc->crop_rect.var = obs_data_get_double(settings, \
|
dc->crop_rect.var = \
|
||||||
CROP_VAR_NAME(var, mode));
|
obs_data_get_double(settings, CROP_VAR_NAME(var, mode));
|
||||||
switch (dc->crop) {
|
switch (dc->crop) {
|
||||||
case CROP_MANUAL:
|
case CROP_MANUAL:
|
||||||
LOAD_CROP_VAR(origin.x, "manual");
|
LOAD_CROP_VAR(origin.x, "manual");
|
||||||
|
@ -582,12 +575,9 @@ static bool switch_crop_mode(obs_properties_t *props, obs_property_t *p,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *crop_names[] = {
|
static const char *crop_names[] = {"CropMode.None", "CropMode.Manual",
|
||||||
"CropMode.None",
|
|
||||||
"CropMode.Manual",
|
|
||||||
"CropMode.ToWindow",
|
"CropMode.ToWindow",
|
||||||
"CropMode.ToWindowAndManual"
|
"CropMode.ToWindowAndManual"};
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef COUNTOF
|
#ifndef COUNTOF
|
||||||
#define COUNTOF(x) (sizeof(x) / sizeof(x[0]))
|
#define COUNTOF(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
@ -598,8 +588,8 @@ static obs_properties_t *display_capture_properties(void *unused)
|
||||||
|
|
||||||
obs_properties_t *props = obs_properties_create();
|
obs_properties_t *props = obs_properties_create();
|
||||||
|
|
||||||
obs_property_t *list = obs_properties_add_list(props,
|
obs_property_t *list = obs_properties_add_list(
|
||||||
"display", obs_module_text("DisplayCapture.Display"),
|
props, "display", obs_module_text("DisplayCapture.Display"),
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||||
|
|
||||||
for (unsigned i = 0; i < [NSScreen screens].count; i++) {
|
for (unsigned i = 0; i < [NSScreen screens].count; i++) {
|
||||||
|
@ -611,8 +601,8 @@ static obs_properties_t *display_capture_properties(void *unused)
|
||||||
obs_properties_add_bool(props, "show_cursor",
|
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_property_t *crop = obs_properties_add_list(
|
||||||
obs_module_text("CropMode"),
|
props, "crop_mode", obs_module_text("CropMode"),
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||||
obs_property_set_modified_callback(crop, switch_crop_mode);
|
obs_property_set_modified_callback(crop, switch_crop_mode);
|
||||||
|
|
||||||
|
@ -629,8 +619,8 @@ static obs_properties_t *display_capture_properties(void *unused)
|
||||||
float min;
|
float min;
|
||||||
#define LOAD_CROP_VAR(var, mode) \
|
#define LOAD_CROP_VAR(var, mode) \
|
||||||
name = CROP_VAR_NAME(var, mode); \
|
name = CROP_VAR_NAME(var, mode); \
|
||||||
p = obs_properties_add_float(props, name, \
|
p = obs_properties_add_float( \
|
||||||
obs_module_text("Crop."#var), min, 4096.f, .5f); \
|
props, name, obs_module_text("Crop." #var), min, 4096.f, .5f); \
|
||||||
obs_property_set_visible(p, false);
|
obs_property_set_visible(p, false);
|
||||||
|
|
||||||
min = 0.f;
|
min = 0.f;
|
||||||
|
|
|
@ -29,13 +29,12 @@ struct window_capture {
|
||||||
static CGImageRef get_image(struct window_capture *wc)
|
static CGImageRef get_image(struct window_capture *wc)
|
||||||
{
|
{
|
||||||
NSArray *arr = (NSArray *)CGWindowListCreate(
|
NSArray *arr = (NSArray *)CGWindowListCreate(
|
||||||
kCGWindowListOptionIncludingWindow,
|
kCGWindowListOptionIncludingWindow, wc->window.window_id);
|
||||||
wc->window.window_id);
|
|
||||||
[arr autorelease];
|
[arr autorelease];
|
||||||
|
|
||||||
if (arr.count)
|
if (arr.count)
|
||||||
return CGWindowListCreateImage(CGRectNull,
|
return CGWindowListCreateImage(
|
||||||
kCGWindowListOptionIncludingWindow,
|
CGRectNull, kCGWindowListOptionIncludingWindow,
|
||||||
wc->window.window_id, wc->image_option);
|
wc->window.window_id, wc->image_option);
|
||||||
|
|
||||||
if (!find_window(&wc->window, NULL, false))
|
if (!find_window(&wc->window, NULL, false))
|
||||||
|
@ -60,10 +59,9 @@ static inline void capture_frame(struct window_capture *wc)
|
||||||
da_reserve(wc->buffer, width * height * 4);
|
da_reserve(wc->buffer, width * height * 4);
|
||||||
uint8_t *data = wc->buffer.array;
|
uint8_t *data = wc->buffer.array;
|
||||||
|
|
||||||
CGContextRef cg_context = CGBitmapContextCreate(data, width, height,
|
CGContextRef cg_context = CGBitmapContextCreate(
|
||||||
8, width * 4, wc->color_space,
|
data, width, height, 8, width * 4, wc->color_space,
|
||||||
kCGBitmapByteOrder32Host |
|
kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
||||||
kCGImageAlphaPremultipliedFirst);
|
|
||||||
CGContextSetBlendMode(cg_context, kCGBlendModeCopy);
|
CGContextSetBlendMode(cg_context, kCGBlendModeCopy);
|
||||||
CGContextDrawImage(cg_context, rect, img);
|
CGContextDrawImage(cg_context, rect, img);
|
||||||
CGContextRelease(cg_context);
|
CGContextRelease(cg_context);
|
||||||
|
@ -111,8 +109,9 @@ static inline void *window_capture_create_internal(obs_data_t *settings,
|
||||||
|
|
||||||
init_window(&wc->window, settings);
|
init_window(&wc->window, settings);
|
||||||
|
|
||||||
wc->image_option = obs_data_get_bool(settings, "show_shadow") ?
|
wc->image_option = obs_data_get_bool(settings, "show_shadow")
|
||||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
? kCGWindowImageDefault
|
||||||
|
: kCGWindowImageBoundsIgnoreFraming;
|
||||||
|
|
||||||
os_event_init(&wc->capture_event, OS_EVENT_TYPE_AUTO);
|
os_event_init(&wc->capture_event, OS_EVENT_TYPE_AUTO);
|
||||||
os_event_init(&wc->stop_event, OS_EVENT_TYPE_MANUAL);
|
os_event_init(&wc->stop_event, OS_EVENT_TYPE_MANUAL);
|
||||||
|
@ -173,13 +172,15 @@ static obs_properties_t *window_capture_properties(void *unused)
|
||||||
static inline void window_capture_update_internal(struct window_capture *wc,
|
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") ?
|
wc->image_option = obs_data_get_bool(settings, "show_shadow")
|
||||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
? kCGWindowImageDefault
|
||||||
|
: kCGWindowImageBoundsIgnoreFraming;
|
||||||
|
|
||||||
update_window(&wc->window, settings);
|
update_window(&wc->window, settings);
|
||||||
|
|
||||||
if (wc->window.window_name.length) {
|
if (wc->window.window_name.length) {
|
||||||
blog(LOG_INFO, "[window-capture: '%s'] update settings:\n"
|
blog(LOG_INFO,
|
||||||
|
"[window-capture: '%s'] update settings:\n"
|
||||||
"\twindow: %s\n"
|
"\twindow: %s\n"
|
||||||
"\towner: %s",
|
"\towner: %s",
|
||||||
obs_source_get_name(wc->source),
|
obs_source_get_name(wc->source),
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#define OWNER_NAME ((NSString *)kCGWindowOwnerName)
|
#define OWNER_NAME ((NSString *)kCGWindowOwnerName)
|
||||||
#define OWNER_PID ((NSNumber *)kCGWindowOwnerPID)
|
#define OWNER_PID ((NSNumber *)kCGWindowOwnerPID)
|
||||||
|
|
||||||
static NSComparator win_info_cmp = ^(NSDictionary *o1, NSDictionary *o2)
|
static NSComparator win_info_cmp = ^(NSDictionary *o1, NSDictionary *o2) {
|
||||||
{
|
|
||||||
NSComparisonResult res = [o1[OWNER_NAME] compare:o2[OWNER_NAME]];
|
NSComparisonResult res = [o1[OWNER_NAME] compare:o2[OWNER_NAME]];
|
||||||
if (res != NSOrderedSame)
|
if (res != NSOrderedSame)
|
||||||
return res;
|
return res;
|
||||||
|
@ -27,8 +26,7 @@ static NSComparator win_info_cmp = ^(NSDictionary *o1, NSDictionary *o2)
|
||||||
NSArray *enumerate_windows(void)
|
NSArray *enumerate_windows(void)
|
||||||
{
|
{
|
||||||
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
|
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
|
||||||
kCGWindowListOptionOnScreenOnly,
|
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
||||||
kCGNullWindowID);
|
|
||||||
|
|
||||||
[arr autorelease];
|
[arr autorelease];
|
||||||
|
|
||||||
|
@ -129,8 +127,7 @@ static inline bool window_changed_internal(obs_property_t *p,
|
||||||
{
|
{
|
||||||
int window_id = obs_data_get_int(settings, "window");
|
int window_id = obs_data_get_int(settings, "window");
|
||||||
NSString *window_owner = @(obs_data_get_string(settings, "owner_name"));
|
NSString *window_owner = @(obs_data_get_string(settings, "owner_name"));
|
||||||
NSString *window_name =
|
NSString *window_name = @(obs_data_get_string(settings, "window_name"));
|
||||||
@(obs_data_get_string(settings, "window_name"));
|
|
||||||
|
|
||||||
NSDictionary *win_info = @{
|
NSDictionary *win_info = @{
|
||||||
OWNER_NAME: window_owner,
|
OWNER_NAME: window_owner,
|
||||||
|
@ -154,8 +151,8 @@ static inline bool window_changed_internal(obs_property_t *p,
|
||||||
if (!window_added &&
|
if (!window_added &&
|
||||||
win_info_cmp(win_info, dict) == NSOrderedAscending) {
|
win_info_cmp(win_info, dict) == NSOrderedAscending) {
|
||||||
window_added = true;
|
window_added = true;
|
||||||
size_t idx = obs_property_list_add_int(p,
|
size_t idx = obs_property_list_add_int(
|
||||||
make_name(window_owner, window_name),
|
p, make_name(window_owner, window_name),
|
||||||
window_id);
|
window_id);
|
||||||
obs_property_list_item_disable(p, idx, true);
|
obs_property_list_item_disable(p, idx, true);
|
||||||
}
|
}
|
||||||
|
@ -169,9 +166,8 @@ static inline bool window_changed_internal(obs_property_t *p,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window_added) {
|
if (!window_added) {
|
||||||
size_t idx = obs_property_list_add_int(p,
|
size_t idx = obs_property_list_add_int(
|
||||||
make_name(window_owner, window_name),
|
p, make_name(window_owner, window_name), window_id);
|
||||||
window_id);
|
|
||||||
obs_property_list_item_disable(p, idx, true);
|
obs_property_list_item_disable(p, idx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,13 +210,13 @@ void window_defaults(obs_data_t *settings)
|
||||||
|
|
||||||
void add_window_properties(obs_properties_t *props)
|
void add_window_properties(obs_properties_t *props)
|
||||||
{
|
{
|
||||||
obs_property_t *window_list = obs_properties_add_list(props,
|
obs_property_t *window_list = obs_properties_add_list(
|
||||||
"window", obs_module_text("WindowUtils.Window"),
|
props, "window", obs_module_text("WindowUtils.Window"),
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||||
obs_property_set_modified_callback(window_list, window_changed);
|
obs_property_set_modified_callback(window_list, window_changed);
|
||||||
|
|
||||||
obs_property_t *empty = obs_properties_add_bool(props,
|
obs_property_t *empty = obs_properties_add_bool(
|
||||||
"show_empty_names",
|
props, "show_empty_names",
|
||||||
obs_module_text("WindowUtils.ShowEmptyNames"));
|
obs_module_text("WindowUtils.ShowEmptyNames"));
|
||||||
obs_property_set_modified_callback(empty, toggle_empty_names);
|
obs_property_set_modified_callback(empty, toggle_empty_names);
|
||||||
}
|
}
|
||||||
|
@ -228,6 +224,6 @@ void add_window_properties(obs_properties_t *props)
|
||||||
void show_window_properties(obs_properties_t *props, bool show)
|
void show_window_properties(obs_properties_t *props, bool show)
|
||||||
{
|
{
|
||||||
obs_property_set_visible(obs_properties_get(props, "window"), show);
|
obs_property_set_visible(obs_properties_get(props, "window"), show);
|
||||||
obs_property_set_visible(
|
obs_property_set_visible(obs_properties_get(props, "show_empty_names"),
|
||||||
obs_properties_get(props, "show_empty_names"), show);
|
show);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include <obs-module.h>
|
#include <obs-module.h>
|
||||||
|
|
||||||
#define LOG(level, message, ...) \
|
#define LOG(level, message, ...) \
|
||||||
blog(level, "%s: " message, obs_source_get_name(s->source), ##__VA_ARGS__)
|
blog(level, "%s: " message, obs_source_get_name(s->source), \
|
||||||
|
##__VA_ARGS__)
|
||||||
|
|
||||||
struct syphon {
|
struct syphon {
|
||||||
SYPHON_CLIENT_UNIQUE_CLASS_NAME *client;
|
SYPHON_CLIENT_UNIQUE_CLASS_NAME *client;
|
||||||
|
@ -143,8 +144,10 @@ static inline void check_version(syphon_t s, NSDictionary *desc)
|
||||||
"VersionKey");
|
"VersionKey");
|
||||||
|
|
||||||
if (version.unsignedIntValue > 0)
|
if (version.unsignedIntValue > 0)
|
||||||
LOG(LOG_WARNING, "Got server description version %d, "
|
LOG(LOG_WARNING,
|
||||||
"expected 0", version.unsignedIntValue);
|
"Got server description version %d, "
|
||||||
|
"expected 0",
|
||||||
|
version.unsignedIntValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void check_description(syphon_t s, NSDictionary *desc)
|
static inline void check_description(syphon_t s, NSDictionary *desc)
|
||||||
|
@ -169,7 +172,8 @@ static inline void check_description(syphon_t s, NSDictionary *desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *surfaces_string = [NSString stringWithFormat:@"%@", surfaces];
|
NSString *surfaces_string = [NSString stringWithFormat:@"%@", surfaces];
|
||||||
LOG(LOG_WARNING, "SyphonSurfaces does not contain"
|
LOG(LOG_WARNING,
|
||||||
|
"SyphonSurfaces does not contain"
|
||||||
"'SyphonSurfaceTypeIOSurface': %s",
|
"'SyphonSurfaceTypeIOSurface': %s",
|
||||||
surfaces_string.UTF8String);
|
surfaces_string.UTF8String);
|
||||||
}
|
}
|
||||||
|
@ -241,9 +245,9 @@ static void create_client(syphon_t s)
|
||||||
s->client = [[SYPHON_CLIENT_UNIQUE_CLASS_NAME alloc]
|
s->client = [[SYPHON_CLIENT_UNIQUE_CLASS_NAME alloc]
|
||||||
initWithServerDescription:desc
|
initWithServerDescription:desc
|
||||||
options:nil
|
options:nil
|
||||||
newFrameHandler:^
|
newFrameHandler:^(
|
||||||
(SYPHON_CLIENT_UNIQUE_CLASS_NAME *client)
|
SYPHON_CLIENT_UNIQUE_CLASS_NAME
|
||||||
{
|
*client) {
|
||||||
handle_new_frame(s, client);
|
handle_new_frame(s, client);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
@ -314,15 +318,16 @@ static inline void update_inject_state(syphon_t s, NSDictionary *info,
|
||||||
NSString *uuid = info[SyphonServerDescriptionUUIDKey];
|
NSString *uuid = info[SyphonServerDescriptionUUIDKey];
|
||||||
|
|
||||||
if (![uuid isEqual:s->inject_uuid] &&
|
if (![uuid isEqual:s->inject_uuid] &&
|
||||||
(![app_name isEqual:s->inject_app]
|
(![app_name isEqual:s->inject_app] ||
|
||||||
|| ![name isEqual:@"InjectedSyphon"]))
|
![name isEqual:@"InjectedSyphon"]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(s->inject_server_found = announce)) {
|
if (!(s->inject_server_found = announce)) {
|
||||||
s->inject_wait_time = 0.f;
|
s->inject_wait_time = 0.f;
|
||||||
|
|
||||||
objc_release(&s->inject_uuid);
|
objc_release(&s->inject_uuid);
|
||||||
LOG(LOG_INFO, "Injected server retired: "
|
LOG(LOG_INFO,
|
||||||
|
"Injected server retired: "
|
||||||
"[%s] InjectedSyphon (%s)",
|
"[%s] InjectedSyphon (%s)",
|
||||||
s->inject_app.UTF8String, uuid.UTF8String);
|
s->inject_app.UTF8String, uuid.UTF8String);
|
||||||
return;
|
return;
|
||||||
|
@ -333,8 +338,7 @@ static inline void update_inject_state(syphon_t s, NSDictionary *info,
|
||||||
|
|
||||||
s->inject_uuid = [uuid retain];
|
s->inject_uuid = [uuid retain];
|
||||||
LOG(LOG_INFO, "Injected server found: [%s] %s (%s)",
|
LOG(LOG_INFO, "Injected server found: [%s] %s (%s)",
|
||||||
app_name.UTF8String, name.UTF8String,
|
app_name.UTF8String, name.UTF8String, uuid.UTF8String);
|
||||||
uuid.UTF8String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void handle_announce(syphon_t s, NSNotification *note)
|
static inline void handle_announce(syphon_t s, NSNotification *note)
|
||||||
|
@ -430,21 +434,17 @@ static inline bool create_syphon_listeners(syphon_t s)
|
||||||
addObserverForName:SyphonServerAnnounceNotification
|
addObserverForName:SyphonServerAnnounceNotification
|
||||||
object:nil
|
object:nil
|
||||||
queue:[NSOperationQueue mainQueue]
|
queue:[NSOperationQueue mainQueue]
|
||||||
usingBlock:^(NSNotification *note)
|
usingBlock:^(NSNotification *note) {
|
||||||
{
|
|
||||||
handle_announce(s, note);
|
handle_announce(s, note);
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
|
|
||||||
s->retire_listener = [nc
|
s->retire_listener = [nc
|
||||||
addObserverForName:SyphonServerRetireNotification
|
addObserverForName:SyphonServerRetireNotification
|
||||||
object:nil
|
object:nil
|
||||||
queue:[NSOperationQueue mainQueue]
|
queue:[NSOperationQueue mainQueue]
|
||||||
usingBlock:^(NSNotification *note)
|
usingBlock:^(NSNotification *note) {
|
||||||
{
|
|
||||||
handle_retire(s, note);
|
handle_retire(s, note);
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
|
|
||||||
return s->new_server_listener != nil && s->retire_listener != nil;
|
return s->new_server_listener != nil && s->retire_listener != nil;
|
||||||
}
|
}
|
||||||
|
@ -467,8 +467,7 @@ static inline void load_crop(syphon_t s, obs_data_t *settings)
|
||||||
{
|
{
|
||||||
s->crop = obs_data_get_bool(settings, "crop");
|
s->crop = obs_data_get_bool(settings, "crop");
|
||||||
|
|
||||||
#define LOAD_CROP(x) \
|
#define LOAD_CROP(x) s->crop_rect.x = obs_data_get_double(settings, "crop." #x)
|
||||||
s->crop_rect.x = obs_data_get_double(settings, "crop." #x)
|
|
||||||
LOAD_CROP(origin.x);
|
LOAD_CROP(origin.x);
|
||||||
LOAD_CROP(origin.y);
|
LOAD_CROP(origin.y);
|
||||||
LOAD_CROP(size.width);
|
LOAD_CROP(size.width);
|
||||||
|
@ -516,8 +515,8 @@ static void *syphon_create_internal(obs_data_t *settings, obs_source_t *source)
|
||||||
|
|
||||||
load_crop(s, settings);
|
load_crop(s, settings);
|
||||||
|
|
||||||
s->allow_transparency = obs_data_get_bool(settings,
|
s->allow_transparency =
|
||||||
"allow_transparency");
|
obs_data_get_bool(settings, "allow_transparency");
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
@ -549,7 +548,8 @@ static inline void syphon_destroy_internal(syphon_t s)
|
||||||
|
|
||||||
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
||||||
[ws removeObserver:s->launch_listener
|
[ws removeObserver:s->launch_listener
|
||||||
forKeyPath:NSStringFromSelector(@selector(runningApplications))];
|
forKeyPath:NSStringFromSelector(@selector
|
||||||
|
(runningApplications))];
|
||||||
objc_release(&s->launch_listener);
|
objc_release(&s->launch_listener);
|
||||||
|
|
||||||
objc_release(&s->inject_app);
|
objc_release(&s->inject_app);
|
||||||
|
@ -587,7 +587,8 @@ static inline NSString *get_string(obs_data_t *settings, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void update_strings_from_context(syphon_t s, obs_data_t *settings,
|
static inline void update_strings_from_context(syphon_t s, obs_data_t *settings,
|
||||||
NSString **app, NSString **name, NSString **uuid)
|
NSString **app, NSString **name,
|
||||||
|
NSString **uuid)
|
||||||
{
|
{
|
||||||
if (!s || !s->uuid_changed)
|
if (!s || !s->uuid_changed)
|
||||||
return;
|
return;
|
||||||
|
@ -611,8 +612,8 @@ static inline void add_servers(syphon_t s, obs_property_t *list,
|
||||||
NSString *set_name = get_string(settings, "name");
|
NSString *set_name = get_string(settings, "name");
|
||||||
NSString *set_uuid = get_string(settings, "uuid");
|
NSString *set_uuid = get_string(settings, "uuid");
|
||||||
|
|
||||||
update_strings_from_context(s, settings,
|
update_strings_from_context(s, settings, &set_app, &set_name,
|
||||||
&set_app, &set_name, &set_uuid);
|
&set_uuid);
|
||||||
|
|
||||||
obs_property_list_add_string(list, "", "");
|
obs_property_list_add_string(list, "", "");
|
||||||
NSArray *arr = [[SyphonServerDirectory sharedDirectory] servers];
|
NSArray *arr = [[SyphonServerDirectory sharedDirectory] servers];
|
||||||
|
@ -620,11 +621,11 @@ static inline void add_servers(syphon_t s, obs_property_t *list,
|
||||||
NSString *app = server[SyphonServerDescriptionAppNameKey];
|
NSString *app = server[SyphonServerDescriptionAppNameKey];
|
||||||
NSString *name = server[SyphonServerDescriptionNameKey];
|
NSString *name = server[SyphonServerDescriptionNameKey];
|
||||||
NSString *uuid = server[SyphonServerDescriptionUUIDKey];
|
NSString *uuid = server[SyphonServerDescriptionUUIDKey];
|
||||||
NSString *serv = [NSString stringWithFormat:@"[%@] %@",
|
NSString *serv =
|
||||||
app, name];
|
[NSString stringWithFormat:@"[%@] %@", app, name];
|
||||||
|
|
||||||
obs_property_list_add_string(list,
|
obs_property_list_add_string(list, serv.UTF8String,
|
||||||
serv.UTF8String, uuid.UTF8String);
|
uuid.UTF8String);
|
||||||
|
|
||||||
if (!found_current)
|
if (!found_current)
|
||||||
found_current = [uuid isEqual:set_uuid];
|
found_current = [uuid isEqual:set_uuid];
|
||||||
|
@ -633,10 +634,10 @@ static inline void add_servers(syphon_t s, obs_property_t *list,
|
||||||
if (found_current || !set_uuid.length || !set_app.length)
|
if (found_current || !set_uuid.length || !set_app.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSString *serv = [NSString stringWithFormat:@"[%@] %@",
|
NSString *serv =
|
||||||
set_app, set_name];
|
[NSString stringWithFormat:@"[%@] %@", set_app, set_name];
|
||||||
size_t idx = obs_property_list_add_string(list,
|
size_t idx = obs_property_list_add_string(list, serv.UTF8String,
|
||||||
serv.UTF8String, set_uuid.UTF8String);
|
set_uuid.UTF8String);
|
||||||
obs_property_list_item_disable(list, idx, true);
|
obs_property_list_item_disable(list, idx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,8 +663,7 @@ static inline bool is_inject_available_in_lib_dir(NSFileManager *fm, NSURL *url)
|
||||||
if (!url.isFileURL)
|
if (!url.isFileURL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (NSString *path in [fm
|
for (NSString *path in [fm contentsOfDirectoryAtPath:url.path
|
||||||
contentsOfDirectoryAtPath:url.path
|
|
||||||
error:nil]) {
|
error:nil]) {
|
||||||
NSURL *bundle_url = [url URLByAppendingPathComponent:path];
|
NSURL *bundle_url = [url URLByAppendingPathComponent:path];
|
||||||
NSBundle *bundle = [NSBundle bundleWithURL:bundle_url];
|
NSBundle *bundle = [NSBundle bundleWithURL:bundle_url];
|
||||||
|
@ -760,8 +760,9 @@ static inline NSDictionary *get_duplicate_names(NSArray *apps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t add_app(obs_property_t *prop, NSDictionary *duplicates,
|
static inline size_t add_app(obs_property_t *prop, NSDictionary *duplicates,
|
||||||
NSString *name, const char *bundle, const char *json_data,
|
NSString *name, const char *bundle,
|
||||||
bool is_duplicate, pid_t pid)
|
const char *json_data, bool is_duplicate,
|
||||||
|
pid_t pid)
|
||||||
{
|
{
|
||||||
if (!is_duplicate) {
|
if (!is_duplicate) {
|
||||||
NSNumber *val = duplicates[name];
|
NSNumber *val = duplicates[name];
|
||||||
|
@ -769,14 +770,15 @@ static inline size_t add_app(obs_property_t *prop, NSDictionary *duplicates,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_duplicate)
|
if (is_duplicate)
|
||||||
name = [NSString stringWithFormat:@"%@ (%s: %d)",
|
name = [NSString
|
||||||
name, bundle, pid];
|
stringWithFormat:@"%@ (%s: %d)", name, bundle, pid];
|
||||||
|
|
||||||
return obs_property_list_add_string(prop, name.UTF8String, json_data);
|
return obs_property_list_add_string(prop, name.UTF8String, json_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_inject_list_internal(obs_properties_t *props,
|
static void update_inject_list_internal(obs_properties_t *props,
|
||||||
obs_property_t *prop, obs_data_t *settings)
|
obs_property_t *prop,
|
||||||
|
obs_data_t *settings)
|
||||||
{
|
{
|
||||||
UNUSED_PARAMETER(props);
|
UNUSED_PARAMETER(props);
|
||||||
|
|
||||||
|
@ -801,8 +803,7 @@ static void update_inject_list_internal(obs_properties_t *props,
|
||||||
int score = describes_app(current, app);
|
int score = describes_app(current, app);
|
||||||
|
|
||||||
NSString *name = app.localizedName;
|
NSString *name = app.localizedName;
|
||||||
add_app(prop, duplicates, name,
|
add_app(prop, duplicates, name, app.bundleIdentifier.UTF8String,
|
||||||
app.bundleIdentifier.UTF8String,
|
|
||||||
obs_data_get_json(app_data),
|
obs_data_get_json(app_data),
|
||||||
[name isEqual:current_name] && score < 4,
|
[name isEqual:current_name] && score < 4,
|
||||||
app.processIdentifier);
|
app.processIdentifier);
|
||||||
|
@ -928,27 +929,27 @@ static inline obs_properties_t *syphon_properties_internal(syphon_t s)
|
||||||
if (s)
|
if (s)
|
||||||
obs_source_addref(s->source);
|
obs_source_addref(s->source);
|
||||||
|
|
||||||
obs_properties_t *props = obs_properties_create_param(s,
|
obs_properties_t *props =
|
||||||
syphon_release);
|
obs_properties_create_param(s, syphon_release);
|
||||||
|
|
||||||
obs_property_t *list = obs_properties_add_list(props,
|
obs_property_t *list = obs_properties_add_list(
|
||||||
"uuid", obs_module_text("Source"),
|
props, "uuid", obs_module_text("Source"), OBS_COMBO_TYPE_LIST,
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
OBS_COMBO_FORMAT_STRING);
|
||||||
obs_property_set_modified_callback(list, servers_changed);
|
obs_property_set_modified_callback(list, servers_changed);
|
||||||
|
|
||||||
obs_properties_add_bool(props, "allow_transparency",
|
obs_properties_add_bool(props, "allow_transparency",
|
||||||
obs_module_text("AllowTransparency"));
|
obs_module_text("AllowTransparency"));
|
||||||
|
|
||||||
obs_property_t *launch = obs_properties_add_button(props,
|
obs_property_t *launch = obs_properties_add_button(
|
||||||
"launch inject", obs_module_text("LaunchSyphonInject"),
|
props, "launch inject", obs_module_text("LaunchSyphonInject"),
|
||||||
launch_syphon_inject);
|
launch_syphon_inject);
|
||||||
|
|
||||||
obs_property_t *inject = obs_properties_add_bool(props,
|
obs_property_t *inject = obs_properties_add_bool(
|
||||||
"inject", obs_module_text("Inject"));
|
props, "inject", obs_module_text("Inject"));
|
||||||
obs_property_set_modified_callback(inject, toggle_inject);
|
obs_property_set_modified_callback(inject, toggle_inject);
|
||||||
|
|
||||||
obs_property_t *inject_list = obs_properties_add_list(props,
|
obs_property_t *inject_list = obs_properties_add_list(
|
||||||
"application", obs_module_text("Application"),
|
props, "application", obs_module_text("Application"),
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||||
obs_property_set_modified_callback(inject_list, update_inject_list);
|
obs_property_set_modified_callback(inject_list, update_inject_list);
|
||||||
|
|
||||||
|
@ -960,13 +961,14 @@ static inline obs_properties_t *syphon_properties_internal(syphon_t s)
|
||||||
obs_property_set_enabled(inject_list, false);
|
obs_property_set_enabled(inject_list, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_property_t *crop = obs_properties_add_bool(props, "crop",
|
obs_property_t *crop =
|
||||||
obs_module_text("Crop"));
|
obs_properties_add_bool(props, "crop", obs_module_text("Crop"));
|
||||||
obs_property_set_modified_callback(crop, update_crop);
|
obs_property_set_modified_callback(crop, update_crop);
|
||||||
|
|
||||||
#define LOAD_CROP(x) \
|
#define LOAD_CROP(x) \
|
||||||
obs_properties_add_float(props, "crop." #x, \
|
obs_properties_add_float(props, "crop." #x, \
|
||||||
obs_module_text("Crop." #x), 0., 4096.f, .5f);
|
obs_module_text("Crop." #x), 0., 4096.f, \
|
||||||
|
.5f);
|
||||||
LOAD_CROP(origin.x);
|
LOAD_CROP(origin.x);
|
||||||
LOAD_CROP(origin.y);
|
LOAD_CROP(origin.y);
|
||||||
LOAD_CROP(size.width);
|
LOAD_CROP(size.width);
|
||||||
|
@ -1005,7 +1007,8 @@ static void syphon_save(void *data, obs_data_t *settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void build_sprite(struct gs_vb_data *data, float fcx, float fcy,
|
static inline 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;
|
struct vec2 *tvarray = data->tvarray[0].array;
|
||||||
|
|
||||||
|
@ -1018,12 +1021,11 @@ static inline void build_sprite(struct gs_vb_data *data, float fcx, float fcy,
|
||||||
vec2_set(tvarray + 3, end_u, end_v);
|
vec2_set(tvarray + 3, end_u, end_v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void build_sprite_rect(struct gs_vb_data *data,
|
static inline void build_sprite_rect(struct gs_vb_data *data, float origin_x,
|
||||||
float origin_x, float origin_y, float end_x, float end_y)
|
float origin_y, float end_x, float end_y)
|
||||||
{
|
{
|
||||||
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
||||||
origin_x, end_x,
|
origin_x, end_x, origin_y, end_y);
|
||||||
origin_y, end_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void tick_inject_state(syphon_t s, float seconds)
|
static inline void tick_inject_state(syphon_t s, float seconds)
|
||||||
|
@ -1057,10 +1059,8 @@ static void syphon_video_tick(void *data, float seconds)
|
||||||
|
|
||||||
obs_enter_graphics();
|
obs_enter_graphics();
|
||||||
build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer),
|
build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer),
|
||||||
crop->origin.x,
|
crop->origin.x, s->height - crop->origin.y,
|
||||||
s->height - crop->origin.y,
|
s->width - crop->size.width, crop->size.height);
|
||||||
s->width - crop->size.width,
|
|
||||||
crop->size.height);
|
|
||||||
obs_leave_graphics();
|
obs_leave_graphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,9 +1105,8 @@ static uint32_t syphon_get_width(void *data)
|
||||||
syphon_t s = (syphon_t)data;
|
syphon_t s = (syphon_t)data;
|
||||||
if (!s->crop)
|
if (!s->crop)
|
||||||
return s->width;
|
return s->width;
|
||||||
int32_t width = s->width
|
int32_t width =
|
||||||
- s->crop_rect.origin.x
|
s->width - s->crop_rect.origin.x - s->crop_rect.size.width;
|
||||||
- s->crop_rect.size.width;
|
|
||||||
return MAX(0, width);
|
return MAX(0, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,9 +1115,8 @@ static uint32_t syphon_get_height(void *data)
|
||||||
syphon_t s = (syphon_t)data;
|
syphon_t s = (syphon_t)data;
|
||||||
if (!s->crop)
|
if (!s->crop)
|
||||||
return s->height;
|
return s->height;
|
||||||
int32_t height = s->height
|
int32_t height =
|
||||||
- s->crop_rect.origin.y
|
s->height - s->crop_rect.origin.y - s->crop_rect.size.height;
|
||||||
- s->crop_rect.size.height;
|
|
||||||
return MAX(0, height);
|
return MAX(0, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,8 +1143,7 @@ static inline void inject_app(syphon_t s, NSRunningApplication *app, bool retry)
|
||||||
if (retry)
|
if (retry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG(LOG_INFO, "Injected '%s' (%d, '%s')",
|
LOG(LOG_INFO, "Injected '%s' (%d, '%s')", app.localizedName.UTF8String,
|
||||||
app.localizedName.UTF8String,
|
|
||||||
app.processIdentifier, app.bundleIdentifier.UTF8String);
|
app.processIdentifier, app.bundleIdentifier.UTF8String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,20 +1171,17 @@ static inline void find_and_inject_target(syphon_t s, NSArray *arr, bool retry)
|
||||||
|
|
||||||
static inline bool inject_info_equal(obs_data_t *prev, obs_data_t *new)
|
static inline bool inject_info_equal(obs_data_t *prev, obs_data_t *new)
|
||||||
{
|
{
|
||||||
if (![get_string(prev, "name")
|
if (![get_string(prev, "name") isEqual:get_string(new, "name")])
|
||||||
isEqual:get_string(new, "name")])
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (![get_string(prev, "bundle")
|
if (![get_string(prev, "bundle") isEqual:get_string(new, "bundle")])
|
||||||
isEqual:get_string(new, "bundle")])
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (![get_string(prev, "executable")
|
if (![get_string(prev, "executable")
|
||||||
isEqual:get_string(new, "executable")])
|
isEqual:get_string(new, "executable")])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (![get_string(prev, "pid")
|
if (![get_string(prev, "pid") isEqual:get_string(new, "pid")])
|
||||||
isEqual:get_string(new, "pid")])
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1256,8 +1250,8 @@ static inline bool update_syphon(syphon_t s, obs_data_t *settings)
|
||||||
|
|
||||||
static void syphon_update_internal(syphon_t s, obs_data_t *settings)
|
static void syphon_update_internal(syphon_t s, obs_data_t *settings)
|
||||||
{
|
{
|
||||||
s->allow_transparency = obs_data_get_bool(settings,
|
s->allow_transparency =
|
||||||
"allow_transparency");
|
obs_data_get_bool(settings, "allow_transparency");
|
||||||
|
|
||||||
load_crop(s, settings);
|
load_crop(s, settings);
|
||||||
update_inject(s, settings);
|
update_inject(s, settings);
|
||||||
|
@ -1288,4 +1282,3 @@ struct obs_source_info syphon_info = {
|
||||||
.update = syphon_update,
|
.update = syphon_update,
|
||||||
.save = syphon_save,
|
.save = syphon_save,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ static void add_path_fonts(NSFileManager *file_manager, NSString *path)
|
||||||
files = [file_manager contentsOfDirectoryAtPath:path error:nil];
|
files = [file_manager contentsOfDirectoryAtPath:path error:nil];
|
||||||
|
|
||||||
for (NSString *file in files) {
|
for (NSString *file in files) {
|
||||||
NSString *full_path = [path stringByAppendingPathComponent:file];
|
NSString *full_path =
|
||||||
|
[path stringByAppendingPathComponent:file];
|
||||||
|
|
||||||
BOOL is_dir = FALSE;
|
BOOL is_dir = FALSE;
|
||||||
bool folder_exists = [file_manager
|
bool folder_exists = [file_manager fileExistsAtPath:full_path
|
||||||
fileExistsAtPath:full_path
|
|
||||||
isDirectory:&is_dir];
|
isDirectory:&is_dir];
|
||||||
|
|
||||||
if (folder_exists && is_dir) {
|
if (folder_exists && is_dir) {
|
||||||
|
@ -78,17 +78,19 @@ static uint32_t add_font_checksum(uint32_t checksum, const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t add_font_checksum_path(uint32_t checksum,
|
static uint32_t add_font_checksum_path(uint32_t checksum,
|
||||||
NSFileManager *file_manager, NSString *path)
|
NSFileManager *file_manager,
|
||||||
|
NSString *path)
|
||||||
{
|
{
|
||||||
NSArray *files = NULL;
|
NSArray *files = NULL;
|
||||||
|
|
||||||
files = [file_manager contentsOfDirectoryAtPath:path error:nil];
|
files = [file_manager contentsOfDirectoryAtPath:path error:nil];
|
||||||
|
|
||||||
for (NSString *file in files) {
|
for (NSString *file in files) {
|
||||||
NSString *full_path = [path stringByAppendingPathComponent:file];
|
NSString *full_path =
|
||||||
|
[path stringByAppendingPathComponent:file];
|
||||||
|
|
||||||
checksum = add_font_checksum(checksum,
|
checksum = add_font_checksum(
|
||||||
full_path.fileSystemRepresentation);
|
checksum, full_path.fileSystemRepresentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return checksum;
|
return checksum;
|
||||||
|
@ -114,8 +116,8 @@ uint32_t get_font_checksum(void)
|
||||||
isDirectory:&is_dir];
|
isDirectory:&is_dir];
|
||||||
|
|
||||||
if (folder_exists && is_dir)
|
if (folder_exists && is_dir)
|
||||||
checksum = add_font_checksum_path(checksum,
|
checksum = add_font_checksum_path(
|
||||||
file_manager, font_path);
|
checksum, file_manager, font_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ static const int cy = 600;
|
||||||
/* --------------------------------------------------- */
|
/* --------------------------------------------------- */
|
||||||
|
|
||||||
template<typename T, typename D_T, D_T D>
|
template<typename T, typename D_T, D_T D>
|
||||||
struct OBSUniqueHandle : std::unique_ptr<T, std::function<D_T>>
|
struct OBSUniqueHandle : std::unique_ptr<T, std::function<D_T>> {
|
||||||
{
|
|
||||||
using base = std::unique_ptr<T, std::function<D_T>>;
|
using base = std::unique_ptr<T, std::function<D_T>>;
|
||||||
explicit OBSUniqueHandle(T *obj = nullptr) : base(obj, D) {}
|
explicit OBSUniqueHandle(T *obj = nullptr) : base(obj, D) {}
|
||||||
operator T *() { return base::get(); }
|
operator T *() { return base::get(); }
|
||||||
|
@ -26,14 +25,14 @@ struct OBSUniqueHandle : std::unique_ptr<T, std::function<D_T>>
|
||||||
|
|
||||||
#define DECLARE_DELETER(x) decltype(x), x
|
#define DECLARE_DELETER(x) decltype(x), x
|
||||||
|
|
||||||
using SourceContext = OBSUniqueHandle<obs_source,
|
using SourceContext =
|
||||||
DECLARE_DELETER(obs_source_release)>;
|
OBSUniqueHandle<obs_source, DECLARE_DELETER(obs_source_release)>;
|
||||||
|
|
||||||
using SceneContext = OBSUniqueHandle<obs_scene,
|
using SceneContext =
|
||||||
DECLARE_DELETER(obs_scene_release)>;
|
OBSUniqueHandle<obs_scene, DECLARE_DELETER(obs_scene_release)>;
|
||||||
|
|
||||||
using DisplayContext = OBSUniqueHandle<obs_display,
|
using DisplayContext =
|
||||||
DECLARE_DELETER(obs_display_destroy)>;
|
OBSUniqueHandle<obs_display, DECLARE_DELETER(obs_display_destroy)>;
|
||||||
|
|
||||||
#undef DECLARE_DELETER
|
#undef DECLARE_DELETER
|
||||||
|
|
||||||
|
@ -79,8 +78,8 @@ static SceneContext SetupScene()
|
||||||
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
/* create source */
|
/* create source */
|
||||||
SourceContext source{obs_source_create("random", "a test source",
|
SourceContext source{
|
||||||
nullptr, nullptr)};
|
obs_source_create("random", "a test source", nullptr, nullptr)};
|
||||||
if (!source)
|
if (!source)
|
||||||
throw "Couldn't create random test source";
|
throw "Couldn't create random test source";
|
||||||
|
|
||||||
|
@ -99,8 +98,7 @@ static SceneContext SetupScene()
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface OBSTest : NSObject<NSApplicationDelegate, NSWindowDelegate>
|
@interface OBSTest : NSObject <NSApplicationDelegate, NSWindowDelegate> {
|
||||||
{
|
|
||||||
NSWindow *win;
|
NSWindow *win;
|
||||||
NSView *view;
|
NSView *view;
|
||||||
DisplayContext display;
|
DisplayContext display;
|
||||||
|
@ -120,7 +118,8 @@ static SceneContext SetupScene()
|
||||||
NSRect content_rect = NSMakeRect(0, 0, cx, cy);
|
NSRect content_rect = NSMakeRect(0, 0, cx, cy);
|
||||||
win = [[NSWindow alloc]
|
win = [[NSWindow alloc]
|
||||||
initWithContentRect:content_rect
|
initWithContentRect:content_rect
|
||||||
styleMask:NSTitledWindowMask | NSClosableWindowMask
|
styleMask:NSTitledWindowMask |
|
||||||
|
NSClosableWindowMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
if (!win)
|
if (!win)
|
||||||
|
@ -144,10 +143,12 @@ static SceneContext SetupScene()
|
||||||
|
|
||||||
scene = SetupScene();
|
scene = SetupScene();
|
||||||
|
|
||||||
obs_display_add_draw_callback(display.get(),
|
obs_display_add_draw_callback(
|
||||||
|
display.get(),
|
||||||
[](void *, uint32_t, uint32_t) {
|
[](void *, uint32_t, uint32_t) {
|
||||||
obs_render_main_texture();
|
obs_render_main_texture();
|
||||||
}, nullptr);
|
},
|
||||||
|
nullptr);
|
||||||
|
|
||||||
} catch (char const *error) {
|
} catch (char const *error) {
|
||||||
NSLog(@"%s\n", error);
|
NSLog(@"%s\n", error);
|
||||||
|
|
Loading…
Reference in New Issue