#![allow(non_camel_case_types,non_upper_case_globals,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTarget_Binding;
use crate::dom::bindings::codegen::Bindings::RTCRtpTransceiverBinding::RTCRtpTransceiverDirection;
use crate::dom::bindings::codegen::Bindings::RTCRtpTransceiverBinding::RTCRtpTransceiverDirectionValues;
use crate::dom::bindings::import::base::*;
use crate::dom::types::EventTarget;
use crate::dom::types::MediaStream;
#[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCIceTransportPolicy {
Relay,
All
}
pub mod RTCIceTransportPolicyValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCIceTransportPolicy)] = &[
("relay", super::RTCIceTransportPolicy::Relay),
("all", super::RTCIceTransportPolicy::All),
];
impl super::RTCIceTransportPolicy {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCIceTransportPolicy {
fn default() -> super::RTCIceTransportPolicy {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCIceTransportPolicy {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCIceTransportPolicy {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCIceTransportPolicy>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCIceTransportPolicy'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCBundlePolicy {
Balanced,
Max_compat,
Max_bundle
}
pub mod RTCBundlePolicyValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCBundlePolicy)] = &[
("balanced", super::RTCBundlePolicy::Balanced),
("max-compat", super::RTCBundlePolicy::Max_compat),
("max-bundle", super::RTCBundlePolicy::Max_bundle),
];
impl super::RTCBundlePolicy {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCBundlePolicy {
fn default() -> super::RTCBundlePolicy {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCBundlePolicy {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCBundlePolicy {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCBundlePolicy>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCBundlePolicy'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCRtcpMuxPolicy {
Negotiate,
Require
}
pub mod RTCRtcpMuxPolicyValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCRtcpMuxPolicy)] = &[
("negotiate", super::RTCRtcpMuxPolicy::Negotiate),
("require", super::RTCRtcpMuxPolicy::Require),
];
impl super::RTCRtcpMuxPolicy {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCRtcpMuxPolicy {
fn default() -> super::RTCRtcpMuxPolicy {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCRtcpMuxPolicy {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCRtcpMuxPolicy {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCRtcpMuxPolicy>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCRtcpMuxPolicy'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCIceCredentialType {
Password,
Oauth
}
pub mod RTCIceCredentialTypeValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCIceCredentialType)] = &[
("password", super::RTCIceCredentialType::Password),
("oauth", super::RTCIceCredentialType::Oauth),
];
impl super::RTCIceCredentialType {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCIceCredentialType {
fn default() -> super::RTCIceCredentialType {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCIceCredentialType {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCIceCredentialType {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCIceCredentialType>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCIceCredentialType'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCIceGatheringState {
New,
Gathering,
Complete
}
pub mod RTCIceGatheringStateValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCIceGatheringState)] = &[
("new", super::RTCIceGatheringState::New),
("gathering", super::RTCIceGatheringState::Gathering),
("complete", super::RTCIceGatheringState::Complete),
];
impl super::RTCIceGatheringState {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCIceGatheringState {
fn default() -> super::RTCIceGatheringState {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCIceGatheringState {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCIceGatheringState {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCIceGatheringState>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCIceGatheringState'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCIceConnectionState {
New,
Checking,
Connected,
Completed,
Disconnected,
Failed,
Closed
}
pub mod RTCIceConnectionStateValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCIceConnectionState)] = &[
("new", super::RTCIceConnectionState::New),
("checking", super::RTCIceConnectionState::Checking),
("connected", super::RTCIceConnectionState::Connected),
("completed", super::RTCIceConnectionState::Completed),
("disconnected", super::RTCIceConnectionState::Disconnected),
("failed", super::RTCIceConnectionState::Failed),
("closed", super::RTCIceConnectionState::Closed),
];
impl super::RTCIceConnectionState {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCIceConnectionState {
fn default() -> super::RTCIceConnectionState {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCIceConnectionState {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCIceConnectionState {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCIceConnectionState>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCIceConnectionState'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum RTCSignalingState {
Stable,
Have_local_offer,
Have_remote_offer,
Have_local_pranswer,
Have_remote_pranswer,
Closed
}
pub mod RTCSignalingStateValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::RTCSignalingState)] = &[
("stable", super::RTCSignalingState::Stable),
("have-local-offer", super::RTCSignalingState::Have_local_offer),
("have-remote-offer", super::RTCSignalingState::Have_remote_offer),
("have-local-pranswer", super::RTCSignalingState::Have_local_pranswer),
("have-remote-pranswer", super::RTCSignalingState::Have_remote_pranswer),
("closed", super::RTCSignalingState::Closed),
];
impl super::RTCSignalingState {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::RTCSignalingState {
fn default() -> super::RTCSignalingState {
pairs[0].1
}
}
impl ToJSValConvertible for super::RTCSignalingState {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::RTCSignalingState {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::RTCSignalingState>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'RTCSignalingState'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[derive(JSTraceable)]
pub struct RTCConfiguration {
pub bundlePolicy: RTCBundlePolicy,
pub iceCandidatePoolSize: u8,
pub iceServers: Option<Vec<crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceServer>>,
pub iceTransportPolicy: RTCIceTransportPolicy,
pub peerIdentity: Option<DOMString>,
pub rtcpMuxPolicy: RTCRtcpMuxPolicy,
}
impl RTCConfiguration {
pub fn empty() -> Self {
Self {
bundlePolicy: RTCBundlePolicy::Balanced,
iceCandidatePoolSize: 0,
iceServers: None,
iceTransportPolicy: RTCIceTransportPolicy::All,
peerIdentity: None,
rtcpMuxPolicy: RTCRtcpMuxPolicy::Require,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCConfiguration>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCConfiguration {
bundlePolicy: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "bundlePolicy", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
RTCBundlePolicy::Balanced
}
},
iceCandidatePoolSize: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "iceCandidatePoolSize", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ConversionBehavior::EnforceRange) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
0
}
},
iceServers: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "iceServers", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
iceTransportPolicy: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "iceTransportPolicy", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
RTCIceTransportPolicy::All
}
},
peerIdentity: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "peerIdentity", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
rtcpMuxPolicy: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "rtcpMuxPolicy", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
RTCRtcpMuxPolicy::Require
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCConfiguration {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCConfiguration>, ()> {
RTCConfiguration::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCConfiguration {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let bundlePolicy = &self.bundlePolicy;
rooted!(in(cx) let mut bundlePolicy_js = UndefinedValue());
bundlePolicy.to_jsval(cx, bundlePolicy_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "bundlePolicy", bundlePolicy_js.handle()).unwrap();
let iceCandidatePoolSize = &self.iceCandidatePoolSize;
rooted!(in(cx) let mut iceCandidatePoolSize_js = UndefinedValue());
iceCandidatePoolSize.to_jsval(cx, iceCandidatePoolSize_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "iceCandidatePoolSize", iceCandidatePoolSize_js.handle()).unwrap();
if let Some(ref iceServers) = self.iceServers {
rooted!(in(cx) let mut iceServers_js = UndefinedValue());
iceServers.to_jsval(cx, iceServers_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "iceServers", iceServers_js.handle()).unwrap();
}
let iceTransportPolicy = &self.iceTransportPolicy;
rooted!(in(cx) let mut iceTransportPolicy_js = UndefinedValue());
iceTransportPolicy.to_jsval(cx, iceTransportPolicy_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "iceTransportPolicy", iceTransportPolicy_js.handle()).unwrap();
if let Some(ref peerIdentity) = self.peerIdentity {
rooted!(in(cx) let mut peerIdentity_js = UndefinedValue());
peerIdentity.to_jsval(cx, peerIdentity_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "peerIdentity", peerIdentity_js.handle()).unwrap();
}
let rtcpMuxPolicy = &self.rtcpMuxPolicy;
rooted!(in(cx) let mut rtcpMuxPolicy_js = UndefinedValue());
rtcpMuxPolicy.to_jsval(cx, rtcpMuxPolicy_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "rtcpMuxPolicy", rtcpMuxPolicy_js.handle()).unwrap();
}
}
impl ToJSValConvertible for RTCConfiguration {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCIceServer {
pub credential: Option<DOMString>,
pub credentialType: RTCIceCredentialType,
pub urls: UnionTypes::StringOrStringSequence,
pub username: Option<DOMString>,
}
impl RTCIceServer {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCIceServer>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCIceServer {
credential: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "credential", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
credentialType: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "credentialType", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
RTCIceCredentialType::Password
}
},
urls: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "urls", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"urls\".");
return Err(());
}
},
username: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "username", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCIceServer {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCIceServer>, ()> {
RTCIceServer::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCIceServer {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
if let Some(ref credential) = self.credential {
rooted!(in(cx) let mut credential_js = UndefinedValue());
credential.to_jsval(cx, credential_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "credential", credential_js.handle()).unwrap();
}
let credentialType = &self.credentialType;
rooted!(in(cx) let mut credentialType_js = UndefinedValue());
credentialType.to_jsval(cx, credentialType_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "credentialType", credentialType_js.handle()).unwrap();
let urls = &self.urls;
rooted!(in(cx) let mut urls_js = UndefinedValue());
urls.to_jsval(cx, urls_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "urls", urls_js.handle()).unwrap();
if let Some(ref username) = self.username {
rooted!(in(cx) let mut username_js = UndefinedValue());
username.to_jsval(cx, username_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "username", username_js.handle()).unwrap();
}
}
}
impl ToJSValConvertible for RTCIceServer {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCOfferAnswerOptions {
pub voiceActivityDetection: bool,
}
impl RTCOfferAnswerOptions {
pub fn empty() -> Self {
Self {
voiceActivityDetection: true,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCOfferAnswerOptions>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCOfferAnswerOptions {
voiceActivityDetection: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "voiceActivityDetection", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
true
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCOfferAnswerOptions {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCOfferAnswerOptions>, ()> {
RTCOfferAnswerOptions::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCOfferAnswerOptions {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let voiceActivityDetection = &self.voiceActivityDetection;
rooted!(in(cx) let mut voiceActivityDetection_js = UndefinedValue());
voiceActivityDetection.to_jsval(cx, voiceActivityDetection_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "voiceActivityDetection", voiceActivityDetection_js.handle()).unwrap();
}
}
impl ToJSValConvertible for RTCOfferAnswerOptions {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCOfferOptions {
pub parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions,
pub iceRestart: bool,
}
impl RTCOfferOptions {
pub fn empty() -> Self {
Self {
parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions::empty(),
iceRestart: false,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCOfferOptions>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCOfferOptions {
parent: {
match crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
iceRestart: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "iceRestart", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
false
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCOfferOptions {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCOfferOptions>, ()> {
RTCOfferOptions::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCOfferOptions {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
let iceRestart = &self.iceRestart;
rooted!(in(cx) let mut iceRestart_js = UndefinedValue());
iceRestart.to_jsval(cx, iceRestart_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "iceRestart", iceRestart_js.handle()).unwrap();
}
}
impl ToJSValConvertible for RTCOfferOptions {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCAnswerOptions {
pub parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions,
}
impl RTCAnswerOptions {
pub fn empty() -> Self {
Self {
parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions::empty(),
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCAnswerOptions>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCAnswerOptions {
parent: {
match crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferAnswerOptions::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCAnswerOptions {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCAnswerOptions>, ()> {
RTCAnswerOptions::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCAnswerOptions {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
}
}
impl ToJSValConvertible for RTCAnswerOptions {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCRtpCodingParameters {
pub rid: Option<DOMString>,
}
impl RTCRtpCodingParameters {
pub fn empty() -> Self {
Self {
rid: None,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCRtpCodingParameters>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCRtpCodingParameters {
rid: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "rid", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCRtpCodingParameters {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCRtpCodingParameters>, ()> {
RTCRtpCodingParameters::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCRtpCodingParameters {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
if let Some(ref rid) = self.rid {
rooted!(in(cx) let mut rid_js = UndefinedValue());
rid.to_jsval(cx, rid_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "rid", rid_js.handle()).unwrap();
}
}
}
impl ToJSValConvertible for RTCRtpCodingParameters {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCRtpEncodingParameters {
pub parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpCodingParameters,
pub active: bool,
pub maxBitrate: Option<u32>,
pub scaleResolutionDownBy: Option<Finite<f64>>,
}
impl RTCRtpEncodingParameters {
pub fn empty() -> Self {
Self {
parent: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpCodingParameters::empty(),
active: true,
maxBitrate: None,
scaleResolutionDownBy: None,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCRtpEncodingParameters>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCRtpEncodingParameters {
parent: {
match crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpCodingParameters::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
active: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "active", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
true
}
},
maxBitrate: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "maxBitrate", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
})
} else {
None
}
},
scaleResolutionDownBy: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "scaleResolutionDownBy", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCRtpEncodingParameters {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCRtpEncodingParameters>, ()> {
RTCRtpEncodingParameters::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCRtpEncodingParameters {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
let active = &self.active;
rooted!(in(cx) let mut active_js = UndefinedValue());
active.to_jsval(cx, active_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "active", active_js.handle()).unwrap();
if let Some(ref maxBitrate) = self.maxBitrate {
rooted!(in(cx) let mut maxBitrate_js = UndefinedValue());
maxBitrate.to_jsval(cx, maxBitrate_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "maxBitrate", maxBitrate_js.handle()).unwrap();
}
if let Some(ref scaleResolutionDownBy) = self.scaleResolutionDownBy {
rooted!(in(cx) let mut scaleResolutionDownBy_js = UndefinedValue());
scaleResolutionDownBy.to_jsval(cx, scaleResolutionDownBy_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "scaleResolutionDownBy", scaleResolutionDownBy_js.handle()).unwrap();
}
}
}
impl ToJSValConvertible for RTCRtpEncodingParameters {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct RTCRtpTransceiverInit {
pub direction: RTCRtpTransceiverDirection,
pub sendEncodings: Vec<crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpEncodingParameters>,
pub streams: Vec<DomRoot<MediaStream>>,
}
impl RTCRtpTransceiverInit {
pub fn empty() -> Self {
Self {
direction: RTCRtpTransceiverDirection::Sendrecv,
sendEncodings: Vec::new(),
streams: Vec::new(),
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<RTCRtpTransceiverInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = RTCRtpTransceiverInit {
direction: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "direction", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
RTCRtpTransceiverDirection::Sendrecv
}
},
sendEncodings: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "sendEncodings", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
Vec::new()
}
},
streams: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "streams", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
Vec::new()
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for RTCRtpTransceiverInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<RTCRtpTransceiverInit>, ()> {
RTCRtpTransceiverInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl RTCRtpTransceiverInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let direction = &self.direction;
rooted!(in(cx) let mut direction_js = UndefinedValue());
direction.to_jsval(cx, direction_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "direction", direction_js.handle()).unwrap();
let sendEncodings = &self.sendEncodings;
rooted!(in(cx) let mut sendEncodings_js = UndefinedValue());
sendEncodings.to_jsval(cx, sendEncodings_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "sendEncodings", sendEncodings_js.handle()).unwrap();
let streams = &self.streams;
rooted!(in(cx) let mut streams_js = UndefinedValue());
streams.to_jsval(cx, streams_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "streams", streams_js.handle()).unwrap();
}
}
impl ToJSValConvertible for RTCRtpTransceiverInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
pub use self::RTCPeerConnection_Binding::{Wrap, RTCPeerConnectionMethods, GetProtoObject, DefineDOMInterface};
pub mod RTCPeerConnection_Binding {
use crate::dom;
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTarget_Binding;
use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit;
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCAnswerOptions;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCBundlePolicy;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCBundlePolicyValues;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCConfiguration;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceConnectionState;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceConnectionStateValues;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceGatheringState;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceGatheringStateValues;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceServer;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceTransportPolicy;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCIceTransportPolicyValues;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferOptions;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtcpMuxPolicy;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtcpMuxPolicyValues;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpEncodingParameters;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpTransceiverInit;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCSignalingState;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCSignalingStateValues;
use crate::dom::bindings::codegen::Bindings::RTCRtpTransceiverBinding::RTCRtpTransceiverDirection;
use crate::dom::bindings::codegen::Bindings::RTCRtpTransceiverBinding::RTCRtpTransceiverDirectionValues;
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSdpType;
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSdpTypeValues;
use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit;
use crate::dom::bindings::import::module::*;
use crate::dom::promise::Promise;
use crate::dom::types::EventTarget;
use crate::dom::types::MediaStream;
use crate::dom::types::MediaStreamTrack;
use crate::dom::types::RTCDataChannel;
use crate::dom::types::RTCPeerConnection;
use crate::dom::types::RTCRtpTransceiver;
use crate::dom::types::RTCSessionDescription;
unsafe extern fn createOffer(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
let arg0: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferOptions = if args.get(0).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferOptions::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: Rc<Promise> = this.CreateOffer(&arg0, InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx)));
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const createOffer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createOffer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn createAnswer(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
let arg0: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCAnswerOptions = if args.get(0).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCAnswerOptions::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: Rc<Promise> = this.CreateAnswer(&arg0, InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx)));
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const createAnswer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createAnswer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn setLocalDescription(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"RTCPeerConnection.setLocalDescription\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Rc<Promise> = this.SetLocalDescription(&arg0, InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx)));
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setLocalDescription_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setLocalDescription)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_localDescription(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<DomRoot<RTCSessionDescription>> = this.GetLocalDescription();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const localDescription_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_localDescription)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn setRemoteDescription(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"RTCPeerConnection.setRemoteDescription\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Rc<Promise> = this.SetRemoteDescription(&arg0, InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx)));
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setRemoteDescription_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setRemoteDescription)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_remoteDescription(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<DomRoot<RTCSessionDescription>> = this.GetRemoteDescription();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const remoteDescription_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_remoteDescription)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn addIceCandidate(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
let arg0: crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit = if args.get(0).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: Rc<Promise> = this.AddIceCandidate(&arg0, InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx)));
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const addIceCandidate_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(addIceCandidate)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_signalingState(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: RTCSignalingState = this.SignalingState();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const signalingState_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_signalingState)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_STRING as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_iceGatheringState(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: RTCIceGatheringState = this.IceGatheringState();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const iceGatheringState_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_iceGatheringState)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_STRING as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_iceConnectionState(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: RTCIceConnectionState = this.IceConnectionState();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const iceConnectionState_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_iceConnectionState)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_STRING as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn close(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
let result: () = this.Close();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const close_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(close)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_onnegotiationneeded(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOnnegotiationneeded();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_onnegotiationneeded(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOnnegotiationneeded(arg0);
true
});
result
}
const onnegotiationneeded_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_onnegotiationneeded)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const onnegotiationneeded_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_onnegotiationneeded)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_onicecandidate(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOnicecandidate();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_onicecandidate(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOnicecandidate(arg0);
true
});
result
}
const onicecandidate_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_onicecandidate)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const onicecandidate_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_onicecandidate)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_onsignalingstatechange(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOnsignalingstatechange();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_onsignalingstatechange(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOnsignalingstatechange(arg0);
true
});
result
}
const onsignalingstatechange_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_onsignalingstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const onsignalingstatechange_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_onsignalingstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_oniceconnectionstatechange(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOniceconnectionstatechange();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_oniceconnectionstatechange(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOniceconnectionstatechange(arg0);
true
});
result
}
const oniceconnectionstatechange_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_oniceconnectionstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const oniceconnectionstatechange_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_oniceconnectionstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_onicegatheringstatechange(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOnicegatheringstatechange();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_onicegatheringstatechange(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOnicegatheringstatechange(arg0);
true
});
result
}
const onicegatheringstatechange_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_onicegatheringstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const onicegatheringstatechange_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_onicegatheringstatechange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn addStream(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"RTCPeerConnection.addStream\".");
return false;
}
let arg0: DomRoot<MediaStream> = if HandleValue::from_raw(args.get(0)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(0)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface MediaStream.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let result: () = this.AddStream(&arg0);
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const addStream_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(addStream)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn addTransceiver(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"RTCPeerConnection.addTransceiver\".");
return false;
}
let arg0: UnionTypes::MediaStreamTrackOrString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let arg1: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpTransceiverInit = if args.get(1).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpTransceiverInit::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: DomRoot<RTCRtpTransceiver> = this.AddTransceiver(arg0, &arg1);
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const addTransceiver_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(addTransceiver)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_ontrack(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOntrack();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_ontrack(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOntrack(arg0);
true
});
result
}
const ontrack_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_ontrack)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const ontrack_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_ontrack)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn createDataChannel(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"RTCPeerConnection.createDataChannel\".");
return false;
}
let arg0: USVString = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let arg1: crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit = if args.get(1).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: DomRoot<RTCDataChannel> = this.CreateDataChannel(arg0, &arg1);
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const createDataChannel_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createDataChannel)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn get_ondatachannel(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let result: Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>> = this.GetOndatachannel();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
unsafe extern fn set_ondatachannel(cx: *mut JSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const RTCPeerConnection);
let arg0: Option<Rc<EventHandlerNonNull>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
Some(EventHandlerNonNull::new(cx, HandleValue::from_raw(args.get(0)).get().to_object()))
} else {
None
};
let result: () = this.SetOndatachannel(arg0);
true
});
result
}
const ondatachannel_getterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
getter: Some(get_ondatachannel)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Getter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNKNOWN as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
const ondatachannel_setterinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
setter: Some(set_ondatachannel)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::RTCPeerConnection as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Setter as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn _finalize(_cx: *mut GCContext, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<RTCPeerConnection>(obj).unwrap();
finalize_common(this);
})
}
unsafe extern fn _trace(trc: *mut JSTracer, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<RTCPeerConnection>(obj).unwrap();
if this.is_null() { return; } (*this).trace(trc);
})
}
static CLASS_OPS: JSClassOps = JSClassOps {
addProperty: None,
delProperty: None,
enumerate: None,
newEnumerate: None,
resolve: None,
mayResolve: None,
finalize: Some(_finalize),
call: None,
construct: None,
trace: Some(_trace),
};
static Class: DOMJSClass = DOMJSClass {
base: JSClass {
name: b"RTCPeerConnection\0" as *const u8 as *const libc::c_char,
flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
(((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
,
cOps: &CLASS_OPS,
spec: ptr::null(),
ext: ptr::null(),
oOps: ptr::null(),
},
dom_class: DOMClass {
interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::RTCPeerConnection, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
depth: 1,
type_id: crate::dom::bindings::codegen::InheritTypes::TopTypeId { eventtarget: (crate::dom::bindings::codegen::InheritTypes::EventTargetTypeId::RTCPeerConnection) },
malloc_size_of: malloc_size_of_including_raw_self::<RTCPeerConnection> as unsafe fn(&mut _, _) -> _,
global: InterfaceObjectMap::Globals::EMPTY,
}
};
impl RTCPeerConnection {
fn __assert_parent_type(&self) {
use crate::dom::bindings::inheritance::HasParent;
let _: &EventTarget = self.as_parent();
}
}
pub unsafe fn Wrap(cx: SafeJSContext, scope: &GlobalScope, given_proto: Option<HandleObject>, object: Box<RTCPeerConnection>) -> DomRoot<RTCPeerConnection> {
let raw = Root::new(MaybeUnreflectedDom::from_box(object));
let scope = scope.reflector().get_jsobject();
assert!(!scope.get().is_null());
assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
let _ac = JSAutoRealm::new(*cx, scope.get());
rooted!(in(*cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
GetProtoObject(cx, scope, canonical_proto.handle_mut());
assert!(!canonical_proto.is_null());
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
if let Some(given) = given_proto {
*proto = *given;
if get_context_realm(*cx) != get_object_realm(*given) {
assert!(JS_WrapObject(*cx, proto.handle_mut()));
}
} else {
*proto = *canonical_proto;
}
rooted!(in(*cx) let obj = JS_NewObjectWithGivenProto(
*cx,
&Class.base,
proto.handle(),
));
assert!(!obj.is_null());
JS_SetReservedSlot(
obj.get(),
DOM_OBJECT_SLOT,
&PrivateValue(raw.as_ptr() as *const libc::c_void),
);
let root = raw.reflect_with(obj.get());
DomRoot::from_ref(&*root)
}
impl DomObjectWrap for dom::rtcpeerconnection::RTCPeerConnection {
const WRAP: unsafe fn(
SafeJSContext,
&GlobalScope,
Option<HandleObject>,
Box<Self>,
) -> Root<Dom<Self>> = Wrap;
}
impl IDLInterface for RTCPeerConnection {
#[inline]
fn derives(class: &'static DOMClass) -> bool {
ptr::eq(class, &Class.dom_class)
}
}
impl PartialEq for RTCPeerConnection {
fn eq(&self, other: &RTCPeerConnection) -> bool {
self as *const RTCPeerConnection == other
}
}
pub trait RTCPeerConnectionMethods {
fn CreateOffer(&self, options: &crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCOfferOptions, _comp: InRealm) -> Rc<Promise>;
fn CreateAnswer(&self, options: &crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCAnswerOptions, _comp: InRealm) -> Rc<Promise>;
fn SetLocalDescription(&self, description: &crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit, _comp: InRealm) -> Rc<Promise>;
fn GetLocalDescription(&self) -> Option<DomRoot<RTCSessionDescription>>;
fn SetRemoteDescription(&self, description: &crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionInit, _comp: InRealm) -> Rc<Promise>;
fn GetRemoteDescription(&self) -> Option<DomRoot<RTCSessionDescription>>;
fn AddIceCandidate(&self, candidate: &crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit, _comp: InRealm) -> Rc<Promise>;
fn SignalingState(&self) -> RTCSignalingState;
fn IceGatheringState(&self) -> RTCIceGatheringState;
fn IceConnectionState(&self) -> RTCIceConnectionState;
fn Close(&self);
fn GetOnnegotiationneeded(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOnnegotiationneeded(&self, value: Option<Rc<EventHandlerNonNull>>);
fn GetOnicecandidate(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOnicecandidate(&self, value: Option<Rc<EventHandlerNonNull>>);
fn GetOnsignalingstatechange(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOnsignalingstatechange(&self, value: Option<Rc<EventHandlerNonNull>>);
fn GetOniceconnectionstatechange(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOniceconnectionstatechange(&self, value: Option<Rc<EventHandlerNonNull>>);
fn GetOnicegatheringstatechange(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOnicegatheringstatechange(&self, value: Option<Rc<EventHandlerNonNull>>);
fn AddStream(&self, stream: &MediaStream);
fn AddTransceiver(&self, trackOrKind: UnionTypes::MediaStreamTrackOrString, init: &crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCRtpTransceiverInit) -> DomRoot<RTCRtpTransceiver>;
fn GetOntrack(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOntrack(&self, value: Option<Rc<EventHandlerNonNull>>);
fn CreateDataChannel(&self, label: USVString, dataChannelDict: &crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit) -> DomRoot<RTCDataChannel>;
fn GetOndatachannel(&self) -> Option<Rc<crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull>>;
fn SetOndatachannel(&self, value: Option<Rc<EventHandlerNonNull>>);
}
const sMethods_specs: &[&[JSFunctionSpec]] = &[
&[
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"createOffer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createOffer_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"createAnswer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createAnswer_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setLocalDescription\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setLocalDescription_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setRemoteDescription\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setRemoteDescription_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"addIceCandidate\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &addIceCandidate_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"close\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &close_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"addStream\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &addStream_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: ptr::null() },
call: JSNativeWrapper { op: None, info: ptr::null() },
nargs: 0,
flags: 0,
selfHostedName: ptr::null()
}]
,
&[
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"addTransceiver\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &addTransceiver_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: ptr::null() },
call: JSNativeWrapper { op: None, info: ptr::null() },
nargs: 0,
flags: 0,
selfHostedName: ptr::null()
}]
,
&[
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"createDataChannel\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createDataChannel_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: ptr::null() },
call: JSNativeWrapper { op: None, info: ptr::null() },
nargs: 0,
flags: 0,
selfHostedName: ptr::null()
}]
];
const sMethods: &[Guard<&[JSFunctionSpec]>] = &[
Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sMethods_specs[0]),
Guard::new(Condition::Pref("dom.webrtc.transceiver.enabled"), sMethods_specs[1]),
Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sMethods_specs[2])
];
const sAttributes_specs: &[&[JSPropertySpec]] = &[
&[
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"localDescription\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &localDescription_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"remoteDescription\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &remoteDescription_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"signalingState\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &signalingState_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"iceGatheringState\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &iceGatheringState_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"iceConnectionState\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &iceConnectionState_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"onnegotiationneeded\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &onnegotiationneeded_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &onnegotiationneeded_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"onicecandidate\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &onicecandidate_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &onicecandidate_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"onsignalingstatechange\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &onsignalingstatechange_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &onsignalingstatechange_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"oniceconnectionstatechange\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &oniceconnectionstatechange_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &oniceconnectionstatechange_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"onicegatheringstatechange\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &onicegatheringstatechange_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &onicegatheringstatechange_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"ontrack\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &ontrack_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &ontrack_setterinfo },
}
}
}
}
,
JSPropertySpec {
name: JSPropertySpec_Name { string_: b"ondatachannel\0" as *const u8 as *const libc::c_char },
attributes_: (JSPROP_ENUMERATE),
kind_: (JSPropertySpec_Kind::NativeAccessor),
u: JSPropertySpec_AccessorsOrValue {
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
getter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_getter), info: &ondatachannel_getterinfo },
},
setter: JSPropertySpec_Accessor {
native: JSNativeWrapper { op: Some(generic_setter), info: &ondatachannel_setterinfo },
}
}
}
}
,
JSPropertySpec::ZERO]
,
&[
JSPropertySpec {
name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
attributes_: (JSPROP_READONLY),
kind_: (JSPropertySpec_Kind::Value),
u: JSPropertySpec_AccessorsOrValue {
value: JSPropertySpec_ValueWrapper {
type_: JSPropertySpec_ValueWrapper_Type::String,
__bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
string: b"RTCPeerConnection\0" as *const u8 as *const libc::c_char,
}
}
}
}
,
JSPropertySpec::ZERO]
];
const sAttributes: &[Guard<&[JSPropertySpec]>] = &[
Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sAttributes_specs[0]),
Guard::new(Condition::Satisfied, sAttributes_specs[1])
];
pub fn GetProtoObject(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject) {
get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCPeerConnection), CreateInterfaceObjects, rval)
}
static PrototypeClass: JSClass = JSClass {
name: b"RTCPeerConnectionPrototype\0" as *const u8 as *const libc::c_char,
flags:
(0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
cOps: 0 as *const _,
spec: ptr::null(),
ext: ptr::null(),
oOps: ptr::null(),
};
unsafe extern fn _constructor(cx: *mut JSContext, argc: u32, vp: *mut JSVal) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let args = CallArgs::from_vp(vp, argc);
let global = GlobalScope::from_object(JS_CALLEE(*cx, vp).to_object());
let global = DomRoot::downcast::<dom::types::Window>(global).unwrap();
if !callargs_is_constructing(&args) {
throw_constructor_without_new(*cx, "RTCPeerConnection");
return false;
}
rooted!(in(*cx) let mut desired_proto = ptr::null_mut::<JSObject>());
let proto_result = get_desired_proto(
cx,
&args,
PrototypeList::ID::RTCPeerConnection,
CreateInterfaceObjects,
desired_proto.handle_mut(),
);
assert!(proto_result.is_ok());
if proto_result.is_err() {
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCConfiguration = if args.get(0).is_undefined() {
crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCConfiguration::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: Result<DomRoot<RTCPeerConnection>, Error> = RTCPeerConnection::Constructor(&global, Some(desired_proto.handle()), &arg0);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, global.upcast::<GlobalScope>(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
static INTERFACE_OBJECT_CLASS: NonCallbackInterfaceObjectClass =
NonCallbackInterfaceObjectClass::new(
{
const BEHAVIOR: InterfaceConstructorBehavior = InterfaceConstructorBehavior::call(_constructor);
&BEHAVIOR
},
b"function RTCPeerConnection() {\n [native code]\n}",
PrototypeList::ID::RTCPeerConnection,
1);
pub fn DefineDOMInterface(cx: SafeJSContext, global: HandleObject) {
define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCPeerConnection), CreateInterfaceObjects, ConstructorEnabled)
}
fn ConstructorEnabled(aCx: SafeJSContext, aObj: HandleObject) -> bool {
is_exposed_in(aObj, InterfaceObjectMap::Globals::WINDOW) &&
pref!(dom.webrtc.enabled)
}
unsafe fn CreateInterfaceObjects(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray) {
rooted!(in(*cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
EventTarget_Binding::GetProtoObject(cx, global, prototype_proto.handle_mut());
assert!(!prototype_proto.is_null());
rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
create_interface_prototype_object(cx,
global,
prototype_proto.handle(),
&PrototypeClass,
sMethods,
sAttributes,
&[],
&[],
prototype.handle_mut());
assert!(!prototype.is_null());
assert!((*cache)[PrototypeList::ID::RTCPeerConnection as usize].is_null());
(*cache)[PrototypeList::ID::RTCPeerConnection as usize] = prototype.get();
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::RTCPeerConnection as isize),
ptr::null_mut(),
prototype.get());
rooted!(in(*cx) let mut interface_proto = ptr::null_mut::<JSObject>());
EventTarget_Binding::GetConstructorObject(cx, global, interface_proto.handle_mut());
assert!(!interface_proto.is_null());
rooted!(in(*cx) let mut interface = ptr::null_mut::<JSObject>());
create_noncallback_interface_object(cx,
global,
interface_proto.handle(),
&INTERFACE_OBJECT_CLASS,
&[],
&[],
&[],
prototype.handle(),
b"RTCPeerConnection\0",
0,
&[],
interface.handle_mut());
assert!(!interface.is_null());
}
}