mirror of
https://github.com/servo/servo.git
synced 2025-07-08 16:03:40 +01:00
Fill in RTCSessionDescription
This commit is contained in:
parent
69931934ac
commit
be48cf23f9
2 changed files with 36 additions and 8 deletions
|
@ -3,11 +3,15 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* 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;
|
||||||
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit;
|
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionMethods;
|
||||||
|
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::{
|
||||||
|
RTCSdpType, RTCSessionDescriptionInit,
|
||||||
|
};
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||||
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -15,18 +19,26 @@ use dom_struct::dom_struct;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCSessionDescription {
|
pub struct RTCSessionDescription {
|
||||||
reflector: Reflector,
|
reflector: Reflector,
|
||||||
|
ty: RTCSdpType,
|
||||||
|
sdp: DOMString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RTCSessionDescription {
|
impl RTCSessionDescription {
|
||||||
pub fn new_inherited() -> RTCSessionDescription {
|
pub fn new_inherited(ty: RTCSdpType, sdp: DOMString) -> RTCSessionDescription {
|
||||||
RTCSessionDescription {
|
RTCSessionDescription {
|
||||||
reflector: Reflector::new(),
|
reflector: Reflector::new(),
|
||||||
|
ty,
|
||||||
|
sdp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<RTCSessionDescription> {
|
pub fn new(
|
||||||
|
global: &GlobalScope,
|
||||||
|
ty: RTCSdpType,
|
||||||
|
sdp: DOMString,
|
||||||
|
) -> DomRoot<RTCSessionDescription> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(RTCSessionDescription::new_inherited()),
|
Box::new(RTCSessionDescription::new_inherited(ty, sdp)),
|
||||||
global,
|
global,
|
||||||
RTCSessionDescriptionBinding::Wrap,
|
RTCSessionDescriptionBinding::Wrap,
|
||||||
)
|
)
|
||||||
|
@ -34,8 +46,24 @@ impl RTCSessionDescription {
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
_config: &RTCSessionDescriptionInit,
|
config: &RTCSessionDescriptionInit,
|
||||||
) -> Fallible<DomRoot<RTCSessionDescription>> {
|
) -> Fallible<DomRoot<RTCSessionDescription>> {
|
||||||
Ok(RTCSessionDescription::new(&window.global()))
|
Ok(RTCSessionDescription::new(
|
||||||
|
&window.global(),
|
||||||
|
config.type_,
|
||||||
|
config.sdp.clone(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RTCSessionDescriptionMethods for RTCSessionDescription {
|
||||||
|
/// https://www.w3.org/TR/webrtc/#dom-rtcsessiondescription-type
|
||||||
|
fn Type(&self) -> RTCSdpType {
|
||||||
|
self.ty
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://www.w3.org/TR/webrtc/#dom-rtcsessiondescription-sdp
|
||||||
|
fn Sdp(&self) -> DOMString {
|
||||||
|
self.sdp.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
[Constructor(RTCSessionDescriptionInit descriptionInitDict),
|
[Constructor(RTCSessionDescriptionInit descriptionInitDict),
|
||||||
Exposed=Window, Pref="dom.webrtc.enabled"]
|
Exposed=Window, Pref="dom.webrtc.enabled"]
|
||||||
interface RTCSessionDescription {
|
interface RTCSessionDescription {
|
||||||
// readonly attribute RTCSdpType type;
|
readonly attribute RTCSdpType type;
|
||||||
// readonly attribute DOMString sdp;
|
readonly attribute DOMString sdp;
|
||||||
// [Default] object toJSON();
|
// [Default] object toJSON();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue