diff --git a/src/platform/macos/av_video.h b/src/platform/macos/av_video.h index fac5a78c6e6..b2cb1898f95 100644 --- a/src/platform/macos/av_video.h +++ b/src/platform/macos/av_video.h @@ -30,7 +30,7 @@ typedef bool (^FrameCallbackBlock)(CMSampleBufferRef); @property (nonatomic, assign) NSMapTable *captureSignals; + (NSArray *)displayNames; -+ (NSString *)getDisplayName:(CGDirectDisplayID)displayID; ++ (NSString *)getDisplayName:(CGDirectDisplayID)displayID with: (NSArray*)screens; - (id)initWithDisplay:(CGDirectDisplayID)displayID frameRate:(int)frameRate; diff --git a/src/platform/macos/av_video.m b/src/platform/macos/av_video.m index 874a87f7b18..722a7402a17 100644 --- a/src/platform/macos/av_video.m +++ b/src/platform/macos/av_video.m @@ -18,21 +18,21 @@ @implementation AVVideo return [NSArray array]; } + NSArray *screens = [NSScreen screens]; NSMutableArray *result = [NSMutableArray array]; for (uint32_t i = 0; i < count; i++) { [result addObject:@{ @"id": [NSNumber numberWithUnsignedInt:displays[i]], @"name": [NSString stringWithFormat:@"%d", displays[i]], - @"displayName": [self getDisplayName:displays[i]], + @"displayName": [self getDisplayName:displays[i] with:screens], }]; } return [NSArray arrayWithArray:result]; } -+ (NSString *)getDisplayName:(CGDirectDisplayID)displayID { - NSScreen *screens = [NSScreen screens]; ++ (NSString *)getDisplayName:(CGDirectDisplayID)displayID with: (NSArray*)screens { for (NSScreen *screen in screens) { if (screen.deviceDescription[@"NSScreenNumber"] == [NSNumber numberWithUnsignedInt:displayID]) { return screen.localizedName;