-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add player time ranges * chore: refacotr player and add basic tests * chore: add logger level tests * chore: add mute/unmute tests * chore: add parser deps for types * fix: update dispose method * chore: restructure files * chore: update bun.lockb * chore: add factory for networkManager * chore: update pipelines --------- Co-authored-by: Dzianis Dashkevich <ddashkevich@brightcove.com>
- Loading branch information
1 parent
63c207e
commit da14e73
Showing
28 changed files
with
832 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export class RequestInterceptorNetworkError extends Error {} | ||
|
||
export class ResponseInterceptorNetworkError extends Error {} | ||
|
||
export class RequestAbortedNetworkError extends Error {} | ||
|
||
export class TimeoutNetworkError extends Error {} | ||
|
||
export class BadStatusNetworkError extends Error { | ||
public readonly response: Response; | ||
|
||
public constructor(response: Response) { | ||
super(); | ||
|
||
this.response = response; | ||
} | ||
} | ||
|
||
export class FetchError extends Error { | ||
public readonly fetchError: TypeError; | ||
|
||
public constructor(fetchError: TypeError) { | ||
super(); | ||
|
||
this.fetchError = fetchError; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
import type NetworkManager from '../network/networkManager'; | ||
import type Logger from '../utils/logger'; | ||
|
||
interface PipelineDependencies { | ||
logger: Logger; | ||
} | ||
|
||
export default abstract class Pipeline { | ||
public abstract loadRemoteAsset(uri: string): void; | ||
private readonly logger: Logger; | ||
|
||
public constructor(dependencies: PipelineDependencies) { | ||
this.logger = dependencies.logger; | ||
} | ||
|
||
protected mapProtocolToNetworkManager = new Map<string, NetworkManager>(); | ||
|
||
public loadRemoteAsset(uri: URL): void { | ||
const networkManager = this.mapProtocolToNetworkManager.get(uri.protocol); | ||
|
||
if (!networkManager) { | ||
// trigger error; | ||
return; | ||
} | ||
|
||
return this.loadRemoteAssetWithNetworkManager(uri, networkManager); | ||
} | ||
|
||
public abstract loadRemoteAssetWithNetworkManager(uri: URL, networkManager: NetworkManager): void; | ||
|
||
public abstract loadLocalAsset(asset: string | ArrayBuffer): void; | ||
|
||
public setMapProtocolToNetworkManager(map: Map<string, NetworkManager>): void { | ||
this.mapProtocolToNetworkManager = map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const PipelineEvents = {} as const; |
1 change: 1 addition & 0 deletions
1
packages/playback/src/lib/pipelines/events/pipelineEventTypeToEventMap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface PipelinePlayerEventTypeToEventMap {} |
21 changes: 17 additions & 4 deletions
21
packages/playback/src/lib/pipelines/mse/dash/dashPipeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
import MsePipeLine from '../msePipeline'; | ||
import type NetworkManager from '../../../network/networkManager'; | ||
|
||
export default class DashPipeline extends MsePipeLine { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public loadLocalAsset(asset: string | ArrayBuffer): void { | ||
//TODO | ||
public loadRemoteAssetWithNetworkManager(uri: URL, networkManager: NetworkManager): void { | ||
// if (this.progressiveParser) { | ||
// load and parse progressively | ||
// } | ||
// if (this.fullPlaylistParser) { | ||
// load and parse sequentially | ||
// } | ||
//trigger error; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public loadRemoteAsset(uri: string): void { | ||
//TODO | ||
public loadLocalAsset(asset: string | ArrayBuffer): void { | ||
// if (this.fullPlaylistParser) { | ||
// just parse | ||
// } | ||
// if (this.progressiveParser) { | ||
// push | ||
// } | ||
// trigger error; | ||
} | ||
} |
37 changes: 33 additions & 4 deletions
37
packages/playback/src/lib/pipelines/mse/hls/hlsPipeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
import type { FullPlaylistParser, ProgressiveParser } from '@videojs/hls-parser'; | ||
import MsePipeLine from '../msePipeline'; | ||
import type NetworkManager from '../../../network/networkManager'; | ||
|
||
export default class HlsPipeline extends MsePipeLine { | ||
private progressiveParser: ProgressiveParser | null = null; | ||
private fullPlaylistParser: FullPlaylistParser | null = null; | ||
|
||
public setProgressiveParser(parser: ProgressiveParser): void { | ||
this.progressiveParser = parser; | ||
} | ||
|
||
public setFullPlaylistParser(parser: FullPlaylistParser): void { | ||
this.fullPlaylistParser = parser; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public loadLocalAsset(asset: string | ArrayBuffer): void { | ||
//TODO | ||
public loadRemoteAssetWithNetworkManager(uri: URL, networkManager: NetworkManager): void { | ||
if (this.progressiveParser) { | ||
// load and parse progressively | ||
} | ||
|
||
if (this.fullPlaylistParser) { | ||
// load and parse sequentially | ||
} | ||
|
||
//trigger error; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public loadRemoteAsset(uri: string): void { | ||
//TODO | ||
public loadLocalAsset(asset: string | ArrayBuffer): void { | ||
if (this.fullPlaylistParser) { | ||
// just parse | ||
} | ||
|
||
if (this.progressiveParser) { | ||
// push | ||
} | ||
|
||
// trigger error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import Pipeline from '../basePipeline'; | ||
import type NetworkManager from '../../network/networkManager'; | ||
|
||
export default abstract class MsePipeLine extends Pipeline { | ||
public abstract loadLocalAsset(asset: string | ArrayBuffer): void; | ||
|
||
public abstract loadRemoteAsset(uri: string): void; | ||
public abstract loadRemoteAssetWithNetworkManager(uri: URL, networkManager: NetworkManager): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/playback/src/lib/player/configuration/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// interface NetworkConfiguration { | ||
// maxAttempts: number; | ||
// delay: number; | ||
// delayFactor: number; | ||
// fuzzFactor: number; | ||
// timeout: number; | ||
// } | ||
// | ||
// interface StreamingConfiguration { | ||
// network: NetworkConfiguration; | ||
// } | ||
// | ||
// interface HlsConfiguration extends StreamingConfiguration {} | ||
// | ||
// interface DashConfiguration extends StreamingConfiguration {} | ||
// | ||
// export interface PlayerConfiguration { | ||
// hls: HlsConfiguration; | ||
// dash: DashConfiguration; | ||
// } | ||
|
||
interface PlayerConfiguration {} | ||
|
||
export const createDefaultConfiguration = (): PlayerConfiguration => ({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const ErrorCategory = { | ||
Pipeline: 'Pipeline', | ||
Network: 'Network', | ||
} as const; | ||
|
||
export const PipelineErrorCodes = { | ||
NoSupportedPipeline: 'NoSupportedPipeline', | ||
} as const; | ||
|
||
export const NetworkErrorCodes = { | ||
NoNetworkManagerRegisteredForProtocol: 'NoNetworkManagerRegisteredForProtocol', | ||
} as const; | ||
|
||
export type ErrorCode = keyof typeof PipelineErrorCodes | keyof typeof NetworkErrorCodes; |
Oops, something went wrong.