blob: ecb28878e32937bd75627bb45019a4cf5a6a2e03 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module cros.mojom;
import "media/capture/mojom/image_capture.mojom";
import "media/capture/video/chromeos/mojom/camera_common.mojom";
import "media/capture/video/chromeos/mojom/camera_metadata.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/range/mojom/range.mojom";
// Effect that recognized by Chrome OS.
enum Effect {
NO_EFFECT = 0,
PORTRAIT_MODE = 1,
};
// Stream types that can be observed by camera app device.
// This is a mirror of the StreamType in camera_device_delegate.h
enum StreamType {
PREVIEW_OUTPUT = 0,
JPEG_OUTPUT = 1,
YUV_INPUT = 2,
YUV_OUTPUT = 3,
UNKNOWN = 4,
};
// Status code for getting camera app device.
enum GetCameraAppDeviceStatus {
SUCCESS = 0,
ERROR_INVALID_ID = 1,
};
// The purpose of this capture is to help the camera device decide optimal
// configurations.
enum CaptureIntent {
DEFAULT = 0,
VIDEO_RECORD = 1,
STILL_CAPTURE = 2,
DOCUMENT = 3,
};
// Interface to let Chrome Camera App (Remote) get specific CameraAppDevice from
// Chrome (Receiver).
interface CameraAppDeviceProvider {
// Gets the interface to communicate with specific camera device given by
// |source_id|. If the |status| is not success, the |device| would be null.
GetCameraAppDevice(string source_id)
=> (GetCameraAppDeviceStatus status,
pending_remote<CameraAppDevice>? device);
// Checks if the device supports direct communication between camera devices
// and camera app. Currently only devices running camera HAL v3 support this
// feature.
IsSupported() => (bool is_supported);
// Add/Remove a virtual device for recording stream according to |enabled|.
// The virtual device has the same config as |device_id| except facing
// attribute.
SetMultipleStreamsEnabled(string device_id, bool enabled) => (bool success);
};
// Inner interface that used to communicate between browser process (Remote) and
// the Video Capture service (Receiver).
interface CameraAppDeviceBridge {
// Gets the interface to communicate with specific camera device given by
// |device_id|. If the |status| is not success, the |device| would be null.
GetCameraAppDevice(string device_id)
=> (GetCameraAppDeviceStatus status,
pending_remote<CameraAppDevice>? device);
// Checks if the device supports direct communication between camera devices
// and camera app. Currently only devices running camera HAL v3 support this
// feature.
IsSupported() => (bool is_supported);
// Add/Remove a virtual device for recording stream according to |enabled|.
// The virtual device has the same config as |device_id| except facing
// attribute.
SetMultipleStreamsEnabled(string device_id, bool enabled) => (bool success);
};
// Interface for communication from the Chrome Camera App (Remote) to the camera
// device (Receiver). The Chrome Camera App is a system web app and runs inside
// a renderer process, with all the code resides in the Chrome OS rootfs. The
// camera device runs inside the browser process.
interface CameraAppDevice {
// Gets camera information |camera_info| which includes camera facing,
// characteristics, orientation, etc.
GetCameraInfo() => (CameraInfo camera_info);
// Sets reprocess options to bind with the coming take photo request. When
// this method is called, the reprocess options will be queued. All reprocess
// options in the queue will be consumed when ImageCapture::TakePhoto() is
// triggered and all the queued reprocess options will be bound to that take
// photo request.
SetReprocessOptions(array<Effect> effects,
pending_remote<ReprocessResultListener> listener) => ();
// Sets the fps range for upcoming configured camera stream.
// The caller sets the |fps_range|.
// If the given fps range is valid and set successfully, |is_success| returns
// true. If the given fps range is invalid, the fps range which is cached
// previously will be cleared and |is_success| will return false.
SetFpsRange(gfx.mojom.Range fps_range) => (bool is_success);
// Sets the |resolution| for still capture stream which should be
// configured later so that we can configure the most suitable properties.
SetStillCaptureResolution(gfx.mojom.Size resolution) => ();
// Sets the intent for the upcoming capture session. The underlying video
// capture device should configure the streams accordingly. Returns an empty
// response after the intent is set, which could be used to sequence the
// other calls such as getUserMedia().
SetCaptureIntent(CaptureIntent intent) => ();
// Adds the remote of a ResultMetadataObserver to CameraAppDevice.
// The |observer| will have a remote call from camera device.
AddResultMetadataObserver(pending_remote<ResultMetadataObserver> observer,
StreamType stream_type) => ();
// Adds an observer for camera events. The |observer| is the remote of the
// observer to be added.
AddCameraEventObserver(pending_remote<CameraEventObserver> observer) => ();
// Sets whether to disable the camera frame rotation at source. Sets
// |is_success| to true if |is_enabled| is correctly set.
SetCameraFrameRotationEnabledAtSource(bool is_enabled) => (bool is_success);
// Gets the clock-wise rotation in degree applied, or needs to be applied if
// the rotation is disabled at source, on the raw camera frame in order to
// display the camera preview upright in the UI. The only valid values for
// |rotation| are 0, 90, 180, and 270.
GetCameraFrameRotation() => (uint32 rotation);
// Registers the document corners observer for preview.
RegisterDocumentCornersObserver(
pending_remote<DocumentCornersObserver> observer) => ();
};
// Interface for camera device to send camera metadata to Chrome Camera App.
interface ResultMetadataObserver {
// Remotely invoked by camera device whenever a |camera_metadata| of a frame
// is produced.
OnMetadataAvailable(CameraMetadata camera_metadata);
};
// Interface for observing camera events such as shutter done.
interface CameraEventObserver {
// Triggered when the shutter is done for a still capture image.
OnShutterDone();
};
// Interface for document corners detection.
interface DocumentCornersObserver {
// Triggered when the detected document |corners| should be updated.
// The amount of corners will be either 0, indicating there are no corners
// detected, or 4, which are in top-left => bottom-left => bottom-right =>
// top-right order. The value of the coordinate of a corner will be in [0, 1).
OnDocumentCornersUpdated(array<gfx.mojom.PointF> corners);
};
// Interface for the listener of reprocess results.
interface ReprocessResultListener {
// Triggered when reprocess done for target |effect|.
OnReprocessDone(Effect effect, int32 status, media.mojom.Blob? blob);
};