blob: a6429037e79938631e509ab9bd45c34a635641ca [file] [log] [blame]
// Copyright 2021 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 crosapi.mojom;
import "media/capture/mojom/image_capture.mojom";
import "media/capture/mojom/video_capture_types.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/native_handle_types.mojom";
// This API is used to forward requests/respond of video_capture::DeviceFactory
// and video_capture::Device from Lacros (Client) to the actual implementation
// in Ash-Chrome.
// In addition, to avoid affecting too much on non-Chrome OS components and
// depends on components which will cause cyclic dependency, we used some
// similar but simplified version of structures rather than directly depends on
// the structures in other components.
// Similar to |gfx.mojom.NativePixmapHandle| but does not contain fields which
// are not available on Chrome OS.
// Next min field ID: 2
struct NativePixmapHandle {
array<gfx.mojom.NativePixmapPlane> planes@0;
uint64 modifier@1;
// Similar to |gfx.mojom.GpuMemoryBufferPlatformHandle| but does not contain
// fields which are not available on Chrome OS.
// Next min field ID: 2
union GpuMemoryBufferPlatformHandle {
mojo_base.mojom.UnsafeSharedMemoryRegion shared_memory_handle@0;
NativePixmapHandle native_pixmap_handle@1;
// Similar to |gfx.mojom.GpuMemoryBufferHandle| but does not depend on
// |gfx.mojom.GpuMemoryBufferPlatformHandle|.
// Next min field ID: 4
struct GpuMemoryBufferHandle {
int32 id@0;
uint32 offset@1;
uint32 stride@2;
GpuMemoryBufferPlatformHandle? platform_handle@3;
// Similar to |media.mojom.VideoBufferHandle| but does not contain fields which
// are not used in Chrome OS implementation.
// Next min field ID: 3
[Stable, Uuid="0259e126-6da3-4cbb-8774-da1a7bf7f2f8"]
union VideoBufferHandle {
handle<shared_buffer> shared_buffer_handle@0;
GpuMemoryBufferHandle gpu_memory_buffer_handle@1;
// TODO( Until unions truly support versioning, we
// don't have a way to check this/it ends up ignored. Currently this is only
// set by code in ash to be read by lacros, which is strictly guaranteed to be
// flowing from an older version to a newer version, so this is fine. It can
// be proxied by checking if VideoCaptureDevice supports RequestRefreshFrame,
// which was added at the same time.
mojo_base.mojom.ReadOnlySharedMemoryRegion read_only_shmem_region@2;
[Stable, Extensible]
enum DeviceAccessResultCode {
// Identical to |media.mojom.VideoRotation|.
[Stable, Extensible]
enum VideoRotation {
// Similar to |media.mojom.VideoFrameInfo| but without some fields which does
// not implement on Chrome OS. In addition, since most of the fields in
// |metadata| field is not used in Chrome OS implementation, we also simplify
// the structure by only containing |rotation| and |reference_time|.
// Next min field ID: 6
struct VideoFrameInfo {
mojo_base.mojom.TimeDelta timestamp@0;
media.mojom.VideoCapturePixelFormat pixel_format@1;
gfx.mojom.Size coded_size@2;
gfx.mojom.Rect visible_rect@3;
// The following fields are the fields we may use for constructing
// media::VideoFrameMetadata.
VideoRotation rotation@4;
mojo_base.mojom.TimeTicks reference_time@5;
// Similar to |video_capture.mojom.ReadyFrameInBuffer| but does not depend on
// |media.mojom.VideoFrameInfo| and
// |video_capture.mojom.ScopedAccessPermission|.
// Next min field ID: 4
struct ReadyFrameInBuffer {
int32 buffer_id@0;
int32 frame_feedback_id@1;
pending_remote<ScopedAccessPermission> access_permission@2;
VideoFrameInfo frame_info@3;
// Identical to |video_capture.mojom.ScopedAccessPermission|.
// Next min method ID: 0
[Stable, Uuid="bf0f3239-26d2-45f8-9875-490563f5af97"]
interface ScopedAccessPermission {};
// Similar to |video_capture.mojom.VideoFrameHandler| but depends on simplified
// structures.
// Next min method ID: 11
[Stable, Uuid="590ab36a-9162-4c9d-8429-1753108825ea"]
interface VideoFrameHandler {
OnNewBuffer@0(int32 buffer_id, VideoBufferHandle buffer_handle);
OnFrameReadyInBuffer@1(ReadyFrameInBuffer buffer,
array<ReadyFrameInBuffer> scaled_buffers);
OnBufferRetired@2(int32 buffer_id);
OnError@3(media.mojom.VideoCaptureError error);
OnFrameDropped@4(media.mojom.VideoCaptureFrameDropReason reason);
OnNewCropVersion@10(uint32 crop_version);
OnLog@5(string message);
// Similar to |video_capture.mojom.Device| but depends on simplified structures.
// Next min method ID: 8
[Stable, Uuid="f50f1672-d512-451e-9c70-998ed45ab596"]
interface VideoCaptureDevice {
// It is assumed that it will be called only once.
Start@0(media.mojom.VideoCaptureParams requested_settings,
pending_remote<VideoFrameHandler> handler);
GetPhotoState@3() => (media.mojom.PhotoState? capabilities);
SetPhotoOptions@4(media.mojom.PhotoSettings settings) => (bool success);
TakePhoto@5() => (media.mojom.Blob? blob);
ProcessFeedback@6(media.mojom.VideoCaptureFeedback feedback);
[MinVersion = 1]
// Similar to |video_capture.mojom.DeviceFactory| but depends on simplified
// structures.
// Next min method ID: 2
[Stable, Uuid="b79ed8be-cf39-4d0d-a819-2d299022124a"]
interface VideoCaptureDeviceFactory {
=> (array<media.mojom.VideoCaptureDeviceInfo> device_infos);
CreateDevice@1(string device_id,
pending_receiver<VideoCaptureDevice> device_receiver)
=> (DeviceAccessResultCode result_code);