Skip to content

Commit

Permalink
Include main variant init segments in TTFB sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Nov 28, 2022
1 parent 6e130fb commit b4b3bfd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/controller/abr-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,23 @@ class AbrController implements ComponentAPI {
event: Events.FRAG_LOADED,
{ frag, part }: FragLoadedData
) {
const stats = part ? part.stats : frag.stats;
if (frag.type === PlaylistLevelType.MAIN) {
this.bwEstimator.sampleTTFB(stats.loading.first - stats.loading.start);
}
if (this.ignoreFragment(frag)) {
return;
}
const stats = part ? part.stats : frag.stats;
const duration = part ? part.duration : frag.duration;
// stop monitoring bw once frag loaded
this.clearTimer();
// store level id after successful fragment load
this.lastLoadedFragLevel = frag.level;
// reset forced auto level value so that next level will be selected
this._nextAutoLevel = -1;

this.bwEstimator.sampleTTFB(stats.loading.first - stats.loading.start);

// compute level average bitrate
if (this.hls.config.abrMaxWithRealBitrate) {
const duration = part ? part.duration : frag.duration;
const level = this.hls.levels[frag.level];
const loadedBytes =
(level.loaded ? level.loaded.bytes : 0) + stats.loaded;
Expand Down

0 comments on commit b4b3bfd

Please sign in to comment.