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 | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 8 | |
| 9 | [Native] |
| 10 | enum MediaDeviceType; |
| 11 | |
| 12 | [Native] |
| 13 | struct MediaDeviceInfo; |
| 14 | |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 15 | // The values for this enum match the ones defined in |
| 16 | // https://w3c.github.io/mediacapture-main/#def-constraint-facingMode |
| 17 | // with the addition of NONE, which would map to the empty string in |
| 18 | // JavaScript. |
| 19 | enum FacingMode { |
| 20 | NONE, |
| 21 | USER, |
| 22 | ENVIRONMENT, |
| 23 | LEFT, |
| 24 | RIGHT |
| 25 | }; |
| 26 | |
| 27 | struct VideoInputDeviceCapabilities { |
| 28 | string device_id; |
| 29 | array<media.mojom.VideoCaptureFormat> formats; |
| 30 | FacingMode facing_mode; |
| 31 | }; |
| 32 | |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 33 | // This object lives in the browser and is responsible for processing device |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 34 | // enumeration requests and managing subscriptions for device-change |
| 35 | // notifications. |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 36 | interface MediaDevicesDispatcherHost { |
| 37 | // The reply always contains NUM_MEDIA_DEVICE_TYPES elements. |
| 38 | // The result is indexed by device type as defined in |
| 39 | // content/common/media/media_devices.h. |
| 40 | EnumerateDevices(bool request_audio_input, |
| 41 | bool request_video_input, |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame^] | 42 | bool request_audio_output) |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 43 | => (array<array<MediaDeviceInfo>> enumeration); |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 44 | |
| 45 | // Returns a list of video devices and their capabilities. |
| 46 | // If there is a user-preferred device, it is the first in the result. |
| 47 | // The result of this function is intended for the implementation details |
| 48 | // of algorithms such as settings selection for getUserMedia. |
| 49 | // Do not expose the data contained in result of this function to JavaScript. |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame^] | 50 | GetVideoInputCapabilities() |
guidou | 8a440b84 | 2017-01-30 13:58:43 | [diff] [blame] | 51 | => (array<VideoInputDeviceCapabilities> video_input_device_capabilities); |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 52 | |
| 53 | // Creates a subscription for device-change notifications for the calling |
| 54 | // frame/security origin. It is the responsibility of the caller to send |
| 55 | // |subscription_id| values that are unique per device type. |
| 56 | // Requests to create a subscription with an ID that already exists for type |
| 57 | // |type| are invalid and result in a renderer crash. |
| 58 | SubscribeDeviceChangeNotifications(MediaDeviceType type, |
guidou | a72075a | 2017-05-15 08:36:17 | [diff] [blame^] | 59 | uint32 subscription_id); |
guidou | 57409ac | 2016-11-07 17:39:31 | [diff] [blame] | 60 | |
| 61 | // Removes a subscription to device-change notifications for the calling |
| 62 | // frame. The caller is responsible for sending |subscription_id| values that |
| 63 | // that refer to existing subscriptions for type |type|. Requests to remove |
| 64 | // a nonexisting subscription with are invalid and result in a renderer crash. |
| 65 | UnsubscribeDeviceChangeNotifications(MediaDeviceType type, |
| 66 | uint32 subscription_id); |
| 67 | }; |
| 68 | |
| 69 | // This object lives in the renderer process and is used by the browser process |
| 70 | // to pass device-change notifications to the renderer. |
| 71 | interface MediaDevicesListener { |
| 72 | // Called to notify a change in the set of devices of type |type| for |
| 73 | // subscription |subscription_id|. |device_infos| contains the new list of |
| 74 | // devices of type |type|, with device and group IDs obfuscated according to |
| 75 | // the subscription's security origin. |
| 76 | OnDevicesChanged(MediaDeviceType type, |
| 77 | uint32 subscription_id, |
| 78 | array<MediaDeviceInfo> device_infos); |
guidou | 9357cc5 | 2016-10-11 19:53:36 | [diff] [blame] | 79 | }; |