#![allow(dead_code)]
use codec::decode::{self, Decoder};
use codec::encode::{self, Encoder, EncoderConfig};
use codec::frame::StreamInfo;
pub fn try_av1_encoder(config: EncoderConfig) -> Option<Box<dyn Encoder>> {
match encode::select_encoder(config, None) {
Ok(e) => Some(e),
Err(e) => {
eprintln!(
"SKIP: no AV1 encoder on this host/build ({e}); needs NVENC (Ada+) / AMF \
(RDNA3+) / QSV (Arc+) or the `ffmpeg` feature"
);
None
}
}
}
pub fn try_av1_decoder(info: StreamInfo) -> Option<Box<dyn Decoder>> {
match decode::create_decoder("av1", info) {
Ok(d) => Some(d),
Err(e) => {
eprintln!("SKIP: no AV1 decoder on this host/build ({e})");
None
}
}
}
pub fn test_media_dir() -> std::path::PathBuf {
if let Some(dir) = std::env::var_os("RIVET_TEST_MEDIA") {
return std::path::PathBuf::from(dir);
}
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.join("test_media")
}
pub fn read_test_media(name: &str) -> Option<Vec<u8>> {
std::fs::read(test_media_dir().join(name)).ok()
}