Skip to content

Commit

Permalink
configurable airplay mirror scale factor
Browse files Browse the repository at this point in the history
  • Loading branch information
amitv87 committed Mar 18, 2024
1 parent edbb584 commit 7c1ba7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions pip/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef enum{
} DisplayRendererType;

NSObject* getPref(NSString* key);
NSObject* getPrefOption(NSString* key);
void setPref(NSString* key, NSObject* val);

@interface Preferences : NSPanel<NSWindowDelegate, NSTableViewDelegate, NSTableViewDataSource>
Expand Down
8 changes: 7 additions & 1 deletion pip/preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
OPTION(renderer, "Display Renderer", Select, (@[@"Metal", @"Opengl"]), [NSNumber numberWithInt:DisplayRendererTypeOpenGL], [NSNull null]),
#ifndef NO_AIRPLAY
OPTION(airplay, "AirPlay Receiver", CheckBox, [NSNull null], @1, @"Use PiP as Airplay receiver"),
OPTION(airplay_scale_factor, "AirPlay Scale factor", Select, (@[@"1.00", @"2.00", @"3.00", @"Default"]), @3, [NSNull null]),
#endif
OPTION(wfilter_null_title, "Exclude windows", CheckBox, [NSNull null], @0, @"when title is null"),
OPTION(wfilter_epmty_title, "Exclude windows", CheckBox, [NSNull null], @0, @"when title is empty"),
Expand Down Expand Up @@ -54,14 +55,19 @@ void setPref(NSString* key, NSObject* val){
return val;
}

NSObject* getPrefOption(NSString* key){
NSArray* options = getDefaultPrefs()[key][@"options"];
return [options objectAtIndex:[(NSNumber*)getPref(key) intValue]];
}

@implementation Preferences{
NSViewController* nvc;
NSArray* opts;
}

-(id)init{
self = [super
initWithContentRect:NSMakeRect(0, 0, 450, 210)
initWithContentRect:NSMakeRect(0, 0, 450, 230)
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskNonactivatingPanel
backing:NSBackingStoreBuffered defer:YES
];
Expand Down
12 changes: 9 additions & 3 deletions pip/receiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ void airplay_receiver_start(void){
};

NSSize size = [[NSScreen mainScreen] frame].size;
// NSLog(@"screen res: %@", NSStringFromSize(size));
float scale = [NSScreen mainScreen].backingScaleFactor;

NSNumberFormatter* f = [[NSNumberFormatter alloc] init];
f.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber* ns_scale = [f numberFromString:(NSString*)getPrefOption(@"airplay_scale_factor")];
if(ns_scale) scale = [ns_scale floatValue];
// NSLog(@"screen res: %@, scale: %f", NSStringFromSize(size), scale);

raop = raop_init(MAX_ACTIVE_SESSIONS * 2, &raop_cbs);
raop_set_plist(raop, "width", size.width);
raop_set_plist(raop, "height", size.height);
raop_set_plist(raop, "width", size.width * scale);
raop_set_plist(raop, "height", size.height * scale);
raop_set_plist(raop, "refreshRate", 60);
raop_set_plist(raop, "maxFPS", 60);
raop_set_plist(raop, "overscanned", 0);
Expand Down

0 comments on commit 7c1ba7f

Please sign in to comment.