MediaDevices
MediaDevices of Media Capture and Streams, which provides the synthetic microphone and camera of the library.
- class webrtc.interfaces.media_devices.MediaDeviceInfo(*, device_id, kind, label, group_id)
A media device, as listed by
MediaDevices.enumerate_devices().See MDN: MediaDeviceInfo.
- Parameters:
device_id (
str) β The ID of the device.kind (
webrtc.MediaDeviceKind) β Whether itβs a microphone, a speaker or a camera.label (
str) β The human-readable name of the device.group_id (
str) β The ID shared by the devices of one physical device.
- property device_id: str
The ID of the device. Itβs
'synthetic-microphone'or'synthetic-camera'.See MDN: MediaDeviceInfo/deviceId.
- Type:
- property kind: webrtc.MediaDeviceKind
Whether itβs a microphone, a speaker or a camera.
See MDN: MediaDeviceInfo/kind.
- Type:
- property label: str
The human-readable name of the device. Itβs always given, since no permission is needed.
See MDN: MediaDeviceInfo/label.
- Type:
- property group_id: str
The ID shared by the devices of one physical device. Both devices use
'synthetic'.See MDN: MediaDeviceInfo/groupId.
- Type:
- class webrtc.interfaces.media_devices.InputDeviceInfo(*, device_id, kind, label, group_id, capabilities)
An input device, which is the synthetic microphone or the synthetic camera.
See MDN: InputDeviceInfo.
- Parameters:
device_id (
str) β The ID of the device.kind (
webrtc.MediaDeviceKind) β Whether itβs a microphone or a camera.label (
str) β The human-readable name of the device.group_id (
str) β The ID shared by the devices of one physical device.capabilities (
webrtc.MediaTrackCapabilities) β What the device can do.
- get_capabilities()
Returns what the device can do. This matches
webrtc.MediaStreamTrack.get_capabilities()of its tracks.See MDN: InputDeviceInfo/getCapabilities.
- Returns:
webrtc.MediaTrackCapabilitiesβ A copy of the capabilities.- Return type:
- class webrtc.interfaces.media_devices.MediaDevices
The media devices of the library, which are a synthetic microphone and camera. Use
webrtc.media_devices.No hardware is opened. The microphone plays quiet noise and the camera draws a moving pattern. To send real media, write it to a
webrtc.VideoTrackGeneratororwebrtc.MediaStreamTrackGenerator.See MDN: MediaDevices.
- Events:
devicechange (
webrtc.DeviceChangeEvent) β The devices changed. It never fires, because the devices are fixed.
Events
devicechange:Event
Handlers are registered with
on().- async enumerate_devices()
Lists the synthetic microphone and camera. Labels are included and no permission prompt is shown.
See MDN: MediaDevices/enumerateDevices.
- Returns:
listofwebrtc.MediaDeviceInfoβ The devices, all of themwebrtc.InputDeviceInfo.- Return type:
- get_supported_constraints()
Returns the constraints the library recognizes, which are all of them.
See MDN: MediaDevices/getSupportedConstraints.
- Returns:
webrtc.MediaTrackSupportedConstraintsβ The constraints, with every member set toTrue.- Return type:
- async get_user_media(constraints=None)
Returns a stream with a track of the synthetic microphone, the synthetic camera, or both.
The camera starts at 640x480 and 30 frames per second, adjusted to fit the constraints. The microphone has a fixed format. The constraints become the constraints of the tracks, as
webrtc.MediaStreamTrack.get_constraints()shows.See MDN: MediaDevices/getUserMedia.
- Parameters:
constraints (
webrtc.MediaStreamConstraints, optional) β Whether to get an audio and a video track, and the constraints of each.- Returns:
webrtc.MediaStreamβ The stream.- Raises:
TypeError β If neither audio nor video is requested, or a double isnβt finite.
webrtc.OverconstrainedError β If an
exact,minormaxvalue is beyond what the device can do, like a camera more than 4096 pixels wide or faster than 120 frames per second. Other values are clamped to the capabilities.
- Return type:
- webrtc.interfaces.media_devices.media_devices = <webrtc.interfaces.media_devices.MediaDevices object>
The media devices of the library,
navigator.mediaDevicesin a browser. See MDN: Navigator/mediaDevices.
- webrtc.interfaces.media_devices.mediaDevices = <webrtc.interfaces.media_devices.MediaDevices object>
Alias for
media_devices