-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS では USB で接続されたカメラも取得する #44
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f66b0b
macOS では USB で接続されたカメラも取得する
enm10k 49d2827
GitHub Actions で利用する macOS のバージョンを 14 に更新
enm10k 8af5b0a
AVCaptureDeviceTypeExternal の利用には macOS 14 以上が必要だったが、 GitHub Actions …
enm10k 8ea7616
CHANGES.md を更新する
enm10k 9850b2b
iOS の captureDevices も自作する
enm10k 488d952
captureDevices を static にする
enm10k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,9 +91,24 @@ - (void)capturer:(RTCVideoCapturer*)capturer | |
return rtc::make_ref_counted<MacCapturer>(c); | ||
} | ||
|
||
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 | ||
return [RTCCameraVideoCapturer captureDevices]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これ macOS 以外は RTCCameraVideoCapturer に渡してますけど、libwebrtc のデバイス列挙の処理が変わったらまた問題起きるかもなので、iOS の場合も自作した方が良さそうな気がします There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. レビューありがとうございます |
||
# 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]); | ||
|
@@ -107,7 +122,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) { | ||
// 便利なのでデバイスの一覧をログに出力しておく | ||
|
@@ -149,8 +164,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; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melpon
EnumVideoDevice のように MacCapturer のプライベート・メソッドとして定義しようとしたのですが、その場合ヘッダーファイルの修正が必要でした (NSArray を利用しているためです)。
ヘッダーファイルの修正を避けるために captureDevices をこのように定義していますが、問題があれば教えてください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このままだとグローバルに定義されちゃうので、static 関数として定義して下さい