diff options
Diffstat (limited to 'client/src/assets/player/p2p-media-loader')
-rw-r--r-- | client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts | 2 | ||||
-rw-r--r-- | client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts | 17 |
2 files changed, 2 insertions, 17 deletions
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts index 0c8c612ee..c44c184d5 100644 --- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts +++ b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts | |||
@@ -92,7 +92,7 @@ class P2pMediaLoaderPlugin extends Plugin { | |||
92 | this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => { | 92 | this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => { |
93 | console.error('Segment error.', segment, err) | 93 | console.error('Segment error.', segment, err) |
94 | 94 | ||
95 | this.options.redundancyUrlManager.removeByOriginUrl(segment.url) | 95 | this.options.redundancyUrlManager.removeBySegmentUrl(segment.requestUrl) |
96 | }) | 96 | }) |
97 | 97 | ||
98 | this.statsP2PBytes.numPeers = 1 + this.options.redundancyUrlManager.countBaseUrls() | 98 | this.statsP2PBytes.numPeers = 1 + this.options.redundancyUrlManager.countBaseUrls() |
diff --git a/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts b/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts index 7fc2b6ab1..abab8aa99 100644 --- a/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts +++ b/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts | |||
@@ -2,9 +2,6 @@ import { basename, dirname } from 'path' | |||
2 | 2 | ||
3 | class RedundancyUrlManager { | 3 | class RedundancyUrlManager { |
4 | 4 | ||
5 | // Remember by what new URL we replaced an origin URL | ||
6 | private replacedSegmentUrls: { [originUrl: string]: string } = {} | ||
7 | |||
8 | constructor (private baseUrls: string[] = []) { | 5 | constructor (private baseUrls: string[] = []) { |
9 | // empty | 6 | // empty |
10 | } | 7 | } |
@@ -17,16 +14,7 @@ class RedundancyUrlManager { | |||
17 | this.baseUrls = this.baseUrls.filter(u => u !== baseUrl && u !== baseUrl + '/') | 14 | this.baseUrls = this.baseUrls.filter(u => u !== baseUrl && u !== baseUrl + '/') |
18 | } | 15 | } |
19 | 16 | ||
20 | removeByOriginUrl (originUrl: string) { | ||
21 | const replaced = this.replacedSegmentUrls[originUrl] | ||
22 | if (!replaced) return | ||
23 | |||
24 | return this.removeBySegmentUrl(replaced) | ||
25 | } | ||
26 | |||
27 | buildUrl (url: string) { | 17 | buildUrl (url: string) { |
28 | delete this.replacedSegmentUrls[url] | ||
29 | |||
30 | const max = this.baseUrls.length + 1 | 18 | const max = this.baseUrls.length + 1 |
31 | const i = this.getRandomInt(max) | 19 | const i = this.getRandomInt(max) |
32 | 20 | ||
@@ -35,10 +23,7 @@ class RedundancyUrlManager { | |||
35 | const newBaseUrl = this.baseUrls[i] | 23 | const newBaseUrl = this.baseUrls[i] |
36 | const slashPart = newBaseUrl.endsWith('/') ? '' : '/' | 24 | const slashPart = newBaseUrl.endsWith('/') ? '' : '/' |
37 | 25 | ||
38 | const newUrl = newBaseUrl + slashPart + basename(url) | 26 | return newBaseUrl + slashPart + basename(url) |
39 | this.replacedSegmentUrls[url] = newUrl | ||
40 | |||
41 | return newUrl | ||
42 | } | 27 | } |
43 | 28 | ||
44 | countBaseUrls () { | 29 | countBaseUrls () { |