mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 21:38:15 +00:00
make vlc range cache startup non-blocking
This commit is contained in:
parent
c4236afe7a
commit
f141d26fb5
6 changed files with 424 additions and 4 deletions
|
|
@ -43,6 +43,9 @@ struct StreamResolverTests {
|
|||
testRangeCacheForegroundMissFetchesAlignedChunks()
|
||||
await testRangeCacheForegroundMissReprioritizesPrefetch()
|
||||
await testRangeCacheHitFollowsActualPostSeekReadArea()
|
||||
testRangeCacheStartupPolicySkipsHLSAndNonHTTPImmediately()
|
||||
testRangeCacheStartupPolicyUsesCacheOnlyForConclusiveProbe()
|
||||
testRangeCacheStartupPolicySkipsInconclusiveProbe()
|
||||
await testRangeProbeAllowsRangeCacheForMKVWhenServerSupportsRanges()
|
||||
await testRangeProbeAppliesRequestTimeout()
|
||||
await testRangeProbeFallsBackWhenServerIgnoresRange()
|
||||
|
|
@ -542,6 +545,41 @@ struct StreamResolverTests {
|
|||
try? await Task.sleep(nanoseconds: 50_000_000)
|
||||
}
|
||||
|
||||
private static func testRangeCacheStartupPolicySkipsHLSAndNonHTTPImmediately() {
|
||||
assertEqual(
|
||||
HTTPRangeCacheStartupPolicy.immediateSkipReason(for: URL(string: "https://cdn.example.test/live.m3u8")!),
|
||||
"hls-playlist"
|
||||
)
|
||||
assertEqual(
|
||||
HTTPRangeCacheStartupPolicy.immediateSkipReason(for: URL(string: "file:///tmp/movie.mkv")!),
|
||||
"non-http-url"
|
||||
)
|
||||
assertEqual(
|
||||
HTTPRangeCacheStartupPolicy.immediateSkipReason(for: URL(string: "https://cdn.example.test/movie.mkv")!),
|
||||
nil
|
||||
)
|
||||
}
|
||||
|
||||
private static func testRangeCacheStartupPolicyUsesCacheOnlyForConclusiveProbe() {
|
||||
let decision = HTTPRangeCacheStartupPolicy.decision(
|
||||
for: HTTPRangeProbeResult(isCacheable: true, contentLength: 20, fallbackReason: nil)
|
||||
)
|
||||
|
||||
assertEqual(decision, .useLocalCache)
|
||||
}
|
||||
|
||||
private static func testRangeCacheStartupPolicySkipsInconclusiveProbe() {
|
||||
let rejectedDecision = HTTPRangeCacheStartupPolicy.decision(
|
||||
for: HTTPRangeProbeResult(isCacheable: false, contentLength: nil, fallbackReason: "range-probe-status-200")
|
||||
)
|
||||
let missingLengthDecision = HTTPRangeCacheStartupPolicy.decision(
|
||||
for: HTTPRangeProbeResult(isCacheable: true, contentLength: nil, fallbackReason: nil)
|
||||
)
|
||||
|
||||
assertEqual(rejectedDecision, .skip(reason: "range-probe-status-200"))
|
||||
assertEqual(missingLengthDecision, .skip(reason: "range-probe-inconclusive"))
|
||||
}
|
||||
|
||||
private static func testRangeProbeAllowsRangeCacheForMKVWhenServerSupportsRanges() async {
|
||||
var requestCount = 0
|
||||
MockURLProtocol.handler = { request in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue