diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-03 13:36:19 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-03 14:24:54 +0200 |
| commit | 67af4248c97d2e1568e5c22179fa0026dbbc5219 (patch) | |
| tree | 1d48024f64c2eda25628d81fc4dced98088aff10 /packages/meshbay-android/app/src/test | |
| parent | 721ad9b77f7513d341e3c7aa4817d1c2474f749e (diff) | |
| download | meshbay-67af4248c97d2e1568e5c22179fa0026dbbc5219.tar.gz | |
fix(android): the cast header is everything before the first moof
The node's first chunk can be the 28-byte ftyp alone, the moov in the next;
served as the header, the receiver had no moov and gave up. A receiver early
for the header now waits for all of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-android/app/src/test')
| -rw-r--r-- | packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt index 1c604d0..5d3125f 100644 --- a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt +++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt @@ -106,6 +106,31 @@ class CastRelayTest { assertArrayEquals("header, then each fragment once", stream, reply.body) } + @Test fun `a header split across chunks is served whole`() { + // Measured on a fresh start: the first chunk was the 28-byte ftyp + // alone, the moov came in the next push. Served as the header, the + // receiver had no moov and gave up — the first cast failed every time. + val ftyp = box("ftyp", 20) + val moov = box("moov", 2124) + val started = relay.start(ftyp, null) + val url = started.getString("url") + // The page pushes the first chunk too, then the rest. + relay.push(ftyp); relay.push(moov); relay.push(fragment(1)); relay.push(fragment(2)) + val reply = get(url, readBytes = ftyp.size + moov.size + fragment(1).size + fragment(2).size) + assertArrayEquals(ftyp + moov + fragment(1) + fragment(2), reply.body) + } + + @Test fun `a receiver early for the header waits for all of it`() { + val ftyp = box("ftyp", 20) + val moov = box("moov", 2124) + val url = relay.start(ftyp, null).getString("url") + relay.push(ftyp) + val late = Thread { Thread.sleep(400); relay.push(moov); relay.push(fragment(1)) }.apply { start() } + val reply = get(url, readBytes = ftyp.size + moov.size + fragment(1).size) + late.join() + assertArrayEquals(ftyp + moov + fragment(1), reply.body) + } + @Test fun `the token is required and unguessable`() { val url = relay.start(null, null).getString("url") val token = url.substringAfter("t=") |