diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2019-01-27 09:10:39 -0800 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-01-29 11:36:27 -0800 |
commit | 93a359e528a3813feaa338fc6020614d3bd7b99b (patch) | |
tree | 6b553595d891a5c7c90b5b99066da9bbfbb047ad | |
parent | 95cd67cb6556920b846e222513414e7bded43d93 (diff) | |
download | servo-93a359e528a3813feaa338fc6020614d3bd7b99b.tar.gz servo-93a359e528a3813feaa338fc6020614d3bd7b99b.zip |
Add RTCPeerConnection::SetRemoteDescription
-rw-r--r-- | components/script/dom/rtcpeerconnection.rs | 41 | ||||
-rw-r--r-- | components/script/dom/webidls/RTCPeerConnection.webidl | 4 |
2 files changed, 43 insertions, 2 deletions
diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 75048b2dee8..6105bdd81eb 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -55,6 +55,7 @@ pub struct RTCPeerConnection { #[ignore_malloc_size_of = "promises are hard"] answer_promises: DomRefCell<Vec<Rc<Promise>>>, local_description: MutNullableDom<RTCSessionDescription>, + remote_description: MutNullableDom<RTCSessionDescription>, } struct RTCSignaller { @@ -103,6 +104,7 @@ impl RTCPeerConnection { offer_promises: DomRefCell::new(vec![]), answer_promises: DomRefCell::new(vec![]), local_description: Default::default(), + remote_description: Default::default(), } } @@ -318,8 +320,14 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { self.local_description.get() } + /// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-remotedescription + fn GetRemoteDescription(&self) -> Option<DomRoot<RTCSessionDescription>> { + self.remote_description.get() + } + /// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-setlocaldescription fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> { + // XXXManishearth validate the current state let p = Promise::new(&self.global()); let this = Trusted::new(self); let desc: SessionDescription = desc.into(); @@ -349,6 +357,39 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { }).into()); p } + + /// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-setremotedescription + fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> { + // XXXManishearth validate the current state + let p = Promise::new(&self.global()); + let this = Trusted::new(self); + let desc: SessionDescription = desc.into(); + let trusted_promise = TrustedPromise::new(p.clone()); + let (task_source, canceller) = self + .global() + .as_window() + .task_manager() + .networking_task_source_with_canceller(); + self.controller + .borrow_mut() + .as_ref() + .unwrap() + .set_remote_description(desc.clone(), (move || { + let _ = task_source.queue_with_canceller( + task!(remote_description_set: move || { + // XXXManishearth spec actually asks for an intricate + // dance between pending/current local/remote descriptions + let this = this.root(); + let desc = desc.into(); + let desc = RTCSessionDescription::Constructor(&this.global().as_window(), &desc).unwrap(); + this.remote_description.set(Some(&desc)); + trusted_promise.root().resolve_native(&()) + }), + &canceller, + ); + }).into()); + p + } } impl From<SessionDescription> for RTCSessionDescriptionInit { diff --git a/components/script/dom/webidls/RTCPeerConnection.webidl b/components/script/dom/webidls/RTCPeerConnection.webidl index babe009e302..c68efd7e2b0 100644 --- a/components/script/dom/webidls/RTCPeerConnection.webidl +++ b/components/script/dom/webidls/RTCPeerConnection.webidl @@ -13,8 +13,8 @@ interface RTCPeerConnection : EventTarget { readonly attribute RTCSessionDescription? localDescription; // readonly attribute RTCSessionDescription? currentLocalDescription; // readonly attribute RTCSessionDescription? pendingLocalDescription; - // Promise<void> setRemoteDescription(RTCSessionDescriptionInit description); - // readonly attribute RTCSessionDescription? remoteDescription; + Promise<void> setRemoteDescription(RTCSessionDescriptionInit description); + readonly attribute RTCSessionDescription? remoteDescription; // readonly attribute RTCSessionDescription? currentRemoteDescription; // readonly attribute RTCSessionDescription? pendingRemoteDescription; Promise<void> addIceCandidate(optional RTCIceCandidateInit candidate); |