mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #22780 - Manishearth:webrtc, r=jdm
Initial webrtc and getUserMedia DOM support This is able to reach the point where connections are properly negotiated and ready to exchange streams. <s>The `toJSON()` stuff doesn't work yet, so most example code will need to be tweaked to manually construct JSON first before sending SDP and ICE messages over websockets. I'll add support for this soon. (This may need webidl tweaks to support `[Default]` and `toJSON()`)</s> For some reason I haven't yet figured out, connections are one-way, Servo is able to receive streams but the other end doesn't see the streams Servo sends. I don't think this is due to https://github.com/servo/media/issues/191, but that bug is making it harder to test. This implementation simply drops streams that it receives, without connecting them up to any output elements, since servo-media-player doesn't yet have mediastream support. Since servo can neither effectively send nor receive streams this implementation isn't useful yet, however it is getting large and I figured I'd get it reviewed and landed early as a base. r? @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22780) <!-- Reviewable:end -->
This commit is contained in:
commit
6b648429f5
19 changed files with 1261 additions and 46 deletions
88
components/script/dom/webidls/MediaDevices.webidl
Normal file
88
components/script/dom/webidls/MediaDevices.webidl
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/mediacapture-main/#dom-mediadevices
|
||||
|
||||
[Exposed=Window,
|
||||
SecureContext, Pref="dom.webrtc.enabled"]
|
||||
interface MediaDevices : EventTarget {
|
||||
// attribute EventHandler ondevicechange;
|
||||
// Promise<sequence<MediaDeviceInfo>> enumerateDevices();
|
||||
};
|
||||
|
||||
partial interface Navigator {
|
||||
// [SameObject, SecureContext]
|
||||
[Pref="dom.webrtc.enabled"] readonly attribute MediaDevices mediaDevices;
|
||||
};
|
||||
|
||||
partial interface MediaDevices {
|
||||
// MediaTrackSupportedConstraints getSupportedConstraints();
|
||||
Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);
|
||||
};
|
||||
|
||||
|
||||
dictionary MediaStreamConstraints {
|
||||
// (boolean or MediaTrackConstraints) video = false;
|
||||
// (boolean or MediaTrackConstraints) audio = false;
|
||||
boolean video = false;
|
||||
boolean audio = false;
|
||||
};
|
||||
|
||||
// dictionary DoubleRange {
|
||||
// double max;
|
||||
// double min;
|
||||
// };
|
||||
|
||||
// dictionary ConstrainDoubleRange : DoubleRange {
|
||||
// double exact;
|
||||
// double ideal;
|
||||
// };
|
||||
|
||||
// dictionary ULongRange {
|
||||
// [Clamp] unsigned long max;
|
||||
// [Clamp] unsigned long min;
|
||||
// };
|
||||
|
||||
// dictionary ConstrainULongRange : ULongRange {
|
||||
// [Clamp] unsigned long exact;
|
||||
// [Clamp] unsigned long ideal;
|
||||
// };
|
||||
|
||||
// dictionary ConstrainBooleanParameters {
|
||||
// boolean exact;
|
||||
// boolean ideal;
|
||||
// };
|
||||
|
||||
// dictionary ConstrainDOMStringParameters {
|
||||
// (DOMString or sequence<DOMString>) exact;
|
||||
// (DOMString or sequence<DOMString>) ideal;
|
||||
// };
|
||||
|
||||
// dictionary MediaTrackConstraints : MediaTrackConstraintSet {
|
||||
// sequence<MediaTrackConstraintSet> advanced;
|
||||
// };
|
||||
|
||||
// typedef ([Clamp] unsigned long or ConstrainULongRange) ConstrainULong;
|
||||
// typedef (double or ConstrainDoubleRange) ConstrainDouble;
|
||||
// typedef (boolean or ConstrainBooleanParameters) ConstrainBoolean;
|
||||
// typedef (DOMString or sequence<DOMString> or ConstrainDOMStringParameters) ConstrainDOMString;
|
||||
|
||||
// dictionary MediaTrackConstraintSet {
|
||||
// ConstrainULong width;
|
||||
// ConstrainULong height;
|
||||
// ConstrainDouble aspectRatio;
|
||||
// ConstrainDouble frameRate;
|
||||
// ConstrainDOMString facingMode;
|
||||
// ConstrainDOMString resizeMode;
|
||||
// ConstrainDouble volume;
|
||||
// ConstrainULong sampleRate;
|
||||
// ConstrainULong sampleSize;
|
||||
// ConstrainBoolean echoCancellation;
|
||||
// ConstrainBoolean autoGainControl;
|
||||
// ConstrainBoolean noiseSuppression;
|
||||
// ConstrainDouble latency;
|
||||
// ConstrainULong channelCount;
|
||||
// ConstrainDOMString deviceId;
|
||||
// ConstrainDOMString groupId;
|
||||
// };
|
24
components/script/dom/webidls/MediaStream.webidl
Normal file
24
components/script/dom/webidls/MediaStream.webidl
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/mediacapture-main/#dom-mediastream
|
||||
|
||||
// [Exposed=Window,
|
||||
// Constructor,
|
||||
// Constructor(MediaStream stream),
|
||||
// Constructor(sequence<MediaStreamTrack> tracks)]
|
||||
[Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||
interface MediaStream : EventTarget {
|
||||
// readonly attribute DOMString id;
|
||||
// sequence<MediaStreamTrack> getAudioTracks();
|
||||
// sequence<MediaStreamTrack> getVideoTracks();
|
||||
// sequence<MediaStreamTrack> getTracks();
|
||||
// MediaStreamTrack? getTrackById(DOMString trackId);
|
||||
// void addTrack(MediaStreamTrack track);
|
||||
// void removeTrack(MediaStreamTrack track);
|
||||
// MediaStream clone();
|
||||
// readonly attribute boolean active;
|
||||
// attribute EventHandler onaddtrack;
|
||||
// attribute EventHandler onremovetrack;
|
||||
};
|
33
components/script/dom/webidls/RTCIceCandidate.webidl
Normal file
33
components/script/dom/webidls/RTCIceCandidate.webidl
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
|
||||
|
||||
|
||||
[Constructor(optional RTCIceCandidateInit candidateInitDict),
|
||||
Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||
interface RTCIceCandidate {
|
||||
readonly attribute DOMString candidate;
|
||||
readonly attribute DOMString? sdpMid;
|
||||
readonly attribute unsigned short? sdpMLineIndex;
|
||||
// readonly attribute DOMString? foundation;
|
||||
// readonly attribute RTCIceComponent? component;
|
||||
// readonly attribute unsigned long? priority;
|
||||
// readonly attribute DOMString? address;
|
||||
// readonly attribute RTCIceProtocol? protocol;
|
||||
// readonly attribute unsigned short? port;
|
||||
// readonly attribute RTCIceCandidateType? type;
|
||||
// readonly attribute RTCIceTcpCandidateType? tcpType;
|
||||
// readonly attribute DOMString? relatedAddress;
|
||||
// readonly attribute unsigned short? relatedPort;
|
||||
readonly attribute DOMString? usernameFragment;
|
||||
RTCIceCandidateInit toJSON();
|
||||
};
|
||||
|
||||
dictionary RTCIceCandidateInit {
|
||||
DOMString candidate = "";
|
||||
DOMString? sdpMid = null;
|
||||
unsigned short? sdpMLineIndex = null;
|
||||
DOMString usernameFragment;
|
||||
};
|
91
components/script/dom/webidls/RTCPeerConnection.webidl
Normal file
91
components/script/dom/webidls/RTCPeerConnection.webidl
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/webrtc-pc/#interface-definition
|
||||
|
||||
[Constructor(optional RTCConfiguration configuration),
|
||||
Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||
interface RTCPeerConnection : EventTarget {
|
||||
Promise<RTCSessionDescriptionInit> createOffer(optional RTCOfferOptions options);
|
||||
Promise<RTCSessionDescriptionInit> createAnswer(optional RTCAnswerOptions options);
|
||||
Promise<void> setLocalDescription(RTCSessionDescriptionInit description);
|
||||
readonly attribute RTCSessionDescription? localDescription;
|
||||
// readonly attribute RTCSessionDescription? currentLocalDescription;
|
||||
// readonly attribute RTCSessionDescription? pendingLocalDescription;
|
||||
Promise<void> setRemoteDescription(RTCSessionDescriptionInit description);
|
||||
readonly attribute RTCSessionDescription? remoteDescription;
|
||||
// readonly attribute RTCSessionDescription? currentRemoteDescription;
|
||||
// readonly attribute RTCSessionDescription? pendingRemoteDescription;
|
||||
Promise<void> addIceCandidate(optional RTCIceCandidateInit candidate);
|
||||
// readonly attribute RTCSignalingState signalingState;
|
||||
// readonly attribute RTCIceGatheringState iceGatheringState;
|
||||
// readonly attribute RTCIceConnectionState iceConnectionState;
|
||||
// readonly attribute RTCPeerConnectionState connectionState;
|
||||
// readonly attribute boolean? canTrickleIceCandidates;
|
||||
// static sequence<RTCIceServer> getDefaultIceServers();
|
||||
// RTCConfiguration getConfiguration();
|
||||
// void setConfiguration(RTCConfiguration configuration);
|
||||
// void close();
|
||||
attribute EventHandler onnegotiationneeded;
|
||||
attribute EventHandler onicecandidate;
|
||||
// attribute EventHandler onicecandidateerror;
|
||||
// attribute EventHandler onsignalingstatechange;
|
||||
// attribute EventHandler oniceconnectionstatechange;
|
||||
// attribute EventHandler onicegatheringstatechange;
|
||||
// attribute EventHandler onconnectionstatechange;
|
||||
|
||||
// removed from spec, but still shipped by browsers
|
||||
void addStream (MediaStream stream);
|
||||
};
|
||||
|
||||
dictionary RTCConfiguration {
|
||||
sequence<RTCIceServer> iceServers;
|
||||
RTCIceTransportPolicy iceTransportPolicy = "all";
|
||||
RTCBundlePolicy bundlePolicy = "balanced";
|
||||
RTCRtcpMuxPolicy rtcpMuxPolicy = "require";
|
||||
DOMString peerIdentity;
|
||||
// sequence<RTCCertificate> certificates;
|
||||
[EnforceRange]
|
||||
octet iceCandidatePoolSize = 0;
|
||||
};
|
||||
|
||||
enum RTCIceTransportPolicy {
|
||||
"relay",
|
||||
"all"
|
||||
};
|
||||
|
||||
enum RTCBundlePolicy {
|
||||
"balanced",
|
||||
"max-compat",
|
||||
"max-bundle"
|
||||
};
|
||||
|
||||
enum RTCRtcpMuxPolicy {
|
||||
// At risk due to lack of implementers' interest.
|
||||
"negotiate",
|
||||
"require"
|
||||
};
|
||||
|
||||
dictionary RTCIceServer {
|
||||
required (DOMString or sequence<DOMString>) urls;
|
||||
DOMString username;
|
||||
DOMString /*(DOMString or RTCOAuthCredential)*/ credential;
|
||||
RTCIceCredentialType credentialType = "password";
|
||||
};
|
||||
|
||||
enum RTCIceCredentialType {
|
||||
"password",
|
||||
"oauth"
|
||||
};
|
||||
|
||||
dictionary RTCOfferAnswerOptions {
|
||||
boolean voiceActivityDetection = true;
|
||||
};
|
||||
|
||||
dictionary RTCOfferOptions : RTCOfferAnswerOptions {
|
||||
boolean iceRestart = false;
|
||||
};
|
||||
|
||||
dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/webrtc-pc/#rtcpeerconnectioniceevent
|
||||
|
||||
[Constructor(DOMString type, optional RTCPeerConnectionIceEventInit eventInitDict),
|
||||
Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||
interface RTCPeerConnectionIceEvent : Event {
|
||||
readonly attribute RTCIceCandidate? candidate;
|
||||
readonly attribute DOMString? url;
|
||||
};
|
||||
|
||||
dictionary RTCPeerConnectionIceEventInit : EventInit {
|
||||
RTCIceCandidate? candidate;
|
||||
DOMString? url;
|
||||
};
|
25
components/script/dom/webidls/RTCSessionDescription.webidl
Normal file
25
components/script/dom/webidls/RTCSessionDescription.webidl
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://w3c.github.io/webrtc-pc/#rtcsessiondescription-class
|
||||
|
||||
[Constructor(RTCSessionDescriptionInit descriptionInitDict),
|
||||
Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||
interface RTCSessionDescription {
|
||||
readonly attribute RTCSdpType type;
|
||||
readonly attribute DOMString sdp;
|
||||
[Default] object toJSON();
|
||||
};
|
||||
|
||||
dictionary RTCSessionDescriptionInit {
|
||||
required RTCSdpType type;
|
||||
DOMString sdp = "";
|
||||
};
|
||||
|
||||
enum RTCSdpType {
|
||||
"offer",
|
||||
"pranswer",
|
||||
"answer",
|
||||
"rollback"
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue