1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Integration tests for MPEG-DASH / MPD network stream support (issue #223).
//!
//! Tests that require a reachable DASH server are skipped gracefully when the
//! server is unavailable (e.g. in CI without a local test server — see #235).
mod fixtures;
use fixtures::*;
use ff_decode::{DecodeError, SeekMode, VideoDecoder};
use ff_format::NetworkOptions;
// ── File-backed decoder is not a DASH live stream ────────────────────────────
#[test]
fn file_video_decoder_should_not_be_live_dash() {
// Re-verify the baseline: a file-backed decoder never reports is_live=true,
// even after the DASH demuxer detection logic was added.
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 (DASH regression guard)"
);
}
// ── MPD URL does not produce FileNotFound ────────────────────────────────────
#[test]
fn dash_mpd_open_should_not_return_file_not_found() {
// Use an unreachable loopback address. The important assertion is that the
// file-existence guard is bypassed for HTTP URLs regardless of extension.
let result = VideoDecoder::open("http://127.0.0.1:65535/nonexistent/manifest.mpd")
.network(NetworkOptions::default())
.build();
if let Err(DecodeError::FileNotFound { path }) = result {
panic!("HTTP MPD URL must not produce FileNotFound; path={path:?}");
}
}
// ── Live DASH stream detection (requires reachable DASH server) ──────────────
/// Validates that a live DASH stream (`type="dynamic"` MPD) is detected as live.
///
/// Skipped gracefully when no local DASH test server is reachable (see #235).
#[test]
fn dash_live_decoder_should_report_is_live() {
let decoder = match VideoDecoder::open("http://localhost:8080/dash/live/manifest.mpd")
.network(NetworkOptions::default())
.build()
{
Ok(d) => d,
Err(e) => {
println!("Skipping: no live DASH server available ({e})");
return;
}
};
assert!(
decoder.is_live(),
"Live DASH (type=dynamic) must report is_live=true"
);
}
/// Validates that `seek()` on a live DASH decoder returns `SeekNotSupported`.
///
/// Skipped gracefully when no local DASH test server is reachable (see #235).
#[test]
fn dash_live_decoder_seek_should_return_seek_not_supported() {
let mut decoder = match VideoDecoder::open("http://localhost:8080/dash/live/manifest.mpd")
.network(NetworkOptions::default())
.build()
{
Ok(d) => d,
Err(e) => {
println!("Skipping: no live DASH server available ({e})");
return;
}
};
if !decoder.is_live() {
println!("Skipping: decoder did not detect live DASH source (VOD manifest?)");
return;
}
let result = decoder.seek(std::time::Duration::from_secs(5), SeekMode::Keyframe);
assert!(
matches!(result, Err(DecodeError::SeekNotSupported)),
"Expected SeekNotSupported on live DASH stream, got: {result:?}"
);
}