Skip to content

Commit

Permalink
remove IRepresentationStreamPlaybackObservation
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent-Bouisset committed Oct 31, 2024
1 parent e630bb5 commit 6791b75
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ import {
getLastSegmentBeforePeriod,
SegmentSinkOperation,
} from "../../segment_sinks";
import type {
IRepresentationsChoice,
IRepresentationStreamPlaybackObservation,
} from "../representation";
import type { IRepresentationsChoice } from "../representation";
import type { IAdaptationStreamPlaybackObservation } from "./types";

export default function getRepresentationsSwitchingStrategy(
period: IPeriod,
adaptation: IAdaptation,
settings: IRepresentationsChoice,
segmentSink: SegmentSink,
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>,
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>,
): IRepresentationSwitchStrategy {
if (settings.switchingMode === "lazy") {
return { type: "continue", value: undefined };
Expand Down
14 changes: 8 additions & 6 deletions src/core/stream/adaptation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import type {
IAudioTrackSwitchingMode,
IVideoTrackSwitchingMode,
} from "../../../public_types";
import type { IRange } from "../../../utils/ranges";
import type { IReadOnlySharedReference } from "../../../utils/reference";
import type { IRepresentationEstimator } from "../../adaptive";
import type { SegmentQueueCreator } from "../../fetchers";
import type { IBufferType, SegmentSink } from "../../segment_sinks";
import type { IPeriodStreamPlaybackObservation } from "../period";
import type {
IRepresentationsChoice,
IRepresentationStreamCallbacks,
IRepresentationStreamPlaybackObservation,
} from "../representation";

/** Callbacks called by the `AdaptationStream` on various events. */
Expand Down Expand Up @@ -112,16 +113,17 @@ export interface INeedsBufferFlushPayload {

/** Regular playback information needed by the AdaptationStream. */
export interface IAdaptationStreamPlaybackObservation
extends IRepresentationStreamPlaybackObservation {
extends Omit<IPeriodStreamPlaybackObservation, "buffered"> {
/**
* For the current SegmentSink, difference in seconds between the next position
* where no segment data is available and the current position.
*/
bufferGap: number;
/** `duration` property of the HTMLMediaElement on which the content plays. */
duration: number;
/** Theoretical maximum position on the content that can currently be played. */
maximumPosition: number;
/**
* Ranges of buffered data for the adaptation media type.
* `null` if no buffer exists for the media type.
*/
buffered: IRange[] | null;
}

/** Arguments given when creating a new `AdaptationStream`. */
Expand Down
24 changes: 3 additions & 21 deletions src/core/stream/representation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import type {
IRepresentation,
} from "../../../manifest";
import type { IEMSG } from "../../../parsers/containers/isobmff";
import type {
ObservationPosition,
IReadOnlyPlaybackObserver,
} from "../../../playback_observer";
import type { IReadOnlyPlaybackObserver } from "../../../playback_observer";
import type {
IAudioRepresentationsSwitchingMode,
IPlayerError,
Expand All @@ -20,6 +17,7 @@ import type { IRange } from "../../../utils/ranges";
import type { IReadOnlySharedReference } from "../../../utils/reference";
import type { SegmentQueue } from "../../fetchers";
import type { IBufferType, SegmentSink } from "../../segment_sinks";
import type { IAdaptationStreamPlaybackObservation } from "../adaptation";

/** Callbacks called by the `RepresentationStream` on various events. */
export interface IRepresentationStreamCallbacks {
Expand Down Expand Up @@ -178,22 +176,6 @@ export interface IBufferDiscontinuity {
end: number | null;
}

/** Object that should be emitted by the given `IReadOnlyPlaybackObserver`. */
export interface IRepresentationStreamPlaybackObservation {
/**
* Information on the current media position in seconds at the time of a
* Playback Observation.
*/
position: ObservationPosition;
/**
* Information on whether the media element was paused at the time of the
* Observation.
*/
paused: IPausedPlaybackObservation;
/** Last "playback rate" asked by the user. */
speed: number;
}

/** Pause-related information linked to an emitted Playback observation. */
export interface IPausedPlaybackObservation {
/**
Expand Down Expand Up @@ -269,7 +251,7 @@ export interface IRepresentationStreamArguments<TSegmentDataType> {
*/
terminate: IReadOnlySharedReference<null | ITerminationOrder>;
/** Periodically emits the current playback conditions. */
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>;
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>;
/** Supplementary arguments which configure the RepresentationStream's behavior. */
options: IRepresentationStreamOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
IPushChunkInfos,
SegmentSink,
} from "../../../segment_sinks";
import type { IRepresentationStreamPlaybackObservation } from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";

/**
* Append a segment to the given segmentSink.
Expand All @@ -46,7 +46,7 @@ import type { IRepresentationStreamPlaybackObservation } from "../types";
* @returns {Promise}
*/
export default async function appendSegmentToBuffer<T>(
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>,
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>,
segmentSink: SegmentSink,
dataInfos: IPushChunkInfos<T> & { inventoryInfos: IInsertedChunkInfos },
bufferGoal: IReadOnlySharedReference<number>,
Expand Down
9 changes: 3 additions & 6 deletions src/core/stream/representation/utils/get_buffer_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ import type {
SegmentSink,
} from "../../../segment_sinks";
import SegmentSinksStore, { SegmentSinkOperation } from "../../../segment_sinks";
import type {
IBufferDiscontinuity,
IRepresentationStreamPlaybackObservation,
IQueuedSegment,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";
import type { IBufferDiscontinuity, IQueuedSegment } from "../types";
import checkForDiscontinuity from "./check_for_discontinuity";
import getNeededSegments from "./get_needed_segments";
import getSegmentPriority from "./get_segment_priority";
Expand Down Expand Up @@ -92,7 +89,7 @@ export default function getBufferStatus(
representation: IRepresentation;
},
initialWantedTime: number,
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>,
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>,
fastSwitchThreshold: number | undefined,
bufferGoal: number,
maxBufferSize: number,
Expand Down
8 changes: 3 additions & 5 deletions src/core/stream/representation/utils/push_init_segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import objectAssign from "../../../../utils/object_assign";
import type { IReadOnlySharedReference } from "../../../../utils/reference";
import type { CancellationSignal } from "../../../../utils/task_canceller";
import type { IPushedChunkData, SegmentSink } from "../../../segment_sinks";
import type {
IRepresentationStreamPlaybackObservation,
IStreamEventAddedSegmentPayload,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";
import type { IStreamEventAddedSegmentPayload } from "../types";
import appendSegmentToBuffer from "./append_segment_to_buffer";

/**
Expand All @@ -47,7 +45,7 @@ export default async function pushInitSegment<T>(
segmentSink,
bufferGoal,
}: {
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>;
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>;
content: {
adaptation: IAdaptation;
manifest: IManifest;
Expand Down
8 changes: 3 additions & 5 deletions src/core/stream/representation/utils/push_media_segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ import objectAssign from "../../../../utils/object_assign";
import type { IReadOnlySharedReference } from "../../../../utils/reference";
import type { CancellationSignal } from "../../../../utils/task_canceller";
import type { SegmentSink } from "../../../segment_sinks";
import type {
IRepresentationStreamPlaybackObservation,
IStreamEventAddedSegmentPayload,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";
import type { IStreamEventAddedSegmentPayload } from "../types";
import appendSegmentToBuffer from "./append_segment_to_buffer";

/**
Expand All @@ -50,7 +48,7 @@ export default async function pushMediaSegment<T>(
segment,
segmentSink,
}: {
playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>;
playbackObserver: IReadOnlyPlaybackObserver<IAdaptationStreamPlaybackObservation>;
content: {
adaptation: IAdaptation;
manifest: IManifest;
Expand Down

0 comments on commit 6791b75

Please sign in to comment.