Skip to content

Commit 2ae626e

Browse files
committed
CoreInterface: Rename files and classes
1 parent e4cfe39 commit 2ae626e

43 files changed

Lines changed: 3572 additions & 5144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/README.md

Lines changed: 88 additions & 198 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { config } from "../../../experimental";
2-
import log from "../../../log";
3-
import type { IAdaptation, IPeriod, IRepresentation } from "../../../manifest";
1+
import { config } from "../../experimental";
2+
import log from "../../log";
3+
import type { IAdaptation, IPeriod, IRepresentation } from "../../manifest";
44
import type {
55
IFreezingStatus,
66
IRebufferingStatus,
77
ObservationPosition,
8-
} from "../../../playback_observer";
9-
import getMonotonicTimeStamp from "../../../utils/monotonic_timestamp";
10-
import type SegmentSinksStore from "../../segment_sinks";
11-
import type { IBufferedChunk } from "../../segment_sinks";
8+
} from "../../playback_observer";
9+
import getMonotonicTimeStamp from "../../utils/monotonic_timestamp";
10+
import type SegmentSinksStore from "../segment_sinks";
11+
import type { IBufferedChunk } from "../segment_sinks";
1212

1313
/**
1414
* "Freezing" is a complex situation indicating that playback is not advancing
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| Multithread environment | Should be runnable in a WebWorker entirely |
77

88
[1] In a Multithreading mode, no file from that directory should ever be imported by
9-
external code but the `WorkerMain` to generate the worker bundle. In a monothreading mode,
9+
external code but the `CoreEntry` to generate the worker bundle. In a monothreading mode,
1010
any file may be directly imported.
1111

1212
## Overview
Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1-
import { MediaSource_ } from "../../../compat/browser_compatibility_types";
2-
import features from "../../../features";
3-
import log from "../../../log";
4-
import type { IManifest } from "../../../manifest";
5-
import { createRepresentationFilterFromFnString } from "../../../manifest";
6-
import type Manifest from "../../../manifest/classes";
7-
import type { IMediaSourceInterface } from "../../../mse";
8-
import MainMediaSourceInterface from "../../../mse/main_media_source_interface";
9-
import WorkerMediaSourceInterface from "../../../mse/worker_media_source_interface";
10-
import type {
11-
IAttachMediaSourceWorkerMessagePayload,
12-
IContentInitializationData,
13-
IWorkerMessage,
14-
} from "../../../multithread_types";
15-
import { WorkerMessageType } from "../../../multithread_types";
16-
import type { IPlayerError } from "../../../public_types";
17-
import idGenerator from "../../../utils/id_generator";
18-
import isNullOrUndefined from "../../../utils/is_null_or_undefined";
19-
import type {
20-
CancellationError,
21-
CancellationSignal,
22-
} from "../../../utils/task_canceller";
23-
import TaskCanceller from "../../../utils/task_canceller";
24-
import type { IRepresentationEstimator } from "../../adaptive";
25-
import createAdaptiveRepresentationSelector from "../../adaptive";
26-
import type { IRepresentationEstimatorThrottlers } from "../../adaptive/adaptive_representation_selector";
27-
import CmcdDataBuilder from "../../cmcd";
28-
import type { IManifestRefreshSettings } from "../../fetchers";
29-
import { ManifestFetcher, SegmentQueueCreator } from "../../fetchers";
30-
import CdnPrioritizer from "../../fetchers/cdn_prioritizer";
31-
import createThumbnailFetcher from "../../fetchers/thumbnails/thumbnail_fetcher";
32-
import type { IThumbnailFetcher } from "../../fetchers/thumbnails/thumbnail_fetcher";
33-
import SegmentSinksStore from "../../segment_sinks";
34-
import FreezeResolver from "../common/FreezeResolver";
1+
import { MediaSource_ } from "../../compat/browser_compatibility_types";
2+
import features from "../../features";
3+
import log from "../../log";
4+
import type { IContentInitializationData } from "../../main_thread/types";
5+
import type { IManifest } from "../../manifest";
6+
import { createRepresentationFilterFromFnString } from "../../manifest";
7+
import type Manifest from "../../manifest/classes";
8+
import type { IMediaSourceInterface } from "../../mse";
9+
import MainMediaSourceInterface from "../../mse/main_media_source_interface";
10+
import WorkerMediaSourceInterface from "../../mse/worker_media_source_interface";
11+
import type { IPlayerError } from "../../public_types";
12+
import idGenerator from "../../utils/id_generator";
13+
import isNullOrUndefined from "../../utils/is_null_or_undefined";
14+
import type { CancellationError, CancellationSignal } from "../../utils/task_canceller";
15+
import TaskCanceller from "../../utils/task_canceller";
16+
import type { IRepresentationEstimator } from "../adaptive";
17+
import createAdaptiveRepresentationSelector from "../adaptive";
18+
import type { IRepresentationEstimatorThrottlers } from "../adaptive/adaptive_representation_selector";
19+
import CmcdDataBuilder from "../cmcd";
20+
import type { IManifestRefreshSettings } from "../fetchers";
21+
import { ManifestFetcher, SegmentQueueCreator } from "../fetchers";
22+
import CdnPrioritizer from "../fetchers/cdn_prioritizer";
23+
import createThumbnailFetcher from "../fetchers/thumbnails/thumbnail_fetcher";
24+
import type { IThumbnailFetcher } from "../fetchers/thumbnails/thumbnail_fetcher";
25+
import SegmentSinksStore from "../segment_sinks";
26+
import type { IAttachMediaSourceCoreMessagePayload, ICoreMessage } from "../types";
27+
import { CoreMessageType } from "../types";
28+
import CoreTextDisplayerInterface from "./core_text_displayer_interface";
29+
import FreezeResolver from "./FreezeResolver";
3530
import TrackChoiceSetter from "./track_choice_setter";
3631
import { formatErrorForSender } from "./utils";
37-
import WorkerTextDisplayerInterface from "./worker_text_displayer_interface";
3832

3933
/** Function allowing to associate a unique identifier to all created `MediaSource` */
4034
const generateMediaSourceId = idGenerator();
@@ -110,7 +104,7 @@ export default class ContentPreparer {
110104
* @returns {Promise.<Object>}
111105
*/
112106
public initializeNewContent(
113-
sendMessage: (msg: IWorkerMessage, transferables?: Transferable[]) => void,
107+
sendMessage: (msg: ICoreMessage, transferables?: Transferable[]) => void,
114108
context: IContentInitializationData,
115109
/** Allows to filter which Representations can be choosen. */
116110
throttlers: IRepresentationEstimatorThrottlers,
@@ -192,7 +186,7 @@ export default class ContentPreparer {
192186

193187
const trackChoiceSetter = new TrackChoiceSetter();
194188

195-
const [mediaSource, segmentSinksStore, workerTextSender] =
189+
const [mediaSource, segmentSinksStore, coreTextSender] =
196190
createMediaSourceInterfaceAndSegmentSinksStore(
197191
sendMessage,
198192
contentId,
@@ -216,7 +210,7 @@ export default class ContentPreparer {
216210
segmentSinksStore,
217211
segmentQueueCreator,
218212
fetchThumbnailData,
219-
workerTextSender,
213+
coreTextSender,
220214
trackChoiceSetter,
221215
useMseInWorker,
222216
};
@@ -235,7 +229,7 @@ export default class ContentPreparer {
235229
"warning",
236230
(err: IPlayerError) => {
237231
sendMessage({
238-
type: WorkerMessageType.Warning,
232+
type: CoreMessageType.Warning,
239233
contentId,
240234
value: formatErrorForSender(err),
241235
});
@@ -261,7 +255,7 @@ export default class ContentPreparer {
261255
"error",
262256
(err: unknown) => {
263257
sendMessage({
264-
type: WorkerMessageType.Error,
258+
type: CoreMessageType.Error,
265259
contentId,
266260
value: formatErrorForSender(err),
267261
});
@@ -288,7 +282,7 @@ export default class ContentPreparer {
288282
return;
289283
}
290284
sendMessage({
291-
type: WorkerMessageType.ManifestUpdate,
285+
type: CoreMessageType.ManifestUpdate,
292286
contentId,
293287
value: { manifest, updates },
294288
});
@@ -323,13 +317,16 @@ export default class ContentPreparer {
323317
}
324318

325319
/**
326-
* Signal the ContentPreparer that the MediaSource is "reloading".
320+
* Change the MediaSource attached for the current content.
321+
* It is assumed that main thread is already notified that such a reload is
322+
* happening.
327323
*
328324
* The returned Promise resolves when it restarts being ready.
325+
* @param {Function} sendMessage
329326
* @returns {Promise}
330327
*/
331328
public reloadMediaSource(
332-
sendMessage: (msg: IWorkerMessage, transferables?: Transferable[]) => void,
329+
sendMessage: (msg: ICoreMessage, transferables?: Transferable[]) => void,
333330
): Promise<void> {
334331
this._currentMediaSourceCanceller.cancel();
335332
if (this._currentContent === null) {
@@ -338,21 +335,21 @@ export default class ContentPreparer {
338335
this._currentContent.trackChoiceSetter.reset();
339336
this._currentMediaSourceCanceller = new TaskCanceller();
340337

341-
const [mediaSourceInterface, segmentSinksStore, workerTextSender] =
338+
const [mediaSourceInterface, segmentSinksStore, coreTextSender] =
342339
createMediaSourceInterfaceAndSegmentSinksStore(
343340
sendMessage,
344341
this._currentContent.contentId,
345342
{
346343
useMseInWorker: this._currentContent.useMseInWorker,
347344
hasVideo: this._hasVideo,
348-
hasText: this._currentContent.workerTextSender !== null,
345+
hasText: this._currentContent.coreTextSender !== null,
349346
},
350347
this._currentMediaSourceCanceller.signal,
351348
);
352349
this._currentContent.mediaSource = mediaSourceInterface;
353350
this._currentContent.segmentSinksStore = segmentSinksStore;
354351
this._currentContent.freezeResolver = new FreezeResolver(segmentSinksStore);
355-
this._currentContent.workerTextSender = workerTextSender;
352+
this._currentContent.coreTextSender = coreTextSender;
356353
return new Promise((res, rej) => {
357354
mediaSourceInterface.addEventListener(
358355
"mediaSourceOpen",
@@ -435,7 +432,7 @@ export interface IPreparedContentData {
435432
*/
436433
segmentSinksStore: SegmentSinksStore;
437434
/** Allows to send timed text media data so it can be rendered. */
438-
workerTextSender: WorkerTextDisplayerInterface | null;
435+
coreTextSender: CoreTextDisplayerInterface | null;
439436
/**
440437
* Allows to create `SegmentQueue` which simplifies complex media segment
441438
* fetching.
@@ -467,21 +464,21 @@ export interface IPreparedContentData {
467464
* @returns {Array.<Object>}
468465
*/
469466
function createMediaSourceInterfaceAndSegmentSinksStore(
470-
sendMessage: (msg: IWorkerMessage, transferables?: Transferable[]) => void,
467+
sendMessage: (msg: ICoreMessage, transferables?: Transferable[]) => void,
471468
contentId: string,
472469
capabilities: {
473470
useMseInWorker: boolean;
474471
hasVideo: boolean;
475472
hasText: boolean;
476473
},
477474
cancelSignal: CancellationSignal,
478-
): [IMediaSourceInterface, SegmentSinksStore, WorkerTextDisplayerInterface | null] {
475+
): [IMediaSourceInterface, SegmentSinksStore, CoreTextDisplayerInterface | null] {
479476
let mediaSourceInterface: IMediaSourceInterface;
480477
if (capabilities.useMseInWorker) {
481478
const mainMediaSource = new MainMediaSourceInterface(generateMediaSourceId());
482479
mediaSourceInterface = mainMediaSource;
483480

484-
let sentMediaSourceLink: IAttachMediaSourceWorkerMessagePayload;
481+
let sentMediaSourceLink: IAttachMediaSourceCoreMessagePayload;
485482
const handle = mainMediaSource.handle;
486483
if (handle.type === "handle") {
487484
sentMediaSourceLink = { type: "handle" as const, value: handle.value };
@@ -495,7 +492,7 @@ function createMediaSourceInterfaceAndSegmentSinksStore(
495492

496493
sendMessage(
497494
{
498-
type: WorkerMessageType.AttachMediaSource,
495+
type: CoreMessageType.AttachMediaSource,
499496
contentId,
500497
value: sentMediaSourceLink,
501498
mediaSourceId: mediaSourceInterface.id,
@@ -511,7 +508,7 @@ function createMediaSourceInterfaceAndSegmentSinksStore(
511508
}
512509

513510
const textSender = capabilities.hasText
514-
? new WorkerTextDisplayerInterface(contentId, sendMessage)
511+
? new CoreTextDisplayerInterface(contentId, sendMessage)
515512
: null;
516513
const { hasVideo } = capabilities;
517514
const segmentSinksStore = new SegmentSinksStore(

src/core/main/common/content_time_boundaries_observer.ts renamed to src/core/entry/content_time_boundaries_observer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
import type {
1818
IStreamOrchestratorPlaybackObservation,
1919
IBufferType,
20-
} from "../../../core/types";
21-
import { MediaError } from "../../../errors";
20+
} from "../../core/types";
21+
import { MediaError } from "../../errors";
2222
import type {
2323
IManifest,
2424
IAdaptation,
2525
IRepresentationIndex,
2626
IPeriod,
27-
} from "../../../manifest";
28-
import type { IReadOnlyPlaybackObserver } from "../../../playback_observer";
29-
import type { IPlayerError } from "../../../public_types";
30-
import EventEmitter from "../../../utils/event_emitter";
31-
import isNullOrUndefined from "../../../utils/is_null_or_undefined";
32-
import queueMicrotask from "../../../utils/queue_microtask";
33-
import SortedList from "../../../utils/sorted_list";
34-
import TaskCanceller from "../../../utils/task_canceller";
27+
} from "../../manifest";
28+
import type { IReadOnlyPlaybackObserver } from "../../playback_observer";
29+
import type { IPlayerError } from "../../public_types";
30+
import EventEmitter from "../../utils/event_emitter";
31+
import isNullOrUndefined from "../../utils/is_null_or_undefined";
32+
import queueMicrotask from "../../utils/queue_microtask";
33+
import SortedList from "../../utils/sorted_list";
34+
import TaskCanceller from "../../utils/task_canceller";
3535

3636
/**
3737
* Observes what's being played and take care of media events relating to time

0 commit comments

Comments
 (0)