edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! A decode failure reaches the user, the way a lost sound device already does. |
| 2 | //! |
| 3 | //! A worker that ran to the end of a file and a worker that gave up on a |
| 4 | //! corrupt packet both drop the sender, and `try_frame` returns `None` for |
| 5 | //! either. The app read that as end-of-stream, so a file with a damaged middle |
| 6 | //! froze on its last good picture and the transport said ENDED: no notice, no |
| 7 | //! banner, and nothing on screen to say the film had stopped being the film. |
| 8 | //! The sound path has had a reason channel for a device that dies mid-session |
| 9 | //! all along; this is that channel's picture-side twin. |
| 10 | //! |
| 11 | //! The fixture is **built here**: `test_av.mp4`'s `moov` sits *after* its `mdat`, |
| 12 | //! so truncating the file would take the index with it. What is done instead is |
| 13 | //! what a download that dies mid-transfer leaves behind -- the tail of the |
| 14 | //! sample data overwritten, the container index intact and still claiming every |
| 15 | //! frame. The header and the first seconds stay valid, so frames really do |
| 16 | //! arrive before the failure, which is the whole shape of the bug. |
| 17 | //! |
| 18 | //! ```text |
| 19 | //! cargo test -p engine --test decode_failure -- --test-threads=1 |
| 20 | //! ``` |
| 21 | |
| 22 | use PathBuf; |
| 23 | use ; |
| 24 | |
| 25 | use PlaybackSession; |
| 26 | use Scratch; |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | /// Software everywhere, so the suite proves the path every machine has. |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | /// `test_av.mp4` with the last eighth of its **sample data** overwritten, and |
| 44 | /// the file otherwise untouched: `moov` still claims every frame the header |
| 45 | /// ever did, and the demuxer hands the decoder exactly what it always handed |
| 46 | /// it. |
| 47 | /// |
| 48 | /// The damage is bounded to the `mdat` payload on purpose. `moov` sits *after* |
| 49 | /// `mdat` in this fixture, so a damage that ran to the end of the file would |
| 50 | /// take the index with it and leave a file that will not open at all -- a |
| 51 | /// different defect, reached before a single frame is decoded and invisible to |
| 52 | /// the thing this test is about. |
| 53 | /// |
| 54 | /// Returns the scratch guard too, so the directory goes when the test ends. |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | /// The `mdat` box's payload, start and end: the walk a container parser does, |
| 68 | /// four bytes at a time, and the reason the fixture is damaged rather than |
| 69 | /// truncated. |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | /// Plays `path` to its end and answers what the transport would show and what |
| 87 | /// the session says went wrong. |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | /// The defect: a file whose middle is damaged produces real frames, then stops, |
| 122 | /// and says why. Before this the second half was silent -- the reason was an |
| 123 | /// `eprintln!` on a decode worker's stderr, and the only thing the caller could |
| 124 | /// see was a closed channel, which it read as the film finishing. |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | /// The other half, and the one that keeps the notice from becoming noise: a |
| 148 | /// file that plays all the way through says **nothing**. A reason channel that |
| 149 | /// fires on every film is a channel nobody reads, which is how the audio |
| 150 | /// device-loss notice earns its place on the strip. |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 |