Skip to content
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

Speed up camera publishing #377

Merged
merged 12 commits into from
May 23, 2024
Merged

Speed up camera publishing #377

merged 12 commits into from
May 23, 2024

Conversation

hiroshihorie
Copy link
Member

Maintain a internal list of AVCaptureDevices to speed up publishing.

@hiroshihorie hiroshihorie marked this pull request as ready for review May 20, 2024 09:48

DispatchQueue.global(qos: .background).async { [weak self] in
guard let self else { return }
_observation = session.observe(\.devices, options: [.initial, .new]) { [weak self] _, value in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to periodically refresh this list? thinking about a case where cameras become available after init (i.e. USB/continuity camera on Mac, external camera on iOS)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is observing the devices property so it should be ok. But continuity devices are not included now, maybe I should include it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh awesome, I missed that. lgtm!


DispatchQueue.global(qos: .background).async { [weak self] in
guard let self else { return }
_observation = session.observe(\.devices, options: [.initial, .new]) { [weak self] _, value in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh awesome, I missed that. lgtm!

@hiroshihorie hiroshihorie merged commit 3aaf894 into main May 23, 2024
2 of 7 checks passed
@hiroshihorie hiroshihorie deleted the device-manager branch May 23, 2024 04:45
]
#else
deviceTypes = [
.builtInWideAngleCamera,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about .external and .continuityCamera?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add 🙂

let deviceTypes: [AVCaptureDevice.DeviceType]
#if os(iOS)
deviceTypes = [
.builtInDualCamera,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would these show up as diff devices? or the same? if they are all different, it would be confusing right?

Copy link
Member Author

@hiroshihorie hiroshihorie May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the device manager should bring aware of all devices but for the user facing device enumeration API, i can add a filter option (default on) to output only common devices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants