Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore: update examples and tests for SendableShareableContent API

Richie McIlroydddf629e56d1
diff --git a/apps/cli/src/record.rs b/apps/cli/src/record.rs
index 0fe468cfd..f6e90b08e 100644
--- a/apps/cli/src/record.rs
+++ b/apps/cli/src/record.rs
@@ -63,7 +63,9 @@ impl RecordStart {
.with_custom_cursor(false)
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await.unwrap(),
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await.unwrap(),
+ )),
)
.await
.map_err(|e| e.to_string())?;
diff --git a/crates/cap-test/src/suites/recording.rs b/crates/cap-test/src/suites/recording.rs
index 2e187b7c8..ecf5fe0c1 100644
--- a/crates/cap-test/src/suites/recording.rs
+++ b/crates/cap-test/src/suites/recording.rs
@@ -88,7 +88,8 @@ impl RecordingTestRunner {
#[cfg(target_os = "macos")]
let shareable_content = cidre::sc::ShareableContent::current()
.await
- .context("Failed to get shareable content - check screen recording permissions")?;
+ .context("Failed to get shareable content - check screen recording permissions")
+ .map(cap_recording::SendableShareableContent::from)?;
let (error_tx, _error_rx) = flume::bounded::<StreamError>(16);
@@ -162,7 +163,7 @@ impl RecordingTestRunner {
let handle = builder
.build(
#[cfg(target_os = "macos")]
- shareable_content,
+ Some(shareable_content),
)
.await
.context("Failed to start recording")?;
diff --git a/crates/recording/examples/memory-leak-detector.rs b/crates/recording/examples/memory-leak-detector.rs
index efb5c7004..043d926a1 100644
--- a/crates/recording/examples/memory-leak-detector.rs
+++ b/crates/recording/examples/memory-leak-detector.rs
@@ -251,7 +251,9 @@ async fn run_memory_test(
let handle = builder
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await?,
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await?,
+ )),
)
.await?;
diff --git a/crates/recording/examples/real-device-test-runner.rs b/crates/recording/examples/real-device-test-runner.rs
index a2e1dbb86..797aedaa8 100644
--- a/crates/recording/examples/real-device-test-runner.rs
+++ b/crates/recording/examples/real-device-test-runner.rs
@@ -1373,7 +1373,9 @@ async fn execute_recording(
};
#[cfg(target_os = "macos")]
- let shareable_content = cidre::sc::ShareableContent::current().await?;
+ let shareable_content = cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await?,
+ );
let mut builder = studio_recording::Actor::builder(
recording_dir.clone(),
@@ -1396,7 +1398,7 @@ async fn execute_recording(
let handle = builder
.build(
#[cfg(target_os = "macos")]
- shareable_content,
+ Some(shareable_content),
)
.await?;
diff --git a/crates/recording/examples/recording-benchmark.rs b/crates/recording/examples/recording-benchmark.rs
index 13eab946f..7061c3b2b 100644
--- a/crates/recording/examples/recording-benchmark.rs
+++ b/crates/recording/examples/recording-benchmark.rs
@@ -56,7 +56,9 @@ async fn run_recording_benchmark(
let handle = builder
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await?,
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await?,
+ )),
)
.await?;
@@ -117,7 +119,9 @@ async fn run_pause_resume_benchmark(duration_secs: u64) -> Result<(), Box<dyn st
)
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await?,
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await?,
+ )),
)
.await?;
@@ -175,7 +179,9 @@ async fn stress_test_recording(
)
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await?,
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await?,
+ )),
)
.await?;
start_times.push(start.elapsed());
diff --git a/crates/recording/examples/recording-cli.rs b/crates/recording/examples/recording-cli.rs
index fa122661c..0eaf71a7e 100644
--- a/crates/recording/examples/recording-cli.rs
+++ b/crates/recording/examples/recording-cli.rs
@@ -64,7 +64,9 @@ pub async fn main() {
// .with_mic_feed(Arc::new(mic_feed.ask(microphone::Lock).await.unwrap()))
.build(
#[cfg(target_os = "macos")]
- cidre::sc::ShareableContent::current().await.unwrap(),
+ Some(cap_recording::SendableShareableContent::from(
+ cidre::sc::ShareableContent::current().await.unwrap(),
+ )),
)
.await
.unwrap();
diff --git a/crates/scap-ffmpeg/examples/cli.rs b/crates/scap-ffmpeg/examples/cli.rs
index 053bccc13..883dee1a0 100644
--- a/crates/scap-ffmpeg/examples/cli.rs
+++ b/crates/scap-ffmpeg/examples/cli.rs
@@ -49,7 +49,6 @@ pub async fn main() {
use std::time::Duration;
use cidre::sc;
- use futures::executor::block_on;
use scap_screencapturekit::*;
use scap_targets::Display;
@@ -61,12 +60,9 @@ pub async fn main() {
.with_height(display.physical_size().unwrap().height() as usize)
.build();
+ let content = sc::ShareableContent::current().await.unwrap();
let capturer = Capturer::builder(
- display
- .raw_handle()
- .as_content_filter(sc::ShareableContent::current().await.unwrap())
- .await
- .unwrap(),
+ display.raw_handle().as_content_filter(content).unwrap(),
config,
)
.with_output_sample_buf_cb(|frame| {
diff --git a/crates/scap-screencapturekit/examples/cli.rs b/crates/scap-screencapturekit/examples/cli.rs
index fb5b98ae0..9be41ceb7 100644
--- a/crates/scap-screencapturekit/examples/cli.rs
+++ b/crates/scap-screencapturekit/examples/cli.rs
@@ -9,7 +9,6 @@ mod macos {
use scap_targets::Display;
use std::time::Duration;
- use futures::executor::block_on;
use scap_screencapturekit::{Capturer, StreamCfgBuilder};
#[tokio::main]
@@ -29,8 +28,10 @@ mod macos {
.with_height(display.physical_size().unwrap().height() as usize)
.build();
+ let content = sc::ShareableContent::current().await.unwrap();
let capturer = Capturer::builder(
- block_on(display.as_content_filter(sc::ShareableContent::current().await.unwrap()))
+ display
+ .as_content_filter(content)
.expect("Failed to get display as content filter"),
config,
)