From 30fa6c24b47ef60e57bc8d4c08958670c3cefe10 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 01:04:33 +0900 Subject: [PATCH] wip --- src/mac/mac_capturer.mm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mac/mac_capturer.mm b/src/mac/mac_capturer.mm index d05a37d7..269445ad 100644 --- a/src/mac/mac_capturer.mm +++ b/src/mac/mac_capturer.mm @@ -91,9 +91,22 @@ - (void)capturer:(RTCVideoCapturer*)capturer return rtc::make_ref_counted(c); } +NSArray* CaptureDevices() { +// macOS では外部カメラを取得する +#if defined(SORA_CPP_SDK_MACOS) + AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession + discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeExternal ] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]; + return session.devices; +#else + return [RTCCameraVideoCapturer captureDevices]; +# endif +} + bool MacCapturer::EnumVideoDevice( std::function f) { - NSArray* devices = [RTCCameraVideoCapturer captureDevices]; + NSArray* devices = CaptureDevices(); [devices enumerateObjectsUsingBlock:^(AVCaptureDevice* device, NSUInteger i, BOOL* stop) { f([device.localizedName UTF8String], [device.uniqueID UTF8String]); @@ -107,7 +120,7 @@ - (void)capturer:(RTCVideoCapturer*)capturer // https://www.ffmpeg.org/ffmpeg-devices.html#avfoundation size_t capture_device_index = SIZE_T_MAX; - NSArray* devices = [RTCCameraVideoCapturer captureDevices]; + NSArray* devices = CaptureDevices(); [devices enumerateObjectsUsingBlock:^(AVCaptureDevice* device, NSUInteger i, BOOL* stop) { // 便利なのでデバイスの一覧をログに出力しておく @@ -149,8 +162,7 @@ - (void)capturer:(RTCVideoCapturer*)capturer } if (capture_device_index != SIZE_T_MAX) { - AVCaptureDevice* device = [[RTCCameraVideoCapturer captureDevices] - objectAtIndex:capture_device_index]; + AVCaptureDevice* device = [CaptureDevices() objectAtIndex:capture_device_index]; RTC_LOG(LS_INFO) << "selected video device: [" << capture_device_index << "] device_name=" << [device.localizedName UTF8String]; return device;