servo/components/script/dom/rtcrtpsender.rs
Josh Matthews 575e885529
Mark promise creation methods with CanGc (#33928)
* Add CanGc annotations to promise constructor.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc arguments for Promise::new_in_current_realm.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix out-of-order entries.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from Promise::new.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Suppress clippy warning.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-10-22 09:35:20 +00:00

59 lines
1.8 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::rc::Rc;
use dom_struct::dom_struct;
use crate::dom::bindings::codegen::Bindings::RTCRtpSenderBinding::{
RTCRtcpParameters, RTCRtpParameters, RTCRtpSendParameters, RTCRtpSenderMethods,
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
use crate::script_runtime::CanGc;
#[dom_struct]
pub struct RTCRtpSender {
reflector_: Reflector,
}
impl RTCRtpSender {
fn new_inherited() -> Self {
Self {
reflector_: Reflector::new(),
}
}
pub(crate) fn new(global: &GlobalScope) -> DomRoot<Self> {
reflect_dom_object(Box::new(Self::new_inherited()), global)
}
}
impl RTCRtpSenderMethods for RTCRtpSender {
// https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getparameters
fn GetParameters(&self) -> RTCRtpSendParameters {
RTCRtpSendParameters {
parent: RTCRtpParameters {
headerExtensions: vec![],
rtcp: RTCRtcpParameters {
cname: None,
reducedSize: None,
},
codecs: vec![],
},
transactionId: DOMString::new(),
encodings: vec![],
}
}
// https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-setparameters
fn SetParameters(&self, _parameters: &RTCRtpSendParameters, can_gc: CanGc) -> Rc<Promise> {
let promise = Promise::new(&self.global(), can_gc);
promise.resolve_native(&());
promise
}
}