forge
Explore
Log in

Don't you dare go Hollow

The stand-ins are made when a project asks, not whenever a big film arrives

Browse files at this commit

269b0c24bc2f5462dadf11598cee2fcb86500fa6Ahmet Kaan GümüşParent: db032d5
  • feat
    • the stand-ins are made when a project asks, not whenever a big film arrives
Show full message
✨ feat(app): the stand-ins are made when a project asks, not whenever a big film arrives

A project now says whether an import makes a proxy by itself. On is the
default and the line left out, so every project that came before behaves
exactly as it did; off makes nothing at all, and turning Proxies on is
what asks for the ones the project is missing -- the only ask there is,
since no per-source item exists.

The file grows an `autoproxy` line and the version goes to 13: a v12
project makes them by itself, which is all any project could do.

The switch is a button beside Proxies in the PROJECT panel, ctrl+o, and
a row on the actions card -- the three doors together, as the two
sync tests require.
crates/app/src/keymap.rsmodified+18 -1
@@ -115,6 +115,11 @@ actions! {
115 /// else -- the sound and every export stay the film's whichever way it115 /// else -- the sound and every export stay the film's whichever way it
116 /// is set.116 /// is set.
117 ToggleProxies,117 ToggleProxies,
118+ /// Whether a film that wants a stand-in gets one made as it is imported
119+ /// ([`engine::proxy::wanted`]): what is *encoded*, where the switch above
120+ /// is what is decoded. With it off the switch above is also the ask -- it
121+ /// starts the ones the project is missing.
122+ ToggleAutoProxies,
118 /// The window's own colours, which belong to the person looking at them and123 /// The window's own colours, which belong to the person looking at them and
119 /// not to the project: a list of the palettes, opened here and from the124 /// not to the project: a list of the palettes, opened here and from the
120 /// toolbar's Theme button. It was a build feature once, which made it a125 /// toolbar's Theme button. It was a build feature once, which made it a
@@ -179,6 +184,7 @@ impl ActionId {
179 ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)",184 ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)",
180 ActionId::ToggleSubtitles => "Subtitles on / off over the picture",185 ActionId::ToggleSubtitles => "Subtitles on / off over the picture",
181 ActionId::ToggleProxies => "Proxies on / off for the picture",186 ActionId::ToggleProxies => "Proxies on / off for the picture",
187+ ActionId::ToggleAutoProxies => "Make proxies on import: on / off",
182 ActionId::Theme => "Theme: the window's colours…",188 ActionId::Theme => "Theme: the window's colours…",
183 ActionId::CancelExport => "Cancel export",189 ActionId::CancelExport => "Cancel export",
184 ActionId::ShowActions => "All actions and their keys…",190 ActionId::ShowActions => "All actions and their keys…",
@@ -234,6 +240,7 @@ impl ActionId {
234 ActionId::ToggleSnap => "toggle-snap",240 ActionId::ToggleSnap => "toggle-snap",
235 ActionId::ToggleSubtitles => "toggle-subtitles",241 ActionId::ToggleSubtitles => "toggle-subtitles",
236 ActionId::ToggleProxies => "toggle-proxies",242 ActionId::ToggleProxies => "toggle-proxies",
243+ ActionId::ToggleAutoProxies => "toggle-auto-proxies",
237 ActionId::Theme => "theme",244 ActionId::Theme => "theme",
238 ActionId::CancelExport => "cancel-export",245 ActionId::CancelExport => "cancel-export",
239 ActionId::ShowActions => "show-actions",246 ActionId::ShowActions => "show-actions",
@@ -290,6 +297,10 @@ impl ActionId {
290 // nothing that is saved and nothing that is exported: a stand-in297 // nothing that is saved and nothing that is exported: a stand-in
291 // is what one watches while cutting, not what one delivers.298 // is what one watches while cutting, not what one delivers.
292 | ActionId::ToggleProxies299 | ActionId::ToggleProxies
300+ // ...and whether those stand-ins are made without being asked: the
301+ // other half of the same switch, filed beside it so a card reader
302+ // meets the pair the panel shows as a pair.
303+ | ActionId::ToggleAutoProxies
293 // ...and what the whole window is painted in: it edits nothing at304 // ...and what the whole window is painted in: it edits nothing at
294 // all, it is what one is looking *with*.305 // all, it is what one is looking *with*.
295 | ActionId::Theme => Category::View,306 | ActionId::Theme => Category::View,
@@ -827,6 +838,11 @@ impl Keymap {
827 // thrown once for a whole session rather than one wanted under838 // thrown once for a whole session rather than one wanted under
828 // a hand -- the theme takes ctrl+h for that reason.839 // a hand -- the theme takes ctrl+h for that reason.
829 b(ActionId::ToggleProxies, "p", true),840 b(ActionId::ToggleProxies, "p", true),
841+ // Making them takes the key next to it, ctrl+o: the pair is one
842+ // subject and the two chords are under the same finger, and
843+ // every letter of the word itself is spoken for ("a" adds an
844+ // audio lane, ctrl+a removes one).
845+ b(ActionId::ToggleAutoProxies, "o", true),
830 // The theme takes ctrl+h -- the h of the word, since "t" is the846 // The theme takes ctrl+h -- the h of the word, since "t" is the
831 // subtitles and ctrl+t takes one off -- and a ctrl chord because847 // subtitles and ctrl+t takes one off -- and a ctrl chord because
832 // it is a preference set once, not a stroke wanted under a hand848 // it is a preference set once, not a stroke wanted under a hand
@@ -1101,8 +1117,9 @@ mod tests {
1101 #[test]1117 #[test]
1102 fn every_default_stroke_reaches_its_action() {1118 fn every_default_stroke_reaches_its_action() {
1103 let k = Keymap::defaults();1119 let k = Keymap::defaults();
1104- assert_eq!(k.entries().len(), 50);1120+ assert_eq!(k.entries().len(), 51);
1105 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));1121 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
1122+ assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
1106 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));1123 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
1107 assert_eq!(k.lookup("h", true), Some(ActionId::Theme));1124 assert_eq!(k.lookup("h", true), Some(ActionId::Theme));
1108 assert_eq!(k.lookup("space", false), Some(ActionId::Play));1125 assert_eq!(k.lookup("space", false), Some(ActionId::Play));
crates/app/src/player/actions.rsmodified+1 -0
@@ -88,6 +88,7 @@ impl Player {
88 ActionId::ToggleSnap => self.toggle_snap(cx),88 ActionId::ToggleSnap => self.toggle_snap(cx),
89 ActionId::ToggleSubtitles => self.toggle_subtitles(cx),89 ActionId::ToggleSubtitles => self.toggle_subtitles(cx),
90 ActionId::ToggleProxies => self.toggle_proxies(cx),90 ActionId::ToggleProxies => self.toggle_proxies(cx),
91+ ActionId::ToggleAutoProxies => self.toggle_auto_proxies(cx),
91 // The keyboard's door to the same list the toolbar button opens.92 // The keyboard's door to the same list the toolbar button opens.
92 // At the window's corner, since a stroke names no place -- and93 // At the window's corner, since a stroke names no place -- and
93 // [`menu_at`] keeps it on screen from there.94 // [`menu_at`] keeps it on screen from there.
crates/app/src/player/export.rsmodified+13 -1
@@ -117,7 +117,19 @@ impl Player {
117 // walk above is -- the decision reads the same header -- and the encode117 // walk above is -- the decision reads the same header -- and the encode
118 // itself is the engine's own worker, so what comes back here is a118 // itself is the engine's own worker, so what comes back here is a
119 // handle to poll and not a wait.119 // handle to poll and not a wait.
120- for path in unseen_paths(session.sources(), &self.proxies) {120+ //
121+ // ...unless this project makes none by itself
122+ // ([`engine::PlaybackSession::auto_proxies`]), and then the Proxies
123+ // switch is the ask: turning it on brings the films that want a
124+ // stand-in through here at the next repaint, which is the only door
125+ // there is. Left unseen meanwhile, so nothing is missed by having been
126+ // imported while the switch was off.
127+ for path in proxies_to_start(
128+ session.auto_proxies(),
129+ session.proxies(),
130+ session.sources(),
131+ &self.proxies,
132+ ) {
121 // Two at a time, and the rest at the next repaint: a stand-in is a133 // Two at a time, and the rest at the next repaint: a stand-in is a
122 // whole film re-encoded, and a library of ten dropped at once would134 // whole film re-encoded, and a library of ten dropped at once would
123 // otherwise start ten encodes fighting over the one hardware seat.135 // otherwise start ten encodes fighting over the one hardware seat.
crates/app/src/player/library.rsmodified+23 -0
@@ -414,6 +414,29 @@ impl Player {
414 cx.notify();414 cx.notify();
415 }415 }
416 416
417+ /// Makes the stand-ins as the films arrive, or makes none until they are
418+ /// asked for. The other half of the switch above: this one decides what is
419+ /// *encoded*, that one what is *watched*.
420+ ///
421+ /// With it off nothing is started by an import at all -- turning Proxies on
422+ /// is what asks for the ones this project needs ([`Player::cache_media`]),
423+ /// which is said here because a switch whose only effect is elsewhere is a
424+ /// switch that reads as doing nothing.
425+ pub(crate) fn toggle_auto_proxies(&mut self, cx: &mut Context<Self>) {
426+ let Some(session) = &mut self.session else {
427+ return;
428+ };
429+ let on = !session.auto_proxies();
430+ session.set_auto_proxies(on);
431+ let text = match on {
432+ true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives",
433+ false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them",
434+ };
435+ eprintln!("{text}");
436+ self.notify_user(text.into());
437+ cx.notify();
438+ }
439+
417 pub(crate) fn poll_import(&mut self, cx: &mut Context<Self>) {440 pub(crate) fn poll_import(&mut self, cx: &mut Context<Self>) {
418 match &mut self.importing {441 match &mut self.importing {
419 Some(import) => {442 Some(import) => {
crates/app/src/subs.rsmodified+20 -0
@@ -579,6 +579,26 @@ pub(crate) fn unseen_paths<V>(sources: &[Source], seen: &HashMap<PathBuf, V>) ->
579 out579 out
580 }580 }
581 581
582+/// The films a repaint may start a stand-in for ([`engine::proxy`]): the unseen
583+/// ones while this project makes them by itself, and **none at all** while it
584+/// does not -- until the Proxies switch is thrown, which is the ask, since
585+/// nothing else offers to make one.
586+///
587+/// A film left out here stays out of the map it was checked against, which is
588+/// what brings it back the moment either switch says yes: an import made while
589+/// both were off is not a film that missed its turn.
590+pub(crate) fn proxies_to_start<V>(
591+ auto: bool,
592+ cut_on_them: bool,
593+ sources: &[Source],
594+ seen: &HashMap<PathBuf, V>,
595+) -> Vec<PathBuf> {
596+ match auto || cut_on_them {
597+ true => unseen_paths(sources, seen),
598+ false => Vec::new(),
599+ }
600+}
601+
582 /// Which timeline frame the playhead is on, by the rule the engine's own edits602 /// Which timeline frame the playhead is on, by the rule the engine's own edits
583 /// use (playback.rs `secs_to_frame`): the frame that has started, with the603 /// use (playback.rs `secs_to_frame`): the frame that has started, with the
584 /// epsilon that keeps a clock sitting exactly on a boundary from reading as the604 /// epsilon that keeps a clock sitting exactly on a boundary from reading as the
crates/app/src/tests/editing.rsmodified+30 -0
@@ -1516,6 +1516,36 @@ fn a_source_is_only_ever_asked_for_its_peaks_once() {
1516 assert_eq!(unseen_paths(&sources, &streams).len(), 1);1516 assert_eq!(unseen_paths(&sources, &streams).len(), 1);
1517 }1517 }
1518 1518
1519+/// The auto switch, which is the whole of what an import asks: with it off no
1520+/// film is handed to [`engine::proxy`] at all, and turning Proxies on is what
1521+/// asks for the ones the project is missing -- there is no other door, so a
1522+/// project that never wants a stand-in never spends a minute encoding one.
1523+#[test]
1524+fn a_project_that_makes_no_proxies_by_itself_starts_none_until_it_is_cut_on_them() {
1525+ let sources = [Source {
1526+ path: asset("test_av.mp4"),
1527+ audio_stream: 0,
1528+ }];
1529+ let none: HashMap<PathBuf, ()> = HashMap::new();
1530+ let one = vec![asset("test_av.mp4")];
1531+ // Today's behaviour, both ways round: auto on starts them whether or not
1532+ // the picture is cut on them -- the cache is warmed for later.
1533+ assert_eq!(proxies_to_start(true, false, &sources, &none), one);
1534+ assert_eq!(proxies_to_start(true, true, &sources, &none), one);
1535+ // Auto off and not cut on them: nothing is started at all.
1536+ assert!(
1537+ proxies_to_start(false, false, &sources, &none).is_empty(),
1538+ "an import started a stand-in the project asked it not to"
1539+ );
1540+ // ...and the switch is the ask: the film comes through the moment Proxies
1541+ // goes on, because it was left unseen rather than marked done.
1542+ assert_eq!(proxies_to_start(false, true, &sources, &none), one);
1543+ // One start per film either way: a film already in the map is one already
1544+ // asked about, sixty repaints a second notwithstanding.
1545+ let seen: HashMap<PathBuf, ()> = HashMap::from([(asset("test_av.mp4"), ())]);
1546+ assert!(proxies_to_start(true, true, &sources, &seen).is_empty());
1547+}
1548+
1519 #[test]1549 #[test]
1520 fn the_add_button_is_dead_unless_it_would_do_something() {1550 fn the_add_button_is_dead_unless_it_would_do_something() {
1521 let picked = (PathBuf::from("/m/0.mp4"), 0);1551 let picked = (PathBuf::from("/m/0.mp4"), 0);
crates/app/src/tests/mod.rsmodified+1 -1
@@ -34,7 +34,7 @@ use super::{
34 SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport,34 SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport,
35 EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_FIXED_H, TIMELINE_SHARE, lanes_shown,35 EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_FIXED_H, TIMELINE_SHARE, lanes_shown,
36 px_below, rows_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone,36 px_below, rows_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone,
37- push_notice, typed, unseen_paths, unseen_sources,37+ proxies_to_start, push_notice, typed, unseen_paths, unseen_sources,
38 whole_take, window_title,38 whole_take, window_title,
39 };39 };
40 40
crates/app/src/ui/inspector.rsmodified+19 -0
@@ -302,6 +302,25 @@ impl Player {
302 ActionId::ToggleProxies,302 ActionId::ToggleProxies,
303 cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)),303 cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)),
304 ))304 ))
305+ // Beside it, because the two are one subject: that one is
306+ // what the picture is decoded from, this one is whether the
307+ // stand-in is ever made. Two states and no cycle, the rule
308+ // the switch beside it keeps.
309+ .child(self.action_control(
310+ "auto-proxies",
311+ TONE_SLOT_W,
312+ BG_RAISED(),
313+ None,
314+ match self.session.as_ref().map(PlaybackSession::auto_proxies) {
315+ Some(true) => "Auto proxies on",
316+ Some(false) => "Auto proxies off",
317+ None => "Auto proxies",
318+ },
319+ "makes a stand-in for every big film as it is imported; with it off, \
320+ turning Proxies on is what asks for them",
321+ ActionId::ToggleAutoProxies,
322+ cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_auto_proxies(cx)),
323+ ))
305 .child(self.action_control(324 .child(self.action_control(
306 "inspect-mix",325 "inspect-mix",
307 0.,326 0.,
crates/engine/src/edith.rsmodified+144 -24
@@ -1,12 +1,13 @@
1 //! The project file: a line of text per thing, and nothing else.1 //! The project file: a line of text per thing, and nothing else.
2 //!2 //!
3 //! ```text3 //! ```text
4-//! edith 124+//! edith 13
5 //! playhead 905 //! playhead 90
6 //! resolution 1920 10806 //! resolution 1920 1080
7 //! fps 30.07 //! fps 30.0
8 //! tonemap vivid8 //! tonemap vivid
9 //! proxy on9 //! proxy on
10+//! autoproxy off
10 //! limiter -1.0 on11 //! limiter -1.0 on
11 //! source 0 test_av.mp412 //! source 0 test_av.mp4
12 //! source 1 /elsewhere/test_av2.mp413 //! source 1 /elsewhere/test_av2.mp4
@@ -52,6 +53,14 @@
52 //! film's own path, length and modification time, so the cache is the only53 //! film's own path, length and modification time, so the cache is the only
53 //! answer and a project file cannot go stale about it.54 //! answer and a project file cannot go stale about it.
54 //!55 //!
56+//! The `autoproxy` line is whether a film this machine cuts slowly gets a
57+//! stand-in made for it the moment it is imported ([`crate::proxy::wanted`]),
58+//! spelled `on` or `off`. Left out when it is on, which is what every dialect
59+//! before v13 did and could not be told not to. With it off an import makes
60+//! nothing at all, and turning the `proxy` switch on is what asks for the
61+//! stand-ins this project is missing -- which is the only way to ask, so a
62+//! project that never wants them never spends a minute of encode on one.
63+//!
55 //! The `limiter` line is the master limiter over the whole mix64 //! The `limiter` line is the master limiter over the whole mix
56 //! ([`crate::limiter`]): its ceiling in dBFS and whether it is in circuit,65 //! ([`crate::limiter`]): its ceiling in dBFS and whether it is in circuit,
57 //! spelled `on` or `off`. Left out when it is the default, which is off.66 //! spelled `on` or `off`. Left out when it is the default, which is off.
@@ -108,7 +117,10 @@
108 //! is the only way an empty lane could still be there on the way back. A lane117 //! is the only way an empty lane could still be there on the way back. A lane
109 //! number may not skip one of its kind.118 //! number may not skip one of its kind.
110 //!119 //!
111-//! **Version 11** was this without the `proxy` line: such a project is cut on120+//! **Version 12** was this without the `autoproxy` line: such a project makes a
121+//! stand-in for every film that wants one the moment it arrives, which is all
122+//! any project could do.
123+//! **Version 11** was that without the `proxy` line: such a project is cut on
112 //! its films themselves, which is all any project could do.124 //! its films themselves, which is all any project could do.
113 //! **Version 10** was that without the `tonemap` line: such a project is shown125 //! **Version 10** was that without the `tonemap` line: such a project is shown
114 //! in the reference rendition, which is the only one there was.126 //! in the reference rendition, which is the only one there was.
@@ -133,7 +145,7 @@
133 //! what a v1 timeline meant, and an older file simply equalizes and grades145 //! what a v1 timeline meant, and an older file simply equalizes and grades
134 //! nothing, and an older one plays everything at real time, and an older one146 //! nothing, and an older one plays everything at real time, and an older one
135 //! mixes flat, and an older one shows no subtitles, and an older one is shown147 //! mixes flat, and an older one shows no subtitles, and an older one is shown
136-//! in the reference rendition -- and saving any of them writes v11. An older148+//! in the reference rendition -- and saving any of them writes v13. An older
137 //! reader refuses a newer file by name.149 //! reader refuses a newer file by name.
138 //!150 //!
139 //! Text because an edit list is a few integers and a path, and a path is151 //! Text because an edit list is a few integers and a path, and a path is
@@ -169,7 +181,8 @@ use crate::subtitle::SubtitleTrack;
169 181
170 /// What [`save`] writes. Read support goes back to `edith 1`; see the module182 /// What [`save`] writes. Read support goes back to `edith 1`; see the module
171 /// docs for what those dialects looked like.183 /// docs for what those dialects looked like.
172-const MAGIC: &[u8] = b"edith 12";184+const MAGIC: &[u8] = b"edith 13";
185+const MAGIC_V12: &[u8] = b"edith 12";
173 const MAGIC_V11: &[u8] = b"edith 11";186 const MAGIC_V11: &[u8] = b"edith 11";
174 const MAGIC_V10: &[u8] = b"edith 10";187 const MAGIC_V10: &[u8] = b"edith 10";
175 const MAGIC_V9: &[u8] = b"edith 9";188 const MAGIC_V9: &[u8] = b"edith 9";
@@ -230,6 +243,11 @@ pub struct Document {
230 /// out, which both mean the films themselves -- the only thing those243 /// out, which both mean the films themselves -- the only thing those
231 /// projects could do.244 /// projects could do.
232 pub proxy: bool,245 pub proxy: bool,
246+ /// Whether an import makes a stand-in for a film that wants one by itself
247+ /// ([`crate::proxy`]). `true` for every dialect before v13 and for a v13
248+ /// file that leaves the line out, which both mean by itself -- the only
249+ /// thing those projects did.
250+ pub auto_proxy: bool,
233 pub playhead: u32,251 pub playhead: u32,
234 }252 }
235 253
@@ -250,6 +268,7 @@ pub fn save(
250 fps: Option<f64>,268 fps: Option<f64>,
251 tone: crate::tonemap::Preset,269 tone: crate::tonemap::Preset,
252 proxy: bool,270 proxy: bool,
271+ auto_proxy: bool,
253 limiter: Limiter,272 limiter: Limiter,
254 playhead: u32,273 playhead: u32,
255 ) -> crate::Result<()> {274 ) -> crate::Result<()> {
@@ -265,7 +284,7 @@ pub fn save(
265 .and_then(|mut f| {284 .and_then(|mut f| {
266 f.write_all(&emit(285 f.write_all(&emit(
267 &dir, sources, lanes, gains, subtitles, eq, color, resolution, fps, tone, proxy,286 &dir, sources, lanes, gains, subtitles, eq, color, resolution, fps, tone, proxy,
268- limiter, playhead,287+ auto_proxy, limiter, playhead,
269 ))?;288 ))?;
270 f.sync_all()289 f.sync_all()
271 })290 })
@@ -309,6 +328,7 @@ fn emit(
309 fps: Option<f64>,328 fps: Option<f64>,
310 tone: crate::tonemap::Preset,329 tone: crate::tonemap::Preset,
311 proxy: bool,330 proxy: bool,
331+ auto_proxy: bool,
312 limiter: Limiter,332 limiter: Limiter,
313 playhead: u32,333 playhead: u32,
314 ) -> Vec<u8> {334 ) -> Vec<u8> {
@@ -333,6 +353,12 @@ fn emit(
333 if proxy {353 if proxy {
334 out.extend_from_slice(b"proxy on\n");354 out.extend_from_slice(b"proxy on\n");
335 }355 }
356+ // Beside it and by the same rule the other way up: making them by itself is
357+ // what every project before this line did, so only a project told to stop
358+ // has anything to say here.
359+ if !auto_proxy {
360+ out.extend_from_slice(b"autoproxy off\n");
361+ }
336 // Written only when it is not the default, so a project nobody has limited362 // Written only when it is not the default, so a project nobody has limited
337 // is the same bytes it was in v8 bar the version line.363 // is the same bytes it was in v8 bar the version line.
338 if limiter != Limiter::default() {364 if limiter != Limiter::default() {
@@ -462,8 +488,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
462 // The dialects that wrote a source line without its stream field. Reading488 // The dialects that wrote a source line without its stream field. Reading
463 // one is the whole of what "an old project still opens" means here.489 // one is the whole of what "an old project still opens" means here.
464 let streamless = v1 || first == MAGIC_V2;490 let streamless = v1 || first == MAGIC_V2;
465- // The one that says whether it is cut on stand-ins...491+ // The one that says whether the stand-ins are made by themselves...
466- let v12 = first == MAGIC;492+ let v13 = first == MAGIC;
493+ // ...the ones that say whether it is cut on stand-ins...
494+ let v12 = v13 || first == MAGIC_V12;
467 // ...the ones that carry an HDR rendition...495 // ...the ones that carry an HDR rendition...
468 let v11 = v12 || first == MAGIC_V11;496 let v11 = v12 || first == MAGIC_V11;
469 // ...the ones that carry subtitle tracks...497 // ...the ones that carry subtitle tracks...
@@ -513,6 +541,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
513 limiter: Limiter::default(),541 limiter: Limiter::default(),
514 tone: crate::tonemap::Preset::default(),542 tone: crate::tonemap::Preset::default(),
515 proxy: false,543 proxy: false,
544+ // ...and nothing before v13 could be told *not* to make one: an import
545+ // that wanted a stand-in got one, which is what leaving the line out
546+ // still means.
547+ auto_proxy: true,
516 fps: None,548 fps: None,
517 playhead: 0,549 playhead: 0,
518 };550 };
@@ -602,6 +634,25 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
602 }634 }
603 };635 };
604 }636 }
637+ b"autoproxy" if v13 => {
638+ if !doc.sources.is_empty() {
639+ return Err(
640+ format!("line {n}: autoproxy belongs once, before the sources").into(),
641+ );
642+ }
643+ let f = fields(rest, 1, "autoproxy", n)?;
644+ doc.auto_proxy = match f[0] {
645+ b"on" => true,
646+ b"off" => false,
647+ other => {
648+ return Err(format!(
649+ "line {n}: autoproxy is on or off, not {:?}",
650+ String::from_utf8_lossy(other)
651+ )
652+ .into());
653+ }
654+ };
655+ }
605 b"limiter" if v9 => {656 b"limiter" if v9 => {
606 if !doc.sources.is_empty() {657 if !doc.sources.is_empty() {
607 return Err(658 return Err(
@@ -1122,6 +1173,7 @@ mod tests {
1122 None,1173 None,
1123 crate::tonemap::Preset::default(),1174 crate::tonemap::Preset::default(),
1124 false,1175 false,
1176+ true,
1125 Limiter::default(),1177 Limiter::default(),
1126 playhead,1178 playhead,
1127 )1179 )
@@ -1166,6 +1218,7 @@ mod tests {
1166 None,1218 None,
1167 crate::tonemap::Preset::default(),1219 crate::tonemap::Preset::default(),
1168 false,1220 false,
1221+ true,
1169 Limiter::default(),1222 Limiter::default(),
1170 0,1223 0,
1171 );1224 );
@@ -1194,7 +1247,7 @@ mod tests {
1194 video 1 0 0 30 0 - - - fit 1000\n";1247 video 1 0 0 30 0 - - - fit 1000\n";
1195 let old = parse(v9, &dir).expect("v9 still loads");1248 let old = parse(v9, &dir).expect("v9 still loads");
1196 assert_eq!(old.subtitles, Vec::new());1249 assert_eq!(old.subtitles, Vec::new());
1197- assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 12\n"));1250+ assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 13\n"));
1198 // ...and the line itself is not a v9 line: a dialect may not be mixed.1251 // ...and the line itself is not a v9 line: a dialect may not be mixed.
1199 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)1252 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)
1200 .unwrap_err()1253 .unwrap_err()
@@ -1230,6 +1283,7 @@ mod tests {
1230 None,1283 None,
1231 crate::tonemap::Preset::default(),1284 crate::tonemap::Preset::default(),
1232 proxy,1285 proxy,
1286+ true,
1233 Limiter::default(),1287 Limiter::default(),
1234 0,1288 0,
1235 )1289 )
@@ -1261,7 +1315,7 @@ mod tests {
1261 assert_eq!(mixed, "line 3: unknown keyword \"proxy\"");1315 assert_eq!(mixed, "line 3: unknown keyword \"proxy\"");
1262 // Anything but on or off is a corrupt line, by name.1316 // Anything but on or off is a corrupt line, by name.
1263 for line in ["proxy\n", "proxy yes\n", "proxy On\n"] {1317 for line in ["proxy\n", "proxy yes\n", "proxy On\n"] {
1264- let file = format!("edith 12\nsource 0 a.mp4\n{line}");1318+ let file = format!("edith 13\nsource 0 a.mp4\n{line}");
1265 assert!(1319 assert!(
1266 parse(file.as_bytes(), &dir).is_err(),1320 parse(file.as_bytes(), &dir).is_err(),
1267 "{line:?} is not a proxy line"1321 "{line:?} is not a proxy line"
@@ -1269,6 +1323,69 @@ mod tests {
1269 }1323 }
1270 }1324 }
1271 1325
1326+ /// The v13 line: whether an import makes a stand-in by itself. Written the
1327+ /// other way up from every other switch here -- on is the default and the
1328+ /// line left out -- because that is what every dialect before it did, and a
1329+ /// v12 file must come back doing it.
1330+ #[test]
1331+ fn the_auto_proxy_switch_round_trips_and_a_v12_file_makes_them_by_itself() {
1332+ let dir = PathBuf::from("/proj");
1333+ let (_, sources, lanes) = doc();
1334+ let bytes = |proxy, auto| {
1335+ super::emit(
1336+ &dir,
1337+ &sources,
1338+ &lanes,
1339+ &[],
1340+ &[],
1341+ &[],
1342+ &[],
1343+ (1280, 720),
1344+ None,
1345+ crate::tonemap::Preset::default(),
1346+ proxy,
1347+ auto,
1348+ Limiter::default(),
1349+ 0,
1350+ )
1351+ };
1352+ // The default is the line left out, and the two switches are two lines:
1353+ // a project cut on stand-ins it does not make writes both.
1354+ let on = bytes(false, true);
1355+ assert!(
1356+ !String::from_utf8_lossy(&on).contains("autoproxy"),
1357+ "on is the line left out: {}",
1358+ String::from_utf8_lossy(&on)
1359+ );
1360+ assert!(parse(&on, &dir).expect("v13 parses").auto_proxy);
1361+ let off = bytes(true, false);
1362+ let text = String::from_utf8_lossy(&off).to_string();
1363+ assert!(text.contains("proxy on\nautoproxy off\n"), "{text}");
1364+ let back = parse(&off, &dir).expect("v13 parses");
1365+ assert!(back.proxy, "the other switch came back too");
1366+ assert!(!back.auto_proxy);
1367+
1368+ // A v12 project made them by itself and could not be told otherwise.
1369+ let v12 = b"edith 12\nplayhead 0\nresolution 1280 720\nproxy on\nsource 0 a.mp4\n\
1370+ video 1 0 0 30 0 - - - fit 1000\n";
1371+ let old = parse(v12, &dir).expect("v12 still loads");
1372+ assert!(old.auto_proxy, "a v12 project made its stand-ins by itself");
1373+ assert!(old.proxy, "the rest of it came back too");
1374+ // ...and the line is not a v12 line: a dialect may not be mixed.
1375+ let mixed = parse(b"edith 12\nsource 0 a.mp4\nautoproxy off\n", &dir)
1376+ .unwrap_err()
1377+ .to_string();
1378+ assert_eq!(mixed, "line 3: unknown keyword \"autoproxy\"");
1379+ // Anything but on or off is a corrupt line, by name.
1380+ for line in ["autoproxy\n", "autoproxy no\n", "autoproxy Off\n"] {
1381+ let file = format!("edith 13\nsource 0 a.mp4\n{line}");
1382+ assert!(
1383+ parse(file.as_bytes(), &dir).is_err(),
1384+ "{line:?} is not an autoproxy line"
1385+ );
1386+ }
1387+ }
1388+
1272 /// The v11 line: the HDR rendition, written by name, read back as the very1389 /// The v11 line: the HDR rendition, written by name, read back as the very
1273 /// preset -- and the dialect before it, which had no way to say one and1390 /// preset -- and the dialect before it, which had no way to say one and
1274 /// meant the published conversion.1391 /// meant the published conversion.
@@ -1289,6 +1406,7 @@ mod tests {
1289 None,1406 None,
1290 preset,1407 preset,
1291 false,1408 false,
1409+ true,
1292 Limiter::default(),1410 Limiter::default(),
1293 0,1411 0,
1294 );1412 );
@@ -1383,7 +1501,7 @@ mod tests {
1383 let bytes = flat(&dir, &sources, &lanes, 12);1501 let bytes = flat(&dir, &sources, &lanes, 12);
1384 assert_eq!(1502 assert_eq!(
1385 String::from_utf8_lossy(&bytes),1503 String::from_utf8_lossy(&bytes),
1386- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\1504+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
1387 source 2 /elsewhere/b.mp4\n\1505 source 2 /elsewhere/b.mp4\n\
1388 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\1506 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
1389 audio 1 0 0 30 0 0 - - fit 1000\n",1507 audio 1 0 0 30 0 0 - - fit 1000\n",
@@ -1420,7 +1538,7 @@ mod tests {
1420 let bytes = flat(&dir, &sources, &lanes, 7);1538 let bytes = flat(&dir, &sources, &lanes, 7);
1421 assert_eq!(1539 assert_eq!(
1422 String::from_utf8_lossy(&bytes),1540 String::from_utf8_lossy(&bytes),
1423- "edith 12\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\1541+ "edith 13\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\
1424 video 1 0 0 30 0 4 - - fit 1000\naudio 1\n\1542 video 1 0 0 30 0 4 - - fit 1000\naudio 1\n\
1425 video 2 40 0 10 0 - - - fit 1000\naudio 2 0 0 30 0 4 - - fit 1000\n",1543 video 2 40 0 10 0 - - - fit 1000\naudio 2 0 0 30 0 4 - - fit 1000\n",
1426 "an empty lane is a line of its own; everything else is its clips"1544 "an empty lane is a line of its own; everything else is its clips"
@@ -1528,7 +1646,7 @@ mod tests {
1528 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);1646 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);
1529 assert_eq!(1647 assert_eq!(
1530 String::from_utf8_lossy(&bytes),1648 String::from_utf8_lossy(&bytes),
1531- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\1649+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1532 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\1650 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
1533 eq 16777215.0:-0.1:3.918315e-39:hs\n\1651 eq 16777215.0:-0.1:3.918315e-39:hs\n\
1534 eq\n\1652 eq\n\
@@ -1632,7 +1750,7 @@ mod tests {
1632 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);1750 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);
1633 assert_eq!(1751 assert_eq!(
1634 String::from_utf8_lossy(&bytes),1752 String::from_utf8_lossy(&bytes),
1635- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\1753+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1636 color 0.1:1.2:0.9:-0.3\n\1754 color 0.1:1.2:0.9:-0.3\n\
1637 color -1e-7:16777215.0:3.918315e-39:-0.0\n\1755 color -1e-7:16777215.0:3.918315e-39:-0.0\n\
1638 color 0.0:1.0:1.0:0.0\n\1756 color 0.0:1.0:1.0:0.0\n\
@@ -1697,7 +1815,7 @@ mod tests {
1697 (1280, 720),1815 (1280, 720),
1698 old.playhead1816 old.playhead
1699 )),1817 )),
1700- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\1818+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1701 eq 80.0:-3.0:0.707:ls\n\1819 eq 80.0:-3.0:0.707:ls\n\
1702 video 1 0 0 30 0 0 0 - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"1820 video 1 0 0 30 0 0 0 - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"
1703 );1821 );
@@ -1735,7 +1853,7 @@ mod tests {
1735 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);1853 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
1736 assert_eq!(1854 assert_eq!(
1737 String::from_utf8_lossy(&bytes),1855 String::from_utf8_lossy(&bytes),
1738- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\1856+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1739 video 1 0 0 30 0 - - - fit 2000\nvideo 1 15 30 40 0 - - - fit 250\n\1857 video 1 0 0 30 0 - - - fit 2000\nvideo 1 15 30 40 0 - - - fit 250\n\
1740 audio 1 0 0 30 0 - - - fit 2000\n",1858 audio 1 0 0 30 0 - - - fit 2000\n",
1741 "the rate is the clip line's last field, in thousandths"1859 "the rate is the clip line's last field, in thousandths"
@@ -1764,7 +1882,7 @@ mod tests {
1764 (1280, 720),1882 (1280, 720),
1765 old.playhead1883 old.playhead
1766 )),1884 )),
1767- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\1885+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1768 video 1 0 0 30 0 0 - - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"1886 video 1 0 0 30 0 0 - - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"
1769 );1887 );
1770 // A rate outside what the editor can set is a corrupt line, by name.1888 // A rate outside what the editor can set is a corrupt line, by name.
@@ -1806,12 +1924,13 @@ mod tests {
1806 Some(23.976023976023978),1924 Some(23.976023976023978),
1807 crate::tonemap::Preset::default(),1925 crate::tonemap::Preset::default(),
1808 false,1926 false,
1927+ true,
1809 limiter,1928 limiter,
1810 0,1929 0,
1811 );1930 );
1812 assert_eq!(1931 assert_eq!(
1813 String::from_utf8_lossy(&bytes),1932 String::from_utf8_lossy(&bytes),
1814- "edith 12\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\1933+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\
1815 limiter -1.5 on\nsource 0 a.mp4\n\1934 limiter -1.5 on\nsource 0 a.mp4\n\
1816 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n\1935 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n\
1817 audio 2 0 0 30 0 - - - fit 1000\n\1936 audio 2 0 0 30 0 - - - fit 1000\n\
@@ -1843,7 +1962,7 @@ mod tests {
1843 (1280, 720),1962 (1280, 720),
1844 old.playhead1963 old.playhead
1845 )),1964 )),
1846- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\1965+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1847 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"1966 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"
1848 );1967 );
1849 1968
@@ -2007,7 +2126,7 @@ mod tests {
2007 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");2126 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");
2008 assert_eq!(2127 assert_eq!(
2009 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),2128 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),
2010- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\2129+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2011 source 2 /elsewhere/b.mp4\n\2130 source 2 /elsewhere/b.mp4\n\
2012 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\2131 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
2013 audio 1 0 0 30 0 0 - - fit 1000\n"2132 audio 1 0 0 30 0 0 - - fit 1000\n"
@@ -2060,7 +2179,7 @@ mod tests {
2060 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);2179 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
2061 assert_eq!(2180 assert_eq!(
2062 String::from_utf8_lossy(&v5),2181 String::from_utf8_lossy(&v5),
2063- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\2182+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2064 source 0 /elsewhere/b.mp4\n\2183 source 0 /elsewhere/b.mp4\n\
2065 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\2184 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
2066 audio 1 0 0 30 0 0 - - fit 1000\n",2185 audio 1 0 0 30 0 0 - - fit 1000\n",
@@ -2092,7 +2211,7 @@ mod tests {
2092 // Saved again it is the current version, which round-trips to the2211 // Saved again it is the current version, which round-trips to the
2093 // same document.2212 // same document.
2094 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);2213 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
2095- assert!(v5.starts_with(b"edith 12\n"));2214+ assert!(v5.starts_with(b"edith 13\n"));
2096 let again = parse(&v5, &dir).expect("v5 parses");2215 let again = parse(&v5, &dir).expect("v5 parses");
2097 assert_eq!(again.lanes, back.lanes);2216 assert_eq!(again.lanes, back.lanes);
2098 // A dialect may not be mixed: lane lines under v1, `clip` under v2.2217 // A dialect may not be mixed: lane lines under v1, `clip` under v2.
@@ -2191,6 +2310,7 @@ mod tests {
2191 None,2310 None,
2192 crate::tonemap::Preset::default(),2311 crate::tonemap::Preset::default(),
2193 false,2312 false,
2313+ true,
2194 Limiter::default(),2314 Limiter::default(),
2195 0,2315 0,
2196 )2316 )
@@ -2198,7 +2318,7 @@ mod tests {
2198 let bytes = std::fs::read(&path).expect("read back");2318 let bytes = std::fs::read(&path).expect("read back");
2199 assert_eq!(2319 assert_eq!(
2200 String::from_utf8_lossy(&bytes),2320 String::from_utf8_lossy(&bytes),
2201- "edith 12\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\2321+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\
2202 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"2322 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"
2203 );2323 );
2204 // Loading rejoins the *given* directory, so the file is reached by the2324 // Loading rejoins the *given* directory, so the file is reached by the
@@ -2243,10 +2363,10 @@ mod tests {
2243 #[test]2363 #[test]
2244 fn a_wrong_first_line_is_refused_by_name() {2364 fn a_wrong_first_line_is_refused_by_name() {
2245 let dir = PathBuf::from("/proj");2365 let dir = PathBuf::from("/proj");
2246- let err = parse(b"edith 13\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)2366+ let err = parse(b"edith 14\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)
2247 .unwrap_err()2367 .unwrap_err()
2248 .to_string();2368 .to_string();
2249- assert_eq!(err, "line 1: unsupported version 13");2369+ assert_eq!(err, "line 1: unsupported version 14");
2250 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {2370 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {
2251 assert_eq!(2371 assert_eq!(
2252 parse(junk, &dir).unwrap_err().to_string(),2372 parse(junk, &dir).unwrap_err().to_string(),
crates/engine/src/playback.rsmodified+29 -0
@@ -388,6 +388,12 @@ pub struct PlaybackSession {
388 /// file open that already costs milliseconds, so a proxy made (or deleted)388 /// file open that already costs milliseconds, so a proxy made (or deleted)
389 /// mid-session is picked up at the next seek and nothing can go stale.389 /// mid-session is picked up at the next seek and nothing can go stale.
390 proxies: bool,390 proxies: bool,
391+ /// Whether a source that wants a stand-in gets one made for it as it
392+ /// arrives ([`crate::proxy::wanted`]). On unless a project says otherwise,
393+ /// which is what every project did before the switch existed. Saved with
394+ /// the project like the one above it, and read by the front end: the engine
395+ /// starts no encode of its own.
396+ auto_proxies: bool,
391 }397 }
392 398
393 /// What an edit dirtied -- which half of the pipeline has to be rebuilt for the399 /// What an edit dirtied -- which half of the pipeline has to be rebuilt for the
@@ -505,6 +511,7 @@ impl PlaybackSession {
505 drop_late: false,511 drop_late: false,
506 // A file just opened is a project nobody has picked stand-ins for.512 // A file just opened is a project nobody has picked stand-ins for.
507 proxies: false,513 proxies: false,
514+ auto_proxies: true,
508 })515 })
509 }516 }
510 517
@@ -620,6 +627,7 @@ impl PlaybackSession {
620 drop_late: false,627 drop_late: false,
621 // A file just opened is a project nobody has picked stand-ins for.628 // A file just opened is a project nobody has picked stand-ins for.
622 proxies: false,629 proxies: false,
630+ auto_proxies: true,
623 })631 })
624 }632 }
625 633
@@ -699,6 +707,7 @@ impl PlaybackSession {
699 drop_late: false,707 drop_late: false,
700 // A file just opened is a project nobody has picked stand-ins for.708 // A file just opened is a project nobody has picked stand-ins for.
701 proxies: false,709 proxies: false,
710+ auto_proxies: true,
702 })711 })
703 }712 }
704 713
@@ -996,6 +1005,9 @@ impl PlaybackSession {
996 // What the file says, and `false` for every dialect before v12:1005 // What the file says, and `false` for every dialect before v12:
997 // a project cut on the films themselves opens on them.1006 // a project cut on the films themselves opens on them.
998 proxies: doc.proxy,1007 proxies: doc.proxy,
1008+ // ...and what it says about making them, which is "yes" for every
1009+ // dialect before v13 and for one that leaves the line out.
1010+ auto_proxies: doc.auto_proxy,
999 };1011 };
1000 // The scaffolding above opened source 0 from its first frame and the1012 // The scaffolding above opened source 0 from its first frame and the
1001 // whole of its audio; this puts both onto the clip the playhead is1013 // whole of its audio; this puts both onto the clip the playhead is
@@ -1251,6 +1263,10 @@ impl PlaybackSession {
1251 // *Which* files have one is not saved: [`crate::proxy`] finds that1263 // *Which* files have one is not saved: [`crate::proxy`] finds that
1252 // out from the film itself, so nothing here can go stale.1264 // out from the film itself, so nothing here can go stale.
1253 self.proxies,1265 self.proxies,
1266+ // ...and whether it makes them by itself, which is a different
1267+ // question from whether it cuts on them and the only one an import
1268+ // asks ([`Self::auto_proxies`]).
1269+ self.auto_proxies,
1254 self.project.limiter(),1270 self.project.limiter(),
1255 playhead,1271 playhead,
1256 )1272 )
@@ -1998,6 +2014,19 @@ impl PlaybackSession {
1998 self.seek(now);2014 self.seek(now);
1999 }2015 }
2000 2016
2017+ /// Whether an imported film that wants a stand-in gets one made for it
2018+ /// there and then ([`Self::set_auto_proxies`]).
2019+ pub fn auto_proxies(&self) -> bool {
2020+ self.auto_proxies
2021+ }
2022+
2023+ /// Make the stand-ins on import, or make none until asked. Nothing to
2024+ /// reseek: this decides what is *started*, never what is decoded -- a proxy
2025+ /// already in the cache is still cut on while [`Self::proxies`] is on.
2026+ pub fn set_auto_proxies(&mut self, on: bool) {
2027+ self.auto_proxies = on;
2028+ }
2029+
2001 /// Which source `path` is, canonicalising only if it has to: a source's own2030 /// Which source `path` is, canonicalising only if it has to: a source's own
2002 /// path is canonical ([`Source::new`]), so a caller handing one back from2031 /// path is canonical ([`Source::new`]), so a caller handing one back from
2003 /// [`sources`](Self::sources) -- which is every library row -- hits on the2032 /// [`sources`](Self::sources) -- which is every library row -- hits on the
crates/engine/tests/export.rsmodified+1 -1
@@ -985,7 +985,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() {
985 session.set_proxies(true);985 session.set_proxies(true);
986 session.save_project(&project).expect("save");986 session.save_project(&project).expect("save");
987 let text = std::fs::read_to_string(&project).expect("read the project back");987 let text = std::fs::read_to_string(&project).expect("read the project back");
988- assert!(text.starts_with("edith 12\n"), "{text}");988+ assert!(text.starts_with("edith 13\n"), "{text}");
989 assert!(text.contains("\nproxy on\n"), "{text}");989 assert!(text.contains("\nproxy on\n"), "{text}");
990 let reopened = PlaybackSession::open_project(&project).expect("load");990 let reopened = PlaybackSession::open_project(&project).expect("load");
991 assert!(reopened.proxies(), "the switch came back on");991 assert!(reopened.proxies(), "the switch came back on");
crates/engine/tests/saveload.rsmodified+43 -6
@@ -97,6 +97,43 @@ fn a_picked_audio_stream_lands_saves_and_comes_back() {
97 std::fs::remove_dir_all(&dir).expect("cleanup");97 std::fs::remove_dir_all(&dir).expect("cleanup");
98 }98 }
99 99
100+/// Both stand-in switches through the front door: what the picture is cut on
101+/// and whether an import makes one at all are two settings, saved and reopened
102+/// as the pair they are -- and a session that was never told keeps making them,
103+/// which is what every project did before there was a switch.
104+#[test]
105+fn both_proxy_switches_survive_a_save_and_a_reopen() {
106+ let dir = scratch("proxyswitches");
107+ let media = copy_in(&dir, "test_av.mp4");
108+ let mut session = PlaybackSession::open(&media).expect("open the fixture");
109+ session.set_gain(0.0);
110+ assert!(session.auto_proxies(), "a fresh project makes them by itself");
111+ assert!(!session.proxies(), "and is cut on the film itself");
112+
113+ session.set_proxies(true);
114+ session.set_auto_proxies(false);
115+ let path = dir.join("switches.edith");
116+ session.save_project(&path).expect("save");
117+ let text = std::fs::read_to_string(&path).expect("read back");
118+ assert!(text.contains("proxy on\nautoproxy off\n"), "{text}");
119+
120+ let loaded = PlaybackSession::open_project(&path).expect("reopen");
121+ assert!(loaded.proxies(), "cut on the stand-ins came back");
122+ assert!(!loaded.auto_proxies(), "and so did making none of them");
123+
124+ // ...and the default is the line left out, which is what a v12 file is.
125+ session.set_auto_proxies(true);
126+ session.save_project(&path).expect("save");
127+ let text = std::fs::read_to_string(&path).expect("read back");
128+ assert!(!text.contains("autoproxy"), "on is written by saying nothing");
129+ assert!(
130+ PlaybackSession::open_project(&path)
131+ .expect("reopen")
132+ .auto_proxies()
133+ );
134+ std::fs::remove_dir_all(&dir).expect("cleanup");
135+}
136+
100 /// Why a trim's tail stops where the file ends: a clip reaching past the last137 /// Why a trim's tail stops where the file ends: a clip reaching past the last
101 /// frame of its source is a project that will not open again (`open_project`138 /// frame of its source is a project that will not open again (`open_project`
102 /// refuses it by name). Pulled in on both ends and then dragged out as far as139 /// refuses it by name). Pulled in on both ends and then dragged out as far as
@@ -208,7 +245,7 @@ fn a_version_1_project_loads_fully_grouped_and_saves_as_version_7() {
208 let v2 = dir.join("new.edith");245 let v2 = dir.join("new.edith");
209 loaded.save_project(&v2).expect("save");246 loaded.save_project(&v2).expect("save");
210 let text = std::fs::read_to_string(&v2).expect("read back");247 let text = std::fs::read_to_string(&v2).expect("read back");
211- assert!(text.starts_with("edith 12\n"), "{text}");248+ assert!(text.starts_with("edith 13\n"), "{text}");
212 assert!(249 assert!(
213 text.contains("\nresolution 1280 720\n"),250 text.contains("\nresolution 1280 720\n"),
214 "a project with no resolution of its own is saved at source 0's: {text}"251 "a project with no resolution of its own is saved at source 0's: {text}"
@@ -296,7 +333,7 @@ fn a_version_4_project_holds_more_than_two_lanes() {
296 loaded.save_project(&again).expect("save");333 loaded.save_project(&again).expect("save");
297 assert_eq!(334 assert_eq!(
298 std::fs::read_to_string(&again).expect("read back"),335 std::fs::read_to_string(&again).expect("read back"),
299- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\336+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
300 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\337 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\
301 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",338 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",
302 "a four-lane project is written as it was read, three versions on"339 "a four-lane project is written as it was read, three versions on"
@@ -326,7 +363,7 @@ fn a_version_5_project_carries_per_clip_equalizers() {
326 loaded.save_project(&again).expect("save");363 loaded.save_project(&again).expect("save");
327 assert_eq!(364 assert_eq!(
328 std::fs::read_to_string(&again).expect("read back"),365 std::fs::read_to_string(&again).expect("read back"),
329- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\366+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
330 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\367 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
331 eq 12000.0:6.25:0.5:hs\n\368 eq 12000.0:6.25:0.5:hs\n\
332 video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\369 video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\
@@ -361,7 +398,7 @@ fn a_version_6_project_carries_per_clip_colours() {
361 loaded.save_project(&again).expect("save");398 loaded.save_project(&again).expect("save");
362 assert_eq!(399 assert_eq!(
363 std::fs::read_to_string(&again).expect("read back"),400 std::fs::read_to_string(&again).expect("read back"),
364- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\401+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
365 eq 80.0:-3.0:0.707:ls\n\402 eq 80.0:-3.0:0.707:ls\n\
366 color 0.1:1.2:0.9:-0.3\n\403 color 0.1:1.2:0.9:-0.3\n\
367 color -0.25:1.0:0.0:0.5\n\404 color -0.25:1.0:0.0:0.5\n\
@@ -411,7 +448,7 @@ fn a_version_7_project_carries_a_resolution_and_fit_policies() {
411 loaded.save_project(&again).expect("save");448 loaded.save_project(&again).expect("save");
412 assert_eq!(449 assert_eq!(
413 std::fs::read_to_string(&again).expect("read back"),450 std::fs::read_to_string(&again).expect("read back"),
414- "edith 12\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\451+ "edith 13\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\
415 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\452 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\
416 audio 1 0 0 60 0 - - - fit 1000\n",453 audio 1 0 0 60 0 - - - fit 1000\n",
417 "a v7 project is written back as the v8 it now is: the same clips, each \454 "a v7 project is written back as the v8 it now is: the same clips, each \
@@ -669,7 +706,7 @@ fn malformed_files_are_numbered_errors_and_never_panics() {
669 706
670 for (text, want) in [707 for (text, want) in [
671 (708 (
672- "edith 13\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",709+ "edith 14\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",
673 "line 1",710 "line 1",
674 ),711 ),
675 // An eq index the table does not hold, and a band shape there is none.712 // An eq index the table does not hold, and a band shape there is none.
crates/engine/tests/silence.rsmodified+2 -1
@@ -377,13 +377,14 @@ fn scanning_a_clip_and_cutting_what_it_finds() {
377 None,377 None,
378 p.tone(),378 p.tone(),
379 false,379 false,
380+ true,
380 p.limiter(),381 p.limiter(),
381 0,382 0,
382 )383 )
383 .expect("save");384 .expect("save");
384 let text = std::fs::read_to_string(&file).expect("read it back");385 let text = std::fs::read_to_string(&file).expect("read it back");
385 assert!(386 assert!(
386- text.starts_with("edith 12"),387+ text.starts_with("edith 13"),
387 "{:?}",388 "{:?}",
388 &text[..16.min(text.len())]389 &text[..16.min(text.len())]
389 );390 );
crates/engine/tests/subtitles.rsmodified+1 -1
@@ -259,7 +259,7 @@ fn a_project_keeps_its_subtitles_across_a_save() {
259 let project = dir.join("cut.edith");259 let project = dir.join("cut.edith");
260 session.save_project(&project).expect("save");260 session.save_project(&project).expect("save");
261 let text = std::fs::read_to_string(&project).expect("read the project back");261 let text = std::fs::read_to_string(&project).expect("read the project back");
262- assert!(text.starts_with("edith 12\n"), "{text}");262+ assert!(text.starts_with("edith 13\n"), "{text}");
263 assert!(263 assert!(
264 text.contains("\nsubtitle - test_subs.srt\n"),264 text.contains("\nsubtitle - test_subs.srt\n"),
265 "the reference is written relative, and no cue is: {text}"265 "the reference is written relative, and no cue is: {text}"