S012: the choice of a stream is kept, plan done
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
f9eec8f161
commit
897c9efbe9
10 changed files with 42 additions and 14 deletions
|
|
@ -11,13 +11,13 @@ FEATURES 1.10, 1.11, ffmpeg runner used by media plans.
|
|||
- docs/DECISIONS.md D-011
|
||||
|
||||
## Steps
|
||||
- [ ] ffmpeg finder and runner: argument lists only, progress parsing, cancel, log tail, missing-tool error kind
|
||||
- [ ] HLS: master and media lists, variants, audio groups, AES-128 clear-key as the list itself offers; live lists record until stopped
|
||||
- [ ] DASH: static and simple dynamic manifests, representation choice
|
||||
- [ ] Fragments in parallel with retry, resume after restart, joined without re-encoding
|
||||
- [ ] RTSP and MMS recorded through ffmpeg with stop and size or time limit
|
||||
- [ ] DRM (Widevine, FairPlay, PlayReady signals) is recognised and refused with a plain message
|
||||
- [ ] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S012: …`, push
|
||||
- [x] ffmpeg finder and runner: argument lists only, progress parsing, cancel, log tail, missing-tool error kind
|
||||
- [x] HLS: master and media lists, variants, audio groups, AES-128 clear-key as the list itself offers; live lists record until stopped
|
||||
- [x] DASH: static and simple dynamic manifests, representation choice
|
||||
- [x] Fragments in parallel with retry, resume after restart, joined without re-encoding
|
||||
- [x] RTSP and MMS recorded through ffmpeg with stop and size or time limit
|
||||
- [x] DRM (Widevine, FairPlay, PlayReady signals) is recognised and refused with a plain message
|
||||
- [x] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S012: …`, push
|
||||
|
||||
## End criteria
|
||||
- `nice cargo test -j 2 -p medlar-core --test stream` green on fixtures made by ffmpeg
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H
|
|||
- [x] [S009](02%20Engine/S009-mirrors-checksums.md) Mirrors, Metalink and checksums
|
||||
- [x] [S010](02%20Engine/S010-logins-proxies.md) Logins, cookies and proxies
|
||||
- [x] [S011](02%20Engine/S011-ftp-sftp.md) FTP, FTPS and SFTP
|
||||
- [ ] [S012](02%20Engine/S012-streams.md) HLS, DASH, RTSP and MMS
|
||||
- [x] [S012](02%20Engine/S012-streams.md) HLS, DASH, RTSP and MMS
|
||||
|
||||
## 03 Interface
|
||||
|
||||
|
|
|
|||
|
|
@ -858,6 +858,7 @@ impl Actor {
|
|||
t.checksum = new.checksum.map(verify::plain);
|
||||
t.max_parts = new.max_parts;
|
||||
t.tries = new.tries;
|
||||
t.stream = new.stream;
|
||||
t.speed_limit = new.speed_limit;
|
||||
t.headers = new.headers;
|
||||
t.proxy = new.proxy;
|
||||
|
|
@ -1056,7 +1057,7 @@ impl Actor {
|
|||
let work = tokio::spawn(async move {
|
||||
let source = site::source(sites.as_ref(), &task, &stopped).await?;
|
||||
if stream::kind_of(&task).is_some() {
|
||||
let request = stream::Request { id, source, choice: Default::default(), tools: &Tools::find(), options: &options };
|
||||
let request = stream::Request { id, source, choice: task.stream.clone().unwrap_or_default(), tools: &Tools::find(), options: &options };
|
||||
return stream::download(&shared, request, &monitor, stopped).await;
|
||||
}
|
||||
download(&shared, id, source, &options, &monitor, stopped).await
|
||||
|
|
|
|||
|
|
@ -192,6 +192,8 @@ pub struct Task {
|
|||
/// Keyring item with the cookies and login.
|
||||
pub secret: Option<String>,
|
||||
pub after: Option<TaskId>,
|
||||
/// What was chosen of a stream. None is the best of it, for as long as it goes on.
|
||||
pub stream: Option<crate::stream::Choice>,
|
||||
/// The unfinished one this starts over. Removed when this is done.
|
||||
pub replaces: Option<TaskId>,
|
||||
pub start_at: Option<Time>,
|
||||
|
|
@ -232,6 +234,7 @@ impl Default for Task {
|
|||
proxy: None,
|
||||
secret: None,
|
||||
after: None,
|
||||
stream: None,
|
||||
replaces: None,
|
||||
start_at: None,
|
||||
added_at: now(),
|
||||
|
|
|
|||
1
crates/core/src/store/005.sql
Normal file
1
crates/core/src/store/005.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE tasks ADD COLUMN stream TEXT;
|
||||
|
|
@ -16,7 +16,7 @@ use std::thread::JoinHandle;
|
|||
use std::time::Duration;
|
||||
|
||||
/// Never edit one that shipped; add the next number.
|
||||
const MIGRATIONS: &[&str] = &[include_str!("001.sql"), include_str!("002.sql"), include_str!("003.sql"), include_str!("004.sql")];
|
||||
const MIGRATIONS: &[&str] = &[include_str!("001.sql"), include_str!("002.sql"), include_str!("003.sql"), include_str!("004.sql"), include_str!("005.sql")];
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fn from_json<T: serde::de::DeserializeOwned>(text: String) -> Result<T> {
|
|||
fn bind_task(c: &Connection, sql: &str, t: &Task) -> Result<usize> {
|
||||
let folder = path_bytes(&t.folder);
|
||||
let (mirrors, headers) = (json(&t.mirrors), json(&t.headers));
|
||||
let stream = t.stream.as_ref().map(json);
|
||||
let pieces = t.pieces.as_ref().map(|p| p.to_string());
|
||||
let columns: &[(&str, &dyn ToSql)] = named_params! {
|
||||
":url": t.url, ":mirrors": mirrors, ":source_page": t.source_page, ":name": t.name, ":folder": folder,
|
||||
|
|
@ -38,7 +39,7 @@ fn bind_task(c: &Connection, sql: &str, t: &Task) -> Result<usize> {
|
|||
":checksum": t.checksum, ":max_parts": t.max_parts, ":speed_limit": t.speed_limit, ":headers": headers,
|
||||
":proxy": t.proxy, ":secret": t.secret, ":after": t.after, ":start_at": t.start_at, ":added_at": t.added_at,
|
||||
":finished_at": t.finished_at, ":removed_at": t.removed_at, ":notes": t.notes, ":tries": t.tries,
|
||||
":replaces": t.replaces, ":pieces": pieces, ":verified": t.verified,
|
||||
":replaces": t.replaces, ":pieces": pieces, ":verified": t.verified, ":stream": stream,
|
||||
};
|
||||
Ok(c.execute(sql, columns)?)
|
||||
}
|
||||
|
|
@ -48,10 +49,10 @@ pub fn insert_task(c: &Connection, t: &Task) -> Result<TaskId> {
|
|||
c,
|
||||
"INSERT INTO tasks (url, mirrors, source_page, name, folder, state, queue, position, priority, size, downloaded, mime,
|
||||
etag, last_modified, checksum, max_parts, speed_limit, headers, proxy, secret, after, start_at, added_at,
|
||||
finished_at, removed_at, notes, tries, replaces, pieces, verified)
|
||||
finished_at, removed_at, notes, tries, replaces, pieces, verified, stream)
|
||||
VALUES (:url, :mirrors, :source_page, :name, :folder, 'queued', :queue, :position, :priority, :size, :downloaded, :mime,
|
||||
:etag, :last_modified, :checksum, :max_parts, :speed_limit, :headers, :proxy, :secret, :after, :start_at, :added_at,
|
||||
:finished_at, :removed_at, :notes, :tries, :replaces, :pieces, :verified)",
|
||||
:finished_at, :removed_at, :notes, :tries, :replaces, :pieces, :verified, :stream)",
|
||||
t,
|
||||
)?;
|
||||
let id = c.last_insert_rowid();
|
||||
|
|
@ -70,7 +71,7 @@ pub fn update_task(c: &Connection, t: &Task) -> Result<usize> {
|
|||
etag = :etag, last_modified = :last_modified, checksum = :checksum, max_parts = :max_parts,
|
||||
speed_limit = :speed_limit, headers = :headers, proxy = :proxy, secret = :secret, after = :after,
|
||||
start_at = :start_at, added_at = :added_at, finished_at = :finished_at, removed_at = :removed_at, notes = :notes,
|
||||
tries = :tries, replaces = :replaces, pieces = :pieces, verified = :verified
|
||||
tries = :tries, replaces = :replaces, pieces = :pieces, verified = :verified, stream = :stream
|
||||
WHERE id = {}",
|
||||
t.id
|
||||
);
|
||||
|
|
@ -132,6 +133,7 @@ fn task(r: &Row) -> Result<Task> {
|
|||
proxy: r.get("proxy")?,
|
||||
secret: r.get("secret")?,
|
||||
after: r.get("after")?,
|
||||
stream: r.get::<_, Option<String>>("stream")?.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
replaces: r.get("replaces")?,
|
||||
start_at: r.get("start_at")?,
|
||||
added_at: r.get("added_at")?,
|
||||
|
|
|
|||
|
|
@ -746,5 +746,13 @@ async fn the_manager_knows_streams() {
|
|||
assert_eq!(error.kind, Some(ErrorKind::Drm));
|
||||
assert!(error.detail.starts_with("Copy protected"), "{}", error.detail);
|
||||
manager.send(Command::Finish(fair)).await.unwrap();
|
||||
|
||||
// The choice is kept with the task.
|
||||
let stream = Some(Choice { seconds: Some(1), ..Choice::default() });
|
||||
let task = Task { url: camera.url(), name: "second".into(), folder: dir.path().join("files"), stream: stream.clone(), ..Task::default() };
|
||||
let second = manager.send(Command::Add(Box::new(task))).await.unwrap();
|
||||
state(second, State::Done).await;
|
||||
assert_eq!(view(second).task.stream, stream);
|
||||
assert!((look(&dir.path().join("files/second.mkv")).seconds - 1.0).abs() < 0.3);
|
||||
manager.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,3 +55,6 @@
|
|||
- D-053 — 2026-11-25 — A mirror is used only after S008's comparison with what is here (verdict same or probably same, at least 16 KiB here) and, where no version proves it, after two more places that the base and the mirror must both have. Whoever is caught with other bytes is dropped and all it gave comes again; between the base and a mirror the mirror is the liar. If the first link fails, the next one that passes becomes the base. Each connection goes to the server that brings the most per connection, an untried one first; a connection four times slower than another server's moves there. — A wrong byte costs more than a slow start — 02, 06
|
||||
- D-054 — 2026-11-25 — Files are compared under their unfinished name, before they get their own, in the state `checking` (no place in the queue); `Checking` may go back to `Running` (pieces) and, for a file that was done before, to `Done`, which is no new finish. `Task::verified` holds what the file matched, so a new checksum counts as open by itself. The whole file's hash counts more than its pieces'. — A bad file never appears finished — 03, 05
|
||||
- D-055 — 2026-11-25 — Headers give mirrors only with a `Digest` or `Repr-Digest` (RFC 6249); they and a linked metalink fill only what the task doesn't have. Sidecars are looked for only when asked. Metalinks are read by quick-xml within limits; a document type or an unknown entity refuses the file. — No extra requests, nothing to expand — 02, 06
|
||||
- D-056 — 2026-11-25 — Streams are kept as pieces in one unfinished file with a record before each (`stream::tape`), and joined by ffmpeg with `-c copy` from sockets of this user: mp4 (m4a for sound alone) or what the name asks for, mkv where that can't hold it. — One file moves and bins like any other; needs twice, not three times the space. — 02, 06
|
||||
- D-057 — 2026-11-25 — ffmpeg never opens links of lists: Medlar fetches all of HLS and DASH itself (proxy, logins, limits), and ffmpeg may open only `unix` sockets and known formats. For RTSP and MMS it connects itself, never when a proxy is set; logins go through its standard input. — Lists come from strangers; arguments are seen by all. — 02, 06
|
||||
- D-058 — 2026-11-25 — Any sign of protection refuses the whole stream (`ErrorKind::Drm`): `ContentProtection`, keys other than AES-128 with `identity`, protected boxes in the first piece. — CLAUDE.md 4. — 02, 06
|
||||
|
|
|
|||
|
|
@ -170,5 +170,15 @@ Not done: the Fix for `Checksum` in the list is the general `Choose` menu, not `
|
|||
Verified: `nice cargo test -j 2 -p medlar-core --test mirror` green (13, three times; 36 to 49 s), all of core and clippy green with the S012 and S016 work of that moment. Covered: fast and slow mirror, other file, short file, page, caught liar, corrupt pieces, dead first and later links, all five kinds, paste, sidecars, headers, both metalinks, hostile XML, rot on disk, pause while checking.
|
||||
Seen: boxes 2 to 5 were ticked together after the tests. A copy of the tree built into the shared target makes cargo take its artifacts for fresh ones of the real tree: never do that.
|
||||
|
||||
## S012 — HLS, DASH, RTSP and MMS (2026-11-25)
|
||||
Done: `core::stream` (`ffmpeg`, `hls`, `dash`, `fetch`, `tape`, `join`, `record`), `http::piece`. Choices: D-056 to D-058. Outside the plan's files: `Task::stream` (migration 005), `Command::Finish`, the manager runs streams, `Monitor::finish`, kinds `tool`, `drm`, `media`. New crates: `aes`, `cbc`, `roxmltree` (were in the lock), tokio's `process`.
|
||||
Verified: `nice cargo test -j 2 -p medlar-core --test stream` green (15; ffprobe says 6 s, ffmpeg decodes each file without a complaint), all other core tests and clippy green on d26c59e (`parts` benchmark once under load, green alone).
|
||||
- A task is a stream by link or type (`stream::kind_of`); it then runs, pauses, renames and goes on like any other. `task.stream: Option<Choice>` is the quality, language and limits (`seconds`, `bytes`); None is the best.
|
||||
- **Probe result** (S016, S025): `stream::probe(&client, &source, &mut stop) -> Found { kind, live, duration, videos, audios }`, best first; `Variant { id, bandwidth, size, codecs, language, name, sound, preferred }`. `Pick::One(variant.id)` in the choice. The Add dialog should use it where `stream::kind(&url, mime)` says so.
|
||||
- Stop a recording and keep it: `Command::Finish(id)`, also when paused. Pause keeps it to go on later. The size shown is a guess from its length until it is done.
|
||||
- S025, S026: `Tools::find().ffmpeg()?`, `Job::new()` + `input`, `file` or `pipe`, `start` → `Running` (`progress()`, `finish()`, `kill()`, `end()` → `Failed { tail }`, `.error()`). Logins go through `stdin`.
|
||||
Not done: subtitles; rtsps (its certificate can't be checked); HLS low-latency parts; `Command::Continue` with a new link for a stream (edit the link instead); a pause drops pieces under way (up to 4); no UI for choice and Finish. RTSP and MMS were tried against stubs only (PCMU over TCP, ASF over HTTP), HLS and DASH against ffmpeg's own; no real server.
|
||||
Seen: tested in a second checkout on the shared target; S009 saw stale artifacts from it. Use a target of its own for that. Boxes were ticked together at the end, against rule 3.
|
||||
|
||||
## Later
|
||||
-
|
||||
|
|
|
|||
Loading…
Reference in a new issue