Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rogurotus committed Oct 20, 2023
1 parent 339fb57 commit c8a2be1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
15 changes: 3 additions & 12 deletions src/media/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,10 +997,7 @@ impl AudioTrackConstraints {
) -> bool {
let track = track.as_ref();
satisfies_track(track, MediaKind::Audio).await
&& ConstrainString::satisfies(
&self.device_id,
&Some(track.device_id()),
)
&& ConstrainString::satisfies(&self.device_id, &track.device_id())
// TODO returns Result<bool, Error>
}

Expand Down Expand Up @@ -1213,10 +1210,7 @@ impl DeviceVideoTrackConstraints {
) -> bool {
let track = track.as_ref();
satisfies_track(track, MediaKind::Video).await
&& ConstrainString::satisfies(
&self.device_id,
&Some(track.device_id()),
)
&& ConstrainString::satisfies(&self.device_id, &track.device_id())
&& ConstrainString::satisfies(
&self.facing_mode,
&track.facing_mode(),
Expand Down Expand Up @@ -1301,10 +1295,7 @@ impl DisplayVideoTrackConstraints {
) -> bool {
let track = track.as_ref();
satisfies_track(track, MediaKind::Video).await
&& ConstrainString::satisfies(
&self.device_id,
&Some(track.device_id()),
)
&& ConstrainString::satisfies(&self.device_id, &track.device_id())
&& ConstrainU32::satisfies(self.height, track.height())
&& ConstrainU32::satisfies(self.width, track.width())
&& track.guess_is_from_display()
Expand Down
4 changes: 2 additions & 2 deletions src/platform/dart/media_track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ impl MediaStreamTrack {
/// [1]: https://w3.org/TR/mediacapture-streams#dfn-deviceid
#[inline]
#[must_use]
pub fn device_id(&self) -> String {
pub fn device_id(&self) -> Option<String> {
let device_id =
unsafe { media_stream_track::device_id(self.inner.get()) };
unsafe { dart_string_into_rust(device_id) }
Some(unsafe { dart_string_into_rust(device_id) })
}

/// Returns [kind][1] of this [`MediaStreamTrack`].
Expand Down
3 changes: 1 addition & 2 deletions src/platform/wasm/media_track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ impl MediaStreamTrack {
/// [1]: https://tinyurl.com/w3-streams#dom-mediatracksettings-deviceid
/// [2]: https://w3.org/TR/mediacapture-streams#mediastreamtrack
#[must_use]
pub fn device_id(&self) -> String {
pub fn device_id(&self) -> Option<String> {
#[allow(clippy::unwrap_used)]
get_property_by_name(&self.sys_track.get_settings(), "deviceId", |v| {
v.as_string()
})
.unwrap()
}

/// Return a [`facingMode`][1] of the underlying [MediaStreamTrack][2].
Expand Down

0 comments on commit c8a2be1

Please sign in to comment.