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 Connection media state management (#41) #43

Merged
merged 25 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ All user visible changes to this project will be documented in this file. This p
- `MediaStateTransitionException`;
- `MediaSettingsUpdateException`.
- `MediaManagerHandle.set_output_audio_id()` function switching output audio device on Dart platform ([#29]);
- `MediaManagerHandle.on_device_change()` callback firing whenever `MediaManagerHandle.enumerate_devices()` list changes ([#30]).
- `MediaManagerHandle.on_device_change()` callback firing whenever `MediaManagerHandle.enumerate_devices()` list changes ([#30]);
- `ConnectionHandle` methods ([#43]):
- `enable_remote_video`;
- `disable_remote_video`;
- `enable_remote_audio`;
- `disable_remote_audio`.

### Updated

Expand All @@ -70,6 +75,7 @@ All user visible changes to this project will be documented in this file. This p
[#16]: /../../pull/16
[#29]: /../../pull/29
[#30]: /../../pull/30
[#43]: /../../pull/43



Expand Down
90 changes: 45 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tracerr = "0.3"
url = "2.1"

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.10"
android_logger = "0.11"

[target.'cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))'.dependencies]
simple_logger = "2.1"
Expand Down
60 changes: 59 additions & 1 deletion e2e/src/object/connection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! `Connection` JS object's representation.

use std::borrow::Cow;

use crate::{
browser::Statement,
object::{tracks_store, Object},
object::{tracks_store, MediaKind, Object},
};

use super::Error;
Expand All @@ -28,6 +30,62 @@ impl Object<Connection> {
.await
}

/// Enables remote media receiving for the provided [`MediaKind`].
///
/// # Errors
///
/// If failed to execute JS statement.
pub async fn enable_remote_media(
&self,
kind: MediaKind,
) -> Result<(), Error> {
let enable: Cow<'_, _> = match kind {
MediaKind::Audio => "c.conn.enable_remote_audio()".into(),
MediaKind::Video => "c.conn.enable_remote_video()".into(),
};
self.execute(Statement::new(
// language=JavaScript
&format!(
r#"
async (c) => {{
await {enable};
}}
"#,
),
[],
))
.await
.map(drop)
}

/// Disables remote media receiving for the provided [`MediaKind`].
///
/// # Errors
///
/// If failed to execute JS statement.
pub async fn disable_remote_media(
&self,
kind: MediaKind,
) -> Result<(), Error> {
let disable: Cow<'_, _> = match kind {
MediaKind::Audio => "c.conn.disable_remote_audio()".into(),
MediaKind::Video => "c.conn.disable_remote_video()".into(),
};
self.execute(Statement::new(
// language=JavaScript
&format!(
r#"
async (c) => {{
await {disable};
}}
"#,
),
[],
))
.await
.map(drop)
}

/// Returns a [`Future`] resolving when `Connection.on_close()` callback is
/// fired.
///
Expand Down
Loading