Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacto current position handling again just to work-around tizen mischievous seek-backs #1327

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
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
25 changes: 4 additions & 21 deletions src/core/adaptive/adaptive_representation_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import SharedReference, {
import TaskCanceller, {
CancellationSignal,
} from "../../utils/task_canceller";
import { IReadOnlyPlaybackObserver } from "../api";
import { IObservationPosition, IReadOnlyPlaybackObserver } from "../api";
import { IBufferType } from "../segment_buffers";
import BufferBasedChooser from "./buffer_based_chooser";
import GuessBasedChooser from "./guess_based_chooser";
Expand Down Expand Up @@ -272,7 +272,7 @@ function getEstimateReference(
}
const { position, speed } = lastPlaybackObservation;
const timeRanges = val.buffered;
const bufferGap = getLeftSizeOfBufferedTimeRange(timeRanges, position.last);
const bufferGap = getLeftSizeOfBufferedTimeRange(timeRanges, position.getWanted());
const { representation } = val.content;
const currentScore = scoreCalculator.getEstimate(representation);
const currentBitrate = representation.bitrate;
Expand Down Expand Up @@ -389,7 +389,7 @@ function getEstimateReference(
if (lowLatencyMode &&
currentRepresentationVal !== null &&
context.manifest.isDynamic &&
maximumPosition - position.last < 40)
maximumPosition - position.getWanted() < 40)
{
chosenRepFromGuessMode = guessBasedChooser
.getGuess(sortedRepresentations,
Expand Down Expand Up @@ -595,24 +595,7 @@ export interface IRepresentationEstimatorPlaybackObservation {
* Information on the current media position in seconds at the time of a
* Playback Observation.
*/
position : {
/**
* Known position at the time the Observation was emitted, in seconds.
*
* Note that it might have changed since. If you want truly precize
* information, you should recuperate it from the HTMLMediaElement directly
* through another mean.
*/
last : number;
/**
* Actually wanted position in seconds that is not yet reached.
*
* This might for example be set to the initial position when the content is
* loading (and thus potentially at a `0` position) but which will be seeked
* to a given position once possible.
*/
pending : number | undefined;
};
position : IObservationPosition;
/**
* Last "playback rate" set by the user. This is the ideal "playback rate" at
* which the media should play.
Expand Down
6 changes: 3 additions & 3 deletions src/core/adaptive/network_analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function estimateStarvationModeBitrate(
const { bufferGap, speed, position } = playbackInfo;
const realBufferGap = isFinite(bufferGap) ? bufferGap :
0;
const nextNeededPosition = position.last + realBufferGap;
const nextNeededPosition = position.getWanted() + realBufferGap;
const concernedRequests = getConcernedRequests(pendingRequests, nextNeededPosition);

if (concernedRequests.length !== 1) { // 0 == no request
Expand Down Expand Up @@ -238,7 +238,7 @@ function shouldDirectlySwitchToLowBitrate(
}
const realBufferGap = isFinite(playbackInfo.bufferGap) ? playbackInfo.bufferGap :
0;
const nextNeededPosition = playbackInfo.position.last + realBufferGap;
const nextNeededPosition = playbackInfo.position.getWanted() + realBufferGap;
const nextRequest = arrayFind(requests, ({ content }) =>
content.segment.duration > 0 &&
(content.segment.time + content.segment.duration) > nextNeededPosition);
Expand Down Expand Up @@ -334,7 +334,7 @@ export default class NetworkAnalyzer {
const { ABR_STARVATION_DURATION_DELTA } = config.getCurrent();
// check if should get in/out of starvation mode
if (isNaN(duration) ||
realBufferGap + position.last < duration - ABR_STARVATION_DURATION_DELTA)
realBufferGap + position.getWanted() < duration - ABR_STARVATION_DURATION_DELTA)
{
if (!this._inStarvationMode && realBufferGap <= localConf.starvationGap) {
log.info("ABR: enter starvation mode.");
Expand Down
1 change: 1 addition & 0 deletions src/core/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PlaybackObserver from "./playback_observer";
import Player from "./public_api";
export { PlaybackObserver };
export {
IObservationPosition,
IPlaybackObservation,
IPlaybackObserverEventType,
IReadOnlyPlaybackObserver,
Expand Down
Loading
Loading