aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/p2p-media-loader
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/p2p-media-loader')
-rw-r--r--client/src/assets/player/p2p-media-loader/segment-validator.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/client/src/assets/player/p2p-media-loader/segment-validator.ts b/client/src/assets/player/p2p-media-loader/segment-validator.ts
index 9add35184..844956d6a 100644
--- a/client/src/assets/player/p2p-media-loader/segment-validator.ts
+++ b/client/src/assets/player/p2p-media-loader/segment-validator.ts
@@ -6,11 +6,14 @@ type SegmentsJSON = { [filename: string]: string | { [byterange: string]: string
6 6
7const maxRetries = 3 7const maxRetries = 3
8 8
9function segmentValidatorFactory (segmentsSha256Url: string) { 9function segmentValidatorFactory (segmentsSha256Url: string, isLive: boolean) {
10 let segmentsJSON = fetchSha256Segments(segmentsSha256Url) 10 let segmentsJSON = fetchSha256Segments(segmentsSha256Url)
11 const regex = /bytes=(\d+)-(\d+)/ 11 const regex = /bytes=(\d+)-(\d+)/
12 12
13 return async function segmentValidator (segment: Segment, retry = 1) { 13 return async function segmentValidator (segment: Segment, retry = 1) {
14 // Wait for hash generation from the server
15 if (isLive) await wait(1000)
16
14 const filename = basename(segment.url) 17 const filename = basename(segment.url)
15 18
16 const segmentValue = (await segmentsJSON)[filename] 19 const segmentValue = (await segmentsJSON)[filename]
@@ -20,10 +23,10 @@ function segmentValidatorFactory (segmentsSha256Url: string) {
20 } 23 }
21 24
22 if (!segmentValue) { 25 if (!segmentValue) {
23 await wait(1000)
24
25 console.log('Refetching sha segments for %s.', filename) 26 console.log('Refetching sha segments for %s.', filename)
26 27
28 await wait(1000)
29
27 segmentsJSON = fetchSha256Segments(segmentsSha256Url) 30 segmentsJSON = fetchSha256Segments(segmentsSha256Url)
28 await segmentValidator(segment, retry + 1) 31 await segmentValidator(segment, retry + 1)
29 32