Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RTCRtpSender.getCapabilities method #3737

Merged
merged 6 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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` dictionary, `RTCRtpEncodingParameters.codec` and `RTCRtpEncodingParameters.scalabilityMode` fields.
[#3737](https://github.com/rustwasm/wasm-bindgen/pull/3737)

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

Expand Down
1 change: 1 addition & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ RtcPeerConnectionIceEventInit = []
RtcPeerConnectionState = []
RtcPriorityType = []
RtcRtcpParameters = []
RtcRtpCapabilities = []
RtcRtpCodecParameters = []
RtcRtpContributingSource = []
RtcRtpEncodingParameters = []
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() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
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
}
}
impl Default for RtcRtpCapabilities {
fn default() -> Self {
Self::new()
}
}
31 changes: 31 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ impl RtcRtpEncodingParameters {
let _ = r;
self
}
#[cfg(feature = "RtcRtpCodecParameters")]
#[doc = "Change the `codec` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecParameters`, `RtcRtpEncodingParameters`*"]
pub fn codec(&mut self, val: &RtcRtpCodecParameters) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("codec"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(feature = "RtcDegradationPreference")]
#[doc = "Change the `degradationPreference` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -128,6 +142,23 @@ impl RtcRtpEncodingParameters {
let _ = r;
self
}
#[doc = "Change the `scalabilityMode` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpEncodingParameters`*"]
pub fn scalability_mode(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("scalabilityMode"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `scaleResolutionDownBy` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpEncodingParameters`*"]
Expand Down
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) -> RtcRtpCapabilities;
#[cfg(feature = "RtcRtpParameters")]
# [wasm_bindgen (method , structural , js_class = "RTCRtpSender" , js_name = getParameters)]
#[doc = "The `getParameters()` method."]
Expand Down
6 changes: 6 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,12 @@ 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 = "RtcRtpCodecParameters")]
#[allow(non_snake_case)]
mod gen_RtcRtpCodecParameters;
Expand Down
8 changes: 8 additions & 0 deletions crates/web-sys/webidls/enabled/RTCRtpSender.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dictionary RTCRtpEncodingParameters {
RTCDegradationPreference degradationPreference = "balanced";
DOMString rid;
float scaleResolutionDownBy = 1.0;
DOMString scalabilityMode;
RTCRtpCodecParameters codec;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DOMString scalabilityMode;
RTCRtpCodecParameters codec;

This whole type seems to be wrong, but where did you get these added fields from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these bindings seems fine to me, but they would have to be added as unstable as far as I can see.

};

dictionary RTCRtpHeaderExtensionParameters {
Expand Down Expand Up @@ -66,6 +68,11 @@ dictionary RTCRtpParameters {
sequence<RTCRtpCodecParameters> codecs;
};

dictionary RTCRtpCapabilities {
sequence<RTCRtpCodecParameters> codecs;
sequence<RTCRtpHeaderExtensionParameters> headerExtensions;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where exactly did you get this from?

Suggested change
dictionary RTCRtpCapabilities {
sequence<RTCRtpCodecParameters> codecs;
sequence<RTCRtpHeaderExtensionParameters> headerExtensions;
};
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 +81,7 @@ interface RTCRtpSender {
RTCRtpParameters getParameters();
Promise<undefined> replaceTrack(MediaStreamTrack? withTrack);
Promise<RTCStatsReport> getStats();
static RTCRtpCapabilities getCapabilities(DOMString kind);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static RTCRtpCapabilities getCapabilities(DOMString kind);
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