@vkontakte/videoplayer-core 2.0.103 → 2.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +73 -27
- package/es2015.esm.js +72 -26
- package/es2018.cjs.js +73 -27
- package/es2018.esm.js +72 -26
- package/esnext.cjs.js +75 -29
- package/esnext.esm.js +73 -27
- package/evergreen.esm.js +73 -27
- package/package.json +7 -7
- package/types/enums/AndroidPreferredFormat.d.ts +8 -0
- package/types/enums/WebmCodecStrategy.d.ts +7 -0
- package/types/env.d.ts +1 -0
- package/types/index.d.ts +12 -0
- package/types/player/Player.d.ts +173 -0
- package/{index.d.ts → types/player/types.d.ts} +64 -391
- package/types/player/utils/optimisticPosition.d.ts +12 -0
- package/types/player/utils/selectContainer.d.ts +3 -0
- package/types/providers/ChromecastProvider/ChromecastInitializer/index.d.ts +31 -0
- package/types/providers/ChromecastProvider/ChromecastInitializer/types.d.ts +23 -0
- package/types/providers/ChromecastProvider/index.d.ts +33 -0
- package/types/providers/DashLiveProvider/DashLiveProvider.d.ts +37 -0
- package/types/providers/DashLiveProvider/index.d.ts +2 -0
- package/types/providers/DashLiveProvider/types.d.ts +21 -0
- package/types/providers/DashLiveProvider/utils/FilesFetcher.d.ts +25 -0
- package/types/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +143 -0
- package/types/providers/DashLiveProvider/utils/ThroughputEstimator.d.ts +33 -0
- package/types/providers/DashLiveProvider/utils/liveDashPlayerUtil.d.ts +42 -0
- package/types/providers/DashProvider/baseDashProvider.d.ts +52 -0
- package/types/providers/DashProvider/consts.d.ts +1 -0
- package/types/providers/DashProvider/dashCmafLiveProvider.d.ts +8 -0
- package/types/providers/DashProvider/dashProvider.d.ts +6 -0
- package/types/providers/DashProvider/index.d.ts +2 -0
- package/types/providers/DashProvider/lib/buffer.d.ts +103 -0
- package/types/providers/DashProvider/lib/fetcher.d.ts +51 -0
- package/types/providers/DashProvider/lib/parsers/mpd.d.ts +3 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/BoxModel.d.ts +20 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/BoxParser.d.ts +21 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/BoxTypeEnum.d.ts +26 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/box.d.ts +79 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/equi.d.ts +21 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/ftyp.d.ts +17 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/index.d.ts +22 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mdat.d.ts +15 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mdia.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mfhd.d.ts +11 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/minf.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/moof.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/moov.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/prhd.d.ts +16 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/proj.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/sidx.d.ts +48 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/st3d.d.ts +23 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/sv3d.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tfdt.d.ts +17 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tfhd.d.ts +22 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tkhd.d.ts +42 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/traf.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/trak.d.ts +7 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/trun.d.ts +31 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/unknown.d.ts +6 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/boxes/uuid.d.ts +6 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/fullBox.d.ts +15 -0
- package/types/providers/DashProvider/lib/parsers/mpeg/isobmff.d.ts +12 -0
- package/types/providers/DashProvider/lib/parsers/webm/ebml.d.ts +76 -0
- package/types/providers/DashProvider/lib/parsers/webm/webm.d.ts +3 -0
- package/types/providers/DashProvider/lib/player.d.ts +75 -0
- package/types/providers/DashProvider/lib/sourceBufferTaskQueue.d.ts +18 -0
- package/types/providers/DashProvider/lib/types.d.ts +156 -0
- package/types/providers/DashProvider/lib/utils.d.ts +14 -0
- package/types/providers/HlsJsProvider/index.d.ts +24 -0
- package/types/providers/HlsLiveProvider/index.d.ts +30 -0
- package/types/providers/HlsLiveProvider/seekBackTimeExtractor.d.ts +3 -0
- package/types/providers/HlsProvider/index.d.ts +21 -0
- package/types/providers/HlsProvider/manifestDataExtractor.d.ts +21 -0
- package/types/providers/MpegProvider/index.d.ts +20 -0
- package/types/providers/ProviderContainer/index.d.ts +42 -0
- package/types/providers/ProviderContainer/types.d.ts +20 -0
- package/types/providers/ProviderContainer/utils/formatsSupport.d.ts +20 -0
- package/types/providers/ProviderContainer/utils/playbackHangup.d.ts +12 -0
- package/types/providers/WebRTCLiveProvider/WebRTCLiveClient.d.ts +188 -0
- package/types/providers/WebRTCLiveProvider/WebRTCLiveProvider.d.ts +60 -0
- package/types/providers/WebRTCLiveProvider/interface/WebRTCLiveClientOptions.d.ts +9 -0
- package/types/providers/types.d.ts +83 -0
- package/types/providers/utils/HTMLVideoElement/DroppedFramesManager.d.ts +44 -0
- package/types/providers/utils/HTMLVideoElement/TextTrackManager.d.ts +30 -0
- package/types/providers/utils/HTMLVideoElement/clear.d.ts +1 -0
- package/types/providers/utils/HTMLVideoElement/destroy.d.ts +1 -0
- package/types/providers/utils/HTMLVideoElement/forcePlay.d.ts +7 -0
- package/types/providers/utils/HTMLVideoElement/observable.d.ts +25 -0
- package/types/providers/utils/HTMLVideoElement/pool.d.ts +2 -0
- package/types/providers/utils/HTMLVideoElement/surface.d.ts +2 -0
- package/types/providers/utils/LiveOffset/index.d.ts +14 -0
- package/types/providers/utils/LiveOffset/types.d.ts +10 -0
- package/types/providers/utils/addQuicParam.d.ts +2 -0
- package/types/providers/utils/extractConnectionHeaders.d.ts +6 -0
- package/types/providers/utils/generateLiveUrl.d.ts +9 -0
- package/types/providers/utils/okQualityStringToVideoQuality.d.ts +3 -0
- package/types/providers/utils/parseFps.d.ts +1 -0
- package/types/providers/utils/syncDesiredState.d.ts +12 -0
- package/types/providers/utils/syncPlaybackState.d.ts +4 -0
- package/types/utils/3d/Camera3D.d.ts +14 -0
- package/types/utils/3d/CameraRotationManager.d.ts +62 -0
- package/types/utils/3d/Scene3D.d.ts +132 -0
- package/types/utils/3d/types.d.ts +25 -0
- package/types/utils/StateMachine/StateMachine.d.ts +19 -0
- package/types/utils/StateMachine/types.d.ts +60 -0
- package/types/utils/StatefulIterator/index.d.ts +13 -0
- package/types/utils/ThroughputEstimator.d.ts +25 -0
- package/types/utils/addScript.d.ts +2 -0
- package/types/utils/autoSelectVideoTrack.d.ts +26 -0
- package/types/utils/buffer/getBufferedRangeForPosition.d.ts +3 -0
- package/types/utils/buffer/getForwardBufferDuration.d.ts +3 -0
- package/types/utils/buffer/getTotalBufferDuration.d.ts +3 -0
- package/types/utils/buffer/isPositionBuffered.d.ts +3 -0
- package/types/utils/changePlaybackRate.d.ts +2 -0
- package/types/utils/hostnameFromUrl.d.ts +2 -0
- package/types/utils/isInPiP.d.ts +1 -0
- package/types/utils/link.d.ts +2 -0
- package/types/utils/mediaSource.d.ts +8 -0
- package/types/utils/observeElementVisibility.d.ts +3 -0
- package/types/utils/playbackTelemetry.d.ts +12 -0
- package/types/utils/setStateWithSubscribe.d.ts +3 -0
- package/types/utils/smoothedValue/baseSmoothedValue.d.ts +18 -0
- package/types/utils/smoothedValue/emaAndMaSmoothedValue.d.ts +7 -0
- package/types/utils/smoothedValue/emaTopExtremumValue.d.ts +10 -0
- package/types/utils/smoothedValue/smoothedValueFactory.d.ts +6 -0
- package/types/utils/smoothedValue/twoEmaSmoothedValue.d.ts +8 -0
- package/types/utils/smoothedValue/types.d.ts +26 -0
- package/types/utils/smoothedValue/utils.d.ts +3 -0
- package/types/utils/tuningConfig.d.ts +164 -0
- package/types/utils/videoFormat.d.ts +2 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Byte, IError, ISubject, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
declare class SourceBufferTaskQueue {
|
|
3
|
+
bufferFull$: ISubject<Byte>;
|
|
4
|
+
error$: ISubject<IError>;
|
|
5
|
+
private buffer;
|
|
6
|
+
private queue;
|
|
7
|
+
private currentTask;
|
|
8
|
+
private destroyed;
|
|
9
|
+
constructor(buffer: SourceBuffer);
|
|
10
|
+
append(data: BufferSource, signal?: AbortSignal): Promise<boolean>;
|
|
11
|
+
remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
|
|
12
|
+
abort(init?: BufferSource): Promise<boolean>;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
private completeTask;
|
|
15
|
+
private pull;
|
|
16
|
+
private execute;
|
|
17
|
+
}
|
|
18
|
+
export default SourceBufferTaskQueue;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Byte, Kbps, Milliseconds, IRange, IObservable, ISubject, IValueSubject } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { IDesiredState, IProviderOutput, IProviderParams } from '../../../providers/types';
|
|
3
|
+
import { IObservableVideo } from '../../../providers/utils/HTMLVideoElement/observable';
|
|
4
|
+
import { IDashURLSource } from '../../../player/types';
|
|
5
|
+
export declare enum RepresentationKind {
|
|
6
|
+
VIDEO = "video",
|
|
7
|
+
AUDIO = "audio",
|
|
8
|
+
TEXT = "text"
|
|
9
|
+
}
|
|
10
|
+
export declare enum LiveStatus {
|
|
11
|
+
ActiveLowLatency = 0,
|
|
12
|
+
LiveWithTargetOffset = 1,
|
|
13
|
+
LiveForwardBuffering = 2,
|
|
14
|
+
None = 3
|
|
15
|
+
}
|
|
16
|
+
export declare enum Profile {
|
|
17
|
+
WEBM_AS_IN_SPEC = "urn:mpeg:dash:profile:webm-on-demand:2012",
|
|
18
|
+
WEBM_AS_IN_FFMPEG = "urn:webm:dash:profile:webm-on-demand:2012"
|
|
19
|
+
}
|
|
20
|
+
export interface Representation {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: RepresentationKind;
|
|
23
|
+
segmentReference: SegmentReference;
|
|
24
|
+
profiles: Array<Profile | string>;
|
|
25
|
+
duration?: Milliseconds;
|
|
26
|
+
bitrate: Kbps;
|
|
27
|
+
mime: string;
|
|
28
|
+
codecs: string;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
fps?: number;
|
|
32
|
+
quality?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare enum SegmentReferencingType {
|
|
35
|
+
BYTE_RANGE = "byteRange",
|
|
36
|
+
TEMPLATE = "template"
|
|
37
|
+
}
|
|
38
|
+
export type ByteRangeSegmentReference = {
|
|
39
|
+
type: SegmentReferencingType.BYTE_RANGE;
|
|
40
|
+
url: string;
|
|
41
|
+
initRange: IRange<Byte>;
|
|
42
|
+
indexRange?: IRange<Byte>;
|
|
43
|
+
};
|
|
44
|
+
export type TemplateSegmentReference = {
|
|
45
|
+
type: SegmentReferencingType.TEMPLATE;
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
initUrl: string;
|
|
48
|
+
segmentTemplateUrl: string;
|
|
49
|
+
totalSegmentsDurationMs: Milliseconds;
|
|
50
|
+
segments: {
|
|
51
|
+
url: string;
|
|
52
|
+
time: IRange<Milliseconds>;
|
|
53
|
+
}[];
|
|
54
|
+
nextSegmentBeyondManifest: {
|
|
55
|
+
url: string;
|
|
56
|
+
time: IRange<Milliseconds>;
|
|
57
|
+
};
|
|
58
|
+
timescale: number;
|
|
59
|
+
};
|
|
60
|
+
export type SegmentReference = ByteRangeSegmentReference | TemplateSegmentReference;
|
|
61
|
+
export interface ByteRangeSegment {
|
|
62
|
+
status: SegmentStatus;
|
|
63
|
+
time: IRange<Milliseconds>;
|
|
64
|
+
byte: IRange<Byte>;
|
|
65
|
+
}
|
|
66
|
+
export interface TemplateSegment {
|
|
67
|
+
status: SegmentStatus;
|
|
68
|
+
time: IRange<Milliseconds>;
|
|
69
|
+
size?: Byte;
|
|
70
|
+
url: string;
|
|
71
|
+
}
|
|
72
|
+
export type Segment = ByteRangeSegment | TemplateSegment;
|
|
73
|
+
export declare enum SegmentStatus {
|
|
74
|
+
NONE = "none",
|
|
75
|
+
DOWNLOADING = "downloading",
|
|
76
|
+
DOWNLOADED = "downloaded",
|
|
77
|
+
PARTIALLY_FED = "partially_fed",
|
|
78
|
+
PARTIALLY_EJECTED = "partially_ejected",
|
|
79
|
+
FED = "fed"
|
|
80
|
+
}
|
|
81
|
+
export interface Manifest {
|
|
82
|
+
dynamic: boolean;
|
|
83
|
+
liveAvailabilityStartTime: Milliseconds | undefined;
|
|
84
|
+
duration: Milliseconds | undefined;
|
|
85
|
+
container: Container;
|
|
86
|
+
representations: {
|
|
87
|
+
[key in RepresentationKind]: Representation[];
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export declare enum Container {
|
|
91
|
+
MP4 = "mp4",
|
|
92
|
+
WEBM = "webm"
|
|
93
|
+
}
|
|
94
|
+
export declare enum ProjectionType {
|
|
95
|
+
RECTANGULAR = 0,
|
|
96
|
+
EQUIRECTANGULAR = 1,
|
|
97
|
+
CUBEMAP = 2,
|
|
98
|
+
MESH = 3
|
|
99
|
+
}
|
|
100
|
+
export interface BoxLike {
|
|
101
|
+
id: string;
|
|
102
|
+
size: Byte;
|
|
103
|
+
contents: DataView;
|
|
104
|
+
}
|
|
105
|
+
export interface GenericContainerParser<InitData> {
|
|
106
|
+
validateData(data: DataView): boolean;
|
|
107
|
+
getIndexRange(init: InitData): IRange<Byte> | undefined;
|
|
108
|
+
parseInit(data: DataView): InitData;
|
|
109
|
+
parseSegments(data: DataView, init: InitData, indexRange?: IRange<Byte>): Segment[];
|
|
110
|
+
parseFeedableSegmentChunk(data: DataView, isLive?: boolean): DataView | null;
|
|
111
|
+
}
|
|
112
|
+
export interface CommonInit {
|
|
113
|
+
is3dVideo: boolean;
|
|
114
|
+
stereoMode?: number;
|
|
115
|
+
projectionType?: ProjectionType;
|
|
116
|
+
projectionData?: {
|
|
117
|
+
pose: {
|
|
118
|
+
yaw: number;
|
|
119
|
+
pitch: number;
|
|
120
|
+
roll: number;
|
|
121
|
+
};
|
|
122
|
+
bounds: {
|
|
123
|
+
top: number;
|
|
124
|
+
bottom: number;
|
|
125
|
+
left: number;
|
|
126
|
+
right: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export interface WebmInit extends CommonInit {
|
|
131
|
+
segmentStart: Byte;
|
|
132
|
+
segmentEnd: Byte;
|
|
133
|
+
timeScale: number;
|
|
134
|
+
segmentDuration: number;
|
|
135
|
+
cuesSeekPosition?: Byte;
|
|
136
|
+
}
|
|
137
|
+
export interface IProviderSubscriptionInfo {
|
|
138
|
+
output: IProviderOutput;
|
|
139
|
+
desiredState: IDesiredState;
|
|
140
|
+
observableVideo: IObservableVideo;
|
|
141
|
+
genericErrorListener: (error: Error | unknown) => void;
|
|
142
|
+
connect: <Value>(from: IObservable<Value>, to: ISubject<Value> | IValueSubject<Value> | ((v: Value) => void)) => void;
|
|
143
|
+
}
|
|
144
|
+
export declare enum ProviderState {
|
|
145
|
+
STOPPED = "stopped",
|
|
146
|
+
READY = "ready",
|
|
147
|
+
PLAYING = "playing",
|
|
148
|
+
PAUSED = "paused"
|
|
149
|
+
}
|
|
150
|
+
export type IParams = IProviderParams<IDashURLSource>;
|
|
151
|
+
export type MpegInit = CommonInit;
|
|
152
|
+
export type WebmParser = GenericContainerParser<WebmInit>;
|
|
153
|
+
export type MpegParser = GenericContainerParser<MpegInit> & {
|
|
154
|
+
getSegmentEndTime(data: DataView, timescale: number): Milliseconds;
|
|
155
|
+
};
|
|
156
|
+
export type ContainerParser = WebmParser | MpegParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Representation, Segment, SegmentReference, TemplateSegment, TemplateSegmentReference } from '../../../providers/DashProvider/lib/types';
|
|
2
|
+
import { IAudioTrack, IInternalTextTrack, IVideoTrack } from '../../../player/types';
|
|
3
|
+
export declare const representationToVideoTrack: ({ id, width, height, bitrate, fps, quality: qualityString }: Representation) => IVideoTrack | undefined;
|
|
4
|
+
export declare const representationToAudioTrack: ({ id, bitrate }: Representation) => IAudioTrack | undefined;
|
|
5
|
+
export declare const selectAudioRepresentation: (audioRepresentations: Representation[], videoRepresentations: Representation[], selectedVideo: Representation) => Representation | undefined;
|
|
6
|
+
export declare const representationToTextTrack: ({ id, lang, label, url, isAuto }: Representation & {
|
|
7
|
+
lang: string;
|
|
8
|
+
label: string;
|
|
9
|
+
url: string;
|
|
10
|
+
isAuto: boolean;
|
|
11
|
+
}) => IInternalTextTrack;
|
|
12
|
+
export declare const isTemplateSegment: (segment: Segment) => segment is TemplateSegment;
|
|
13
|
+
export declare const isTemplateSegmentReference: (segmentReference: SegmentReference) => segmentReference is TemplateSegmentReference;
|
|
14
|
+
export declare const isAbortError: (e: Error | unknown) => boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IHLSSource } from '../../player/types';
|
|
2
|
+
import { IProvider, IProviderParams } from '../../providers/types';
|
|
3
|
+
type Params = IProviderParams<IHLSSource>;
|
|
4
|
+
export default class HlsJsProvider implements IProvider {
|
|
5
|
+
private subscription;
|
|
6
|
+
private videoState;
|
|
7
|
+
private video;
|
|
8
|
+
private params;
|
|
9
|
+
private hls;
|
|
10
|
+
private textTracksManager;
|
|
11
|
+
private trackLevels;
|
|
12
|
+
constructor(params: Params);
|
|
13
|
+
destroy(): void;
|
|
14
|
+
private loadHlsJs;
|
|
15
|
+
private init;
|
|
16
|
+
private subscribe;
|
|
17
|
+
private syncPlayback;
|
|
18
|
+
private prepare;
|
|
19
|
+
private playIfAllowed;
|
|
20
|
+
private pause;
|
|
21
|
+
private seek;
|
|
22
|
+
private stop;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IHLSLiveSource, VideoFormat } from '../../player/types';
|
|
2
|
+
import { IProvider, IProviderParams } from '../../providers/types';
|
|
3
|
+
import { Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
4
|
+
type Params = IProviderParams<IHLSLiveSource> & {
|
|
5
|
+
config: {
|
|
6
|
+
maxPausedTime: Milliseconds;
|
|
7
|
+
};
|
|
8
|
+
format: VideoFormat.HLS_LIVE | VideoFormat.HLS_LIVE_CMAF;
|
|
9
|
+
};
|
|
10
|
+
export default class HlsLiveProvider implements IProvider {
|
|
11
|
+
private subscription;
|
|
12
|
+
private videoState;
|
|
13
|
+
private video;
|
|
14
|
+
private params;
|
|
15
|
+
private textTracksManager;
|
|
16
|
+
private masterManifest;
|
|
17
|
+
private manifests$;
|
|
18
|
+
private maxSeekBackTime$;
|
|
19
|
+
private liveOffset;
|
|
20
|
+
private manifestStartTime$;
|
|
21
|
+
constructor(params: Params);
|
|
22
|
+
private selectManifest;
|
|
23
|
+
private subscribe;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
private prepare;
|
|
26
|
+
private playIfAllowed;
|
|
27
|
+
private seek;
|
|
28
|
+
private syncPlayback;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IHLSSource } from '../../player/types';
|
|
2
|
+
import { IProvider, IProviderParams } from '../../providers/types';
|
|
3
|
+
type Params = IProviderParams<IHLSSource>;
|
|
4
|
+
export default class HlsProvider implements IProvider {
|
|
5
|
+
private subscription;
|
|
6
|
+
private videoState;
|
|
7
|
+
private video;
|
|
8
|
+
private params;
|
|
9
|
+
private textTracksManager;
|
|
10
|
+
private masterManifest;
|
|
11
|
+
private manifests$;
|
|
12
|
+
constructor(params: Params);
|
|
13
|
+
private selectManifest;
|
|
14
|
+
private subscribe;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
private prepare;
|
|
17
|
+
private playIfAllowed;
|
|
18
|
+
private seek;
|
|
19
|
+
private syncPlayback;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Kbps, IRectangle, VideoQuality } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { IInternalTextTrack } from '../../player/types';
|
|
3
|
+
export type ManifestUrl = {
|
|
4
|
+
id: string;
|
|
5
|
+
quality: VideoQuality;
|
|
6
|
+
url: string;
|
|
7
|
+
bandwidth?: Kbps;
|
|
8
|
+
size?: IRectangle;
|
|
9
|
+
fps?: number;
|
|
10
|
+
};
|
|
11
|
+
export type HLSManifestData = {
|
|
12
|
+
qualityManifests: ManifestUrl[];
|
|
13
|
+
textTracks: IInternalTextTrack[];
|
|
14
|
+
};
|
|
15
|
+
type ExtractHLSManifestDataConfig = {
|
|
16
|
+
manifestRetryMaxCount: number;
|
|
17
|
+
manifestRetryInterval: number;
|
|
18
|
+
manifestRetryMaxInterval: number;
|
|
19
|
+
};
|
|
20
|
+
declare const extractHLSManifestData: (masterManifestUrl: string, baseUrl: string | undefined, config: ExtractHLSManifestDataConfig) => Promise<HLSManifestData>;
|
|
21
|
+
export default extractHLSManifestData;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IMpegSource } from '../../player/types';
|
|
2
|
+
import { IProvider, IProviderParams } from '../types';
|
|
3
|
+
type Params = IProviderParams<IMpegSource>;
|
|
4
|
+
export default class MpegProvider implements IProvider {
|
|
5
|
+
private subscription;
|
|
6
|
+
private videoState;
|
|
7
|
+
private video;
|
|
8
|
+
private trackUrls;
|
|
9
|
+
private params;
|
|
10
|
+
private textTracksManager;
|
|
11
|
+
constructor(params: Params);
|
|
12
|
+
private subscribe;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
private prepare;
|
|
15
|
+
private playIfAllowed;
|
|
16
|
+
private seek;
|
|
17
|
+
private syncPlayback;
|
|
18
|
+
private handleQualityLimitTransition;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IMetadata, ISources, VideoFormat } from '../../player/types';
|
|
2
|
+
import { ITuningConfig } from '../../utils/tuningConfig';
|
|
3
|
+
import { IError, ISubject, IValueSubject } from '@vkontakte/videoplayer-shared';
|
|
4
|
+
import { IDesiredState, IProviderDependencies, IProviderOutput } from '../types';
|
|
5
|
+
import { IProviderContainer, IProviderEntry } from './types';
|
|
6
|
+
interface IParams extends IProviderDependencies {
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
sources: ISources;
|
|
9
|
+
meta: IMetadata;
|
|
10
|
+
failoverHosts: string[];
|
|
11
|
+
desiredState: IDesiredState;
|
|
12
|
+
tuning: ITuningConfig;
|
|
13
|
+
}
|
|
14
|
+
export default class ProviderContainer implements IProviderContainer {
|
|
15
|
+
current$: IValueSubject<IProviderEntry>;
|
|
16
|
+
providerError$: ISubject<IError>;
|
|
17
|
+
noAvailableProvidersError$: ISubject<VideoFormat | undefined>;
|
|
18
|
+
providerOutput: IProviderOutput;
|
|
19
|
+
private subscription;
|
|
20
|
+
private screenFormatsIterator;
|
|
21
|
+
private chromecastFormatsIterator;
|
|
22
|
+
private log;
|
|
23
|
+
private params;
|
|
24
|
+
private failoverIndex;
|
|
25
|
+
constructor(params: IParams);
|
|
26
|
+
init(): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
private initProvider;
|
|
29
|
+
private reinitProvider;
|
|
30
|
+
private switchToNextProvider;
|
|
31
|
+
private destroyProvider;
|
|
32
|
+
private createProvider;
|
|
33
|
+
private createScreenProvider;
|
|
34
|
+
private createChromecastProvider;
|
|
35
|
+
private chooseDestination;
|
|
36
|
+
private chooseFormat;
|
|
37
|
+
private skipFormat;
|
|
38
|
+
private handleNoFormatsError;
|
|
39
|
+
private applyFailoverHost;
|
|
40
|
+
private initProviderErrorHandling;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ISubject, IValueObservable, IError } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { VideoDestination, VideoFormat } from '../../player/types';
|
|
3
|
+
import { IProvider, IProviderOutput } from '../types';
|
|
4
|
+
export interface IProviderContainer {
|
|
5
|
+
current$: IValueObservable<IProviderEntry>;
|
|
6
|
+
providerError$: ISubject<IError>;
|
|
7
|
+
noAvailableProvidersError$: ISubject<VideoFormat | undefined>;
|
|
8
|
+
providerOutput: IProviderOutput;
|
|
9
|
+
init(): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
export type IProviderEntry = {
|
|
13
|
+
type: VideoFormat;
|
|
14
|
+
provider: IProvider;
|
|
15
|
+
destination: VideoDestination;
|
|
16
|
+
} | {
|
|
17
|
+
type: undefined;
|
|
18
|
+
provider?: undefined;
|
|
19
|
+
destination?: undefined;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VideoFormat } from '../../../player/types';
|
|
2
|
+
import { ITuningConfig } from '../../../utils/tuningConfig';
|
|
3
|
+
export declare const nativeHlsSupported: boolean;
|
|
4
|
+
export declare const getSupportedCodecs: () => string[];
|
|
5
|
+
export declare const filterAvailableFormats: (formats: VideoFormat[], useHlsJs?: boolean, useManagedMediaSource?: boolean) => VideoFormat[];
|
|
6
|
+
type VodFormat = VideoFormat.MPEG | VideoFormat.DASH_SEP | VideoFormat.DASH_WEBM | VideoFormat.DASH_WEBM_AV1 | VideoFormat.DASH_ONDEMAND | VideoFormat.HLS | VideoFormat.HLS_ONDEMAND;
|
|
7
|
+
type Constraints = Pick<ITuningConfig, 'webmCodec' | 'androidPreferredFormat' | 'preferCMAF' | 'preferWebRTC'>;
|
|
8
|
+
/**
|
|
9
|
+
* Все ONDEMAND форматы ниже готовых эквивалентов потому что ONDEMAND требует серверных ресурсов для нарезки.
|
|
10
|
+
* Из дашей VP9 (WEBM) самый оптимальный
|
|
11
|
+
* Интерливнутый (DASH) устарел и от него отказываемся в пользу DASH_SEP
|
|
12
|
+
* HLS нативно поддерживается в Сафари и на мобильных девайсах, при этом на андроиде он играет плохо
|
|
13
|
+
* MPEG – более-менее пуленепробиваемый формат который играет везде и есть у всех видео (за редкими исключениями), но он не адаптивный
|
|
14
|
+
*/
|
|
15
|
+
export declare const getFormatsPriority: ({ webmCodec, androidPreferredFormat }: Constraints) => VodFormat[];
|
|
16
|
+
type LiveFormat = VideoFormat.WEB_RTC_LIVE | VideoFormat.HLS_LIVE | VideoFormat.DASH_LIVE | VideoFormat.DASH_LIVE_CMAF | VideoFormat.HLS_LIVE_CMAF;
|
|
17
|
+
type AllLiveFormats = [LiveFormat, LiveFormat, LiveFormat, LiveFormat, LiveFormat];
|
|
18
|
+
export declare const getLiveFormatsPriority: ({ androidPreferredFormat, preferCMAF, preferWebRTC }: Constraints) => AllLiveFormats;
|
|
19
|
+
export declare const getChromeCastFormatsPriority: (live: boolean) => VideoFormat[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IProviderEntry } from '../../../providers/ProviderContainer/types';
|
|
2
|
+
import { IObservable, Observable } from '@vkontakte/videoplayer-shared';
|
|
3
|
+
import { IStateMachine } from '../../../utils/StateMachine/types';
|
|
4
|
+
import { PlaybackState } from '../../../player/types';
|
|
5
|
+
interface IParams {
|
|
6
|
+
desiredPlaybackState$: IStateMachine<PlaybackState>;
|
|
7
|
+
position$: IObservable<number>;
|
|
8
|
+
providerChanged$: IObservable<IProviderEntry>;
|
|
9
|
+
maxTransitionInterval: number;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: (params: IParams) => Observable<string>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { WebRTCLiveClientOptions } from '../../providers/WebRTCLiveProvider/interface/WebRTCLiveClientOptions';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export declare class WebRTCLiveClient {
|
|
6
|
+
private options;
|
|
7
|
+
private ws;
|
|
8
|
+
private peerConnection;
|
|
9
|
+
serverUrl: string;
|
|
10
|
+
streamKey: string;
|
|
11
|
+
stream: MediaStream | null;
|
|
12
|
+
signalingType: string;
|
|
13
|
+
private retryTimeout;
|
|
14
|
+
private retryCount;
|
|
15
|
+
private externalStartCallback;
|
|
16
|
+
private externalStopCallback;
|
|
17
|
+
private externalErrorCallback;
|
|
18
|
+
/**
|
|
19
|
+
* @param url
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
22
|
+
constructor(url: string, options?: Partial<WebRTCLiveClientOptions>);
|
|
23
|
+
/**
|
|
24
|
+
* Sets start streaming callback
|
|
25
|
+
*
|
|
26
|
+
* @param cb
|
|
27
|
+
*/
|
|
28
|
+
onStart(cb: (stream: MediaStream) => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Sets stop streaming callback
|
|
31
|
+
*
|
|
32
|
+
* @param cb
|
|
33
|
+
*/
|
|
34
|
+
onStop(cb: () => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Sets streaming or connection error callback
|
|
37
|
+
*
|
|
38
|
+
* @param cb
|
|
39
|
+
*/
|
|
40
|
+
onError(cb: (e: Error) => void): void;
|
|
41
|
+
/**
|
|
42
|
+
* Start connection dialog
|
|
43
|
+
*/
|
|
44
|
+
connect(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Kill connection
|
|
47
|
+
*/
|
|
48
|
+
disconnect(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Begins socket opening
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private connectWS;
|
|
54
|
+
/**
|
|
55
|
+
* Socket opened event handler
|
|
56
|
+
* Begins login process
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
private onSocketOpen;
|
|
60
|
+
/**
|
|
61
|
+
* Socket close event handler
|
|
62
|
+
* @param e
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private onSocketClose;
|
|
66
|
+
/**
|
|
67
|
+
* Socket connection error handler
|
|
68
|
+
* @param e
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private onSocketError;
|
|
72
|
+
/**
|
|
73
|
+
* Socket message handler
|
|
74
|
+
* @param message
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
private onSocketMessage;
|
|
78
|
+
/**
|
|
79
|
+
* Socket JOIN message handler
|
|
80
|
+
* @param message
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
private handleJoinMessage;
|
|
84
|
+
/**
|
|
85
|
+
* Socket STATUS message handler
|
|
86
|
+
* @param message
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private handleStatusMessage;
|
|
90
|
+
/**
|
|
91
|
+
* Socket UPDATE message handler
|
|
92
|
+
* @param message
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
private handleUpdateMessage;
|
|
96
|
+
/**
|
|
97
|
+
* Handles peer connection login process
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private handleLogin;
|
|
101
|
+
/**
|
|
102
|
+
* Adds received remote offer to peer connection
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
private handleAnswer;
|
|
106
|
+
/**
|
|
107
|
+
* Adds ICE candidate to peer connection
|
|
108
|
+
* @param candidate
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private handleCandidate;
|
|
112
|
+
/**
|
|
113
|
+
* Live stream finish handler
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
private handleUnpublished;
|
|
117
|
+
/**
|
|
118
|
+
* Handles system failures
|
|
119
|
+
*/
|
|
120
|
+
private handleSystemError;
|
|
121
|
+
/**
|
|
122
|
+
* Peer connection stream received handler
|
|
123
|
+
* @param e
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private onPeerConnectionStream;
|
|
127
|
+
/**
|
|
128
|
+
* ICE candidate received handler
|
|
129
|
+
* @param e
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
private onPeerConnectionIceCandidate;
|
|
133
|
+
/**
|
|
134
|
+
* Peer connection ICE connection state change handler
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
private onPeerConnectionIceConnectionStateChange;
|
|
138
|
+
/**
|
|
139
|
+
* Returns newly created offer
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
private createOffer;
|
|
143
|
+
/**
|
|
144
|
+
* Handles RTC connection error
|
|
145
|
+
* @param e
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
private handleRTCError;
|
|
149
|
+
/**
|
|
150
|
+
* Handles network error
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
private handleNetworkError;
|
|
154
|
+
/**
|
|
155
|
+
* Sends message to websocket
|
|
156
|
+
* @param message
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
private send;
|
|
160
|
+
/**
|
|
161
|
+
* Parses JSON message to object
|
|
162
|
+
* @param message
|
|
163
|
+
*/
|
|
164
|
+
private parseMessage;
|
|
165
|
+
/**
|
|
166
|
+
* Closes all connections (ws and peer connection)
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
169
|
+
private closeConnections;
|
|
170
|
+
/**
|
|
171
|
+
* Kills peer connection
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
private removePeerConnection;
|
|
175
|
+
/**
|
|
176
|
+
* Schedules connection retry
|
|
177
|
+
*
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
private scheduleRetry;
|
|
181
|
+
/**
|
|
182
|
+
* Returns normalized options with all defaults set
|
|
183
|
+
*
|
|
184
|
+
* @param userOptions
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
private normalizeOptions;
|
|
188
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IProvider, IProviderParams } from '../../providers/types';
|
|
2
|
+
import { URLSource } from '../../player/types';
|
|
3
|
+
/**
|
|
4
|
+
* @class WebRTCLiveProvider
|
|
5
|
+
*
|
|
6
|
+
* Provides implementation of WEBRTC live streaming support
|
|
7
|
+
*/
|
|
8
|
+
export default class WebRTCLiveProvider implements IProvider {
|
|
9
|
+
private readonly subscription;
|
|
10
|
+
private readonly params;
|
|
11
|
+
private log;
|
|
12
|
+
private video;
|
|
13
|
+
private videoState;
|
|
14
|
+
private liveStreamClient;
|
|
15
|
+
private maxSeekBackTime$;
|
|
16
|
+
/**
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
constructor(params: IProviderParams<URLSource>);
|
|
20
|
+
/**
|
|
21
|
+
* Destroys the provider
|
|
22
|
+
*/
|
|
23
|
+
destroy(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Creates all needed provider subscriptions
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
private subscribe;
|
|
29
|
+
/**
|
|
30
|
+
* Live stream start handler
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
private onLiveStreamStart;
|
|
34
|
+
/**
|
|
35
|
+
* Live stream stop handler
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private onLiveStreamStop;
|
|
39
|
+
/**
|
|
40
|
+
* Live stream error handler
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private onLiveStreamError;
|
|
44
|
+
/**
|
|
45
|
+
* Tries to start playing
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private playIfAllowed;
|
|
49
|
+
/**
|
|
50
|
+
* Runs preparation phase
|
|
51
|
+
* Starts live client connection
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
private prepare;
|
|
55
|
+
/**
|
|
56
|
+
* Performs synchronization between desired state and video state
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
private syncPlayback;
|
|
60
|
+
}
|