Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Aug 31, 2023
1 parent 3bed407 commit 3a7df03
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/core/api/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
const segmentBufferStatus = this._priv_contentInfos
.segmentBuffersStore.getStatus(bufferType);
return segmentBufferStatus.type === "initialized" ?
segmentBufferStatus.value.getInventory() :
segmentBufferStatus.value.getLastKnownInventory() :
null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/init/utils/rebuffering_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export default class RebufferingController
let isClear = true;
for (const status of [statusAudio, statusVideo]) {
if (status.type === "initialized") {
for (const segment of status.value.getInventory()) {
for (const segment of status.value.getLastKnownInventory()) {
const { representation } = segment.infos;
if (representation.decipherable === false) {
log.warn(
Expand Down
16 changes: 10 additions & 6 deletions src/core/segment_buffers/implementations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,18 @@ export abstract class SegmentBuffer {
) : Promise<void>;

/**
* Returns the currently buffered data for which the content is known with
* the corresponding content information.
* /!\ This data can fall out of sync with the real buffered ranges. Please
* call `synchronizeInventory` before to make sure it is correctly
* synchronized.
* Returns an inventory of the last known segments to be currently contained in
* the SegmentBuffer.
*
* /!\ Note that this data may not be up-to-date with the real current content
* of the SegmentBuffer.
* Generally speaking, pushed segments are added right away to it but segments
* may have been since removed, which might not be known right away.
* Please consider this when using this method, by considering that it does
* not reflect the full reality of the underlying buffer.
* @returns {Array.<Object>}
*/
public getInventory() : IBufferedChunk[] {
public getLastKnownInventory() : IBufferedChunk[] {
// The default implementation just use the SegmentInventory
return this._segmentInventory.getInventory();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function getRepresentationsSwitchingStrategy(
return { type: "continue", value: undefined };
}

const inventory = segmentBuffer.getInventory();
const inventory = segmentBuffer.getLastKnownInventory();

/** Data already in the right Adaptation */
const rangesWithReps =
Expand Down
3 changes: 1 addition & 2 deletions src/core/stream/orchestrator/get_time_ranges_for_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ export default function getTimeRangesForContent(
if (contents.length === 0) {
return [];
}
// segmentBuffer.synchronizeInventory();
const accumulator : IRange[] = [];
const inventory = segmentBuffer.getInventory();
const inventory = segmentBuffer.getLastKnownInventory();

for (let i = 0; i < inventory.length; i++) {
const chunk = inventory[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function getAdaptationSwitchStrategy(
return { type: "continue", value: undefined };
}

const inventory = segmentBuffer.getInventory();
const inventory = segmentBuffer.getLastKnownInventory();

// Continue if we have no other Adaptation buffered in the current Period
if (!inventory.some(buf => buf.infos.period.id === period.id &&
Expand Down
2 changes: 1 addition & 1 deletion src/core/stream/representation/utils/get_buffer_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function getBufferStatus(
const bufferedSegments =
getPlayableBufferedSegments({ start: Math.max(neededRange.start - 0.5, 0),
end: neededRange.end + 0.5 },
segmentBuffer.getInventory());
segmentBuffer.getLastKnownInventory());
let currentPlaybackTime = playbackObserver.getCurrentTime();
if (currentPlaybackTime === undefined) {
// We're in a WebWorker, just consider the last known position
Expand Down

0 comments on commit 3a7df03

Please sign in to comment.