-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathmediadevices.dart
150 lines (134 loc) · 4.83 KB
/
mediadevices.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import 'media_stream.dart';
/// [MediaTrackSupportedConstraints] represents the list of constraints
/// controlling the capabilities of a [MediaStreamTrack].
class MediaTrackSupportedConstraints {
MediaTrackSupportedConstraints({
this.aspectRatio = false,
this.autoGainControl = false,
this.brightness = false,
this.channelCount = false,
this.colorTemperature = false,
this.contrast = false,
this.deviceId = false,
this.echoCancellation = false,
this.exposureCompensation = false,
this.exposureMode = false,
this.exposureTime = false,
this.facingMode = false,
this.focusDistance = false,
this.focusMode = false,
this.frameRate = false,
this.groupId = false,
this.height = false,
this.iso = false,
this.latency = false,
this.noiseSuppression = false,
this.pan = false,
this.pointsOfInterest = false,
this.resizeMode = false,
this.sampleRate = false,
this.sampleSize = false,
this.saturation = false,
this.sharpness = false,
this.tilt = false,
this.torch = false,
this.whiteBalanceMode = false,
this.width = false,
this.zoom = false,
});
final bool aspectRatio,
autoGainControl,
brightness,
channelCount,
colorTemperature,
contrast,
deviceId,
echoCancellation,
exposureCompensation,
exposureMode,
exposureTime,
facingMode,
focusDistance,
focusMode,
frameRate,
groupId,
height,
iso,
latency,
noiseSuppression,
pan,
pointsOfInterest,
resizeMode,
sampleRate,
sampleSize,
saturation,
sharpness,
tilt,
torch,
whiteBalanceMode,
width,
zoom;
}
abstract class MediaDevices {
/// Calling this method will prompts the user to select and grant permission
/// to capture the contents of a display or portion thereof (such as a window)
/// as a MediaStream. The resulting stream can then be recorded using the
/// MediaStream Recording API or transmitted as part of a WebRTC session.
Future<MediaStream> getUserMedia(Map<String, dynamic> mediaConstraints);
/// Calling this method will prompts the user to select and grant permission
/// to capture the contents of a display or portion thereof (such as a window)
/// as a MediaStream. The resulting stream can then be recorded using the
/// MediaStream Recording API or transmitted as part of a WebRTC session.
Future<MediaStream> getDisplayMedia(Map<String, dynamic> mediaConstraints);
@Deprecated('use enumerateDevices() instead')
Future<List<dynamic>> getSources();
/// Returns a List of [MediaDeviceInfo] describing the devices.
Future<List<MediaDeviceInfo>> enumerateDevices();
/// Returns [MediaTrackSupportedConstraints] recognized by a User Agent for
/// controlling the Capabilities of a [MediaStreamTrack] object.
MediaTrackSupportedConstraints getSupportedConstraints() {
throw UnimplementedError();
}
/// A function you provide which accepts as input a Event object describing
/// the devicechange event that occurred. There is no information about the
/// change included in the event object; to get the updated list of devices,
/// you'll have to use enumerateDevices().
Function(dynamic event)? ondevicechange;
/// Prompts the user to select a specific audio output device.
Future<MediaDeviceInfo> selectAudioOutput([AudioOutputOptions? options]) =>
throw UnimplementedError();
}
/// This describe the media input and output devices, such as microphones,
/// cameras, headsets, and so forth.
class MediaDeviceInfo {
MediaDeviceInfo({
this.kind,
required this.label,
this.groupId,
required this.deviceId,
});
/// Returns a String that is an identifier for the represented device that
/// is persisted across sessions. It is un-guessable by other applications
/// and unique to the origin of the calling application. It is reset when
/// the user clears cookies (for Private Browsing, a different identifier
/// is used that is not persisted across sessions).
final String deviceId;
/// Returns a String that is a group identifier. Two devices have the same
/// group identifier if they belong to the same physical device
/// — for example a monitor with both a built-in camera and a microphone.
final String? groupId;
/// Returns an enumerated value that is either 'videoinput', 'audioinput' or
/// 'audiooutput'.
final String? kind;
/// Returns a String that is a label describing this device
/// (for example "External USB Webcam").
final String label;
}
/// An object that configures what device(s) may be offered in the user prompt.
class AudioOutputOptions {
AudioOutputOptions({
this.deviceId = '',
});
/// A string representing the id of the (only) device to display in the prompt (with default value: "").
final String deviceId;
}