// 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; // Equivalent to idl MediaSettingsRange, arbitrary range representing the // allowed variations of a Capability or an Option. // https://w3c.github.io/mediacapture-image/#mediasettingsrange-section [Stable] struct Range { double max; double min; double current; double step; }; [Stable, Extensible] enum BackgroundBlurMode { [Default] OFF, BLUR }; // https://w3c.github.io/mediacapture-image/#meteringmode-section [Stable, Extensible] enum MeteringMode { NONE, MANUAL, SINGLE_SHOT, CONTINUOUS }; // https://w3c.github.io/mediacapture-image/#redeyereduction-section [Stable, Extensible] enum RedEyeReduction { NEVER, ALWAYS, CONTROLLABLE }; // https://www.w3.org/TR/image-capture/#FillLightMode [Stable, Extensible] enum FillLightMode { OFF, AUTO, FLASH }; // Equivalent to idl's MediaTrackCapabilities plus PhotoCapabilities and their // associated current settings (MediaTrackSettings plus PhotoSettings). // // A capability can be expressed as an array of unique supported values for // requested settings in |PhotoSettings| (e.g. |supported_white_balance_modes| // for |PhotoSettings.white_balance_mode|), as a range of supported values for // requested settings in |PhotoSettings| (e.g. from |exposure_compensation.min| // to |exposure_compensation.max| for |PhotoState.exposure_compensation|) or as // a boolean flag indicating whether all (boolean) values are supported for // requested settings in |PhotoSettings| (e.g. |supports_torch| for // |PhotoState.torch|). // // The current settings are expressed right after or along the corresponding // capabilities (e.g. |current_white_balance_mode| after // |supported_white_balance_modes|, |exposure_compensation.current| along // |exposure_compensation.min| and |exposure_compensation.max| and |torch| // after |supports_torch|). // // If there are no supported values for a requested setting in |PhotoSettings| // (an array of unique supported values is empty, a range of supported values // is empty or a boolean flag is false), the corresponding current setting // should be ignored and the corresponding |has_bla| flag in |PhotoSettings| // should be false. // // As non-nullable fields are only allowed in version 0 of a struct, non-POD // fields with version higher than 0 are nullable. That nullability should not // be utilised. [Stable] struct PhotoState { // https://w3c.github.io/mediacapture-image/#mediatrackcapabilities-section // and https://w3c.github.io/mediacapture-image/#mediatracksettings-section // An array of unique supported values for // |PhotoSettings.white_balance_mode|. array supported_white_balance_modes; // The current white balance mode. // Only meaningful if |supported_white_balance_modes| is non-empty. MeteringMode current_white_balance_mode; // An array of unique supported values for |PhotoSettings.exposure_mode|. array supported_exposure_modes; // The current exposure_mode. // Only meaningful if |supported_exposure_modes| is non-empty. MeteringMode current_exposure_mode; // An array of unique supported values for |PhotoSettings.focus_mode|. array supported_focus_modes; // The current focus mode. // Only meaningful if |supported_focus_modes| is non-empty. MeteringMode current_focus_mode; // An array of current points of interest. array points_of_interest; // A range of supported values for |PhotoSettings.exposure_compensation| and // the current exposure compensation. // |exposure_compensation.current| is meaningful only if // |exposure_compensation.min| < |exposure_compensation.max|. Range exposure_compensation; // A range of supported values for |PhotoSettings.exposure_time| and // the current exposure time. // |exposure_time.current| is meaningful only if // |exposure_time.min| < |exposure_time.max|. Range exposure_time; // A range of supported values for |PhotoSettings.color_temperature| and // the current color temporature. // |color_temperature.current| is meaningful only if // |color_temperature.min| < |color_temperature.max|. Range color_temperature; // A range of supported values for |PhotoSettings.iso| and // the current exposure compensation. // |iso.current| is meaningful only if |iso.min| < |iso.max|. Range iso; // A range of supported values for |PhotoSettings.brightness| and the current // brightness. // |brightness.current| is meaningful only if // |brightness.min| < |brightness.max|. Range brightness; // A range of supported values for |PhotoSettings.contrast| and the current // contrast. // |contrast.current| is meaningful only if |contrast.min| < |contrast.max|. Range contrast; // A range of supported values for |PhotoSettings.saturation| and the current // saturation. // |saturation.current| is meaningful only if // |saturation.min| < |saturation.max|. Range saturation; // A range of supported values for |PhotoSettings.sharpness| and // the current sharpness. // |sharpness.current| is meaningful only if // |sharpness.min| < |sharpness.max|. Range sharpness; // A range of supported values for |PhotoSettings.focus_distance| and // the current focus distance. // |focus_distance.current| is meaningful only if // |focus_distance.min| < |focus_distance.max|. Range focus_distance; // A range of supported values for |PhotoSettings.pan| and the current pan. // |pan.current| is meaningful only if |pan.min| < |pan.max|. Range pan; // A range of supported values for |PhotoSettings.tilt| and the current tilt. // |tilt.current| is meaningful only if |tilt.min| < |tilt.max|. Range tilt; // A range of supported values for |PhotoSettings.zoom| and the current zoom. // |zoom.current| is meaningful only if |zoom.min| < |zoom.max|. Range zoom; // Whether |PhotoSettings.torch| is supported. bool supports_torch; // The current torch. // Only meaningful if |supports_torch| is true. bool torch; // https://w3c.github.io/mediacapture-image/##photocapabilities-section and // https://w3c.github.io/mediacapture-image/##photosettings-section RedEyeReduction red_eye_reduction; Range height; Range width; array fill_light_mode; // W3C Media Capture Extensions // An array of unique supported values for // |PhotoSettings.background_blur_mode|. // Should not be null (but is nullable for stable backward compatibility). [MinVersion=1] array? supported_background_blur_modes; // The current background blur mode. // Only meaningful if |supported_background_blur_modes| is non-empty. [MinVersion=1] BackgroundBlurMode background_blur_mode; }; // Equivalent to idl Point2D. // https://w3c.github.io/mediacapture-image/#point2d-section // TODO(mcasas): use gfx::mojom::PointF after https://crbug.com/640049. [Stable] struct Point2D { double x; double y; }; // Equivalent to idl PhotoSettings + MediaTrackConstraintSet. // PODs cannot be nullable, i.e. uint32? bla doesn't work, use |has_bla| flags. [Stable] struct PhotoSettings { // https://w3c.github.io/mediacapture-image/#mediatracksettings-section and // https://w3c.github.io/mediacapture-image/#mediatrackconstraintset-section bool has_white_balance_mode; MeteringMode white_balance_mode; bool has_exposure_mode; MeteringMode exposure_mode; bool has_focus_mode; MeteringMode focus_mode; array points_of_interest; bool has_exposure_compensation; double exposure_compensation; bool has_exposure_time; double exposure_time; bool has_color_temperature; double color_temperature; bool has_iso; double iso; bool has_brightness; double brightness; bool has_contrast; double contrast; bool has_saturation; double saturation; bool has_sharpness; double sharpness; bool has_focus_distance; double focus_distance; bool has_pan; double pan; bool has_tilt; double tilt; bool has_zoom; double zoom; bool has_torch; bool torch; // https://w3c.github.io/mediacapture-image/##photosettings-section bool has_fill_light_mode; FillLightMode fill_light_mode; bool has_width; double width; bool has_height; double height; bool has_red_eye_reduction; bool red_eye_reduction; // W3C Media Capture Extensions [MinVersion=1] bool has_background_blur_mode; [MinVersion=1] BackgroundBlurMode background_blur_mode; }; // This is a mojo move-only equivalent of a Blob, i.e. MIME type and Data. [Stable] struct Blob { string mime_type; array data; }; // |source_id| is the renderer-side UUID identifier of the image capture device. interface ImageCapture { // Retrieves the image capture device capabilities and current settings. // https://www.w3.org/TR/image-capture/#dom-imagecapture-getphotocapabilities GetPhotoState(string source_id) => (PhotoState state); // Sets the |settings| on the associated video capture device. // https://www.w3.org/TR/image-capture/#dom-imagecapture-setoptions SetOptions(string source_id, PhotoSettings settings) => (bool success); // Takes a Photo from the given |source_id|, returning it encoded in |blob| // with the format specified in its |mime_type|. // https://www.w3.org/TR/image-capture/#dom-imagecapture-takephoto TakePhoto(string source_id) => (Blob blob); };