summaryrefslogtreecommitdiff
path: root/chromium/media/capture/mojom/video_capture_types.mojom
blob: 672078673c09f41568134e1806e4f51479f458e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
// Copyright 2016 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 media.mojom;

import "gpu/ipc/common/mailbox_holder.mojom";
import "media/mojo/mojom/media_types.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
import "ui/gfx/mojom/color_space.mojom";

enum VideoCapturePixelFormat {
  UNKNOWN,
  I420,
  YV12,
  I422,
  I420A,
  I444,
  NV12,
  NV21,
  UYVY,
  YUY2,
  ARGB,
  XRGB,
  RGB24,
  MJPEG,
  YUV420P9,
  YUV420P10,
  YUV422P9,
  YUV422P10,
  YUV444P9,
  YUV444P10,
  YUV420P12,
  YUV422P12,
  YUV444P12,
  Y16,
  ABGR,
  XBGR,
  P016LE,
  XR30,
  XB30,
  BGRA,
};

enum ResolutionChangePolicy {
  FIXED_RESOLUTION,
  FIXED_ASPECT_RATIO,
  ANY_WITHIN_LIMIT,
};

enum PowerLineFrequency {
  DEFAULT,
  HZ_50,
  HZ_60
};

enum VideoFacingMode {
  NONE,
  USER,
  ENVIRONMENT
};

enum VideoCaptureApi {
  LINUX_V4L2_SINGLE_PLANE,
  WIN_MEDIA_FOUNDATION,
  WIN_MEDIA_FOUNDATION_SENSOR,
  WIN_DIRECT_SHOW,
  MACOSX_AVFOUNDATION,
  MACOSX_DECKLINK,
  ANDROID_API1,
  ANDROID_API2_LEGACY,
  ANDROID_API2_FULL,
  ANDROID_API2_LIMITED,
  FUCHSIA_CAMERA3,
  VIRTUAL_DEVICE,
  UNKNOWN
};

enum VideoCaptureTransportType {
  // For MACOSX_AVFOUNDATION Api, identifies devices that are built-in or USB.
  MACOSX_USB_OR_BUILT_IN,
  OTHER_TRANSPORT
};

enum VideoCaptureBufferType {
  kSharedMemory,

  // Warning: This case is a workaround for compatibility with an older version
  // of Mojo only and will be deleted as soon as the Mojo version of ChromiumOS
  // becomes compatible with the |kSharedMemory|.
  // TODO(chfremer): Remove this when https://crbug.com/857537 is resolved.
  kSharedMemoryViaRawFileDescriptor,

  kMailboxHolder,

  kGpuMemoryBuffer
};

// Represents capture device's support for different controls.
struct VideoCaptureControlSupport {
  bool pan;
  bool tilt;
  bool zoom;
};

