Skip to content

Refactor and enable switching between cameras using physical id. #676

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

KasemJaffer
Copy link
Contributor

@KasemJaffer KasemJaffer commented May 20, 2025

This PR is mainly to make switchCamera api support deviceId that is physical. The previous PR #668 supports it only during initialization.

Copy link

changeset-bot bot commented May 20, 2025

🦋 Changeset detected

Latest commit: c3a2981

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
client-sdk-android Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

) : Camera2Enumerator(context) {

override fun createCapturer(
deviceName: String?,
eventsHandler: CameraVideoCapturer.CameraEventsHandler?,
): CameraVideoCapturer {
return CameraXCapturer(context, lifecycleOwner, deviceName, eventsHandler, useCases, physicalCameraId)
val deviceInfo = findCamera(cameraManager!!, deviceName, fallback = true)!!
return CameraXCapturer(this, lifecycleOwner, cameraManager!!, deviceInfo, eventsHandler, useCases)
Copy link
Contributor Author

@KasemJaffer KasemJaffer May 20, 2025

Choose a reason for hiding this comment

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

Passing this instead of creating it again inside CameraXCapturer. From my testing I didn't see any problems with this change. Let me know if i'm missing anything.

@KasemJaffer KasemJaffer changed the title Refactor and enable switching between cameras using physical id. switchCamera: Refactor and enable switching between cameras using physical id. May 20, 2025
@KasemJaffer KasemJaffer changed the title switchCamera: Refactor and enable switching between cameras using physical id. Refactor and enable switching between cameras using physical id. May 20, 2025
@KasemJaffer KasemJaffer marked this pull request as ready for review May 20, 2025 16:47
@KasemJaffer
Copy link
Contributor Author

@davidliu I'm not sure why the check is failing. Any ideas how to fix it?

@davidliu
Copy link
Contributor

@davidliu I'm not sure why the check is failing. Any ideas how to fix it?

Looks like the test is failing due to this:

	Suppressed: kotlin.NotImplementedError: An operation is not implemented.
		at io.livekit.android.room.track.LocalVideoTrack$Companion.createCameraTrack$livekit_android_sdk_debug(LocalVideoTrack.kt:465)

This is thrown when the capturer couldn't be created, likely due to no camera being found. We have a MockCameraProvider for use in unit tests here:

https://github.com/livekit/client-sdk-android/blob/main/livekit-android-test/src/main/java/io/livekit/android/test/mock/camera/MockCameraProvider.kt

You can run tests locally, through ./gradlew livekit-android-test:testRelease or simply right clicking the livekit-android-test test folder and running the tests through Android Studio.

@KasemJaffer KasemJaffer requested a review from davidliu May 23, 2025 16:42
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.

3 participants