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 DisplayMediaStreamConstraints and getDisplayMedia #2423

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ DeviceRotationRateInit = []
DhKeyDeriveParams = []
DirectionSetting = []
Directory = []
DisplayMediaStreamConstraints = []
DisplayNameOptions = []
DisplayNameResult = []
DistanceModelType = []
Expand Down
48 changes: 48 additions & 0 deletions crates/web-sys/src/features/gen_DisplayMediaStreamConstraints.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = DisplayMediaStreamConstraints)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `DisplayMediaStreamConstraints` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DisplayMediaStreamConstraints`*"]
pub type DisplayMediaStreamConstraints;
}
impl DisplayMediaStreamConstraints {
#[doc = "Construct a new `DisplayMediaStreamConstraints`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DisplayMediaStreamConstraints`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `audio` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DisplayMediaStreamConstraints`*"]
pub fn audio(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("audio"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `video` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DisplayMediaStreamConstraints`*"]
pub fn video(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("video"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
18 changes: 18 additions & 0 deletions crates/web-sys/src/features/gen_MediaDevices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `MediaDevices`*"]
pub fn enumerate_devices(this: &MediaDevices) -> Result<::js_sys::Promise, JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "MediaDevices" , js_name = getDisplayMedia)]
#[doc = "The `getDisplayMedia()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `MediaDevices`*"]
pub fn get_display_media(this: &MediaDevices) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "DisplayMediaStreamConstraints")]
# [wasm_bindgen (catch , method , structural , js_class = "MediaDevices" , js_name = getDisplayMedia)]
#[doc = "The `getDisplayMedia()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DisplayMediaStreamConstraints`, `MediaDevices`*"]
pub fn get_display_media_with_constraints(
this: &MediaDevices,
constraints: &DisplayMediaStreamConstraints,
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "MediaTrackSupportedConstraints")]
# [wasm_bindgen (method , structural , js_class = "MediaDevices" , js_name = getSupportedConstraints)]
#[doc = "The `getSupportedConstraints()` 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 @@ -1432,6 +1432,12 @@ mod gen_Directory;
#[cfg(feature = "Directory")]
pub use gen_Directory::*;

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

#[cfg(feature = "DisplayNameOptions")]
#[allow(non_snake_case)]
mod gen_DisplayNameOptions;
Expand Down
3 changes: 3 additions & 0 deletions crates/web-sys/webidls/enabled/MediaDevices.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ interface MediaDevices : EventTarget {

[Throws, NeedsCallerType]
Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);

[SecureContext, Pref="media.getdisplaymedia.enabled", Throws, NeedsCallerType]
Promise<MediaStream> getDisplayMedia(optional DisplayMediaStreamConstraints constraints);
};
5 changes: 5 additions & 0 deletions crates/web-sys/webidls/enabled/MediaStream.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ dictionary MediaStreamConstraints {
DOMString? peerIdentity = null;
};

dictionary DisplayMediaStreamConstraints {
(boolean or MediaTrackConstraints) video = true;
(boolean or MediaTrackConstraints) audio = false;
};

[Exposed=Window,
Constructor,
Constructor (MediaStream stream),
Expand Down