mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-26 04:02:51 +02:00
refactor(streaming): extract delay resume helpers from startStream
The delayed-HLS branch inline-computed two things: the resume segment number parsed from the existing delay playlist (last-or-previous line's _<n>.ts index), and the delay sleep seconds (delay_minutes*60 reduced ~10s per already-produced segment, floored at 0). Pull both into pure resolveDelaySegmentStart() and resolveDelaySleepTime() helpers with unit tests. The playlist merge and the short-playlist abort stay inline. No behaviour change. Verified: phpstan level 5 green, phpunit 391/391, make gates green.
This commit is contained in:
@@ -322,4 +322,33 @@ final class StreamProcessMovieOutputTest extends TestCase {
|
||||
$this->assertSame(1080, $out['codecs']['video']['height']);
|
||||
$this->assertSame('aac', $out['codecs']['audio']['codec_name']);
|
||||
}
|
||||
|
||||
// ── resolveDelaySegmentStart / resolveDelaySleepTime (delay) ─
|
||||
|
||||
public function testDelaySegmentStartFromLastLine(): void {
|
||||
// last line is this stream's segment: _4.ts -> resume at 5.
|
||||
$this->assertSame(5, $this->call('resolveDelaySegmentStart', ['#EXTINF:6,', '77_4.ts'], 77));
|
||||
}
|
||||
|
||||
public function testDelaySegmentStartFromPrevLineWhenLastNotOwn(): void {
|
||||
// last line isn't a segment of this stream -> fall back to prev line.
|
||||
$this->assertSame(9, $this->call('resolveDelaySegmentStart', ['77_8.ts', '#EXTINF:6,'], 77));
|
||||
}
|
||||
|
||||
public function testDelaySegmentStartZeroWhenNoTsIndex(): void {
|
||||
$this->assertSame(0, $this->call('resolveDelaySegmentStart', ['#EXTM3U', '#EXT-X-VERSION:3'], 77));
|
||||
}
|
||||
|
||||
public function testDelaySleepTimeFullWhenFresh(): void {
|
||||
$this->assertSame(300, $this->call('resolveDelaySleepTime', 5, 0));
|
||||
}
|
||||
|
||||
public function testDelaySleepTimeReducedPerSegment(): void {
|
||||
$this->assertSame(270, $this->call('resolveDelaySleepTime', 5, 4)); // 300 - (4-1)*10
|
||||
$this->assertSame(300, $this->call('resolveDelaySleepTime', 5, 1)); // (1-1)*10 = 0
|
||||
}
|
||||
|
||||
public function testDelaySleepTimeClampedToZero(): void {
|
||||
$this->assertSame(0, $this->call('resolveDelaySleepTime', 1, 100)); // 60 - 990 -> 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user