Skip to content

Commit

Permalink
Merge branch 'release/2023.15.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
miosakuma committed Nov 9, 2023
2 parents def8607 + 1366e0a commit 7fe2df8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

## develop

## 2023.15.1 (2023-11-09)

- [FIX] macOS で USB 接続されたカメラが利用できなくなっていた問題を修正する
- 2023.15.0 リリース時の WebRTC の更新に伴い、 macOS で USB 接続されたカメラが取得できなくなっていた
- @enm10k

## 2023.15.0 (2023-10-31)

- [UPDATE] WebRTC を m119.6045.2.1 に上げる
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SORA_CPP_SDK_VERSION=2023.15.0
SORA_CPP_SDK_VERSION=2023.15.1
WEBRTC_BUILD_VERSION=m119.6045.2.1
BOOST_VERSION=1.83.0
CMAKE_VERSION=3.27.7
Expand Down
26 changes: 22 additions & 4 deletions src/mac/mac_capturer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,28 @@ - (void)capturer:(RTCVideoCapturer*)capturer
return rtc::make_ref_counted<MacCapturer>(c);
}

static NSArray<AVCaptureDevice*>* captureDevices() {
// macOS では USB で接続されたカメラも取得する
#if defined(SORA_CPP_SDK_MACOS)
// 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
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ]
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
return session.devices;
# endif
}

bool MacCapturer::EnumVideoDevice(
std::function<void(std::string, std::string)> f) {
NSArray<AVCaptureDevice*>* devices = [RTCCameraVideoCapturer captureDevices];
NSArray<AVCaptureDevice*>* devices = captureDevices();
[devices enumerateObjectsUsingBlock:^(AVCaptureDevice* device, NSUInteger i,
BOOL* stop) {
f([device.localizedName UTF8String], [device.uniqueID UTF8String]);
Expand All @@ -107,7 +126,7 @@ - (void)capturer:(RTCVideoCapturer*)capturer
// https://www.ffmpeg.org/ffmpeg-devices.html#avfoundation

size_t capture_device_index = SIZE_T_MAX;
NSArray<AVCaptureDevice*>* devices = [RTCCameraVideoCapturer captureDevices];
NSArray<AVCaptureDevice*>* devices = captureDevices();
[devices enumerateObjectsUsingBlock:^(AVCaptureDevice* device, NSUInteger i,
BOOL* stop) {
// 便利なのでデバイスの一覧をログに出力しておく
Expand Down Expand Up @@ -149,8 +168,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;
Expand Down

0 comments on commit 7fe2df8

Please sign in to comment.