From 7f66b0b99f3f09b626be1098a7c25aebb00d9175 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 01:04:33 +0900 Subject: [PATCH 1/6] =?UTF-8?q?macOS=20=E3=81=A7=E3=81=AF=20USB=20?= =?UTF-8?q?=E3=81=A7=E6=8E=A5=E7=B6=9A=E3=81=95=E3=82=8C=E3=81=9F=E3=82=AB?= =?UTF-8?q?=E3=83=A1=E3=83=A9=E3=82=82=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..057936cf 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 では USB で接続されたカメラも取得する +#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; From 49d28271ccea543c54751985c671d1c1dae61934 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 10:13:49 +0900 Subject: [PATCH 2/6] =?UTF-8?q?GitHub=20Actions=20=E3=81=A7=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=20macOS=20=E3=81=AE=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=92=2014=20=E3=81=AB?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eed88475..4dd158ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: - macos_arm64 - ios name: Build sora-cpp-sdk for ${{ matrix.name }} - runs-on: macos-12 + runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: Env to output From 8af5b0ad600b5129ebe81e1a2665280c4a129a87 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 10:56:58 +0900 Subject: [PATCH 3/6] =?UTF-8?q?AVCaptureDeviceTypeExternal=20=E3=81=AE?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=AB=E3=81=AF=20macOS=2014=20=E4=BB=A5?= =?UTF-8?q?=E4=B8=8A=E3=81=8C=E5=BF=85=E8=A6=81=E3=81=A0=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=8C=E3=80=81=20GitHub=20Actions=20=E3=81=A7=E3=81=AF=20ma?= =?UTF-8?q?cOS=2014=20=E3=81=8C=E5=88=A9=E7=94=A8=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81=E5=8F=A4?= =?UTF-8?q?=E3=81=84=20API=20=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- src/mac/mac_capturer.mm | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4dd158ba..eed88475 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: - macos_arm64 - ios name: Build sora-cpp-sdk for ${{ matrix.name }} - runs-on: macos-14 + runs-on: macos-12 steps: - uses: actions/checkout@v4 - name: Env to output diff --git a/src/mac/mac_capturer.mm b/src/mac/mac_capturer.mm index 057936cf..475ff9c3 100644 --- a/src/mac/mac_capturer.mm +++ b/src/mac/mac_capturer.mm @@ -94,11 +94,13 @@ - (void)capturer:(RTCVideoCapturer*)capturer NSArray* captureDevices() { // macOS では USB で接続されたカメラも取得する #if defined(SORA_CPP_SDK_MACOS) - AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeExternal ] - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]; - return session.devices; + // AVCaptureDeviceTypeExternal の利用には macOS 14 以上が必要だが、 GitHub Actions では macOS 14 が利用出来ないため一時的に古い API を使う + // AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession + // discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeExternal ] + // mediaType:AVMediaTypeVideo + // position:AVCaptureDevicePositionUnspecified]; + // return session.devices; + return [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; #else return [RTCCameraVideoCapturer captureDevices]; # endif From 8ea7616154971c33c5b74b35412c60c44b63a0f8 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 11:28:59 +0900 Subject: [PATCH 4/6] =?UTF-8?q?CHANGES.md=20=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 36fb3fef..ab497c9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,10 @@ ## develop +- [FIX] macOS で USB 接続されたカメラが利用できなくなっていた問題を修正する + - 2023.15.0 リリース時の WebRTC の更新に伴い、 macOS で USB 接続されたカメラが取得できなくなっていた + - @enm10k + ## 2023.15.0 (2023-10-31) - [UPDATE] WebRTC を m119.6045.2.1 に上げる From 9850b2bb0c866d66b537a350950c1988b180b46c Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 12:12:27 +0900 Subject: [PATCH 5/6] =?UTF-8?q?iOS=20=E3=81=AE=20captureDevices=20?= =?UTF-8?q?=E3=82=82=E8=87=AA=E4=BD=9C=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mac/mac_capturer.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mac/mac_capturer.mm b/src/mac/mac_capturer.mm index 475ff9c3..90cb2d35 100644 --- a/src/mac/mac_capturer.mm +++ b/src/mac/mac_capturer.mm @@ -102,7 +102,11 @@ - (void)capturer:(RTCVideoCapturer*)capturer // return session.devices; return [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; #else - return [RTCCameraVideoCapturer captureDevices]; + AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession + discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]; + return session.devices; # endif } From 488d952f53a0ef8293efe57301653f54058f977d Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 1 Nov 2023 12:14:59 +0900 Subject: [PATCH 6/6] =?UTF-8?q?captureDevices=20=E3=82=92=20static=20?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mac/mac_capturer.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mac/mac_capturer.mm b/src/mac/mac_capturer.mm index 90cb2d35..481b8d1a 100644 --- a/src/mac/mac_capturer.mm +++ b/src/mac/mac_capturer.mm @@ -91,7 +91,7 @@ - (void)capturer:(RTCVideoCapturer*)capturer return rtc::make_ref_counted(c); } -NSArray* captureDevices() { +static NSArray* captureDevices() { // macOS では USB で接続されたカメラも取得する #if defined(SORA_CPP_SDK_MACOS) // AVCaptureDeviceTypeExternal の利用には macOS 14 以上が必要だが、 GitHub Actions では macOS 14 が利用出来ないため一時的に古い API を使う