Skip to content

Commit

Permalink
cameras not supported on Windows yet
Browse files Browse the repository at this point in the history
  • Loading branch information
slivingston committed Jan 7, 2025
1 parent e34a95a commit c05a196
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
- name: Install OpenSSL manually if on Windows
if: runner.os == 'Windows'
run: |
choco install openssl
- name: Prepare to build
run: |
mkdir keys
touch keys/public.pem
- name: Lint
if: runner.os != 'Windows'
run: |
cargo fmt --check
cargo check
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tokio = { version = "1.40", features = ["net", "rt", "signal", "sync"] }
[target.'cfg(target_os="linux")'.dependencies]
v4l = { version = "0.14", features = ["v4l2"] }

[target.'cfg(any(target_os="macos", target_os = "windows"))'.dependencies]
[target.'cfg(target_os="macos")'.dependencies]
openpnp_capture = "0.2.4"

[dependencies.clap]
Expand Down
21 changes: 19 additions & 2 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ enum CaptureCommand {
Quit, // Return from (close) the thread
}

#[cfg(any(target_os = "macos", target_os = "windows"))]
#[cfg(target_os = "macos")]
fn verify_capture_ability(
camera_path: &str,
dimensions: Option<CameraDimensions>,
Expand Down Expand Up @@ -155,7 +155,7 @@ fn verify_capture_ability(
Ok(())
}

#[cfg(any(target_os = "macos", target_os = "windows"))]
#[cfg(target_os = "macos")]
fn video_capture(
camera_path: &str,
dimensions: Option<CameraDimensions>,
Expand Down Expand Up @@ -263,6 +263,23 @@ fn video_capture(
}
}

#[cfg(target_os = "windows")]
fn verify_capture_ability(
camera_path: &str,
dimensions: Option<CameraDimensions>,
) -> Result<(), Box<dyn std::error::Error>> {
return Err(CheckError::new("cameras not supported on Windows"));
}

#[cfg(target_os = "windows")]
fn video_capture(
camera_path: &str,
dimensions: Option<CameraDimensions>,
wsclient_addr: Addr<WSClient>,
cap_command: mpsc::Receiver<CaptureCommand>,
) {
}

#[cfg(target_os = "linux")]
fn verify_capture_ability(
camera_path: &str,
Expand Down
5 changes: 3 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ fn dissolve_subcommand(matches: &clap::ArgMatches) -> Result<(), CliError> {
}

fn attach_camera_subcommand(matches: &clap::ArgMatches) -> Result<(), CliError> {
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
return CliError::new("only Linux, Mac, and Windows supported", 1);
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
return CliError::new("only Linux and Mac supported", 1);

if matches.values_of("id_prefix").is_some()
&& matches.values_of("attach_camera_crop_config").is_some()
Expand Down Expand Up @@ -1158,6 +1158,7 @@ fn monitor_subcommand(matches: &clap::ArgMatches) -> Result<(), CliError> {

pub fn main() -> Result<(), CliError> {
let app = clap::App::new("hardshare")
.bin_name("hardshare")
.max_term_width(80)
.about("Command-line interface for the hardshare client")
.subcommand(SubCommand::with_name("version")
Expand Down

0 comments on commit c05a196

Please sign in to comment.