Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Make webcam resource work across multiple platforms
Browse files Browse the repository at this point in the history
Use conditional compilation to hardcode different webcam gstreamer pipelines
for each platform. I'm not certain if the linux pipeline works, but it's
a fine placeholder for now.

Closes #32
  • Loading branch information
jshrake committed Apr 1, 2019
1 parent ab4bc59 commit 0182a11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions examples/webcam/grim.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[webcam]
#windows
pipeline = "ksvideosrc ! videoconvert ! video/x-raw,format=BGRA ! appsink name=appsink async=false sync=false"
#macos
#pipeline = "autovideosrc ! video/x-raw,format=BGRA ! appsink name=appsink async=false sync=false"
webcam = true



Expand Down
5 changes: 5 additions & 0 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ impl Video {
}

pub fn new_webcam() -> Result<Self> {
#[cfg(target_os = "macos")]
let pipeline = "autovideosrc ! video/x-raw,format=RGB,format=RGBA,format=BGR,format=BGRA ! appsink name=appsink async=false sync=false";
#[cfg(target_os = "linux")]
let pipeline = "autovideosrc ! video/x-raw,format=RGB,format=RGBA,format=BGR,format=BGRA ! appsink name=appsink async=false sync=false";
#[cfg(target_os = "windows")]
let pipeline = "ksvideosrc ! video/x-raw,format=RGB,format=RGBA,format=BGR,format=BGRA ! appsink name=appsink async=false sync=false";
let pipeline = gst::parse_launch(&pipeline).map_err(|e| Error::gstreamer(e.to_string()))?;
let sink = pipeline
.clone()
Expand Down

0 comments on commit 0182a11

Please sign in to comment.