Jeremy Leconte 2d75cd3664 Roll chromium_revision ccf648df91..aa68dfe997 (1365600:1366639)
Change log: ccf648df91..aa68dfe997
Full diff: ccf648df91..aa68dfe997

Changed dependencies
* reclient_version: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip
* src/base: 006d78d70b..68128fa0f0
* src/build: f2790bfa32..6d08a23c99
* src/buildtools: 0a905dcb6d..754803453c
* src/buildtools/reclient: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip
* src/ios: 26dfb6e15c..53b28a3235
* src/testing: 3ef5641e1f..b6f87cfcfb
* src/third_party: c8056c18ac..512db14abf
* src/third_party/android_build_tools/error_prone/cipd: 15eqqvDTRtPu1Sy8b4WuOiqkivE9ibCjSdoOtqJYyBEC..hUxlP8GvC1xhmZ6r9xjYau2laPlzHbs_P2emx4ZL4jgC
* src/third_party/android_build_tools/manifest_merger/cipd: p2c9mSgfF-HErc8CM-jOFuuMbaMK-POsiqbeG5plk2cC..qI7pOwGO6rjfncAZKTugRAPn9Qs_MdwCWpzfRuiBgGMC
* src/third_party/androidx/cipd: yhwW_7P0l18P6ykZSqwXqx6HFyhPIcUGNcebIIppU-IC..k1wif7sS51pJGSFGN7FAeGWDorxgPart9E1f383TQL4C
* src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/fa0214602c..905c3903fd
* src/third_party/depot_tools: c109945e72..0ab52232ff
* src/third_party/kotlin_stdlib/cipd: 5lJOPRAms_Yty4OyjHlXdB_6UFqzeGHM6YuuuUZ3P9MC..zgrGgJIQ7F4H3GT_uf41Ya6Pw7BBQlC99_kJVEwfEk8C
* src/third_party/libc++/src: f114473071..283f1aa1ad
* src/third_party/libc++abi/src: 829f51051c..975ef56df0
* src/third_party/libvpx/source/libvpx: 09b3d5fc5a..906334ac1d
* src/third_party/libyuv: 77f3acade4..a8e59d2074
* src/third_party/perfetto: 5361e5909e..48c5df53f4
* src/third_party/r8/d8/cipd: yEomA-IPmb_JtuiEvwgtxRHtSEaICkDY1sDko_rQGO0C..3KCj5eRYCvGGYs5i90pRaeihkzsqgUGc4OkICT8AOlIC
* src/tools: 8c5814c8d2..3a202879c1
* src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77
* src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77
DEPS diff: ccf648df91..aa68dfe997/DEPS

No update to Clang.

BUG=None

Change-Id: Ib8b14ce25ae98d98f648e31dc64197c3578b1c92
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365261
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43212}
2024-10-10 09:11:32 +00:00

