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

Add RTCRtpTransceiver.setCodecPreferences() #3828

Merged
merged 10 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

### Added

* Added bindings for the `RTCRtpTransceiver.setCodecPreferences()` and unstable bindings for the `RTCRtpEncodingParameters.scalabilityMode`.
[#3828](https://github.com/rustwasm/wasm-bindgen/pull/3828)

* Add unstable bindings for the FileSystemAccess API
[#3810](https://github.com/rustwasm/wasm-bindgen/pull/3810)

* Added support for running tests in shared and service workers with ``wasm_bindgen_test_configure!` `run_in_shared_worker` and `run_in_service_worker`.
* Added support for running tests in shared and service workers with `wasm_bindgen_test_configure!` `run_in_shared_worker` and `run_in_service_worker`.
[#3804](https://github.com/rustwasm/wasm-bindgen/pull/3804)

* Accept the `--skip` flag with `wasm-bindgen-test-runner`.
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 @@ -1108,6 +1108,7 @@ RtcPeerConnectionState = []
RtcPriorityType = []
RtcRtcpParameters = []
RtcRtpCapabilities = []
RtcRtpCodec = []
RtcRtpCodecCapability = []
RtcRtpCodecParameters = []
RtcRtpContributingSource = []
Expand Down
93 changes: 93 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpCodec.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 = RTCRtpCodec)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `RtcRtpCodec` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodec`*"]
pub type RtcRtpCodec;
}
impl RtcRtpCodec {
#[doc = "Construct a new `RtcRtpCodec`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodec`*"]
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: `RtcRtpCodec`*"]
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: `RtcRtpCodec`*"]
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: `RtcRtpCodec`*"]
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: `RtcRtpCodec`*"]
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
}
}
22 changes: 10 additions & 12 deletions crates/web-sys/src/features/gen_RtcRtpCodecParameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ impl RtcRtpCodecParameters {
#[doc = "Construct a new `RtcRtpCodecParameters`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecParameters`*"]
pub fn new() -> Self {
pub fn new(clock_rate: u32, mime_type: &str, payload_type: u8) -> Self {
logist322 marked this conversation as resolved.
Show resolved Hide resolved
#[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.payload_type(payload_type);
ret
}
#[doc = "Change the `channels` field of this object."]
Expand Down Expand Up @@ -71,14 +74,14 @@ impl RtcRtpCodecParameters {
let _ = r;
self
}
#[doc = "Change the `payloadType` field of this object."]
#[doc = "Change the `sdpFmtpLine` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecParameters`*"]
pub fn payload_type(&mut self, val: u16) -> &mut Self {
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("payloadType"),
&JsValue::from("sdpFmtpLine"),
&JsValue::from(val),
);
debug_assert!(
Expand All @@ -88,14 +91,14 @@ impl RtcRtpCodecParameters {
let _ = r;
self
}
#[doc = "Change the `sdpFmtpLine` field of this object."]
#[doc = "Change the `payloadType` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpCodecParameters`*"]
pub fn sdp_fmtp_line(&mut self, val: &str) -> &mut Self {
pub fn payload_type(&mut self, val: u8) -> &mut Self {
logist322 marked this conversation as resolved.
Show resolved Hide resolved
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("sdpFmtpLine"),
&JsValue::from("payloadType"),
&JsValue::from(val),
);
debug_assert!(
Expand All @@ -106,8 +109,3 @@ impl RtcRtpCodecParameters {
self
}
}
impl Default for RtcRtpCodecParameters {
fn default() -> Self {
Self::new()
}
}
21 changes: 21 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ impl RtcRtpEncodingParameters {
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `scalabilityMode` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpEncodingParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
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
7 changes: 7 additions & 0 deletions crates/web-sys/src/features/gen_RtcRtpTransceiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpTransceiver`*"]
pub fn get_remote_track_id(this: &RtcRtpTransceiver) -> String;
# [wasm_bindgen (method , structural , js_class = "RTCRtpTransceiver" , js_name = setCodecPreferences)]
#[doc = "The `setCodecPreferences()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/setCodecPreferences)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpTransceiver`*"]
pub fn set_codec_preferences(this: &RtcRtpTransceiver, codecs: &::wasm_bindgen::JsValue);
# [wasm_bindgen (method , structural , js_class = "RTCRtpTransceiver" , js_name = stop)]
#[doc = "The `stop()` method."]
#[doc = ""]
Expand Down
7 changes: 7 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7537,6 +7537,13 @@ mod gen_RtcRtpCapabilities;
#[allow(unused_imports)]
pub use gen_RtcRtpCapabilities::*;

#[cfg(feature = "RtcRtpCodec")]
#[allow(non_snake_case)]
mod gen_RtcRtpCodec;
#[cfg(feature = "RtcRtpCodec")]
#[allow(unused_imports)]
pub use gen_RtcRtpCodec::*;

#[cfg(feature = "RtcRtpCodecCapability")]
#[allow(non_snake_case)]
mod gen_RtcRtpCodecCapability;
Expand Down
25 changes: 12 additions & 13 deletions crates/web-sys/webidls/enabled/RTCRtpSender.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ dictionary RTCRtcpParameters {
boolean reducedSize;
};

dictionary RTCRtpCodecParameters {
unsigned short payloadType;
DOMString mimeType;
unsigned long clockRate;
unsigned short channels = 1;
DOMString sdpFmtpLine;
dictionary RTCRtpCodec {
required DOMString mimeType;
required unsigned long clockRate;
unsigned short channels;
DOMString sdpFmtpLine;
};

dictionary RTCRtpCodecParameters : RTCRtpCodec {
required octet payloadType;
};

dictionary RTCRtpCodecCapability : RTCRtpCodec {
};

dictionary RTCRtpParameters {
Expand All @@ -66,13 +72,6 @@ dictionary RTCRtpParameters {
sequence<RTCRtpCodecParameters> codecs;
};

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

dictionary RTCRtpHeaderExtensionCapability {
required DOMString uri;
};
Expand Down
3 changes: 1 addition & 2 deletions crates/web-sys/webidls/enabled/RTCRtpTransceiver.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ interface RTCRtpTransceiver {
readonly attribute RTCRtpTransceiverDirection? currentDirection;

undefined stop();
// TODO: bug 1396922
// undefined setCodecPreferences(sequence<RTCRtpCodecCapability> codecs);
undefined setCodecPreferences(sequence<RTCRtpCodecCapability> codecs);

[ChromeOnly]
undefined setRemoteTrackId(DOMString trackId);
Expand Down
3 changes: 3 additions & 0 deletions crates/web-sys/webidls/unstable/RTCRtpSender.webidl
logist322 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
partial dictionary RTCRtpEncodingParameters {
DOMString scalabilityMode;
};
Loading