Commit Graph
4 Commits
Author SHA1 Message Date
Divarion_D 9168853419 refactor(monitor): dedupe segment-duration handling into persistSegmentDuration
The label195 and label562 probe blocks each clamped the probed of_duration to
10s, wrote it to the stream's _.dur file and raised $rSegmentTime -- identical
seven-line cores. Extract them into a shared persistSegmentDuration() helper
returning [clamped probe, updated segment time], with unit tests (temp
STREAMS_PATH). No control-flow change; behaviour preserved.

Verified: phpstan level 5 green, phpunit 11 monitor tests green, make gates green.
2026-08-08 20:03:30 +03:00
Divarion_D 0020b11bec refactor(monitor): extract resolveStreamCodecMeta from the label562 block
The post-start block derived player compatibility, audio/video codec names and
the resolution (snapped to the nearest standard height) inline from the
stream_info JSON. Pull it into a pure resolveStreamCodecMeta() helper with unit
tests. No control-flow change; behaviour preserved.

Verified: phpstan level 5 green, phpunit 9 monitor tests green, make gates green.
2026-08-08 19:58:07 +03:00
Divarion_D 5e92e521da refactor(monitor): extract isAutoRestartDue from the label195 goto chain
The scheduled auto-restart check was three chained `if (!cond) goto label195;`
statements testing the configured days + HH:MM against the current
weekday/hour/minute. Replace them with a pure isAutoRestartDue() predicate
(injectable for tests) and a single `goto label195`. Two more gotos gone
(47 -> 45), and the schedule logic is unit tested.

Verified: phpstan level 5 green, phpunit 6 monitor tests green, make gates green.
2026-08-08 19:54:59 +03:00
Divarion_D e7ceb42699 refactor(monitor): extract parseFrameRate from the FPS-check goto cluster
First step of untangling MonitorCommand::execute()'s obfuscated goto control
flow. The FPS baseline computation flattened a "30/1" -> 30.0 rational parse
across five labels (label768/780/1047/1052/1057). Pull the pure parse into
parseFrameRate() with unit tests; the label768 entry and the label1847 exit are
kept so control flow is unchanged -- four labels and their gotos are gone.

Guards a zero denominator (PHP 8 would otherwise throw on "x/0") -- an input
ffprobe does not produce, so behaviour is unchanged in practice.

PHPStan cannot see the self::parseFrameRate call through the surrounding goto
maze and reports the method unused; baselined until the label768 region is
destructured, then the entry drops out.

Verified: phpstan level 5 green, phpunit 408/408, make gates green.
2026-08-08 19:28:37 +03:00