336 lines
10 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 static org.junit.Assert.fail;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.Nullable;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.filters.MediumTest;
import androidx.test.filters.SmallTest;
import java.util.concurrent.CountDownLatch;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class Camera2CapturerTest {
static final String TAG = "Camera2CapturerTest";
/**
* Simple camera2 implementation that only knows how to open the camera and close it.
*/
private class SimpleCamera2 {
final CameraManager cameraManager;
final LooperThread looperThread;
final CountDownLatch openDoneSignal;
final Object cameraDeviceLock;
@Nullable CameraDevice cameraDevice; // Guarded by cameraDeviceLock
boolean openSucceeded; // Guarded by cameraDeviceLock
@SuppressWarnings("ClassCanBeStatic")
private class LooperThread extends Thread {
final CountDownLatch startedSignal = new CountDownLatch(1);
private Handler handler;
@Override
public void run() {
Looper.prepare();
handler = new Handler();
startedSignal.countDown();
Looper.loop();
}
public void waitToStart() {
ThreadUtils.awaitUninterruptibly(startedSignal);
}
public void requestStop() {
handler.getLooper().quit();
}
public Handler getHandler() {
return handler;
}
}
private class CameraStateCallback extends CameraDevice.StateCallback {
@Override
public void onClosed(CameraDevice cameraDevice) {
Logging.d(TAG, "Simple camera2 closed.");
synchronized (cameraDeviceLock) {
SimpleCamera2.this.cameraDevice = null;
}
}
@Override
public void onDisconnected(CameraDevice cameraDevice) {
Logging.d(TAG, "Simple camera2 disconnected.");
synchronized (cameraDeviceLock) {
SimpleCamera2.this.cameraDevice = null;
}
}
@Override
public void onError(CameraDevice cameraDevice, int errorCode) {
Logging.w(TAG, "Simple camera2 error: " + errorCode);
synchronized (cameraDeviceLock) {
SimpleCamera2.this.cameraDevice = cameraDevice;
openSucceeded = false;
}
openDoneSignal.countDown();
}
@Override
public void onOpened(CameraDevice cameraDevice) {
Logging.d(TAG, "Simple camera2 opened.");
synchronized (cameraDeviceLock) {
SimpleCamera2.this.cameraDevice = cameraDevice;
openSucceeded = true;
}
openDoneSignal.countDown();
}
}
SimpleCamera2(Context context, String deviceName) {
cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
looperThread = new LooperThread();
looperThread.start();
looperThread.waitToStart();
cameraDeviceLock = new Object();
openDoneSignal = new CountDownLatch(1);
cameraDevice = null;
Logging.d(TAG, "Opening simple camera2.");
try {
cameraManager.openCamera(deviceName, new CameraStateCallback(), looperThread.getHandler());
} catch (CameraAccessException e) {
fail("Simple camera2 CameraAccessException: " + e.getMessage());
}
Logging.d(TAG, "Waiting for simple camera2 to open.");
ThreadUtils.awaitUninterruptibly(openDoneSignal);
synchronized (cameraDeviceLock) {
if (!openSucceeded) {
fail("Opening simple camera2 failed.");
}
}
}
public void close() {
Logging.d(TAG, "Closing simple camera2.");
synchronized (cameraDeviceLock) {
if (cameraDevice != null) {
cameraDevice.close();
}
}
looperThread.requestStop();
ThreadUtils.joinUninterruptibly(looperThread);
}
}
private class TestObjectFactory extends CameraVideoCapturerTestFixtures.TestObjectFactory {
@Override
public CameraEnumerator getCameraEnumerator() {
return new Camera2Enumerator(getAppContext());
}
@Override
public Context getAppContext() {
return InstrumentationRegistry.getTargetContext();
}
@SuppressWarnings("deprecation")
@Override
public Object rawOpenCamera(String cameraName) {
return new SimpleCamera2(getAppContext(), cameraName);
}
@SuppressWarnings("deprecation")
@Override
public void rawCloseCamera(Object camera) {
((SimpleCamera2) camera).close();
}
}
private CameraVideoCapturerTestFixtures fixtures;
@Before
public void setUp() {
fixtures = new CameraVideoCapturerTestFixtures(new TestObjectFactory());
}
@After
public void tearDown() {
fixtures.dispose();
}
@Test
@SmallTest
public void testCreateAndDispose() throws InterruptedException {
fixtures.createCapturerAndDispose();
}
@Test
@SmallTest
public void testCreateNonExistingCamera() throws InterruptedException {
fixtures.createNonExistingCamera();
}
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using a "default" capturer.
// It tests both the Java and the C++ layer.
@Test
@MediumTest
public void testCreateCapturerAndRender() throws InterruptedException {
fixtures.createCapturerAndRender();
}
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using the front facing video capturer.
// It tests both the Java and the C++ layer.
@Test
@MediumTest
public void testStartFrontFacingVideoCapturer() throws InterruptedException {
fixtures.createFrontFacingCapturerAndRender();
}
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using the back facing video capturer.
// It tests both the Java and the C++ layer.
@Test
@MediumTest
public void testStartBackFacingVideoCapturer() throws InterruptedException {
fixtures.createBackFacingCapturerAndRender();
}
// This test that the default camera can be started and that the camera can
// later be switched to another camera.
// It tests both the Java and the C++ layer.
@Test
@MediumTest
public void testSwitchVideoCapturer() throws InterruptedException {
fixtures.switchCamera();
}
@Test
@MediumTest
public void testSwitchVideoCapturerToSpecificCameraName() throws InterruptedException {
fixtures.switchCamera(true /* specifyCameraName */);
}
@Test
@MediumTest
public void testCameraEvents() throws InterruptedException {
fixtures.cameraEventsInvoked();
}
// Test what happens when attempting to call e.g. switchCamera() after camera has been stopped.
@Test
@MediumTest
public void testCameraCallsAfterStop() throws InterruptedException {
fixtures.cameraCallsAfterStop();
}
// This test that the VideoSource that the CameraVideoCapturer is connected to can
// be stopped and restarted. It tests both the Java and the C++ layer.
@Test
@LargeTest
public void testStopRestartVideoSource() throws InterruptedException {
fixtures.stopRestartVideoSource();
}
// This test that the camera can be started at different resolutions.
// It does not test or use the C++ layer.
@Test
@LargeTest
public void testStartStopWithDifferentResolutions() throws InterruptedException {
fixtures.startStopWithDifferentResolutions();
}
// This test what happens if buffers are returned after the capturer have
// been stopped and restarted. It does not test or use the C++ layer.
@Test
@LargeTest
public void testReturnBufferLate() throws InterruptedException {
fixtures.returnBufferLate();
}
// This test that we can capture frames, keep the frames in a local renderer, stop capturing,
// and then return the frames. The difference between the test testReturnBufferLate() is that we
// also test the JNI and C++ AndroidVideoCapturer parts.
@Test
@MediumTest
public void testReturnBufferLateEndToEnd() throws InterruptedException {
fixtures.returnBufferLateEndToEnd();
}
// This test that CameraEventsHandler.onError is triggered if video buffers are not returned to
// the capturer.
@Test
@LargeTest
public void testCameraFreezedEventOnBufferStarvation() throws InterruptedException {
fixtures.cameraFreezedEventOnBufferStarvation();
}
// This test that frames forwarded to a renderer is scaled if adaptOutputFormat is
// called. This test both Java and C++ parts of of the stack.
@Test
@MediumTest
public void testScaleCameraOutput() throws InterruptedException {
fixtures.scaleCameraOutput();
}
// This test that frames forwarded to a renderer is cropped to a new orientation if
// adaptOutputFormat is called in such a way. This test both Java and C++ parts of of the stack.
@Test
@MediumTest
public void testCropCameraOutput() throws InterruptedException {
fixtures.cropCameraOutput();
}
// This test that an error is reported if the camera is already opened
// when CameraVideoCapturer is started.
@Test
@LargeTest
public void testStartWhileCameraIsAlreadyOpen() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpen();
}
// This test that CameraVideoCapturer can be started, even if the camera is already opened
// if the camera is closed while CameraVideoCapturer is re-trying to start.
@Test
@LargeTest
public void testStartWhileCameraIsAlreadyOpenAndCloseCamera() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpenAndCloseCamera();
}
// This test that CameraVideoCapturer.stop can be called while CameraVideoCapturer is
// re-trying to start.
@Test
@MediumTest
public void testStartWhileCameraIsAlreadyOpenAndStop() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpenAndStop();
}
}