mod fixtures;
use fixtures::*;
use ff_decode::{DecodeError, VideoDecoder};
use ff_format::NetworkOptions;
#[test]
fn file_video_decoder_should_not_be_live_srt() {
let decoder = VideoDecoder::open(test_video_path())
.build()
.expect("Failed to open test video");
assert!(
!decoder.is_live(),
"File-backed VideoDecoder must report is_live=false (SRT regression guard)"
);
}
#[cfg(not(feature = "srt"))]
#[test]
fn srt_url_without_feature_should_return_connection_failed() {
let result = VideoDecoder::open("srt://127.0.0.1:4200")
.network(NetworkOptions::default())
.build();
match result {
Err(DecodeError::ConnectionFailed { message, .. }) => {
assert!(
message.contains("srt"),
"ConnectionFailed message must mention the srt feature; got: {message}"
);
}
Err(other) => panic!("Expected ConnectionFailed for srt:// without feature, got: {other}"),
Ok(_) => panic!("Expected an error for unreachable SRT endpoint without feature"),
}
}
#[cfg(feature = "srt")]
#[test]
fn srt_url_open_should_not_return_file_not_found() {
let result = VideoDecoder::open("srt://127.0.0.1:65535")
.network(NetworkOptions::default())
.build();
if let Err(DecodeError::FileNotFound { path }) = result {
panic!("srt:// URL must not produce FileNotFound; path={path:?}");
}
}
#[test]
fn http_url_open_should_not_be_affected_by_srt_check() {
let result = VideoDecoder::open("http://127.0.0.1:65535/stream.ts")
.network(NetworkOptions::default())
.build();
if let Err(DecodeError::FileNotFound { path }) = result {
panic!("http:// URL must not produce FileNotFound; path={path:?}");
}
}
#[cfg(feature = "srt")]
#[test]
fn srt_live_decoder_should_report_is_live() {
let decoder = match VideoDecoder::open("srt://127.0.0.1:4200")
.network(NetworkOptions::default())
.build()
{
Ok(d) => d,
Err(e) => {
println!("Skipping: no SRT server available ({e})");
return;
}
};
assert!(decoder.is_live(), "SRT source must report is_live=true");
}