Remove ffmpeg implementation
This commit is contained in:
parent
d61426957d
commit
f10350c7ec
11 changed files with 605 additions and 2304 deletions
|
|
@ -4,12 +4,7 @@ use cosmic::{
|
|||
cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry},
|
||||
theme,
|
||||
};
|
||||
use lexopt::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
use crate::app::hardware::DeviceType;
|
||||
|
||||
pub const CONFIG_VERSION: u64 = 1;
|
||||
|
||||
|
|
@ -34,68 +29,12 @@ impl AppTheme {
|
|||
#[serde(default)]
|
||||
pub struct Config {
|
||||
pub app_theme: AppTheme,
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
pub hw_decoder: DeviceType,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
app_theme: AppTheme::System,
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
hw_decoder: DeviceType::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
impl Config {
|
||||
pub fn with_args(&mut self, args: &mut Args) {
|
||||
if let Some(decoder) = args.decoder {
|
||||
self.hw_decoder = decoder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
pub struct Args {
|
||||
pub paths: Vec<PathBuf>,
|
||||
pub decoder: Option<DeviceType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
impl Args {
|
||||
pub fn parse_args() -> Result<Self, lexopt::Error> {
|
||||
let mut paths = Vec::new();
|
||||
let mut decoder = None;
|
||||
|
||||
let mut parser = lexopt::Parser::from_env();
|
||||
while let Some(arg) = parser.next()? {
|
||||
match arg {
|
||||
Long("list-hwdec") => {
|
||||
println!("Supported hardware decoders:");
|
||||
for hwdec in DeviceType::supported_devices() {
|
||||
println!("\t* [{}] {hwdec}", hwdec.short_name());
|
||||
}
|
||||
process::exit(0);
|
||||
}
|
||||
Long("hwdec") => {
|
||||
decoder = Some(parser.value()?.parse()?);
|
||||
}
|
||||
Value(path) => {
|
||||
let path = path.parse()?;
|
||||
paths.push(path);
|
||||
}
|
||||
_ => return Err(arg.unexpected()),
|
||||
}
|
||||
}
|
||||
|
||||
if paths.is_empty() {
|
||||
return Err(lexopt::Error::MissingValue {
|
||||
option: Some("missing video path".into()),
|
||||
});
|
||||
}
|
||||
|
||||
Ok(Self { paths, decoder })
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue