// Copyright 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. module media.mojom; import "ui/gfx/geometry/mojom/geometry.mojom"; enum VideoCapturePixelFormat { UNKNOWN, I420, YV12, I422, I420A, I444, NV12, NV21, UYVY, YUY2, ARGB, XRGB, RGB24, MJPEG, YUV420P9_DEPRECATED, YUV420P10, YUV422P9_DEPRECATED, YUV422P10, YUV444P9_DEPRECATED, YUV444P10, YUV420P12, YUV422P12, YUV444P12, Y16, ABGR, XBGR, P010LE, XR30, XB30, BGRA, RGBAF16, I422A, I444A, YUV420AP10, YUV422AP10, YUV444AP10, NV12A, NV16, NV24, P210LE, P410LE, }; enum ResolutionChangePolicy { FIXED_RESOLUTION, FIXED_ASPECT_RATIO, ANY_WITHIN_LIMIT, }; enum PowerLineFrequency { DEFAULT, HZ_50, HZ_60 }; enum VideoFacingMode { NONE, USER, ENVIRONMENT }; enum CameraAvailability { kAvailable, kUnavailableExclusivelyUsedByOtherApplication, }; 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, WEBRTC_LINUX_PIPEWIRE_SINGLE_PLANE, }; enum VideoCaptureTransportType { // For AVFoundation Api, identify devices that are built-in or USB. APPLE_USB_OR_BUILT_IN, OTHER_TRANSPORT }; enum VideoCaptureBufferType { kSharedMemory, kGpuMemoryBuffer, kSharedImage }; // Represents capture device's support for different controls. struct VideoCaptureControlSupport { bool pan; bool tilt; bool zoom; }; enum VideoCaptureError { kNone, kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested, kVideoCaptureControllerIsAlreadyInErrorState, kVideoCaptureManagerDeviceConnectionLost, kFrameSinkVideoCaptureDeviceAlreadyEndedOnFatalError, 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, kCrosHalV3BufferManagerFailedToCreateMappableSI, 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, kCrosHalV3DeviceContextDuplicatedClient, kDesktopCaptureDeviceMacFailedStreamCreate, kDesktopCaptureDeviceMacFailedStreamStart, kCrosHalV3BufferManagerFailedToReserveBuffers, kWinMediaFoundationSystemPermissionDenied, kVideoCaptureImplTimedOutOnStart, kLacrosVideoCaptureDeviceProxyAlreadyEndedOnFatalError, kLacrosVideoCaptureDeviceProxyEncounteredFatalError, kScreenCaptureKitFailedGetShareableContent, kScreenCaptureKitFailedAddStreamOutput, kScreenCaptureKitFailedStartCapture, kScreenCaptureKitFailedStopCapture, kScreenCaptureKitStreamError, kScreenCaptureKitFailedToFindSCDisplay, kVideoCaptureControllerInvalid, kVideoCaptureDeviceFactoryChromeOSCreateDeviceFailed, kVideoCaptureControllerUnsupportedPixelFormat, kVideoCaptureDeviceAlreadyReleased, kVideoCaptureSystemDeviceIdNotFound, kVideoCaptureDeviceFactoryWinUnknownError, kWinMediaFoundationDeviceInitializationFailed, kWinMediaFoundationSourceCreationFailed, kWinDirectShowDeviceFilterCreationFailed, kWinDirectShowDeviceInitializationFailed, kVideoCaptureDeviceFactorySecondCreateDenied, kScreenCaptureKitResetStreamError, kWinMediaFoundationCameraBusy, kWebRtcStartCaptureFailed, kDesktopCaptureDeviceGpuAdapterChanged, }; enum VideoCaptureFrameDropReason { kNone, kDeviceClientFrameHasInvalidFormat, kDeviceClientLibyuvConvertToI420Failed, kV4L2BufferErrorFlagWasSet, kV4L2InvalidNumberOfBytesInBuffer, kAndroidThrottling, kAndroidGetByteArrayElementsFailed, kAndroidApi1UnexpectedDataLength, kAndroidApi2AcquiredImageIsNull, kWinDirectShowUnexpectedSampleLength, kWinDirectShowFailedToGetMemoryPointerFromMediaSample, kWinMediaFoundationReceivedSampleIsNull, kWinMediaFoundationLockingBufferDelieveredNullptr, kWinMediaFoundationGetBufferByIndexReturnedNull, kBufferPoolMaxBufferCountExceeded, kBufferPoolBufferAllocationFailed, kVideoCaptureImplNotInStartedState, kVideoCaptureImplFailedToWrapDataAsMediaVideoFrame, kVideoTrackAdapterHasNoResolutionAdapters, kResolutionAdapterFrameIsNotValid, kResolutionAdapterWrappingFrameForCroppingFailed, kResolutionAdapterTimestampTooCloseToPrevious_DEPRECATED, kResolutionAdapterFrameRateIsHigherThanRequested, kResolutionAdapterHasNoCallbacks, kVideoTrackFrameDelivererNotEnabledReplacingWithBlackFrame, kRendererSinkFrameDelivererIsNotStarted, kCropVersionNotCurrent_DEPRECATED, kGpuMemoryBufferMapFailed, kSubCaptureTargetVersionNotCurrent_DEPRECATED, kPostProcessingFailed, kResolutionAdapterFrameIsNotMappable, kResolutionAdapterCannotCreateConvertFrame, kResolutionAdapterConvertAndScaleFailed, kOldCaptureVersion, }; struct VideoCaptureFormat { gfx.mojom.Size frame_size; float frame_rate; VideoCapturePixelFormat pixel_format; }; // The request type of the capture source. [Extensible] enum CaptureSourceRequestType { [Default] kUnknown, kGetUserMedia, kGetDisplayMedia }; struct VideoCaptureParams { VideoCaptureFormat requested_format; VideoCaptureBufferType buffer_type; ResolutionChangePolicy resolution_change_policy; PowerLineFrequency power_line_frequency; bool enable_face_detection; // TODO(crbug.com/40255351): remove this once HiDPI is enabled for // all video capture sessions. bool is_high_dpi_enabled; // Starts at 0 when the capture starts, and is incremented // whenever the target of the capture is dynamically changed, // as for example when using share-this-tab-instead. uint32 capture_version_source; CaptureSourceRequestType request_type; }; struct VideoCaptureFeedback { // 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. double resource_utilization; // The requested maximum frame-rate, float::inifinty used to signal no limit. float max_framerate_fps; // The requested maximum resolution (in sense of image area). // int::max used to signal no limit. int32 max_pixels; // Set by the consumer to request a CPU readable frame. Currently, only // supported for NV12 frames obtained from the Windows Media Foundation // camera capturer. bool require_mapped_frame; // TODO: crbug.com/453992558 - Remove deprecated field. // DEPRECATED - DO NOT USE. Only kept for backwards compatibility. array? DEPRECATED_mapped_sizes; // The frame that this feedback is associated with. Some consumers do not // break down their analysis on a per-frame basis; while some may expect to // hear any reports with a particular frame, so they can build a "timeline" of // performance (e.g. to know if they have recovered). This struct is often // funneled through multiple layers, so this frame_id may only be used by an // intermediate layer to help route the feedback accordingly. // This should usually be set to the same value as the |frame_feedback_id| // received with the frame (often from a received `ReadyFrameInBuffer`). int32? frame_id; }; // 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 stride_by_plane; }; // 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; // TODO: crbug.com/453992558 - Remove ? added for backwards compatibility. CameraAvailability? availability; }; // Bundles a VideoCaptureDeviceDescriptor with corresponding supported // video formats. struct VideoCaptureDeviceInfo { VideoCaptureDeviceDescriptor descriptor; array supported_formats; }; enum SubCaptureTargetType { kCropTarget, kRestrictionTarget }; // The result of an attempt by the client to start/stop cropping, // restricting or otherwise applying a sub-capture target. // TODO(crbug.com/40203554): Remove kNotImplemented. enum ApplySubCaptureTargetResult { kSuccess, kErrorGeneric, kUnsupportedCaptureDevice, kNotImplemented, kNonIncreasingVersion, kInvalidTarget, }; enum DeviceEnumerationResult { kSuccess, kUnknownError, kErrorCaptureServiceCrash, kErrorCaptureServiceDroppedRequest };