Skip to content
Permalink
Browse files

Add RTCSessionDescription::ToJSON

  • Loading branch information...
Manishearth committed Jan 29, 2019
1 parent 0d9f538 commit ab04f0429bef3c2613c6a249d5a04a8cc9ca64de
@@ -15,6 +15,10 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use js::conversions::ToJSValConvertible;
use js::jsapi::{JSContext, JSObject};
use js::jsval::UndefinedValue;
use std::ptr::NonNull;

#[dom_struct]
pub struct RTCSessionDescription {
@@ -66,4 +70,16 @@ impl RTCSessionDescriptionMethods for RTCSessionDescription {
fn Sdp(&self) -> DOMString {
self.sdp.clone()
}

#[allow(unsafe_code)]
/// https://w3c.github.io/webrtc-pc/#dom-rtcsessiondescription-tojson
unsafe fn ToJSON(&self, cx: *mut JSContext) -> NonNull<JSObject> {
let init = RTCSessionDescriptionInit {
type_: self.ty,
sdp: self.sdp.clone(),
};
rooted!(in(cx) let mut jsval = UndefinedValue());
init.to_jsval(cx, jsval.handle_mut());
NonNull::new(jsval.to_object()).unwrap()
}
}
@@ -9,7 +9,7 @@
interface RTCSessionDescription {
readonly attribute RTCSdpType type;
readonly attribute DOMString sdp;
// [Default] object toJSON();
[Default] object toJSON();
};

dictionary RTCSessionDescriptionInit {

0 comments on commit ab04f04

Please sign in to comment.
You can’t perform that action at this time.