From b82df0a39910e2cb079bf7f9f92de3ec2b0b09aa Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Thu, 5 Sep 2019 17:21:44 +0200
Subject: Cleanup HLS redundancy manager in client

With the new p2p-media-loader release
---
 .../player/p2p-media-loader/p2p-media-loader-plugin.ts  |  2 +-
 .../player/p2p-media-loader/redundancy-url-manager.ts   | 17 +----------------
 2 files changed, 2 insertions(+), 17 deletions(-)

(limited to 'client/src')

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 {
     this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => {
       console.error('Segment error.', segment, err)
 
-      this.options.redundancyUrlManager.removeByOriginUrl(segment.url)
+      this.options.redundancyUrlManager.removeBySegmentUrl(segment.requestUrl)
     })
 
     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'
 
 class RedundancyUrlManager {
 
-  // Remember by what new URL we replaced an origin URL
-  private replacedSegmentUrls: { [originUrl: string]: string } = {}
-
   constructor (private baseUrls: string[] = []) {
     // empty
   }
@@ -17,16 +14,7 @@ class RedundancyUrlManager {
     this.baseUrls = this.baseUrls.filter(u => u !== baseUrl && u !== baseUrl + '/')
   }
 
-  removeByOriginUrl (originUrl: string) {
-    const replaced = this.replacedSegmentUrls[originUrl]
-    if (!replaced) return
-
-    return this.removeBySegmentUrl(replaced)
-  }
-
   buildUrl (url: string) {
-    delete this.replacedSegmentUrls[url]
-
     const max = this.baseUrls.length + 1
     const i = this.getRandomInt(max)
 
@@ -35,10 +23,7 @@ class RedundancyUrlManager {
     const newBaseUrl = this.baseUrls[i]
     const slashPart = newBaseUrl.endsWith('/') ? '' : '/'
 
-    const newUrl = newBaseUrl + slashPart + basename(url)
-    this.replacedSegmentUrls[url] = newUrl
-
-    return newUrl
+    return newBaseUrl + slashPart + basename(url)
   }
 
   countBaseUrls () {
-- 
cgit v1.2.3