Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions src/mediasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
let subtitlesRequestTimeout = 5000
let failoverResetTimeMs = 120000

// Array of CDN names that failed for the playback session
// and we added back in after 120 seconds (failoverResetTimeMs)
const failBackCdns: string[] = []

function init(media: MediaDescriptor, setAudioDescribedOn?: boolean): Promise<void> {
return new Promise((resolve, reject) => {
if (!media.urls?.length) {
Expand Down Expand Up @@ -81,6 +85,7 @@
}

function failover(failoverParams: FailoverParams): Promise<void> {
console.log('*** Failover! ***');

Check failure on line 88 in src/mediasources.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
return new Promise((resolve, reject) => {
if (!isFailoverInfoValid(failoverParams)) {
return reject(new TypeError("Invalid failover params"))
Expand Down Expand Up @@ -278,15 +283,24 @@
sources[currentSources] = failoverSort(sources[currentSources])
}

const failoverResetToken = setTimeout(() => {
if (mediaSource == null || sources[currentSources].length === 0) return

DebugTool.info(`${mediaSource.cdn} has been added back in to available CDNs`)
sources[currentSources].push(mediaSource)
updateDebugOutput()
}, failoverResetTimeMs)

failoverResetTokens.push(failoverResetToken as unknown as number)
const hasFailedBack = failBackCdns.includes(mediaSource.cdn);

// If CDN does not exist in failBackCdns, add
// back in to the available mediasource CDNs
if (!hasFailedBack) {
const failoverResetToken = setTimeout(() => {
console.log('*** Adding CDN back! ***')

Check failure on line 292 in src/mediasources.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
if (mediaSource == null || sources[currentSources].length === 0) return

DebugTool.info(`${mediaSource.cdn} has been added back in to available CDNs`)
sources[currentSources].push(mediaSource)

updateDebugOutput()
}, failoverResetTimeMs)

failoverResetTokens.push(failoverResetToken as unknown as number)
failBackCdns.push(mediaSource.cdn);
}
}

function updateCdns(serviceLocation: string | undefined): void {
Expand Down
Loading