blob: 7d2d2cc3a4f67e8c0ead3f8114f265824ea982a8 [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";
guidou9357cc52016-10-11 19:53:368
9[Native]
10enum MediaDeviceType;
11
12[Native]
13struct MediaDeviceInfo;
14
guidou8a440b842017-01-30 13:58:4315// 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.
19enum FacingMode {
20 NONE,
21 USER,
22 ENVIRONMENT,
23 LEFT,
24 RIGHT
25};
26
27struct VideoInputDeviceCapabilities {
28 string device_id;
29 array<media.mojom.VideoCaptureFormat> formats;
30 FacingMode facing_mode;
31};
32
guidou9357cc52016-10-11 19:53:3633// This object lives in the browser and is responsible for processing device
guidou57409ac2016-11-07 17:39:3134// enumeration requests and managing subscriptions for device-change
35// notifications.
guidou9357cc52016-10-11 19:53:3636interface 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,
guidoua72075a2017-05-15 08:36:1742 bool request_audio_output)
guidou9357cc52016-10-11 19:53:3643 => (array<array<MediaDeviceInfo>> enumeration);
guidou8a440b842017-01-30 13:58:4344
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.
guidoua72075a2017-05-15 08:36:1750 GetVideoInputCapabilities()
guidou8a440b842017-01-30 13:58:4351 => (array<VideoInputDeviceCapabilities> video_input_device_capabilities);
guidou57409ac2016-11-07 17:39:3152
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,
guidoua72075a2017-05-15 08:36:1759 uint32 subscription_id);
guidou57409ac2016-11-07 17:39:3160
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.
71interface 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);
guidou9357cc52016-10-11 19:53:3679};