guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | module mojom; |
| 6 | |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 7 | import "media/capture/mojo/video_capture_types.mojom"; |
guidou | 5c25608 | 2017-05-15 15:50:55 | [diff] [blame] | 8 | import "media/mojo/interfaces/audio_parameters.mojom"; |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 9 | |
| 10 | [Native] |
| 11 | enum MediaDeviceType; |
| 12 | |
| 13 | [Native] |
| 14 | struct MediaDeviceInfo; |
| 15 | |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 16 | // The values for this enum match the ones defined in |
| 17 | // https://w3c.github.io/mediacapture-main/#def-constraint-facingMode |
| 18 | // with the addition of NONE, which would map to the empty string in |
| 19 | // JavaScript. |
| 20 | enum FacingMode { |
| 21 | NONE, |
| 22 | USER, |
| 23 | ENVIRONMENT, |
| 24 | LEFT, |
| 25 | RIGHT |
| 26 | }; |
| 27 | |
| 28 | struct VideoInputDeviceCapabilities { |
| 29 | string device_id; |
| 30 | array<media.mojom.VideoCaptureFormat> formats; |
| 31 | FacingMode facing_mode; |
| 32 | }; |
| 33 | |
guidou | 5c25608 | 2017-05-15 15:50:55 | [diff] [blame] | 34 | struct AudioInputDeviceCapabilities { |
| 35 | string device_id; |
| 36 | media.mojom.AudioParameters parameters; |
| 37 | }; |
| 38 | |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 39 | // This object lives in the browser and is responsible for processing device |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 40 | // enumeration requests and managing subscriptions for device-change |
| 41 | // notifications. |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 42 | interface MediaDevicesDispatcherHost { |
| 43 | // The reply always contains NUM_MEDIA_DEVICE_TYPES elements. |
| 44 | // The result is indexed by device type as defined in |
| 45 | // content/common/media/media_devices.h. |
| 46 | EnumerateDevices(bool request_audio_input, |
| 47 | bool request_video_input, |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame] | 48 | bool request_audio_output) |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 49 | => (array<array<MediaDeviceInfo>> enumeration); |
guidou | 5c25608 | 2017-05-15 15:50:55 | [diff] [blame] | 50 | |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 51 | // Returns a list of video devices and their capabilities. |
| 52 | // If there is a user-preferred device, it is the first in the result. |
| 53 | // The result of this function is intended for the implementation details |
| 54 | // of algorithms such as settings selection for getUserMedia. |
guidou | 5c25608 | 2017-05-15 15:50:55 | [diff] [blame] | 55 | // Do not expose the data contained in the result of this function to |
| 56 | // JavaScript. |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame] | 57 | GetVideoInputCapabilities() |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 58 | => (array<VideoInputDeviceCapabilities> video_input_device_capabilities); |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 59 | |
Guido Urdaneta | 4866b184 | 2017-09-25 19:22:43 | [diff] [blame] | 60 | // Returns a list of all video formats supported by a given device, regardless |
| 61 | // of whether the device is being used or not. If the given |device_id| is |
| 62 | // invalid, the result is empty. |
| 63 | GetAllVideoInputDeviceFormats(string device_id) |
| 64 | => (array<media.mojom.VideoCaptureFormat> formats); |
| 65 | |
| 66 | // Returns a list of video formats currently available for a given device. |
| 67 | // When the device is in use, it is expected that the result will contain only |
| 68 | // one entry. When the device is not in use, the result should be the same as |
| 69 | // for GetAllVideoInputDeviceFormats. If the given |device_id| is not valid, |
| 70 | // the result is empty. |
| 71 | GetAvailableVideoInputDeviceFormats(string device_id) |
| 72 | => (array<media.mojom.VideoCaptureFormat> formats); |
| 73 | |
guidou | 5c25608 | 2017-05-15 15:50:55 | [diff] [blame] | 74 | // Returns a list of audio input devices and their capabilities. |
| 75 | // If there is a user-preferred device, it is the first in the result. |
| 76 | // Otherwise, the system-default device is the first in the result. |
| 77 | // The result of this function is intended for the implementation details |
| 78 | // of algorithms such as settings selection for getUserMedia. |
| 79 | // Do not expose the data contained in the result of this function to |
| 80 | // JavaScript. |
| 81 | GetAudioInputCapabilities() |
| 82 | => (array<AudioInputDeviceCapabilities> audio_input_device_capabilities); |
| 83 | |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 84 | // Creates a subscription for device-change notifications for the calling |
| 85 | // frame/security origin. It is the responsibility of the caller to send |
| 86 | // |subscription_id| values that are unique per device type. |
| 87 | // Requests to create a subscription with an ID that already exists for type |
| 88 | // |type| are invalid and result in a renderer crash. |
| 89 | SubscribeDeviceChangeNotifications(MediaDeviceType type, |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame] | 90 | uint32 subscription_id); |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 91 | |
| 92 | // Removes a subscription to device-change notifications for the calling |
| 93 | // frame. The caller is responsible for sending |subscription_id| values that |
| 94 | // that refer to existing subscriptions for type |type|. Requests to remove |
| 95 | // a nonexisting subscription with are invalid and result in a renderer crash. |
| 96 | UnsubscribeDeviceChangeNotifications(MediaDeviceType type, |
| 97 | uint32 subscription_id); |
| 98 | }; |
| 99 | |
| 100 | // This object lives in the renderer process and is used by the browser process |
| 101 | // to pass device-change notifications to the renderer. |
| 102 | interface MediaDevicesListener { |
| 103 | // Called to notify a change in the set of devices of type |type| for |
| 104 | // subscription |subscription_id|. |device_infos| contains the new list of |
| 105 | // devices of type |type|, with device and group IDs obfuscated according to |
| 106 | // the subscription's security origin. |
| 107 | OnDevicesChanged(MediaDeviceType type, |
| 108 | uint32 subscription_id, |
| 109 | array<MediaDeviceInfo> device_infos); |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 110 | }; |