naiveproxy/content/common/media/media_devices.mojom
2018-01-29 00:30:36 +08:00

111 lines
4.6 KiB
Plaintext

// 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 mojom;
import "media/capture/mojo/video_capture_types.mojom";
import "media/mojo/interfaces/audio_parameters.mojom";
[Native]
enum MediaDeviceType;
[Native]
struct MediaDeviceInfo;
// The values for this enum match the ones defined in
// https://w3c.github.io/mediacapture-main/#def-constraint-facingMode
// with the addition of NONE, which would map to the empty string in
// JavaScript.
enum FacingMode {
NONE,
USER,
ENVIRONMENT,
LEFT,
RIGHT
};
struct VideoInputDeviceCapabilities {
string device_id;
array<media.mojom.VideoCaptureFormat> formats;
FacingMode facing_mode;
};
struct AudioInputDeviceCapabilities {
string device_id;
media.mojom.AudioParameters parameters;
};
// This object lives in the browser and is responsible for processing device
// enumeration requests and managing subscriptions for device-change
// notifications.
interface MediaDevicesDispatcherHost {
// The reply always contains NUM_MEDIA_DEVICE_TYPES elements.
// The result is indexed by device type as defined in
// content/common/media/media_devices.h.
EnumerateDevices(bool request_audio_input,
bool request_video_input,
bool request_audio_output)
=> (array<array<MediaDeviceInfo>> enumeration);
// Returns a list of video devices and their capabilities.
// If there is a user-preferred device, it is the first in the result.
// The result of this function is intended for the implementation details
// of algorithms such as settings selection for getUserMedia.
// Do not expose the data contained in the result of this function to
// JavaScript.
GetVideoInputCapabilities()
=> (array<VideoInputDeviceCapabilities> video_input_device_capabilities);
// Returns a list of all video formats supported by a given device, regardless
// of whether the device is being used or not. If the given |device_id| is
// invalid, the result is empty.
GetAllVideoInputDeviceFormats(string device_id)
=> (array<media.mojom.VideoCaptureFormat> formats);
// Returns a list of video formats currently available for a given device.
// When the device is in use, it is expected that the result will contain only
// one entry. When the device is not in use, the result should be the same as
// for GetAllVideoInputDeviceFormats. If the given |device_id| is not valid,
// the result is empty.
GetAvailableVideoInputDeviceFormats(string device_id)
=> (array<media.mojom.VideoCaptureFormat> formats);
// Returns a list of audio input devices and their capabilities.
// If there is a user-preferred device, it is the first in the result.
// Otherwise, the system-default device is the first in the result.
// The result of this function is intended for the implementation details
// of algorithms such as settings selection for getUserMedia.
// Do not expose the data contained in the result of this function to
// JavaScript.
GetAudioInputCapabilities()
=> (array<AudioInputDeviceCapabilities> audio_input_device_capabilities);
// Creates a subscription for device-change notifications for the calling
// frame/security origin. It is the responsibility of the caller to send
// |subscription_id| values that are unique per device type.
// Requests to create a subscription with an ID that already exists for type
// |type| are invalid and result in a renderer crash.
SubscribeDeviceChangeNotifications(MediaDeviceType type,
uint32 subscription_id);
// Removes a subscription to device-change notifications for the calling
// frame. The caller is responsible for sending |subscription_id| values that
// that refer to existing subscriptions for type |type|. Requests to remove
// a nonexisting subscription with are invalid and result in a renderer crash.
UnsubscribeDeviceChangeNotifications(MediaDeviceType type,
uint32 subscription_id);
};
// This object lives in the renderer process and is used by the browser process
// to pass device-change notifications to the renderer.
interface MediaDevicesListener {
// Called to notify a change in the set of devices of type |type| for
// subscription |subscription_id|. |device_infos| contains the new list of
// devices of type |type|, with device and group IDs obfuscated according to
// the subscription's security origin.
OnDevicesChanged(MediaDeviceType type,
uint32 subscription_id,
array<MediaDeviceInfo> device_infos);
};