blob: c466598c967743b01da7c450923f7e905bdfe637 [file] [log] [blame]
guidou9357cc52016-10-11 19:53:361// 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
5module mojom;
6
guidou8a440b842017-01-30 13:58:437import "media/capture/mojo/video_capture_types.mojom";
guidou5c256082017-05-15 15:50:558import "media/mojo/interfaces/audio_parameters.mojom";
guidou9357cc52016-10-11 19:53:369
10[Native]
11enum MediaDeviceType;
12
13[Native]
14struct MediaDeviceInfo;
15
guidou8a440b842017-01-30 13:58:4316// 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.
20enum FacingMode {
21 NONE,
22 USER,
23 ENVIRONMENT,
24 LEFT,
25 RIGHT
26};
27
28struct VideoInputDeviceCapabilities {
29 string device_id;
30 array<media.mojom.VideoCaptureFormat> formats;
31 FacingMode facing_mode;
32};
33
guidou5c256082017-05-15 15:50:5534struct AudioInputDeviceCapabilities {
35 string device_id;
36 media.mojom.AudioParameters parameters;
37};
38
guidou9357cc52016-10-11 19:53:3639// This object lives in the browser and is responsible for processing device
guidou57409ac2016-11-07 17:39:3140// enumeration requests and managing subscriptions for device-change
41// notifications.
guidou9357cc52016-10-11 19:53:3642interface 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,
guidoua72075a2017-05-15 08:36:1748 bool request_audio_output)
guidou9357cc52016-10-11 19:53:3649 => (array<array<MediaDeviceInfo>> enumeration);
guidou5c256082017-05-15 15:50:5550
guidou8a440b842017-01-30 13:58:4351 // 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.
guidou5c256082017-05-15 15:50:5555 // Do not expose the data contained in the result of this function to
56 // JavaScript.
guidoua72075a2017-05-15 08:36:1757 GetVideoInputCapabilities()
guidou8a440b842017-01-30 13:58:4358 => (array<VideoInputDeviceCapabilities> video_input_device_capabilities);
guidou57409ac2016-11-07 17:39:3159
Guido Urdaneta4866b1842017-09-25 19:22:4360 // 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
guidou5c256082017-05-15 15:50:5574 // 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
guidou57409ac2016-11-07 17:39:3184 // 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,
guidoua72075a2017-05-15 08:36:1790 uint32 subscription_id);
guidou57409ac2016-11-07 17:39:3191
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.
102interface 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);
guidou9357cc52016-10-11 19:53:36110};