mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

Specifically, defer getting the camera index so the error can be reported instead of crashing: Fatal Exception: java.lang.IllegalArgumentException: No such camera: Camera 1, Facing front, Orientation 270 at org.webrtc.Camera1Enumerator.getCameraIndex(Camera1Enumerator.java:170) at org.webrtc.Camera1Capturer.createCameraSession(Camera1Capturer.java:31) at org.webrtc.CameraCapturer$5.run(CameraCapturer.java:272) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:65) Bug: webrtc:13032 Change-Id: Ida6bc65046770c11c2b3ee832906e8454cec10df Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227290 Reviewed-by: Xavier Lepaul <xalep@webrtc.org> Commit-Queue: Xavier Lepaul <xalep@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34855}
33 lines
1.2 KiB
Java
33 lines
1.2 KiB
Java
/*
|
|
* Copyright 2016 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
package org.webrtc;
|
|
|
|
import android.content.Context;
|
|
|
|
public class Camera1Capturer extends CameraCapturer {
|
|
private final boolean captureToTexture;
|
|
|
|
public Camera1Capturer(
|
|
String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) {
|
|
super(cameraName, eventsHandler, new Camera1Enumerator(captureToTexture));
|
|
|
|
this.captureToTexture = captureToTexture;
|
|
}
|
|
|
|
@Override
|
|
protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
|
|
CameraSession.Events events, Context applicationContext,
|
|
SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
|
|
int framerate) {
|
|
Camera1Session.create(createSessionCallback, events, captureToTexture, applicationContext,
|
|
surfaceTextureHelper, cameraName, width, height, framerate);
|
|
}
|
|
}
|