diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index f9a765ad457..9a965aeb860 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -440,6 +440,7 @@ pub mod range; pub mod request; pub mod response; pub mod rtcpeerconnection; +pub mod rtcsessiondescription; pub mod screen; pub mod serviceworker; pub mod serviceworkercontainer; diff --git a/components/script/dom/rtcsessiondescription.rs b/components/script/dom/rtcsessiondescription.rs new file mode 100644 index 00000000000..284774db7a3 --- /dev/null +++ b/components/script/dom/rtcsessiondescription.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::RTCSessionDescriptionBinding; +use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit; +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 RTCSessionDescription { + reflector: Reflector, +} + +impl RTCSessionDescription { + pub fn new_inherited() -> RTCSessionDescription { + RTCSessionDescription { + reflector: Reflector::new(), + } + } + + pub fn new(global: &GlobalScope) -> DomRoot { + reflect_dom_object( + Box::new(RTCSessionDescription::new_inherited()), + global, + RTCSessionDescriptionBinding::Wrap, + ) + } + + pub fn Constructor( + window: &Window, + _config: &RTCSessionDescriptionInit, + ) -> Fallible> { + Ok(RTCSessionDescription::new(&window.global())) + } +} diff --git a/components/script/dom/webidls/RTCSessionDescription.webidl b/components/script/dom/webidls/RTCSessionDescription.webidl new file mode 100644 index 00000000000..4072a2fe90d --- /dev/null +++ b/components/script/dom/webidls/RTCSessionDescription.webidl @@ -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" +};