From 6e81584eca50c33176be83e9d9617b42823b63ee Mon Sep 17 00:00:00 2001 From: rabite Date: Wed, 22 May 2019 20:37:13 +0200 Subject: [PATCH] fix build and correct feature explanation in README --- README.md | 8 ++++---- src/preview-gen.rs | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5c4458c..48893f1 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ If it works on a system not mentioned here, please open an issue. Also feel free Compiling hunter currently requires a nightly Rust compiler! The easiest way to get a nightly compiler is with [rustup](https://rustup.rs/). If you have rustup installed it will automatically download and use a version that is known to work when you run cargo. -By default it will install a full-featured version with support for media-previews. You can control this using the feature flags ```img```, and ```video```. These can be disabled by calling cargo with ```--features ""```, if you want to disable all media previews, or ```--features=img"``` if you only want to disable video/audio previews. +By default it will install a full-featured version with support for media-previews. You can control this using the feature flags ```img```, and ```video```. These can be disabled by calling cargo with ```--no-default-features```. You can then enable image previews with ```--features=img``` and add video/audio with ```--feature=img,video```. Note that video requires img! Note that this only works if hunter can find the "preview-gen" tool somewhere in $PATH! @@ -71,7 +71,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ### Build with cargo ``` -cargo install (--features=...) hunter +cargo install (--no-default-features --features=...) hunter ``` @@ -85,10 +85,10 @@ git clone https://github.com/rabite0/hunter.git cd {source_dir}/hunter/ // (Optional) Build -// cargo build --release (--features=...) +// cargo build --release (--no-default-features --features=...) // Install -cargo install (--features=...) --path . +cargo install (--no-default-features --features=...) --path . ``` ## NOTE: diff --git a/src/preview-gen.rs b/src/preview-gen.rs index 6abbf80..c8d4936 100644 --- a/src/preview-gen.rs +++ b/src/preview-gen.rs @@ -3,8 +3,9 @@ use image::{Pixel, FilterType, DynamicImage, GenericImageView}; -use termion::{color::{Bg, Fg, Rgb}, - input::TermRead, +use termion::color::{Bg, Fg, Rgb}; +#[cfg(feature = "video")] +use termion::{input::TermRead, event::Key}; #[cfg(feature = "video")] @@ -12,7 +13,9 @@ use gstreamer::{self, prelude::*}; #[cfg(feature = "video")] use gstreamer_app; -use failure::{Error, format_err}; +use failure::Error; +#[cfg(feature = "video")] +use failure::format_err; use rayon::prelude::*; @@ -30,14 +33,17 @@ fn main() -> MResult<()> { .expect("provide ysize") .parse() .unwrap(); + #[cfg(feature = "video")] let preview_type = args.get(3) .expect("Provide preview type") .parse::() .unwrap(); + #[cfg(feature = "video")] let autoplay = args.get(4) .expect("Autoplay?") .parse::() .unwrap(); + #[cfg(feature = "video")] let mute = args.get(5) .expect("Muted?") .parse::() @@ -80,6 +86,7 @@ fn image_preview(path: &str, Ok(()) } +#[cfg(feature = "video")] fn video_preview(path: &String, xsize: usize, ysize: usize, @@ -159,6 +166,7 @@ fn video_preview(path: &String, Ok(()) } +#[cfg(feature = "video")] pub fn read_keys(player: gstreamer::Element) -> MResult<()> { let seek_time = gstreamer::ClockTime::from_seconds(5); for key in std::io::stdin().keys() { @@ -216,6 +224,7 @@ pub fn read_keys(player: gstreamer::Element) -> MResult<()> { Ok(()) } +#[cfg(feature = "video")] pub fn audio_preview(path: &String, autoplay: bool, mute: bool) @@ -271,6 +280,7 @@ pub fn audio_preview(path: &String, Ok(()) } +#[cfg(feature = "video")] pub fn make_gstreamer() -> MResult<(gstreamer::Element, gstreamer_app::AppSink)> { gstreamer::init()?; @@ -330,7 +340,7 @@ impl Renderer { Ok(()) } - + #[cfg(feature = "video")] fn send_frame(&self, frame: &gstreamer::sample::SampleRef, position: u64,