1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::RTCPeerConnectionBinding::RTCRtpEncodingParameters;
6use crate::import::base::*;
7
8#[derive(JSTraceable)]
9pub struct RTCRtpHeaderExtensionParameters {
10 pub encrypted: bool,
11 pub id: u16,
12 pub uri: DOMString,
13}
14
15impl RTCRtpHeaderExtensionParameters {
16
17 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
18 -> Result<ConversionResult<RTCRtpHeaderExtensionParameters>, ()> {
19 unsafe {
20 let object = if val.get().is_null_or_undefined() {
21 ptr::null_mut()
22 } else if val.get().is_object() {
23 val.get().to_object()
24 } else {
25 return Ok(ConversionResult::Failure("Value is not an object.".into()));
26 };
27 rooted!(&in(cx) let object = object);
28 let dictionary = RTCRtpHeaderExtensionParameters {
29 encrypted: {
30 rooted!(&in(cx) let mut rval = UndefinedValue());
31 if get_dictionary_property(cx.raw_cx(), object.handle(), "encrypted", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
32 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
33 Ok(ConversionResult::Success(value)) => value,
34 Ok(ConversionResult::Failure(error)) => {
35 throw_type_error(cx.raw_cx(), &error);
36 return Err(());
37
38 }
39 _ => {
40 return Err(());
41
42 },
43 }
44
45 } else {
46 false
47 }
48 },
49 id: {
50 rooted!(&in(cx) let mut rval = UndefinedValue());
51 if get_dictionary_property(cx.raw_cx(), object.handle(), "id", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
52 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
53 Ok(ConversionResult::Success(value)) => value,
54 Ok(ConversionResult::Failure(error)) => {
55 throw_type_error(cx.raw_cx(), &error);
56 return Err(());
57
58 }
59 _ => {
60 return Err(());
61
62 },
63 }
64
65 } else {
66 throw_type_error(cx.raw_cx(), "Missing required member \"id\".");
67 return Err(());
68 }
69 },
70 uri: {
71 rooted!(&in(cx) let mut rval = UndefinedValue());
72 if get_dictionary_property(cx.raw_cx(), object.handle(), "uri", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
73 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
74 Ok(ConversionResult::Success(value)) => value,
75 Ok(ConversionResult::Failure(error)) => {
76 throw_type_error(cx.raw_cx(), &error);
77 return Err(());
78
79 }
80 _ => {
81 return Err(());
82
83 },
84 }
85
86 } else {
87 throw_type_error(cx.raw_cx(), "Missing required member \"uri\".");
88 return Err(());
89 }
90 },
91 };
92 Ok(ConversionResult::Success(dictionary))
93 }
94 }
95}
96
97impl FromJSValConvertible for RTCRtpHeaderExtensionParameters {
98 type Config = ();
99 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
100 -> Result<ConversionResult<RTCRtpHeaderExtensionParameters>, ()> {
101 RTCRtpHeaderExtensionParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
102 }
103}
104
105impl RTCRtpHeaderExtensionParameters {
106 #[allow(clippy::wrong_self_convention)]
107 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
108 let encrypted = &self.encrypted;
109 rooted!(in(cx) let mut encrypted_js = UndefinedValue());
110 encrypted.to_jsval(cx, encrypted_js.handle_mut());
111 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "encrypted", encrypted_js.handle()).unwrap();
112 let id = &self.id;
113 rooted!(in(cx) let mut id_js = UndefinedValue());
114 id.to_jsval(cx, id_js.handle_mut());
115 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "id", id_js.handle()).unwrap();
116 let uri = &self.uri;
117 rooted!(in(cx) let mut uri_js = UndefinedValue());
118 uri.to_jsval(cx, uri_js.handle_mut());
119 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "uri", uri_js.handle()).unwrap();
120 }
121}
122
123impl ToJSValConvertible for RTCRtpHeaderExtensionParameters {
124 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
125 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
126 self.to_jsobject(cx, obj.handle_mut());
127 rval.set(ObjectOrNullValue(obj.get()))
128 }
129}
130
131
132#[derive(JSTraceable)]
133pub struct RTCRtcpParameters {
134 pub cname: Option<DOMString>,
135 pub reducedSize: Option<bool>,
136}
137impl Default for RTCRtcpParameters {
138 fn default() -> Self {
139 Self::empty()
140 }
141}
142
143impl RTCRtcpParameters {
144 pub fn empty() -> Self {
145 Self {
146 cname: None,
147 reducedSize: None,
148 }
149 }
150 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
151 -> Result<ConversionResult<RTCRtcpParameters>, ()> {
152 unsafe {
153 let object = if val.get().is_null_or_undefined() {
154 ptr::null_mut()
155 } else if val.get().is_object() {
156 val.get().to_object()
157 } else {
158 return Ok(ConversionResult::Failure("Value is not an object.".into()));
159 };
160 rooted!(&in(cx) let object = object);
161 let dictionary = RTCRtcpParameters {
162 cname: {
163 rooted!(&in(cx) let mut rval = UndefinedValue());
164 if get_dictionary_property(cx.raw_cx(), object.handle(), "cname", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
165 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
166 Ok(ConversionResult::Success(value)) => value,
167 Ok(ConversionResult::Failure(error)) => {
168 throw_type_error(cx.raw_cx(), &error);
169 return Err(());
170
171 }
172 _ => {
173 return Err(());
174
175 },
176 }
177 )
178 } else {
179 None
180 }
181 },
182 reducedSize: {
183 rooted!(&in(cx) let mut rval = UndefinedValue());
184 if get_dictionary_property(cx.raw_cx(), object.handle(), "reducedSize", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
185 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
186 Ok(ConversionResult::Success(value)) => value,
187 Ok(ConversionResult::Failure(error)) => {
188 throw_type_error(cx.raw_cx(), &error);
189 return Err(());
190
191 }
192 _ => {
193 return Err(());
194
195 },
196 }
197 )
198 } else {
199 None
200 }
201 },
202 };
203 Ok(ConversionResult::Success(dictionary))
204 }
205 }
206}
207
208impl FromJSValConvertible for RTCRtcpParameters {
209 type Config = ();
210 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
211 -> Result<ConversionResult<RTCRtcpParameters>, ()> {
212 RTCRtcpParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
213 }
214}
215
216impl RTCRtcpParameters {
217 #[allow(clippy::wrong_self_convention)]
218 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
219 if let Some(ref cname) = self.cname {
220 rooted!(in(cx) let mut cname_js = UndefinedValue());
221 cname.to_jsval(cx, cname_js.handle_mut());
222 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "cname", cname_js.handle()).unwrap();
223 }
224 if let Some(ref reducedSize) = self.reducedSize {
225 rooted!(in(cx) let mut reducedSize_js = UndefinedValue());
226 reducedSize.to_jsval(cx, reducedSize_js.handle_mut());
227 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "reducedSize", reducedSize_js.handle()).unwrap();
228 }
229 }
230}
231
232impl ToJSValConvertible for RTCRtcpParameters {
233 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
234 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
235 self.to_jsobject(cx, obj.handle_mut());
236 rval.set(ObjectOrNullValue(obj.get()))
237 }
238}
239
240
241#[derive(JSTraceable)]
242pub struct RTCRtpCodecParameters {
243 pub channels: Option<u16>,
244 pub clockRate: u32,
245 pub mimeType: DOMString,
246 pub payloadType: u8,
247 pub sdpFmtpLine: Option<DOMString>,
248}
249
250impl RTCRtpCodecParameters {
251
252 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
253 -> Result<ConversionResult<RTCRtpCodecParameters>, ()> {
254 unsafe {
255 let object = if val.get().is_null_or_undefined() {
256 ptr::null_mut()
257 } else if val.get().is_object() {
258 val.get().to_object()
259 } else {
260 return Ok(ConversionResult::Failure("Value is not an object.".into()));
261 };
262 rooted!(&in(cx) let object = object);
263 let dictionary = RTCRtpCodecParameters {
264 channels: {
265 rooted!(&in(cx) let mut rval = UndefinedValue());
266 if get_dictionary_property(cx.raw_cx(), object.handle(), "channels", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
267 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
268 Ok(ConversionResult::Success(value)) => value,
269 Ok(ConversionResult::Failure(error)) => {
270 throw_type_error(cx.raw_cx(), &error);
271 return Err(());
272
273 }
274 _ => {
275 return Err(());
276
277 },
278 }
279 )
280 } else {
281 None
282 }
283 },
284 clockRate: {
285 rooted!(&in(cx) let mut rval = UndefinedValue());
286 if get_dictionary_property(cx.raw_cx(), object.handle(), "clockRate", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
287 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
288 Ok(ConversionResult::Success(value)) => value,
289 Ok(ConversionResult::Failure(error)) => {
290 throw_type_error(cx.raw_cx(), &error);
291 return Err(());
292
293 }
294 _ => {
295 return Err(());
296
297 },
298 }
299
300 } else {
301 throw_type_error(cx.raw_cx(), "Missing required member \"clockRate\".");
302 return Err(());
303 }
304 },
305 mimeType: {
306 rooted!(&in(cx) let mut rval = UndefinedValue());
307 if get_dictionary_property(cx.raw_cx(), object.handle(), "mimeType", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
308 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
309 Ok(ConversionResult::Success(value)) => value,
310 Ok(ConversionResult::Failure(error)) => {
311 throw_type_error(cx.raw_cx(), &error);
312 return Err(());
313
314 }
315 _ => {
316 return Err(());
317
318 },
319 }
320
321 } else {
322 throw_type_error(cx.raw_cx(), "Missing required member \"mimeType\".");
323 return Err(());
324 }
325 },
326 payloadType: {
327 rooted!(&in(cx) let mut rval = UndefinedValue());
328 if get_dictionary_property(cx.raw_cx(), object.handle(), "payloadType", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
329 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
330 Ok(ConversionResult::Success(value)) => value,
331 Ok(ConversionResult::Failure(error)) => {
332 throw_type_error(cx.raw_cx(), &error);
333 return Err(());
334
335 }
336 _ => {
337 return Err(());
338
339 },
340 }
341
342 } else {
343 throw_type_error(cx.raw_cx(), "Missing required member \"payloadType\".");
344 return Err(());
345 }
346 },
347 sdpFmtpLine: {
348 rooted!(&in(cx) let mut rval = UndefinedValue());
349 if get_dictionary_property(cx.raw_cx(), object.handle(), "sdpFmtpLine", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
350 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
351 Ok(ConversionResult::Success(value)) => value,
352 Ok(ConversionResult::Failure(error)) => {
353 throw_type_error(cx.raw_cx(), &error);
354 return Err(());
355
356 }
357 _ => {
358 return Err(());
359
360 },
361 }
362 )
363 } else {
364 None
365 }
366 },
367 };
368 Ok(ConversionResult::Success(dictionary))
369 }
370 }
371}
372
373impl FromJSValConvertible for RTCRtpCodecParameters {
374 type Config = ();
375 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
376 -> Result<ConversionResult<RTCRtpCodecParameters>, ()> {
377 RTCRtpCodecParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
378 }
379}
380
381impl RTCRtpCodecParameters {
382 #[allow(clippy::wrong_self_convention)]
383 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
384 if let Some(ref channels) = self.channels {
385 rooted!(in(cx) let mut channels_js = UndefinedValue());
386 channels.to_jsval(cx, channels_js.handle_mut());
387 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "channels", channels_js.handle()).unwrap();
388 }
389 let clockRate = &self.clockRate;
390 rooted!(in(cx) let mut clockRate_js = UndefinedValue());
391 clockRate.to_jsval(cx, clockRate_js.handle_mut());
392 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "clockRate", clockRate_js.handle()).unwrap();
393 let mimeType = &self.mimeType;
394 rooted!(in(cx) let mut mimeType_js = UndefinedValue());
395 mimeType.to_jsval(cx, mimeType_js.handle_mut());
396 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "mimeType", mimeType_js.handle()).unwrap();
397 let payloadType = &self.payloadType;
398 rooted!(in(cx) let mut payloadType_js = UndefinedValue());
399 payloadType.to_jsval(cx, payloadType_js.handle_mut());
400 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "payloadType", payloadType_js.handle()).unwrap();
401 if let Some(ref sdpFmtpLine) = self.sdpFmtpLine {
402 rooted!(in(cx) let mut sdpFmtpLine_js = UndefinedValue());
403 sdpFmtpLine.to_jsval(cx, sdpFmtpLine_js.handle_mut());
404 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "sdpFmtpLine", sdpFmtpLine_js.handle()).unwrap();
405 }
406 }
407}
408
409impl ToJSValConvertible for RTCRtpCodecParameters {
410 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
411 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
412 self.to_jsobject(cx, obj.handle_mut());
413 rval.set(ObjectOrNullValue(obj.get()))
414 }
415}
416
417
418#[derive(JSTraceable)]
419pub struct RTCRtpParameters {
420 pub codecs: Vec<crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpCodecParameters>,
421 pub headerExtensions: Vec<crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpHeaderExtensionParameters>,
422 pub rtcp: crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtcpParameters,
423}
424
425impl RTCRtpParameters {
426
427 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
428 -> Result<ConversionResult<RTCRtpParameters>, ()> {
429 unsafe {
430 let object = if val.get().is_null_or_undefined() {
431 ptr::null_mut()
432 } else if val.get().is_object() {
433 val.get().to_object()
434 } else {
435 return Ok(ConversionResult::Failure("Value is not an object.".into()));
436 };
437 rooted!(&in(cx) let object = object);
438 let dictionary = RTCRtpParameters {
439 codecs: {
440 rooted!(&in(cx) let mut rval = UndefinedValue());
441 if get_dictionary_property(cx.raw_cx(), object.handle(), "codecs", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
442 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
443 Ok(ConversionResult::Success(value)) => value,
444 Ok(ConversionResult::Failure(error)) => {
445 throw_type_error(cx.raw_cx(), &error);
446 return Err(());
447
448 }
449 _ => {
450 return Err(());
451
452 },
453 }
454
455 } else {
456 throw_type_error(cx.raw_cx(), "Missing required member \"codecs\".");
457 return Err(());
458 }
459 },
460 headerExtensions: {
461 rooted!(&in(cx) let mut rval = UndefinedValue());
462 if get_dictionary_property(cx.raw_cx(), object.handle(), "headerExtensions", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
463 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
464 Ok(ConversionResult::Success(value)) => value,
465 Ok(ConversionResult::Failure(error)) => {
466 throw_type_error(cx.raw_cx(), &error);
467 return Err(());
468
469 }
470 _ => {
471 return Err(());
472
473 },
474 }
475
476 } else {
477 throw_type_error(cx.raw_cx(), "Missing required member \"headerExtensions\".");
478 return Err(());
479 }
480 },
481 rtcp: {
482 rooted!(&in(cx) let mut rval = UndefinedValue());
483 if get_dictionary_property(cx.raw_cx(), object.handle(), "rtcp", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
484 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
485 Ok(ConversionResult::Success(value)) => value,
486 Ok(ConversionResult::Failure(error)) => {
487 throw_type_error(cx.raw_cx(), &error);
488 return Err(());
489
490 }
491 _ => {
492 return Err(());
493
494 },
495 }
496
497 } else {
498 throw_type_error(cx.raw_cx(), "Missing required member \"rtcp\".");
499 return Err(());
500 }
501 },
502 };
503 Ok(ConversionResult::Success(dictionary))
504 }
505 }
506}
507
508impl FromJSValConvertible for RTCRtpParameters {
509 type Config = ();
510 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
511 -> Result<ConversionResult<RTCRtpParameters>, ()> {
512 RTCRtpParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
513 }
514}
515
516impl RTCRtpParameters {
517 #[allow(clippy::wrong_self_convention)]
518 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
519 let codecs = &self.codecs;
520 rooted!(in(cx) let mut codecs_js = UndefinedValue());
521 codecs.to_jsval(cx, codecs_js.handle_mut());
522 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "codecs", codecs_js.handle()).unwrap();
523 let headerExtensions = &self.headerExtensions;
524 rooted!(in(cx) let mut headerExtensions_js = UndefinedValue());
525 headerExtensions.to_jsval(cx, headerExtensions_js.handle_mut());
526 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "headerExtensions", headerExtensions_js.handle()).unwrap();
527 let rtcp = &self.rtcp;
528 rooted!(in(cx) let mut rtcp_js = UndefinedValue());
529 rtcp.to_jsval(cx, rtcp_js.handle_mut());
530 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "rtcp", rtcp_js.handle()).unwrap();
531 }
532}
533
534impl ToJSValConvertible for RTCRtpParameters {
535 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
536 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
537 self.to_jsobject(cx, obj.handle_mut());
538 rval.set(ObjectOrNullValue(obj.get()))
539 }
540}
541
542
543#[derive(JSTraceable)]
544pub struct RTCRtpSendParameters {
545 pub parent: crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpParameters,
546 pub encodings: Vec<crate::codegen::GenericBindings::RTCPeerConnectionBinding::RTCRtpEncodingParameters>,
547 pub transactionId: DOMString,
548}
549
550impl RTCRtpSendParameters {
551
552 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
553 -> Result<ConversionResult<RTCRtpSendParameters>, ()> {
554 unsafe {
555 let object = if val.get().is_null_or_undefined() {
556 ptr::null_mut()
557 } else if val.get().is_object() {
558 val.get().to_object()
559 } else {
560 return Ok(ConversionResult::Failure("Value is not an object.".into()));
561 };
562 rooted!(&in(cx) let object = object);
563 let dictionary = RTCRtpSendParameters {
564 parent: {
565 match crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpParameters::new(cx, val, can_gc)? {
566 ConversionResult::Success(v) => v,
567 ConversionResult::Failure(error) => {
568 throw_type_error(cx.raw_cx(), &error);
569 return Err(());
570 }
571 }
572 },
573 encodings: {
574 rooted!(&in(cx) let mut rval = UndefinedValue());
575 if get_dictionary_property(cx.raw_cx(), object.handle(), "encodings", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
576 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
577 Ok(ConversionResult::Success(value)) => value,
578 Ok(ConversionResult::Failure(error)) => {
579 throw_type_error(cx.raw_cx(), &error);
580 return Err(());
581
582 }
583 _ => {
584 return Err(());
585
586 },
587 }
588
589 } else {
590 throw_type_error(cx.raw_cx(), "Missing required member \"encodings\".");
591 return Err(());
592 }
593 },
594 transactionId: {
595 rooted!(&in(cx) let mut rval = UndefinedValue());
596 if get_dictionary_property(cx.raw_cx(), object.handle(), "transactionId", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
597 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
598 Ok(ConversionResult::Success(value)) => value,
599 Ok(ConversionResult::Failure(error)) => {
600 throw_type_error(cx.raw_cx(), &error);
601 return Err(());
602
603 }
604 _ => {
605 return Err(());
606
607 },
608 }
609
610 } else {
611 throw_type_error(cx.raw_cx(), "Missing required member \"transactionId\".");
612 return Err(());
613 }
614 },
615 };
616 Ok(ConversionResult::Success(dictionary))
617 }
618 }
619}
620
621impl FromJSValConvertible for RTCRtpSendParameters {
622 type Config = ();
623 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
624 -> Result<ConversionResult<RTCRtpSendParameters>, ()> {
625 RTCRtpSendParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
626 }
627}
628
629impl RTCRtpSendParameters {
630 #[allow(clippy::wrong_self_convention)]
631 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
632 self.parent.to_jsobject(cx, obj.reborrow());
633 let encodings = &self.encodings;
634 rooted!(in(cx) let mut encodings_js = UndefinedValue());
635 encodings.to_jsval(cx, encodings_js.handle_mut());
636 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "encodings", encodings_js.handle()).unwrap();
637 let transactionId = &self.transactionId;
638 rooted!(in(cx) let mut transactionId_js = UndefinedValue());
639 transactionId.to_jsval(cx, transactionId_js.handle_mut());
640 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "transactionId", transactionId_js.handle()).unwrap();
641 }
642}
643
644impl ToJSValConvertible for RTCRtpSendParameters {
645 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
646 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
647 self.to_jsobject(cx, obj.handle_mut());
648 rval.set(ObjectOrNullValue(obj.get()))
649 }
650}
651
652
653pub use self::RTCRtpSender_Binding::{Wrap, RTCRtpSenderMethods, GetProtoObject, DefineDOMInterface};
654pub mod RTCRtpSender_Binding {
655use crate::codegen::GenericBindings::RTCPeerConnectionBinding::RTCRtpEncodingParameters;
656use crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtcpParameters;
657use crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpCodecParameters;
658use crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpHeaderExtensionParameters;
659use crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpSendParameters;
660use crate::import::module::*;
661
662unsafe extern "C" fn setParameters<D: DomTypes>
663(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
664 let mut result = false;
665 wrap_panic(&mut || result = (|| {
666 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
667 let this = &*(this as *const D::RTCRtpSender);
668 let args = &*args;
669 let argc = args.argc_;
670
671 if argc < 1 {
672 throw_type_error(cx.raw_cx(), "Not enough arguments to \"RTCRtpSender.setParameters\".");
673 return false;
674 }
675 let arg0: crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpSendParameters = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
676 Ok(ConversionResult::Success(value)) => value,
677 Ok(ConversionResult::Failure(error)) => {
678 throw_type_error(cx.raw_cx(), &error);
679 return false;
680
681 }
682 _ => {
683 return false;
684
685 },
686 }
687 ;
688 let result: Rc<D::Promise> = this.SetParameters(&arg0, CanGc::note());
689
690 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
691 return true;
692 })());
693 result
694}
695
696unsafe extern "C" fn setParameters_promise_wrapper<D: DomTypes>
697(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
698 let mut result = false;
699 wrap_panic(&mut || result = (|| {
700 let ok = setParameters::<D>(cx, _obj, this, args);
701 if ok {
702 return true;
703 }
704 return exception_to_promise(cx, (*args).rval(), CanGc::note());
705
706 })());
707 result
708}
709
710
711static setParameters_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
712
713pub(crate) fn init_setParameters_methodinfo<D: DomTypes>() {
714 setParameters_methodinfo.set(JSJitInfo {
715 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
716 method: Some(setParameters_promise_wrapper::<D>)
717 },
718 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
719 protoID: PrototypeList::ID::RTCRtpSender as u16,
720 },
721 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
722 _bitfield_align_1: [],
723 _bitfield_1: __BindgenBitfieldUnit::new(
724 new_jsjitinfo_bitfield_1!(
725 JSJitInfo_OpType::Method as u8,
726 JSJitInfo_AliasSet::AliasEverything as u8,
727 JSValueType::JSVAL_TYPE_OBJECT as u8,
728 false,
729 false,
730 false,
731 false,
732 false,
733 false,
734 0,
735 ).to_ne_bytes()
736 ),
737});
738}
739unsafe extern "C" fn getParameters<D: DomTypes>
740(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
741 let mut result = false;
742 wrap_panic(&mut || result = (|| {
743 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
744 let this = &*(this as *const D::RTCRtpSender);
745 let args = &*args;
746 let argc = args.argc_;
747 let result: RTCRtpSendParameters = this.GetParameters();
748
749 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
750 return true;
751 })());
752 result
753}
754
755
756static getParameters_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
757
758pub(crate) fn init_getParameters_methodinfo<D: DomTypes>() {
759 getParameters_methodinfo.set(JSJitInfo {
760 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
761 method: Some(getParameters::<D>)
762 },
763 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
764 protoID: PrototypeList::ID::RTCRtpSender as u16,
765 },
766 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
767 _bitfield_align_1: [],
768 _bitfield_1: __BindgenBitfieldUnit::new(
769 new_jsjitinfo_bitfield_1!(
770 JSJitInfo_OpType::Method as u8,
771 JSJitInfo_AliasSet::AliasEverything as u8,
772 JSValueType::JSVAL_TYPE_OBJECT as u8,
773 true,
774 false,
775 false,
776 false,
777 false,
778 false,
779 0,
780 ).to_ne_bytes()
781 ),
782});
783}
784unsafe extern "C" fn _finalize<D: DomTypes>
785(_cx: *mut GCContext, obj: *mut JSObject){
786 wrap_panic(&mut || {
787
788 let this = native_from_object_static::<D::RTCRtpSender>(obj).unwrap();
789 finalize_common(this);
790 })
791}
792
793unsafe extern "C" fn _trace<D: DomTypes>
794(trc: *mut JSTracer, obj: *mut JSObject){
795 wrap_panic(&mut || {
796
797 let this = native_from_object_static::<D::RTCRtpSender>(obj).unwrap();
798 if this.is_null() { return; } (*this).trace(trc);
800 })
801}
802
803
804static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
805
806pub(crate) fn init_class_ops<D: DomTypes>() {
807 CLASS_OPS.set(JSClassOps {
808 addProperty: None,
809 delProperty: None,
810 enumerate: None,
811 newEnumerate: None,
812 resolve: None,
813 mayResolve: None,
814 finalize: Some(_finalize::<D>),
815 call: None,
816 construct: None,
817 trace: Some(_trace::<D>),
818 });
819}
820
821pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
822
823pub(crate) fn init_domjs_class<D: DomTypes>() {
824 init_class_ops::<D>();
825 Class.set(DOMJSClass {
826 base: JSClass {
827 name: c"RTCRtpSender".as_ptr(),
828 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
829 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
830 ,
831 cOps: unsafe { CLASS_OPS.get() },
832 spec: ptr::null(),
833 ext: ptr::null(),
834 oOps: ptr::null(),
835 },
836 dom_class:
837DOMClass {
838 interface_chain: [ PrototypeList::ID::RTCRtpSender, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
839 depth: 0,
840 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
841 malloc_size_of: malloc_size_of_including_raw_self::<D::RTCRtpSender> as unsafe fn(&mut _, _) -> _,
842 global: Globals::EMPTY,
843},
844 });
845}
846
847#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
848(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::RTCRtpSender>, _can_gc: CanGc) -> DomRoot<D::RTCRtpSender>{
849
850 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
851
852 let scope = scope.reflector().get_jsobject();
853 assert!(!scope.get().is_null());
854 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
855 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
856
857 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
858 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
859 assert!(!canonical_proto.is_null());
860
861
862 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
863 if let Some(given) = given_proto {
864 proto.set(*given);
865 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
866 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
867 }
868 } else {
869 proto.set(*canonical_proto);
870 }
871 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
872 cx.raw_cx(),
873 &Class.get().base,
874 proto.handle(),
875 ));
876 assert!(!obj.is_null());
877 JS_SetReservedSlot(
878 obj.get(),
879 DOM_OBJECT_SLOT,
880 &PrivateValue(raw.as_ptr() as *const libc::c_void),
881 );
882
883 let root = raw.reflect_with(obj.get());
884
885
886
887 DomRoot::from_ref(&*root)
888}
889
890pub trait RTCRtpSenderMethods<D: DomTypes> {
891 fn SetParameters(&self, r#parameters: &crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpSendParameters, r#_can_gc: CanGc) -> Rc<D::Promise>;
892 fn GetParameters(&self, ) -> RTCRtpSendParameters;
893}
894static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
895
896pub(crate) fn init_sMethods_specs<D: DomTypes>() {
897 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
898 JSFunctionSpec {
899 name: JSPropertySpec_Name { string_: c"setParameters".as_ptr() },
900 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { setParameters_methodinfo.get() } as *const _ as *const JSJitInfo },
901 nargs: 1,
902 flags: (JSPROP_ENUMERATE) as u16,
903 selfHostedName: ptr::null()
904 },
905 JSFunctionSpec {
906 name: JSPropertySpec_Name { string_: c"getParameters".as_ptr() },
907 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getParameters_methodinfo.get() } as *const _ as *const JSJitInfo },
908 nargs: 0,
909 flags: (JSPROP_ENUMERATE) as u16,
910 selfHostedName: ptr::null()
911 },
912 JSFunctionSpec {
913 name: JSPropertySpec_Name { string_: ptr::null() },
914 call: JSNativeWrapper { op: None, info: ptr::null() },
915 nargs: 0,
916 flags: 0,
917 selfHostedName: ptr::null()
918 }]))[..]
919])));
920}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
921
922pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
923 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
924}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
925
926pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
927 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
928 JSPropertySpec {
929 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
930 attributes_: (JSPROP_READONLY),
931 kind_: (JSPropertySpec_Kind::Value),
932 u: JSPropertySpec_AccessorsOrValue {
933 value: JSPropertySpec_ValueWrapper {
934 type_: JSPropertySpec_ValueWrapper_Type::String,
935 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
936 string: c"RTCRtpSender".as_ptr(),
937 }
938 }
939 }
940 }
941,
942 JSPropertySpec::ZERO]))[..]
943])));
944}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
945
946pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
947 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
948}
949pub fn GetProtoObject<D: DomTypes>
950(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
951 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCRtpSender), CreateInterfaceObjects::<D>, rval)
953}
954
955
956static PrototypeClass: JSClass = JSClass {
957 name: c"RTCRtpSenderPrototype".as_ptr(),
958 flags:
959 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
961 cOps: ptr::null(),
962 spec: ptr::null(),
963 ext: ptr::null(),
964 oOps: ptr::null(),
965};
966
967
968static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
969
970pub(crate) fn init_interface_object<D: DomTypes>() {
971 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
972 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
973 b"function RTCRtpSender() {\n [native code]\n}",
974 PrototypeList::ID::RTCRtpSender,
975 0,
976 ));
977}
978
979pub fn DefineDOMInterface<D: DomTypes>
980(cx: SafeJSContext, global: HandleObject){
981 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCRtpSender),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
982}
983
984pub fn ConstructorEnabled<D: DomTypes>
985(aCx: SafeJSContext, aObj: HandleObject) -> bool{
986 is_exposed_in(aObj, Globals::WINDOW) &&
987 pref!(dom_webrtc_transceiver_enabled)
988}
989
990unsafe fn CreateInterfaceObjects<D: DomTypes>
991(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
992
993 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
994 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
995 assert!(!prototype_proto.is_null());
996
997 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
998 create_interface_prototype_object::<D>(cx,
999 global,
1000 prototype_proto.handle(),
1001 &PrototypeClass,
1002 sMethods.get(),
1003 sAttributes.get(),
1004 &[],
1005 &[],
1006 prototype.handle_mut());
1007 assert!(!prototype.is_null());
1008 assert!((*cache)[PrototypeList::ID::RTCRtpSender as usize].is_null());
1009 (*cache)[PrototypeList::ID::RTCRtpSender as usize] = prototype.get();
1010 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::RTCRtpSender as isize),
1011 ptr::null_mut(),
1012 prototype.get());
1013
1014 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
1015 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
1016
1017 assert!(!interface_proto.is_null());
1018
1019 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
1020 create_noncallback_interface_object::<D>(cx,
1021 global,
1022 interface_proto.handle(),
1023 INTERFACE_OBJECT_CLASS.get(),
1024 &[],
1025 &[],
1026 &[],
1027 prototype.handle(),
1028 c"RTCRtpSender",
1029 0,
1030 &[],
1031 interface.handle_mut());
1032 assert!(!interface.is_null());
1033}
1034
1035
1036 pub(crate) fn init_statics<D: DomTypes>() {
1037 init_interface_object::<D>();
1038 init_domjs_class::<D>();
1039 crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpSender_Binding::init_setParameters_methodinfo::<D>();
1040crate::codegen::GenericBindings::RTCRtpSenderBinding::RTCRtpSender_Binding::init_getParameters_methodinfo::<D>();
1041
1042
1043
1044 init_sMethods_specs::<D>();
1045init_sMethods_prefs::<D>();
1046init_sAttributes_specs::<D>();
1047init_sAttributes_prefs::<D>();
1048 }
1049 }