// Copyright 2019 The Chromium Authors
// 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 {
kNoEffect = 0,
kPortraitMode = 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 {
kPreviewOutput = 0,
kJpegOutput = 1,
kJpegPortraitOutput = 2,
kRecordingOutput = 3,
kUnknown = 4,
};
// Status code for getting camera app device.
enum GetCameraAppDeviceStatus {
kSuccess = 0,
kErrorInvalidId = 1,
};
// The purpose of this capture is to help the camera device decide optimal
// configurations.
enum CaptureIntent {
kDefault = 0,
kVideoRecord = 1,
kStillCapture = 2,
kPortraitCapture = 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);
// Check if the device with |source_id| is in use.
IsDeviceInUse(string source_id) => (bool in_use);
};
// 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.
SetVirtualDeviceEnabled(string device_id, bool enabled) => (bool success);
// Check if the device with |device_id| is in use.
IsDeviceInUse(string device_id) => (bool in_use);
};
// 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 {
// Takes portrait mode photos and returns the results to the observer.
// The observer will be called by the camera device when the result is ready.
TakePortraitModePhoto(
pending_remote<StillCaptureResultObserver> observer) => ();
// 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) => ();
// Enable/Disable the multiple streams feature for video recording on the
// device given by its |device_id|.
SetMultipleStreamsEnabled(bool enabled) => ();
// Registers the observer to monitor the camera info update.
RegisterCameraInfoObserver(
pending_remote<CameraInfoObserver> observer) => ();
// Sets the crop region to CameraAppDevice. The value will be consumed by
// RequestManager to set it to the capture request repeatedly on every frame,
// until the new crop region value is set, or reset to the full crop region.
SetCropRegion(gfx.mojom.Rect crop_region) => ();
// Resets the crop region set by |SetCropRegion|. It is no-ops if there is no
// crop region value set.
ResetCropRegion() => ();
};
// 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 monitoring the change of camera info.
interface CameraInfoObserver {
// Triggered when the camera info is updated, generally happened when the
// underlying camera is restarted.
OnCameraInfoUpdated(CameraInfo camera_info);
};
// Interface for the returned still capture results.
interface StillCaptureResultObserver {
// Triggered when capture done for target |effect|.
OnStillCaptureDone(Effect effect, int32 status, media.mojom.Blob? blob);
};