Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7b4a416 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Expose camera open event to virtual camera owner" into main

parents e97f84b1 20eca0db
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3648,6 +3648,7 @@ package android.companion.virtual.camera {
  }
  public interface VirtualCameraCallback {
    method @FlaggedApi("android.companion.virtualdevice.flags.virtual_camera_on_open") public default void onOpenCamera();
    method public default void onProcessCaptureRequest(int, long);
    method public void onStreamClosed(int);
    method public void onStreamConfigured(int, @NonNull android.view.Surface, @IntRange(from=1) int, @IntRange(from=1) int, int);
+14 −0
Original line number Diff line number Diff line
@@ -26,6 +26,20 @@ import android.view.Surface;
 */
interface IVirtualCameraCallback {

    /**
     * Called when the client application calls
     * {@link android.hardware.camera2.CameraManager#openCamera}. This is the earliest signal that
     * this camera will be used. At this point, no stream is opened yet, nor any configuration took
     * place. The owner of the virtual camera can use this as signal to prepare the camera and
     * reduce latency for when
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession(SessionConfiguration)} is
     * called and before
     * {@link
     * android.hardware.camera2.CameraCaptureSession.StateCallback#onConfigured(CameraCaptureSession)}
     * is called.
     */
    oneway void onOpenCamera();

    /**
     * Called when one of the requested stream has been configured by the virtual camera service and
     * is ready to receive data onto its {@link Surface}
+22 −0
Original line number Diff line number Diff line
@@ -16,10 +16,14 @@

package android.companion.virtual.camera;

import android.annotation.FlaggedApi;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.companion.virtualdevice.flags.Flags;
import android.graphics.ImageFormat;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.params.SessionConfiguration;
import android.view.Surface;

import java.util.concurrent.Executor;
@@ -34,9 +38,27 @@ import java.util.concurrent.Executor;
@SystemApi
public interface VirtualCameraCallback {

    /**
     * Called when the client application calls
     * {@link android.hardware.camera2.CameraManager#openCamera}. This is the earliest signal that
     * this camera will be used. At this point, no stream is opened yet, nor any configuration took
     * place. The owner of the virtual camera can use this as signal to prepare the camera and
     * reduce latency for when
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession(SessionConfiguration)} is
     * called and before
     * {@link CameraCaptureSession.StateCallback#onConfigured(CameraCaptureSession)}
     * is called.
     */
    @FlaggedApi(Flags.FLAG_VIRTUAL_CAMERA_ON_OPEN)
    default void onOpenCamera() {
    }

    /**
     * Called when one of the requested stream has been configured by the virtual camera service and
     * is ready to receive data onto its {@link Surface}
     * <p>
     * This corresponds to the client calling
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession(SessionConfiguration)}
     *
     * @param streamId The id of the configured stream
     * @param surface The surface to write data into for this stream
+6 −0
Original line number Diff line number Diff line
@@ -351,6 +351,12 @@ public final class VirtualCameraConfig implements Parcelable {
            mExecutor = executor;
        }

        public void onOpenCamera() {
            if (Flags.virtualCameraOnOpen()) {
                mExecutor.execute(mCallback::onOpenCamera);
            }
        }

        @Override
        public void onStreamConfigured(int streamId, Surface surface, int width, int height,
                int format) {
+10 −1
Original line number Diff line number Diff line
@@ -197,3 +197,12 @@ flag {
    description: "Enable VDM access for computer control"
    bug: "410570802"
}

flag {
    name: "virtual_camera_on_open"
    namespace: "virtual_devices"
    description: "Callback called when the virtual camera device is requested to be opened"
    bug: "409241122"
    is_exported: true
}
Loading