diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 9a965aeb860..2f54371f891 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -439,6 +439,7 @@ pub mod radionodelist; pub mod range; pub mod request; pub mod response; +pub mod rtcicecandidate; pub mod rtcpeerconnection; pub mod rtcsessiondescription; pub mod screen; diff --git a/components/script/dom/rtcicecandidate.rs b/components/script/dom/rtcicecandidate.rs new file mode 100644 index 00000000000..89a525294c2 --- /dev/null +++ b/components/script/dom/rtcicecandidate.rs @@ -0,0 +1,41 @@ +/* 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/. */ + +use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding; +use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit; +use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::reflector::reflect_dom_object; +use crate::dom::bindings::reflector::{DomObject, Reflector}; +use crate::dom::bindings::root::DomRoot; +use crate::dom::globalscope::GlobalScope; +use crate::dom::window::Window; +use dom_struct::dom_struct; + +#[dom_struct] +pub struct RTCIceCandidate { + reflector: Reflector, +} + +impl RTCIceCandidate { + pub fn new_inherited() -> RTCIceCandidate { + RTCIceCandidate { + reflector: Reflector::new(), + } + } + + pub fn new(global: &GlobalScope) -> DomRoot { + reflect_dom_object( + Box::new(RTCIceCandidate::new_inherited()), + global, + RTCIceCandidateBinding::Wrap, + ) + } + + pub fn Constructor( + window: &Window, + _config: &RTCIceCandidateInit, + ) -> Fallible> { + Ok(RTCIceCandidate::new(&window.global())) + } +} diff --git a/components/script/dom/webidls/RTCIceCandidate.webidl b/components/script/dom/webidls/RTCIceCandidate.webidl new file mode 100644 index 00000000000..1c5dc88dc09 --- /dev/null +++ b/components/script/dom/webidls/RTCIceCandidate.webidl @@ -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; +};