aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-09-05 17:21:44 +0200
committerChocobozzz <me@florianbigard.com>2019-09-05 17:21:44 +0200
commitb82df0a39910e2cb079bf7f9f92de3ec2b0b09aa (patch)
tree9a89cceb3b0b61284f66108c98f42feea96c67b2 /client/src/assets/player
parent1eb23e12f757dc4e9a6161b1b933f35a761755c3 (diff)
downloadPeerTube-b82df0a39910e2cb079bf7f9f92de3ec2b0b09aa.tar.gz
PeerTube-b82df0a39910e2cb079bf7f9f92de3ec2b0b09aa.tar.zst
PeerTube-b82df0a39910e2cb079bf7f9f92de3ec2b0b09aa.zip
Cleanup HLS redundancy manager in client
With the new p2p-media-loader release
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts2
-rw-r--r--client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts17
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
3class RedundancyUrlManager { 3class 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 () {