Commit 1658ea5
Fix MJPEG fallback glitch: serialize pipeline + guard decoder (#44)
* Fix MJPEG fallback glitch: serialize pipeline + guard decoder
- Serialize rebuildPipeline with a Mutex and make currentCodecMode
@volatile so viewport rebuilds and codec switches can't race into
dual encoders (VideoEncoder + JpegEncoder) with a last-write-wins
VD surface.
- Collapse onCodecModeRequest into a delegate that sets the mode and
reruns rebuildPipeline under the lock — single code path for
encoder/VD setup.
- Client: MJPEG decoder drops non-JPEG payloads (magic-byte check) to
avoid InvalidStateError spam during the codec-switch startup window.
- Client: for MJPEG mode, open the control socket and wait for it
before connecting video, so the server receives the codec preference
before streaming starts.
- Split drawer: group apps by category (Navigation/Video/Music/Apps)
with colored section headers.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Extract codec-mode transition guard into testable pure policy
The "should a codec-mode request trigger a rebuild?" decision was
inline inside MirrorForegroundService.onCodecModeRequest, which is
an Android Service and therefore not reachable from JVM unit tests.
Moving the three-line guard into a CodecModeTransition pure object
lets the decision table be covered directly (non-mjpeg rejected,
already-mjpeg-with-encoder no-op, and the stale-mode recovery case
where the mode flag is "mjpeg" but the JpegEncoder is missing).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 549c15d commit 1658ea5
6 files changed
Lines changed: 191 additions & 75 deletions
File tree
- app/src
- main
- assets/web
- js
- java/com/castla/mirror
- policy
- service
- test/java/com/castla/mirror/policy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1050 | 1062 | | |
1051 | 1063 | | |
1052 | 1064 | | |
| |||
1218 | 1230 | | |
1219 | 1231 | | |
1220 | 1232 | | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1221 | 1240 | | |
1222 | | - | |
1223 | | - | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1224 | 1244 | | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1229 | 1248 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
| 1249 | + | |
| 1250 | + | |
1234 | 1251 | | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1238 | 1287 | | |
1239 | 1288 | | |
1240 | | - | |
| 1289 | + | |
| 1290 | + | |
1241 | 1291 | | |
1242 | 1292 | | |
1243 | 1293 | | |
| |||
1557 | 1607 | | |
1558 | 1608 | | |
1559 | 1609 | | |
1560 | | - | |
1561 | | - | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
1562 | 1622 | | |
1563 | 1623 | | |
1564 | 1624 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 19 additions & 59 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
170 | | - | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
2871 | 2875 | | |
2872 | 2876 | | |
2873 | 2877 | | |
2874 | | - | |
| 2878 | + | |
2875 | 2879 | | |
2876 | 2880 | | |
2877 | 2881 | | |
| |||
2887 | 2891 | | |
2888 | 2892 | | |
2889 | 2893 | | |
2890 | | - | |
| 2894 | + | |
2891 | 2895 | | |
2892 | 2896 | | |
2893 | 2897 | | |
2894 | 2898 | | |
2895 | | - | |
| 2899 | + | |
2896 | 2900 | | |
2897 | 2901 | | |
2898 | 2902 | | |
| |||
3023 | 3027 | | |
3024 | 3028 | | |
3025 | 3029 | | |
3026 | | - | |
3027 | | - | |
3028 | | - | |
3029 | | - | |
3030 | | - | |
3031 | | - | |
3032 | | - | |
3033 | | - | |
3034 | | - | |
3035 | | - | |
3036 | | - | |
3037 | | - | |
3038 | | - | |
3039 | | - | |
3040 | | - | |
3041 | | - | |
3042 | | - | |
3043 | | - | |
3044 | | - | |
3045 | | - | |
3046 | | - | |
3047 | | - | |
3048 | | - | |
3049 | | - | |
3050 | | - | |
3051 | | - | |
3052 | | - | |
3053 | | - | |
3054 | | - | |
3055 | | - | |
3056 | | - | |
3057 | | - | |
3058 | | - | |
3059 | | - | |
3060 | | - | |
3061 | | - | |
3062 | | - | |
3063 | | - | |
3064 | | - | |
3065 | | - | |
3066 | | - | |
3067 | | - | |
3068 | | - | |
3069 | | - | |
3070 | | - | |
3071 | | - | |
3072 | | - | |
3073 | | - | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
3074 | 3038 | | |
3075 | | - | |
3076 | | - | |
3077 | | - | |
3078 | | - | |
3079 | | - | |
3080 | | - | |
| 3039 | + | |
| 3040 | + | |
3081 | 3041 | | |
3082 | | - | |
| 3042 | + | |
3083 | 3043 | | |
3084 | 3044 | | |
3085 | 3045 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments