Skip to main content

script/dom/webrtc/
rtcrtpsender.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
8
9use crate::dom::bindings::codegen::Bindings::RTCRtpSenderBinding::{
10    RTCRtcpParameters, RTCRtpParameters, RTCRtpSendParameters, RTCRtpSenderMethods,
11};
12use crate::dom::bindings::reflector::DomGlobal;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::bindings::str::DOMString;
15use crate::dom::globalscope::GlobalScope;
16use crate::dom::{Promise, RootedPromise};
17
18#[dom_struct]
19pub(crate) struct RTCRtpSender {
20    reflector_: Reflector,
21}
22
23impl RTCRtpSender {
24    fn new_inherited() -> Self {
25        Self {
26            reflector_: Reflector::new(),
27        }
28    }
29
30    pub(crate) fn new(cx: &mut JSContext, global: &GlobalScope) -> DomRoot<Self> {
31        reflect_dom_object_with_cx(Box::new(Self::new_inherited()), global, cx)
32    }
33}
34
35impl RTCRtpSenderMethods<crate::DomTypeHolder> for RTCRtpSender {
36    /// <https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getparameters>
37    fn GetParameters(&self) -> RTCRtpSendParameters {
38        RTCRtpSendParameters {
39            parent: RTCRtpParameters {
40                headerExtensions: vec![],
41                rtcp: RTCRtcpParameters {
42                    cname: None,
43                    reducedSize: None,
44                },
45                codecs: vec![],
46            },
47            transactionId: DOMString::new(),
48            encodings: vec![],
49        }
50    }
51
52    /// <https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-setparameters>
53    fn SetParameters(
54        &self,
55        cx: &mut JSContext,
56        _parameters: &RTCRtpSendParameters,
57    ) -> RootedPromise {
58        Promise::new_resolved_rooted(cx, &self.global(), ())
59    }
60}