enum VideoCaptureError {
  kNone,
  kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested,
  kVideoCaptureControllerIsAlreadyInErrorState,
  kVideoCaptureManagerDeviceConnectionLost,
  kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError,
  kFrameSinkVideoCaptureDeviceEncounteredFatalError,
  kV4L2FailedToOpenV4L2DeviceDriverFile,
  kV4L2ThisIsNotAV4L2VideoCaptureDevice,
  kV4L2FailedToFindASupportedCameraFormat,
  kV4L2FailedToSetVideoCaptureFormat,
  kV4L2UnsupportedPixelFormat,
  kV4L2FailedToSetCameraFramerate,
  kV4L2ErrorRequestingMmapBuffers,
  kV4L2AllocateBufferFailed,
  kV4L2VidiocStreamonFailed,
  kV4L2VidiocStreamoffFailed,
  kV4L2FailedToVidiocReqbufsWithCount0,
  kV4L2PollFailed,
  kV4L2MultipleContinuousTimeoutsWhileReadPolling,
  kV4L2FailedToDequeueCaptureBuffer,
  kV4L2FailedToEnqueueCaptureBuffer,
  kSingleClientVideoCaptureHostLostConnectionToDevice,
  kSingleClientVideoCaptureDeviceLaunchAborted,
  kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed,
  kFileVideoCaptureDeviceCouldNotOpenVideoFile,
  kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate,
  kErrorFakeDeviceIntentionallyEmittingErrorEvent,
  kDeviceClientTooManyFramesDroppedY16,
  kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType,
  kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound,
  kInProcessDeviceLauncherFailedToCreateDeviceInstance,
  kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart,
  kServiceDeviceLauncherServiceRespondedWithDeviceNotFound,
  kServiceDeviceLauncherConnectionLostWhileWaitingForCallback,
  kIntentionalErrorRaisedByUnitTest,
  kCrosHalV3FailedToStartDeviceThread,
  kCrosHalV3DeviceDelegateMojoConnectionError,
  kCrosHalV3DeviceDelegateFailedToGetCameraInfo,
  kCrosHalV3DeviceDelegateMissingSensorOrientationInfo,
  kCrosHalV3DeviceDelegateFailedToOpenCameraDevice,
  kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice,
  kCrosHalV3DeviceDelegateFailedToConfigureStreams,
  kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured,
  kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings,
  kCrosHalV3BufferManagerHalRequestedTooManyBuffers,
  kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer,
  kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer,
  kCrosHalV3BufferManagerUnsupportedVideoPixelFormat,
  kCrosHalV3BufferManagerFailedToDupFd,
  kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle,
  kCrosHalV3BufferManagerFailedToRegisterBuffer,
  kCrosHalV3BufferManagerProcessCaptureRequestFailed,
  kCrosHalV3BufferManagerInvalidPendingResultId,
  kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata,
  kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived,
  kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived,
  kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame,
  kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg,
  kCrosHalV3BufferManagerReceivedInvalidShutterTime,
  kCrosHalV3BufferManagerFatalDeviceError,
  kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder,
  kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd,
  kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut,
  kCrosHalV3BufferManagerInvalidJpegBlob,
  kAndroidFailedToAllocate,
  kAndroidFailedToStartCapture,
  kAndroidFailedToStopCapture,
  kAndroidApi1CameraErrorCallbackReceived,
  kAndroidApi2CameraDeviceErrorReceived,
  kAndroidApi2CaptureSessionConfigureFailed,
  kAndroidApi2ImageReaderUnexpectedImageFormat,
  kAndroidApi2ImageReaderSizeDidNotMatchImageSize,
  kAndroidApi2ErrorRestartingPreview,
  kAndroidScreenCaptureUnsupportedFormat,
  kAndroidScreenCaptureFailedToStartCaptureMachine,
  kAndroidScreenCaptureTheUserDeniedScreenCapture,
  kAndroidScreenCaptureFailedToStartScreenCapture,
  kWinDirectShowCantGetCaptureFormatSettings,
  kWinDirectShowFailedToGetNumberOfCapabilities,
  kWinDirectShowFailedToGetCaptureDeviceCapabilities,
  kWinDirectShowFailedToSetCaptureDeviceOutputFormat,
  kWinDirectShowFailedToConnectTheCaptureGraph,
  kWinDirectShowFailedToPauseTheCaptureDevice,
  kWinDirectShowFailedToStartTheCaptureDevice,
  kWinDirectShowFailedToStopTheCaptureGraph,
  kWinMediaFoundationEngineIsNull,
  kWinMediaFoundationEngineGetSourceFailed ,
  kWinMediaFoundationFillPhotoCapabilitiesFailed ,
  kWinMediaFoundationFillVideoCapabilitiesFailed,
  kWinMediaFoundationNoVideoCapabilityFound,
  kWinMediaFoundationGetAvailableDeviceMediaTypeFailed,
  kWinMediaFoundationSetCurrentDeviceMediaTypeFailed,
  kWinMediaFoundationEngineGetSinkFailed,
  kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed,
  kWinMediaFoundationSinkRemoveAllStreamsFailed,
  kWinMediaFoundationCreateSinkVideoMediaTypeFailed,
  kWinMediaFoundationConvertToVideoSinkMediaTypeFailed,
  kWinMediaFoundationSinkAddStreamFailed,
  kWinMediaFoundationSinkSetSampleCallbackFailed,
  kWinMediaFoundationEngineStartPreviewFailed,
  kWinMediaFoundationGetMediaEventStatusFailed,
  kMacSetCaptureDeviceFailed,
  kMacCouldNotStartCaptureDevice,
  kMacReceivedFrameWithUnexpectedResolution,
  kMacUpdateCaptureResolutionFailed,
  kMacDeckLinkDeviceIdNotFoundInTheSystem,
  kMacDeckLinkErrorQueryingInputInterface,
  kMacDeckLinkErrorCreatingDisplayModeIterator,
  kMacDeckLinkCouldNotFindADisplayMode,
  kMacDeckLinkCouldNotSelectTheVideoFormatWeLike,
  kMacDeckLinkCouldNotStartCapturing,
  kMacDeckLinkUnsupportedPixelFormat,
  kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification,
  kAndroidApi2ErrorConfiguringCamera,
  kCrosHalV3DeviceDelegateFailedToFlush,
  kFuchsiaCameraDeviceDisconnected,
  kFuchsiaCameraStreamDisconnected,
  kFuchsiaSysmemDidNotSetImageFormat,
  kFuchsiaSysmemInvalidBufferIndex,
  kFuchsiaSysmemInvalidBufferSize,
  kFuchsiaUnsupportedPixelFormat,
  kFuchsiaFailedToMapSysmemBuffer,
};

