Skip to content

Commit a66d589

Browse files
committed
Improve DASH player configuration and buffering
1 parent 2031b41 commit a66d589

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

packages/app/src/cores/player/classes/AudioBase.js

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,15 @@ export default class AudioBase {
8181
this.console.timeEnd("instanciate class")
8282
}
8383

84-
if (
85-
manifest.mpd_mode === true &&
86-
!manifest.dash_manifest &&
87-
this.demuxer
88-
) {
84+
if (manifest.mpd_mode === true && !manifest.dash_manifest && this.demuxer) {
8985
this.console.time("fetch")
9086
const manifestString = await fetch(manifest.source).then((res) =>
9187
res.text(),
9288
)
9389
this.console.timeEnd("fetch")
9490

9591
this.console.time("parse mpd")
96-
manifest.dash_manifest = await MPDParser(
97-
manifestString,
98-
manifest.source,
99-
)
92+
manifest.dash_manifest = await MPDParser(manifestString, manifest.source)
10093
this.console.timeEnd("parse mpd")
10194
}
10295

@@ -247,14 +240,51 @@ export default class AudioBase {
247240
streaming: {
248241
//cacheInitSegments: true,
249242
buffer: {
250-
bufferTimeAtTopQuality: 15,
251-
initialBufferLevel: 1,
243+
bufferTimeAtTopQuality: 30,
244+
bufferTimeAtTopQualityLongForm: 60,
245+
bufferTimeDefault: 20,
246+
initialBufferLevel: 5,
247+
bufferToKeep: 10,
248+
longFormContentDurationThreshold: 300,
249+
stallThreshold: 0.5,
250+
bufferPruningInterval: 30,
251+
},
252+
abr: {
253+
initialBitrate: {
254+
audio: 128,
255+
},
256+
rules: {
257+
insufficientBufferRule: {
258+
active: true,
259+
parameters: {
260+
bufferLevel: 0.3,
261+
},
262+
},
263+
switchHistoryRule: {
264+
active: true,
265+
parameters: {
266+
sampleSize: 8,
267+
},
268+
},
269+
},
270+
throughput: {
271+
averageCalculationMode: "slidingWindow",
272+
slidingWindowSize: 20,
273+
ewmaHalfLife: 4,
274+
},
275+
},
276+
retrySettings: {
277+
maxRetries: 5,
278+
retryDelayMs: 1000,
279+
retryBackoffFactor: 2,
280+
},
281+
requests: {
282+
requestTimeout: 30000,
283+
xhrWithCredentials: false,
252284
},
253285
},
254286
})
255287

256-
//this.demuxer.setAutoPlay(false)
257-
258288
// Event listeners
259289
this.demuxer.on(dashjs.MediaPlayer.events.ERROR, (event) => {
260290
console.error("Demuxer error", event)

0 commit comments

Comments
 (0)