-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webcam): begin implementation of webcam audio recorder
- Loading branch information
Showing
16 changed files
with
426 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/cassette-standalone | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
name = "cassette-plugin-webcam-audio" | ||
|
||
authors = { workspace = true } | ||
description = { workspace = true } | ||
documentation = "https://docs.rs/cassette-plugin-webcam-audio" | ||
edition = { workspace = true } | ||
include = { workspace = true } | ||
keywords = { workspace = true } | ||
license = { workspace = true } | ||
readme = { workspace = true } | ||
rust-version = { workspace = true } | ||
homepage = { workspace = true } | ||
repository = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[lints] | ||
workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
cassette-core = { path = "../cassette-core", features = ["ui"] } | ||
cassette-plugin-webcam-core = { path = "../cassette-plugin-webcam-core", features = [ | ||
"ui", | ||
] } | ||
|
||
serde = { workspace = true, features = ["derive"] } | ||
yew = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use cassette_core::{ | ||
cassette::{CassetteContext, GenericCassetteTaskHandle}, | ||
components::ComponentRenderer, | ||
prelude::*, | ||
task::{TaskResult, TaskState}, | ||
}; | ||
use cassette_plugin_webcam_core::{hooks::use_webcam, Constraints, Handler}; | ||
use serde::{Deserialize, Serialize}; | ||
use yew::prelude::*; | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Properties)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Spec { | ||
#[serde(flatten)] | ||
handler: Handler, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct State {} | ||
|
||
impl ComponentRenderer<Spec> for State { | ||
fn render(self, ctx: &mut CassetteContext, spec: Spec) -> TaskResult<Option<Self>> { | ||
let Spec { handler } = spec; | ||
|
||
let constraints = Constraints { | ||
audio: true, | ||
video: false, | ||
}; | ||
let webcam = match use_webcam(ctx, &handler, &constraints).get() { | ||
Ok(webcam) => webcam, | ||
Err(msg) => { | ||
return Ok(TaskState::Break { | ||
body: html! { <Error msg={ msg.clone() } /> }, | ||
state: None, | ||
}) | ||
} | ||
}; | ||
|
||
Ok(TaskState::Skip { | ||
state: Some(Self {}), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[package] | ||
name = "cassette-plugin-webcam-core" | ||
|
||
authors = { workspace = true } | ||
description = { workspace = true } | ||
documentation = "https://docs.rs/cassette-plugin-webcam-core" | ||
edition = { workspace = true } | ||
include = { workspace = true } | ||
keywords = { workspace = true } | ||
license = { workspace = true } | ||
readme = { workspace = true } | ||
rust-version = { workspace = true } | ||
homepage = { workspace = true } | ||
repository = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[lints] | ||
workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
default = [] | ||
ui = [ | ||
"cassette-core/ui", | ||
"dep:anyhow", | ||
"dep:js-sys", | ||
"dep:wasm-bindgen", | ||
"dep:web-sys", | ||
"dep:yew", | ||
] | ||
|
||
[dependencies] | ||
cassette-core = { path = "../cassette-core" } | ||
|
||
anyhow = { workspace = true, optional = true } | ||
js-sys = { workspace = true, optional = true } | ||
serde = { workspace = true } | ||
wasm-bindgen = { workspace = true, optional = true } | ||
web-sys = { workspace = true, optional = true, features = [ | ||
"MediaStream", | ||
"MediaRecorder", | ||
"MediaDevices", | ||
"MediaStreamConstraints", | ||
"MediaTrackConstraints", | ||
"HtmlElement", | ||
"Window", | ||
"console", | ||
"Url", | ||
"Blob", | ||
"BlobEvent", | ||
"EventTarget", | ||
"HtmlAnchorElement", | ||
"Document", | ||
"Navigator", | ||
] } | ||
yew = { workspace = true, optional = true } |
Oops, something went wrong.