enum VideoCaptureFrameDropReason {
  kNone,
  kDeviceClientFrameHasInvalidFormat,
  kDeviceClientLibyuvConvertToI420Failed,
  kV4L2BufferErrorFlagWasSet,
  kV4L2InvalidNumberOfBytesInBuffer,
  kAndroidThrottling,
  kAndroidGetByteArrayElementsFailed,
  kAndroidApi1UnexpectedDataLength,
  kAndroidApi2AcquiredImageIsNull,
  kWinDirectShowUnexpectedSampleLength,
  kWinDirectShowFailedToGetMemoryPointerFromMediaSample,
  kWinMediaFoundationReceivedSampleIsNull,
  kWinMediaFoundationLockingBufferDelieveredNullptr,
  kWinMediaFoundationGetBufferByIndexReturnedNull,
  kBufferPoolMaxBufferCountExceeded,
  kBufferPoolBufferAllocationFailed,
  kVideoCaptureImplNotInStartedState,
  kVideoCaptureImplFailedToWrapDataAsMediaVideoFrame,
  kVideoTrackAdapterHasNoResolutionAdapters,
  kResolutionAdapterFrameIsNotValid,
  kResolutionAdapterWrappingFrameForCroppingFailed,
  kResolutionAdapterTimestampTooCloseToPrevious,
  kResolutionAdapterFrameRateIsHigherThanRequested,
  kResolutionAdapterHasNoCallbacks,
  kVideoTrackFrameDelivererNotEnabledReplacingWithBlackFrame,
  kRendererSinkFrameDelivererIsNotStarted
};

struct VideoCaptureFormat {
  gfx.mojom.Size frame_size;
  float frame_rate;
  VideoCapturePixelFormat pixel_format;
};

struct VideoCaptureParams {
  VideoCaptureFormat requested_format;
  VideoCaptureBufferType buffer_type;
  ResolutionChangePolicy resolution_change_policy;
  PowerLineFrequency power_line_frequency;
  bool enable_face_detection;
};

// |resource_utilization| reports that the frame incurred some fractional
// utilization of the downstream pipeline's per-frame processing capacity.
// See code comments in media::base::VideoFrameMetadata for a discussion of
// how utilization is interpreted. The capturer uses this information to
// auto-adjust the capture resolution based on performance variances in the
// live system environment.
// -1.0 means no value present.
//
// |max_framerate_fps| reports requested maximum frame-rate
// float::inifinty used to signal no limit.
//
// |max_pixels| reports requested maximum resolution (in sense of image area).
// int::max used to signal no limit.
struct VideoFrameFeedback {
  double resource_utilization;

  float max_framerate_fps;

  int32 max_pixels;
};

// Contains one stride value per image plane. Stride means the number of bytes
// per row. If the image format uses fewer than kMaxPlanes planes, the values
// for higher plane indices are ignored. For example, for a YUV format, plane
// index 0 corresponds to the Y plane, index 1 to the U plane, and index 2 to
// the V plane.
struct PlaneStrides {
  // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
  array<uint32, 4> stride_by_plane;
};

struct VideoFrameInfo{
  mojo_base.mojom.TimeDelta timestamp;
  VideoFrameMetadata metadata;
  VideoCapturePixelFormat pixel_format;
  gfx.mojom.Size coded_size;
  gfx.mojom.Rect visible_rect;
  // This field is only optional to work around the issue of native enums
  // not being usable for non-Chromium Mojo clients.
  // TODO(chfremer): Make this non-optional once gfx.mojom.ColorSpace has been
  // migrated to a full Mojo struct. See https://crbug.com/893203.
  gfx.mojom.ColorSpace? color_space;
  // Optionally, stride information can be provided.
  // If not provided, it is assumed that frame data is tightly packed.
  PlaneStrides? strides;
};

// Represents information about a capture device.
// |device_id| represents a unique id of a physical device. Since the same
// physical device may be accessible through different APIs |capture_api|
// disambiguates the API.
struct VideoCaptureDeviceDescriptor {
  string display_name;
  string device_id;
  string model_id;
  VideoFacingMode facing_mode;
  VideoCaptureApi capture_api;
  VideoCaptureControlSupport control_support;
  VideoCaptureTransportType transport_type;
};

// Bundles a VideoCaptureDeviceDescriptor with corresponding supported
// video formats.
struct VideoCaptureDeviceInfo {
  VideoCaptureDeviceDescriptor descriptor;
  array<VideoCaptureFormat> supported_formats;
};

struct MailboxBufferHandleSet {
  // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
  array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
};

struct SharedMemoryViaRawFileDescriptor {
  handle<platform> file_descriptor_handle;
  uint32 shared_memory_size_in_bytes;
};

union VideoBufferHandle {
  handle<shared_buffer> shared_buffer_handle;
  mojo_base.mojom.ReadOnlySharedMemoryRegion read_only_shmem_region;
  SharedMemoryViaRawFileDescriptor shared_memory_via_raw_file_descriptor;
  MailboxBufferHandleSet mailbox_handles;
  gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
};