Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 4963c44

Browse files
committed
resource requester: force requesting to CDN on decodingError
1 parent 1ccb92b commit 4963c44

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/resource_requester.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,23 @@ class ResourceRequester extends BaseObject {
1515
this.cdnRequester = new CDNRequester()
1616
this.p2pManager = new P2PManager(params)
1717
this.isInitialBuffer = true
18-
this.sameSource = 0
18+
this.decodingError = false
1919
}
2020

2121
requestResource(resource, bufferLength, callback) {
22-
if (resource === this.resource) {
23-
this.sameSource += 1
24-
}
2522
this.resource = resource
2623
this.callback = callback
27-
if (bufferLength < Settings.lowBufferLength || this.isInitialBuffer || _.size(this.p2pManager.swarm.utils.contributors) === 0 || this.sameSource >= 3) {
24+
if (this.decodingError) {
25+
this.requestToCDN()
26+
} else if (bufferLength < Settings.lowBufferLength || this.isInitialBuffer || _.size(this.p2pManager.swarm.utils.contributors) === 0) {
2827
this.requestToCDN()
29-
this.sameSource = 0
3028
} else {
3129
this.requestToP2P()
3230
}
3331
}
3432

3533
requestToCDN() {
34+
log.info("getting from CDN: " + this.resource)
3635
this.cdnRequester.requestResource(this.resource, this.callback)
3736
}
3837

0 commit comments

Comments
 (0)