Camera2 multi-client support
Enable multiple clients to establish a shared session. Once the
session is created, allow each client to independently initiate and
terminate streaming using the `startStreaming` and `stopStreaming`
APIs. Additionally, primary clients can call create captureRequest
API. Ensure that all clients can simultaneously stream the camera
images.
Flag: com.android.internal.camera.flags.camera_multi_client
Bug:265196098
API-Coverage-Bug: 377371012
Test: A session is established with a shared configuration that
supports two streams: SurfaceView and ImageReader. The Java client
can create a session utilizing the SurfaceView stream. The native
client can create a session utilizing the ImageReader stream.
The Java client initiates streaming by creating a capture request and
using the `setRepeatingRequest` method. The native client initiates
streaming using the `startStreaming` API and the ImageReader surface
to receive camera images. Also, ran camera CTS tests on these CLs to
ensure we don't introduce any regressions.
Change-Id: I6ab4e5eef094e75c9b1230ad24afe1c50133df86
diff --git a/camera/ndk/NdkCameraCaptureSession.cpp b/camera/ndk/NdkCameraCaptureSession.cpp
index 58370e5..06ee714 100644
--- a/camera/ndk/NdkCameraCaptureSession.cpp
+++ b/camera/ndk/NdkCameraCaptureSession.cpp
@@ -178,30 +178,39 @@
EXPORT
camera_status_t ACameraCaptureSessionShared_startStreaming(
- ACameraCaptureSession* /*session*/, ACameraCaptureSession_captureCallbacksV2* /*callbacks*/,
- int /*numOutputWindows*/, ANativeWindow** /*window*/,
- int* /*captureSequenceId*/) {
+ ACameraCaptureSession* session,
+ /*optional*/ACameraCaptureSession_captureCallbacksV2* callbacks,
+ int numOutputWindows, ANativeWindow** windows,
+ /*optional*/int* captureSequenceId) {
ATRACE_CALL();
- // Todo: need to add implementation
- return ACAMERA_OK;
+ return startStreamingTemplate(session, callbacks, numOutputWindows, windows,
+ captureSequenceId);
}
EXPORT
camera_status_t ACameraCaptureSessionShared_logicalCamera_startStreaming(
- ACameraCaptureSession* /*session*/,
- ACameraCaptureSession_logicalCamera_captureCallbacksV2* /*callbacks*/,
- int /*numOutputWindows*/, ANativeWindow** /*windows*/,
- int* /*captureSequenceId*/) {
+ ACameraCaptureSession* session,
+ /*optional*/ACameraCaptureSession_logicalCamera_captureCallbacksV2* callbacks,
+ int numOutputWindows, ANativeWindow** windows,
+ /*optional*/int* captureSequenceId) {
ATRACE_CALL();
- // Todo: need to add implementation
- return ACAMERA_OK;
+ return startStreamingTemplate(session, callbacks, numOutputWindows, windows,
+ captureSequenceId);
}
EXPORT
-camera_status_t ACameraCaptureSessionShared_stopStreaming(ACameraCaptureSession* /*session*/) {
+camera_status_t ACameraCaptureSessionShared_stopStreaming(ACameraCaptureSession* session) {
ATRACE_CALL();
- // Todo: need to add implementation
- return ACAMERA_OK;
+ if (session == nullptr) {
+ ALOGE("%s: Error: session is null", __FUNCTION__);
+ return ACAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ if (session->isClosed()) {
+ ALOGE("%s: session %p is already closed", __FUNCTION__, session);
+ return ACAMERA_ERROR_SESSION_CLOSED;
+ }
+ return session->stopStreaming();
}
EXPORT