Skip to content

Commit

Permalink
Implement RTCRtpSender.getCapabilities method (#3737)
Browse files Browse the repository at this point in the history
  • Loading branch information
logist322 authored Dec 8, 2023
1 parent cfe3dc2 commit a5d2539
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

### Added

* Add bindings for `RTCRtpSender.getCapabilities(DOMString)` method, `RTCRtpCapabilities`, `RTCRtpCodecCapability` and `RTCRtpHeaderExtensionCapability`.
[#3737](https://github.com/rustwasm/wasm-bindgen/pull/3737)

* Add bindings for `UserActivation`.
[#3719](https://github.com/rustwasm/wasm-bindgen/pull/3719)

Expand Down
3 changes: 3 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,12 @@ RtcPeerConnectionIceEventInit = []
RtcPeerConnectionState = []
RtcPriorityType = []
RtcRtcpParameters = []
RtcRtpCapabilities = []
RtcRtpCodecCapability = []
RtcRtpCodecParameters = []
RtcRtpContributingSource = []
RtcRtpEncodingParameters = []
RtcRtpHeaderExtensionCapability = []
RtcRtpHeaderExtensionParameters = []
RtcRtpParameters = []
RtcRtpReceiver = []
Expand Down
59 changes: 59 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpCapabilities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = RTCRtpCapabilities)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `RtcRtpCapabilities` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCapabilities`*"]
pub type RtcRtpCapabilities;
}
impl RtcRtpCapabilities {
#[doc = "Construct a new `RtcRtpCapabilities`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCapabilities`*"]
pub fn new(
codecs: &::wasm_bindgen::JsValue,
header_extensions: &::wasm_bindgen::JsValue,
) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.codecs(codecs);
ret.header_extensions(header_extensions);
ret
}
#[doc = "Change the `codecs` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCapabilities`*"]
pub fn codecs(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("codecs"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `headerExtensions` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCapabilities`*"]
pub fn header_extensions(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("headerExtensions"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
93 changes: 93 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpCodecCapability.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = RTCRtpCodecCapability)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `RtcRtpCodecCapability` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub type RtcRtpCodecCapability;
}
impl RtcRtpCodecCapability {
#[doc = "Construct a new `RtcRtpCodecCapability`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub fn new(clock_rate: u32, mime_type: &str) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.clock_rate(clock_rate);
ret.mime_type(mime_type);
ret
}
#[doc = "Change the `channels` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub fn channels(&mut self, val: u16) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("channels"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `clockRate` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub fn clock_rate(&mut self, val: u32) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("clockRate"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `mimeType` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub fn mime_type(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("mimeType"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `sdpFmtpLine` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecCapability`*"]
pub fn sdp_fmtp_line(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("sdpFmtpLine"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
37 changes: 37 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpHeaderExtensionCapability.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = RTCRtpHeaderExtensionCapability)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `RtcRtpHeaderExtensionCapability` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpHeaderExtensionCapability`*"]
pub type RtcRtpHeaderExtensionCapability;
}
impl RtcRtpHeaderExtensionCapability {
#[doc = "Construct a new `RtcRtpHeaderExtensionCapability`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpHeaderExtensionCapability`*"]
pub fn new(uri: &str) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.uri(uri);
ret
}
#[doc = "Change the `uri` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpHeaderExtensionCapability`*"]
pub fn uri(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("uri"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
8 changes: 8 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpSender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpSender`, `RtcdtmfSender`*"]
pub fn dtmf(this: &RtcRtpSender) -> Option<RtcdtmfSender>;
#[cfg(feature = "RtcRtpCapabilities")]
# [wasm_bindgen (static_method_of = RtcRtpSender , js_class = "RTCRtpSender" , js_name = getCapabilities)]
#[doc = "The `getCapabilities()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpSender/getCapabilities)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCapabilities`, `RtcRtpSender`*"]
pub fn get_capabilities(kind: &str) -> Option<RtcRtpCapabilities>;
#[cfg(feature = "RtcRtpParameters")]
# [wasm_bindgen (method , structural , js_class = "RTCRtpSender" , js_name = getParameters)]
#[doc = "The `getParameters()` method."]
Expand Down
18 changes: 18 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6394,6 +6394,18 @@ mod gen_RtcRtcpParameters;
#[cfg(feature = "RtcRtcpParameters")]
pub use gen_RtcRtcpParameters::*;

#[cfg(feature = "RtcRtpCapabilities")]
#[allow(non_snake_case)]
mod gen_RtcRtpCapabilities;
#[cfg(feature = "RtcRtpCapabilities")]
pub use gen_RtcRtpCapabilities::*;

#[cfg(feature = "RtcRtpCodecCapability")]
#[allow(non_snake_case)]
mod gen_RtcRtpCodecCapability;
#[cfg(feature = "RtcRtpCodecCapability")]
pub use gen_RtcRtpCodecCapability::*;

#[cfg(feature = "RtcRtpCodecParameters")]
#[allow(non_snake_case)]
mod gen_RtcRtpCodecParameters;
Expand All @@ -6412,6 +6424,12 @@ mod gen_RtcRtpEncodingParameters;
#[cfg(feature = "RtcRtpEncodingParameters")]
pub use gen_RtcRtpEncodingParameters::*;

#[cfg(feature = "RtcRtpHeaderExtensionCapability")]
#[allow(non_snake_case)]
mod gen_RtcRtpHeaderExtensionCapability;
#[cfg(feature = "RtcRtpHeaderExtensionCapability")]
pub use gen_RtcRtpHeaderExtensionCapability::*;

#[cfg(feature = "RtcRtpHeaderExtensionParameters")]
#[allow(non_snake_case)]
mod gen_RtcRtpHeaderExtensionParameters;
Expand Down
17 changes: 17 additions & 0 deletions crates/web-sys/webidls/enabled/RTCRtpSender.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ dictionary RTCRtpParameters {
sequence<RTCRtpCodecParameters> codecs;
};

dictionary RTCRtpCodecCapability {
required DOMString mimeType;
required unsigned long clockRate;
unsigned short channels;
DOMString sdpFmtpLine;
};

dictionary RTCRtpHeaderExtensionCapability {
required DOMString uri;
};

dictionary RTCRtpCapabilities {
required sequence<RTCRtpCodecCapability> codecs;
required sequence<RTCRtpHeaderExtensionCapability> headerExtensions;
};

[Pref="media.peerconnection.enabled",
JSImplementation="@mozilla.org/dom/rtpsender;1"]
interface RTCRtpSender {
Expand All @@ -74,6 +90,7 @@ interface RTCRtpSender {
RTCRtpParameters getParameters();
Promise<undefined> replaceTrack(MediaStreamTrack? withTrack);
Promise<RTCStatsReport> getStats();
static RTCRtpCapabilities? getCapabilities(DOMString kind);
[Pref="media.peerconnection.dtmf.enabled"]
readonly attribute RTCDTMFSender? dtmf;
// Ugh, can't use a ChromeOnly attribute sequence<MediaStream>...
Expand Down

0 comments on commit a5d2539

Please sign in to comment.