@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.
Files changed (130) hide show
  1. package/es2015.cjs.js +73 -27
  2. package/es2015.esm.js +72 -26
  3. package/es2018.cjs.js +73 -27
  4. package/es2018.esm.js +72 -26
  5. package/esnext.cjs.js +75 -29
  6. package/esnext.esm.js +73 -27
  7. package/evergreen.esm.js +73 -27
  8. package/package.json +7 -7
  9. package/types/enums/AndroidPreferredFormat.d.ts +8 -0
  10. package/types/enums/WebmCodecStrategy.d.ts +7 -0
  11. package/types/env.d.ts +1 -0
  12. package/types/index.d.ts +12 -0
  13. package/types/player/Player.d.ts +173 -0
  14. package/{index.d.ts → types/player/types.d.ts} +64 -391
  15. package/types/player/utils/optimisticPosition.d.ts +12 -0
  16. package/types/player/utils/selectContainer.d.ts +3 -0
  17. package/types/providers/ChromecastProvider/ChromecastInitializer/index.d.ts +31 -0
  18. package/types/providers/ChromecastProvider/ChromecastInitializer/types.d.ts +23 -0
  19. package/types/providers/ChromecastProvider/index.d.ts +33 -0
  20. package/types/providers/DashLiveProvider/DashLiveProvider.d.ts +37 -0
  21. package/types/providers/DashLiveProvider/index.d.ts +2 -0
  22. package/types/providers/DashLiveProvider/types.d.ts +21 -0
  23. package/types/providers/DashLiveProvider/utils/FilesFetcher.d.ts +25 -0
  24. package/types/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +143 -0
  25. package/types/providers/DashLiveProvider/utils/ThroughputEstimator.d.ts +33 -0
  26. package/types/providers/DashLiveProvider/utils/liveDashPlayerUtil.d.ts +42 -0
  27. package/types/providers/DashProvider/baseDashProvider.d.ts +52 -0
  28. package/types/providers/DashProvider/consts.d.ts +1 -0
  29. package/types/providers/DashProvider/dashCmafLiveProvider.d.ts +8 -0
  30. package/types/providers/DashProvider/dashProvider.d.ts +6 -0
  31. package/types/providers/DashProvider/index.d.ts +2 -0
  32. package/types/providers/DashProvider/lib/buffer.d.ts +103 -0
  33. package/types/providers/DashProvider/lib/fetcher.d.ts +51 -0
  34. package/types/providers/DashProvider/lib/parsers/mpd.d.ts +3 -0
  35. package/types/providers/DashProvider/lib/parsers/mpeg/BoxModel.d.ts +20 -0
  36. package/types/providers/DashProvider/lib/parsers/mpeg/BoxParser.d.ts +21 -0
  37. package/types/providers/DashProvider/lib/parsers/mpeg/BoxTypeEnum.d.ts +26 -0
  38. package/types/providers/DashProvider/lib/parsers/mpeg/box.d.ts +79 -0
  39. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/equi.d.ts +21 -0
  40. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/ftyp.d.ts +17 -0
  41. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/index.d.ts +22 -0
  42. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mdat.d.ts +15 -0
  43. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mdia.d.ts +7 -0
  44. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/mfhd.d.ts +11 -0
  45. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/minf.d.ts +7 -0
  46. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/moof.d.ts +7 -0
  47. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/moov.d.ts +7 -0
  48. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/prhd.d.ts +16 -0
  49. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/proj.d.ts +7 -0
  50. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/sidx.d.ts +48 -0
  51. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/st3d.d.ts +23 -0
  52. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/sv3d.d.ts +7 -0
  53. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tfdt.d.ts +17 -0
  54. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tfhd.d.ts +22 -0
  55. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/tkhd.d.ts +42 -0
  56. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/traf.d.ts +7 -0
  57. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/trak.d.ts +7 -0
  58. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/trun.d.ts +31 -0
  59. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/unknown.d.ts +6 -0
  60. package/types/providers/DashProvider/lib/parsers/mpeg/boxes/uuid.d.ts +6 -0
  61. package/types/providers/DashProvider/lib/parsers/mpeg/fullBox.d.ts +15 -0
  62. package/types/providers/DashProvider/lib/parsers/mpeg/isobmff.d.ts +12 -0
  63. package/types/providers/DashProvider/lib/parsers/webm/ebml.d.ts +76 -0
  64. package/types/providers/DashProvider/lib/parsers/webm/webm.d.ts +3 -0
  65. package/types/providers/DashProvider/lib/player.d.ts +75 -0
  66. package/types/providers/DashProvider/lib/sourceBufferTaskQueue.d.ts +18 -0
  67. package/types/providers/DashProvider/lib/types.d.ts +156 -0
  68. package/types/providers/DashProvider/lib/utils.d.ts +14 -0
  69. package/types/providers/HlsJsProvider/index.d.ts +24 -0
  70. package/types/providers/HlsLiveProvider/index.d.ts +30 -0
  71. package/types/providers/HlsLiveProvider/seekBackTimeExtractor.d.ts +3 -0
  72. package/types/providers/HlsProvider/index.d.ts +21 -0
  73. package/types/providers/HlsProvider/manifestDataExtractor.d.ts +21 -0
  74. package/types/providers/MpegProvider/index.d.ts +20 -0
  75. package/types/providers/ProviderContainer/index.d.ts +42 -0
  76. package/types/providers/ProviderContainer/types.d.ts +20 -0
  77. package/types/providers/ProviderContainer/utils/formatsSupport.d.ts +20 -0
  78. package/types/providers/ProviderContainer/utils/playbackHangup.d.ts +12 -0
  79. package/types/providers/WebRTCLiveProvider/WebRTCLiveClient.d.ts +188 -0
  80. package/types/providers/WebRTCLiveProvider/WebRTCLiveProvider.d.ts +60 -0
  81. package/types/providers/WebRTCLiveProvider/interface/WebRTCLiveClientOptions.d.ts +9 -0
  82. package/types/providers/types.d.ts +83 -0
  83. package/types/providers/utils/HTMLVideoElement/DroppedFramesManager.d.ts +44 -0
  84. package/types/providers/utils/HTMLVideoElement/TextTrackManager.d.ts +30 -0
  85. package/types/providers/utils/HTMLVideoElement/clear.d.ts +1 -0
  86. package/types/providers/utils/HTMLVideoElement/destroy.d.ts +1 -0
  87. package/types/providers/utils/HTMLVideoElement/forcePlay.d.ts +7 -0
  88. package/types/providers/utils/HTMLVideoElement/observable.d.ts +25 -0
  89. package/types/providers/utils/HTMLVideoElement/pool.d.ts +2 -0
  90. package/types/providers/utils/HTMLVideoElement/surface.d.ts +2 -0
  91. package/types/providers/utils/LiveOffset/index.d.ts +14 -0
  92. package/types/providers/utils/LiveOffset/types.d.ts +10 -0
  93. package/types/providers/utils/addQuicParam.d.ts +2 -0
  94. package/types/providers/utils/extractConnectionHeaders.d.ts +6 -0
  95. package/types/providers/utils/generateLiveUrl.d.ts +9 -0
  96. package/types/providers/utils/okQualityStringToVideoQuality.d.ts +3 -0
  97. package/types/providers/utils/parseFps.d.ts +1 -0
  98. package/types/providers/utils/syncDesiredState.d.ts +12 -0
  99. package/types/providers/utils/syncPlaybackState.d.ts +4 -0
  100. package/types/utils/3d/Camera3D.d.ts +14 -0
  101. package/types/utils/3d/CameraRotationManager.d.ts +62 -0
  102. package/types/utils/3d/Scene3D.d.ts +132 -0
  103. package/types/utils/3d/types.d.ts +25 -0
  104. package/types/utils/StateMachine/StateMachine.d.ts +19 -0
  105. package/types/utils/StateMachine/types.d.ts +60 -0
  106. package/types/utils/StatefulIterator/index.d.ts +13 -0
  107. package/types/utils/ThroughputEstimator.d.ts +25 -0
  108. package/types/utils/addScript.d.ts +2 -0
  109. package/types/utils/autoSelectVideoTrack.d.ts +26 -0
  110. package/types/utils/buffer/getBufferedRangeForPosition.d.ts +3 -0
  111. package/types/utils/buffer/getForwardBufferDuration.d.ts +3 -0
  112. package/types/utils/buffer/getTotalBufferDuration.d.ts +3 -0
  113. package/types/utils/buffer/isPositionBuffered.d.ts +3 -0
  114. package/types/utils/changePlaybackRate.d.ts +2 -0
  115. package/types/utils/hostnameFromUrl.d.ts +2 -0
  116. package/types/utils/isInPiP.d.ts +1 -0
  117. package/types/utils/link.d.ts +2 -0
  118. package/types/utils/mediaSource.d.ts +8 -0
  119. package/types/utils/observeElementVisibility.d.ts +3 -0
  120. package/types/utils/playbackTelemetry.d.ts +12 -0
  121. package/types/utils/setStateWithSubscribe.d.ts +3 -0
  122. package/types/utils/smoothedValue/baseSmoothedValue.d.ts +18 -0
  123. package/types/utils/smoothedValue/emaAndMaSmoothedValue.d.ts +7 -0
  124. package/types/utils/smoothedValue/emaTopExtremumValue.d.ts +10 -0
  125. package/types/utils/smoothedValue/smoothedValueFactory.d.ts +6 -0
  126. package/types/utils/smoothedValue/twoEmaSmoothedValue.d.ts +8 -0
  127. package/types/utils/smoothedValue/types.d.ts +26 -0
  128. package/types/utils/smoothedValue/utils.d.ts +3 -0
  129. package/types/utils/tuningConfig.d.ts +164 -0
  130. package/types/utils/videoFormat.d.ts +2 -0
@@ -0,0 +1,37 @@
1
+ import { IDashURLSource } from '../../player/types';
2
+ import { IProvider, IProviderParams } from '../../providers/types';
3
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
4
+ type Params = IProviderParams<IDashURLSource> & {
5
+ config: {
6
+ maxPausedTime: Milliseconds;
7
+ chunkDuration: number;
8
+ maxParallelRequests: number;
9
+ };
10
+ };
11
+ export default class DashLiveProvider implements IProvider {
12
+ private subscription;
13
+ private video;
14
+ private videoState;
15
+ private dash;
16
+ private representations$;
17
+ private textTracksManager;
18
+ private droppedFramesManager;
19
+ /**
20
+ * Максимальное время перемотки назад из лайва в миллисекундах
21
+ */
22
+ private maxSeekBackTime$;
23
+ private zeroTime$;
24
+ private liveOffset;
25
+ private log;
26
+ private params;
27
+ constructor(params: Params);
28
+ destroy(): void;
29
+ private createLiveDashPlayer;
30
+ private prepare;
31
+ private setVideoTrack;
32
+ private setAutoQuality;
33
+ private seek;
34
+ private _dashCb;
35
+ private syncPlayback;
36
+ }
37
+ export {};
@@ -0,0 +1,2 @@
1
+ import DashLiveProvider from './DashLiveProvider';
2
+ export default DashLiveProvider;
@@ -0,0 +1,21 @@
1
+ import { bps } from '@vkontakte/videoplayer-shared';
2
+ export interface IRepresentation {
3
+ bitrate: bps;
4
+ codecs: string;
5
+ fragUrlTemplate: string;
6
+ headerUrl: string;
7
+ index: number;
8
+ jidxUrl: string;
9
+ name: string;
10
+ video: {
11
+ height: number;
12
+ width: number;
13
+ };
14
+ }
15
+ export declare enum State {
16
+ STOPPED = "stopped",
17
+ MANIFEST_READY = "manifest_ready",
18
+ READY = "ready",
19
+ PLAYING = "playing",
20
+ PAUSED = "paused"
21
+ }
@@ -0,0 +1,25 @@
1
+ export default class FilesFetcher {
2
+ private pendingQueue;
3
+ private activeRequests;
4
+ private completeRequests;
5
+ private averageSegmentDuration;
6
+ private lastPrefetchStart;
7
+ private throttleTimeout;
8
+ private RETRY_COUNT;
9
+ private TIMEOUT;
10
+ private BITRATE_ESTIMATOR;
11
+ private MAX_PARALLEL_REQUESTS;
12
+ private logger;
13
+ constructor(RETRY_COUNT: number, TIMEOUT: number, BITRATE_ESTIMATOR: any, MAX_PARALLEL_REQUESTS: number, logger: (...args: any[]) => void);
14
+ private limitCompleteCount;
15
+ private _sendRequest;
16
+ private _getParallelRequestCount;
17
+ private _getPrefetchDelay;
18
+ private _canSendPending;
19
+ private _sendPending;
20
+ private _removeFromActive;
21
+ abortAll(): void;
22
+ requestData(url: string, cb: (data: any, downloadTime: number) => void, errorCB: (arg: any) => void, retryCB: (arg: any) => void): Record<string, any>;
23
+ prefetch(url: string): void;
24
+ optimizeForSegDuration(duration: number): void;
25
+ }
@@ -0,0 +1,143 @@
1
+ import { ILiveOffset } from '../../../providers/utils/LiveOffset/types';
2
+ import { IStateMachine } from '../../../utils/StateMachine/types';
3
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
4
+ import { IRepresentation, State } from '../types';
5
+ interface IParams {
6
+ videoElement: HTMLVideoElement;
7
+ videoState: IStateMachine<State>;
8
+ liveOffset: ILiveOffset;
9
+ playerCallback: (...args: any) => void;
10
+ config: {
11
+ minBuffer: Milliseconds;
12
+ lowLatencyMinBuffer: Milliseconds;
13
+ minBufferSegments: number;
14
+ lowLatencyMinBufferSegments: number;
15
+ maxParallelRequests: number;
16
+ isLiveCatchUpMode: boolean;
17
+ manifestRetryInterval: number;
18
+ manifestRetryMaxInterval: number;
19
+ manifestRetryMaxCount: number;
20
+ };
21
+ logger: (...args: any[]) => void;
22
+ }
23
+ export default class LiveDashPlayer {
24
+ private paused;
25
+ private autoQuality;
26
+ private maxAutoQuality;
27
+ private buffering;
28
+ private destroyed;
29
+ private videoPlayStarted;
30
+ private lowLatency;
31
+ private rep?;
32
+ private bitrate;
33
+ private manifest;
34
+ private bitrateSwitcher?;
35
+ private filesFetcher?;
36
+ private sourceBuffer?;
37
+ private mediaSource?;
38
+ private currentManifestEntry?;
39
+ private manifestRequest?;
40
+ private manifestRefetchTimer?;
41
+ private bufferStates;
42
+ private downloadRate?;
43
+ private sourceJitter;
44
+ private chunkRateEstimator;
45
+ private manifestUrl;
46
+ private urlResolver;
47
+ private params;
48
+ constructor(params: IParams);
49
+ attachSource(manifestUrl: string): void;
50
+ /**
51
+ * switch to auto quality
52
+ */
53
+ setAutoQualityEnabled(enabled: boolean): void;
54
+ setMaxAutoQuality(height: number | undefined): void;
55
+ /**
56
+ * switch quality by name
57
+ */
58
+ switchByName(name: string): void;
59
+ /**
60
+ * seek to actual video position
61
+ */
62
+ catchUp(): void;
63
+ stop(): void;
64
+ pause(): void;
65
+ play(): void;
66
+ startPlay(targetQ: IRepresentation, autoQuality: boolean): void;
67
+ /**
68
+ * destroy player
69
+ */
70
+ destroy(): void;
71
+ reinit(newManifestUrl: string): void;
72
+ /**
73
+ * if all retries fail...
74
+ */
75
+ private _handleNetworkError;
76
+ /**
77
+ * Retry request
78
+ */
79
+ private _retryCallback;
80
+ /**
81
+ * how many seconds are there in the buffer
82
+ */
83
+ private _getBufferSizeSec;
84
+ /**
85
+ * send buffering notification to player
86
+ */
87
+ private _notifyBuffering;
88
+ /**
89
+ * initialize video tag, add necessary event listeners
90
+ * @private
91
+ */
92
+ private _initVideo;
93
+ /**
94
+ * there may be small gaps of several milliseconds when switching quality
95
+ * we jump over these gaps here
96
+ */
97
+ private _fixupStall;
98
+ /**
99
+ * return best quality for rate
100
+ */
101
+ private _selectQuality;
102
+ private shouldPlay;
103
+ /**
104
+ * set video source
105
+ */
106
+ private _setVideoSrc;
107
+ /**
108
+ * initialize player with target quality
109
+ */
110
+ private _initPlayerWith;
111
+ /**
112
+ * represents specific quality stream
113
+ */
114
+ private _representation;
115
+ /**
116
+ * switch to quality
117
+ * TODO: Если новое качество выше старого – переключиться сразу. Если хуже, доиграть буфер
118
+ */
119
+ private _switchToQuality;
120
+ /**
121
+ * check if quality is available
122
+ */
123
+ private _qualityAvailable;
124
+ /**
125
+ * analyze bitrate data and switch qualities accordingly
126
+ */
127
+ private _initBitrateSwitcher;
128
+ /**
129
+ * load and parse manifest file
130
+ */
131
+ private _fetchManifest;
132
+ private _playVideoElement;
133
+ /**
134
+ * update internal state when manifest was received from remote
135
+ */
136
+ private _handleManifestUpdate;
137
+ /**
138
+ * schedule manifest update after delay
139
+ */
140
+ private _refetchManifest;
141
+ private _initManifest;
142
+ }
143
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Estimate total throughput by counting bytes received over time interval
3
+ * The estimator receives reports of downloaded chunk sizes and time ranges
4
+ * and calculates total bandwidth accounting for chunks downloaded in parallel
5
+ * and network idle time
6
+ *
7
+ * For example:
8
+ * chunk1: [___1000___]
9
+ * chunk2: [_____900_____]
10
+ * chunk3: [___700___]
11
+ * time: 0.2 0.3 0.4 0.5 1.0 1.1
12
+ * --------------------------------------------------->
13
+ *
14
+ * total size = 1000 + 900 + 700 = 2600
15
+ * active time = (1.1 - 1.0) + (0.5 - 0.2) = 0.4
16
+ * throughput = total size / active time = 6500 bytes/sec
17
+ */
18
+ type ILogger = (...args: any[]) => void;
19
+ export default class ThroughputEstimator {
20
+ private intervals;
21
+ private currentRate;
22
+ private logger;
23
+ constructor(logger: ILogger);
24
+ private _updateRate;
25
+ private _createInterval;
26
+ private _doMergeIntervals;
27
+ private _mergeIntervals;
28
+ private _flushIntervals;
29
+ private _joinIntervals;
30
+ addInterval(timeStart: number, timeEnd: number, bytes: number): boolean;
31
+ getBitRate(): number;
32
+ }
33
+ export {};
@@ -0,0 +1,42 @@
1
+ export declare function getTimeMilliseconds(): number;
2
+ export declare function elapsedSince(ts: number): number;
3
+ /**
4
+ * url resolver function
5
+ * constructs full path if URL is relative to manifest
6
+ * optionally adds random url parameter to bypass browser cache
7
+ */
8
+ export declare function urlResolver(homeUrl: string): {
9
+ resolve: (url: string, nocache: boolean, lowLatency?: boolean) => string;
10
+ };
11
+ /**
12
+ * event listener helper - listen just once, then remove listener
13
+ */
14
+ export declare function listenOnce(element: HTMLElement, eventName: string, listener: (...args: any[]) => void): void;
15
+ interface IRequestDataResult {
16
+ withBitrateReporting: IWithBitrateReporting;
17
+ withParallel: IWithParallel;
18
+ withJSONResponse: IWithJSONResponse;
19
+ withRetryCount: IWithRetryCount;
20
+ withRetryInterval: IWithRetryInterval;
21
+ withTimeout: IWithTimeout;
22
+ withFinally: IWithFinally;
23
+ send: ISend;
24
+ abort: () => void;
25
+ }
26
+ type IWithBitrateReporting = IBuilderMethod<[listener: any]>;
27
+ type IWithParallel = IBuilderMethod<[parallel: any]>;
28
+ type IWithJSONResponse = IBuilderMethod<[]>;
29
+ type IWithRetryCount = IBuilderMethod<[count: number]>;
30
+ type IWithRetryInterval = IBuilderMethod<[
31
+ interval: number | undefined,
32
+ maxInterval: number | undefined
33
+ ]>;
34
+ type IWithTimeout = IBuilderMethod<[timeoutMs: number]>;
35
+ type IWithFinally = IBuilderMethod<[final: () => void]>;
36
+ type ISend = IBuilderMethod<[]>;
37
+ type IBuilderMethod<TParams extends any[]> = (...params: TParams) => IRequestDataResult;
38
+ /**
39
+ * fetch data helper with retry and timeout handler
40
+ */
41
+ export declare function requestData(url: string, cb: (response: any) => void, errorCB: () => void, retryCB: () => void): IRequestDataResult;
42
+ export {};
@@ -0,0 +1,52 @@
1
+ import { IAudioTrack, IDashURLSource, IHLSSource, IInternalTextTrack, IVideoTrack } from '../../player/types';
2
+ import { CommonInit, IProviderSubscriptionInfo, ProviderState, Representation } from '../../providers/DashProvider/lib/types';
3
+ import { IProvider, IProviderParams } from '../../providers/types';
4
+ import TextTrackManager from '../../providers/utils/HTMLVideoElement/TextTrackManager';
5
+ import { TrackHistory } from '../../utils/autoSelectVideoTrack';
6
+ import { IStateMachine } from '../../utils/StateMachine/types';
7
+ import { IRectangle, ISubscription, IValueSubject, Milliseconds, ValueSubject } from '@vkontakte/videoplayer-shared';
8
+ import { Player } from './lib/player';
9
+ import { ILiveOffset } from '../utils/LiveOffset/types';
10
+ import { Scene3D } from '../../utils/3d/Scene3D';
11
+ import DroppedFramesManager from '../../providers/utils/HTMLVideoElement/DroppedFramesManager';
12
+ type IParams = IProviderParams<IDashURLSource> & {
13
+ sourceHls?: IHLSSource;
14
+ };
15
+ export default abstract class BaseDashProvider implements IProvider {
16
+ scene3D: Scene3D | undefined;
17
+ protected subscription: ISubscription;
18
+ protected videoState: IStateMachine<ProviderState>;
19
+ protected video: HTMLVideoElement;
20
+ protected player: Player;
21
+ protected params: IParams;
22
+ protected elementSize$: ValueSubject<IRectangle<number> | undefined>;
23
+ protected textTracksManager: TextTrackManager;
24
+ protected droppedFramesManager: DroppedFramesManager;
25
+ protected videoTracks$: IValueSubject<{
26
+ track: IVideoTrack;
27
+ representation: Representation;
28
+ }[]>;
29
+ protected audioTracks: {
30
+ track: IAudioTrack;
31
+ representation: Representation;
32
+ }[];
33
+ protected audioRepresentations: Map<string, Representation>;
34
+ protected videoTrackSwitchHistory: TrackHistory;
35
+ protected textTracks: {
36
+ track: IInternalTextTrack;
37
+ representation: Representation;
38
+ }[];
39
+ protected liveOffset?: ILiveOffset;
40
+ constructor(params: IParams);
41
+ protected abstract seek(position: Milliseconds, forcePrecise: boolean): void;
42
+ protected getProviderSubscriptionInfo(): IProviderSubscriptionInfo;
43
+ protected subscribe(): void;
44
+ protected selectVideoRepresentation(): Representation | undefined;
45
+ protected prepare(manifestOffset?: number): void;
46
+ protected syncPlayback: () => undefined;
47
+ protected init3DScene: (init: CommonInit) => void;
48
+ protected destroy3DScene: () => void;
49
+ protected playIfAllowed(): void;
50
+ destroy(): void;
51
+ }
52
+ export {};
@@ -0,0 +1 @@
1
+ export declare const DASH_LIVE_UPDATE_INTERVAL_MS = 1000;
@@ -0,0 +1,8 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import { IParams } from './lib/types';
3
+ import BaseDashProvider from './baseDashProvider';
4
+ export default class DashCmafLiveProvider extends BaseDashProvider {
5
+ constructor(params: IParams);
6
+ protected subscribe(): void;
7
+ protected seek(position: Milliseconds): void;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import BaseDashProvider from './baseDashProvider';
3
+ export default class DashProvider extends BaseDashProvider {
4
+ protected subscribe(): void;
5
+ protected seek(position: Milliseconds, forcePrecise: boolean): void;
6
+ }
@@ -0,0 +1,2 @@
1
+ export { default as DashProvider } from './dashProvider';
2
+ export { default as DashCmafLiveProvider } from './dashCmafLiveProvider';
@@ -0,0 +1,103 @@
1
+ import { ITuningConfig } from '../../../utils/tuningConfig';
2
+ import { IError, IRange, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
3
+ import type { Fetcher } from './fetcher';
4
+ import { CommonInit, Container, Manifest, Representation, RepresentationKind } from './types';
5
+ export interface Dependencies {
6
+ fetcher: Fetcher;
7
+ tuning: ITuningConfig;
8
+ getCurrentPosition: () => Milliseconds | undefined;
9
+ isActiveLowLatency: () => boolean;
10
+ compatibilityMode?: boolean;
11
+ manifest: Manifest | null;
12
+ }
13
+ export interface Gap extends IRange<Milliseconds> {
14
+ representation: Representation['id'];
15
+ }
16
+ export declare class BufferManager {
17
+ currentSegmentLength$: IValueSubject<number>;
18
+ onLastSegment$: IValueSubject<boolean>;
19
+ fullyBuffered$: IValueSubject<boolean>;
20
+ playingRepresentation$: IValueSubject<Representation['id'] | undefined>;
21
+ playingRepresentationInit$: IValueSubject<CommonInit | undefined>;
22
+ error$: ISubject<IError>;
23
+ gaps: Gap[];
24
+ private subscription;
25
+ private kind;
26
+ private container;
27
+ private containerParser;
28
+ private initData;
29
+ private parsedInitData;
30
+ private representations;
31
+ private segments;
32
+ private allInitsLoaded;
33
+ private activeSegments;
34
+ private mediaSource;
35
+ private playingRepresentationId;
36
+ private downloadingRepresentationId;
37
+ private switchingToRepresentationId;
38
+ private sourceBuffer;
39
+ private downloadAbortController;
40
+ private destroyAbortController;
41
+ private readonly getCurrentPosition;
42
+ private readonly isActiveLowLatency;
43
+ private tuning;
44
+ private forwardBufferTarget;
45
+ private fetcher;
46
+ private bufferLimit;
47
+ private sourceBufferTaskQueue;
48
+ private gapDetectionIdleCallback;
49
+ private initLoadIdleCallback;
50
+ private failedDownloads;
51
+ private compatibilityMode;
52
+ private preloadOnly;
53
+ private isLive;
54
+ private liveUpdateSegmentIndex;
55
+ private liveInitialAdditionalOffset;
56
+ private isSeekingLive;
57
+ private index;
58
+ private loadByteRangeSegmentsTimeoutId;
59
+ constructor(kind: RepresentationKind, mediaSource: MediaSource, container: Container, representations: Representation[], { fetcher, tuning, getCurrentPosition, isActiveLowLatency, compatibilityMode, manifest }: Dependencies);
60
+ startWith: (param_0: string) => Promise<void | undefined>;
61
+ switchTo: (param_0: string) => Promise<void | undefined>;
62
+ abort(): void;
63
+ maintain(currentPosition?: Milliseconds | undefined): void;
64
+ private searchGaps;
65
+ private getActualLiveStartingSegments;
66
+ getLiveSegmentsToLoadState(manifest: Manifest | null): IRange<Milliseconds> | undefined;
67
+ seekLive: (param_0: Representation[] | undefined) => Promise<void | undefined>;
68
+ updateLive(manifest: Manifest | null): void;
69
+ private updateLowLatencyLive;
70
+ findSegmentStartTime(position: Milliseconds): Milliseconds | undefined;
71
+ setTarget(time: Milliseconds): void;
72
+ setPreloadOnly(preloadOnly: boolean): void;
73
+ destroy(): void;
74
+ private selectForwardBufferSegments;
75
+ private selectForwardBufferSegmentsLive;
76
+ private selectForwardBufferSegmentsRecord;
77
+ private loadSegments;
78
+ private loadTemplateSegment;
79
+ private loadByteRangeSegments;
80
+ private prepareByteRangeFetchSegmentParams;
81
+ private prepareTemplateFetchSegmentParams;
82
+ private abortActiveSegments;
83
+ private onSomeTemplateDataLoaded;
84
+ /**
85
+ * Закидываем в буфер сегменты атомарнее чем сегмент целиком. Например, по боксам в мпеге и по блокам в вебме.
86
+ * Таким образом не ждём его полной загрузки и готовы играть его намного быстрее
87
+ * @param dataView – данные, размер буфера – весь запрос
88
+ * @param globalFrom – Отступ dataView от начала файла, совпадает с отсупами сегментов
89
+ * @param loaded – Объём загруженных в dataView данных (всё что больше – пока нули)
90
+ * @private
91
+ */
92
+ private onSomeByteRangesDataLoaded;
93
+ private onSegmentFullyAppended;
94
+ private abortSegment;
95
+ private loadNextInit;
96
+ private loadInit;
97
+ private pruneBuffer;
98
+ private abortBuffer;
99
+ getDebugBufferState(): IRange<Milliseconds> | undefined;
100
+ private detectGaps;
101
+ private detectGapsWhenIdle;
102
+ private checkEjectedSegments;
103
+ }
@@ -0,0 +1,51 @@
1
+ import { HttpConnectionType } from '../../../player/types';
2
+ import type ThroughputEstimator from '../../../utils/ThroughputEstimator';
3
+ import { Byte, IValueSubject, Milliseconds, IRange } from '@vkontakte/videoplayer-shared';
4
+ import { CommonInit, GenericContainerParser, Segment, SegmentReference } from './types';
5
+ export declare enum RangeMethod {
6
+ HEADER = 0,
7
+ PARAM = 1
8
+ }
9
+ export interface IParams {
10
+ throughputEstimator?: ThroughputEstimator;
11
+ requestQuic: boolean;
12
+ compatibilityMode?: boolean;
13
+ }
14
+ export type Priority = 'high' | 'low' | 'auto';
15
+ export interface FetchParamsWithUrl extends FetchParams {
16
+ url: string;
17
+ }
18
+ export interface FetchParams {
19
+ range?: IRange<Byte>;
20
+ rangeMethod?: RangeMethod;
21
+ onProgress?: (dataView: DataView, loaded: number) => void;
22
+ onProgressTasks?: Promise<void>[];
23
+ signal?: AbortSignal;
24
+ priority?: Priority;
25
+ measureThroughput?: boolean;
26
+ isLowLatency?: boolean;
27
+ }
28
+ export type RepresentationFetchResult = {
29
+ init: CommonInit | null;
30
+ segments: Segment[];
31
+ dataView: DataView;
32
+ };
33
+ export declare class Fetcher {
34
+ private throughputEstimator;
35
+ private requestQuic;
36
+ lastConnectionType$: IValueSubject<HttpConnectionType | undefined>;
37
+ lastConnectionReused$: IValueSubject<boolean | undefined>;
38
+ lastRequestFirstBytes$: IValueSubject<Milliseconds | undefined>;
39
+ private abortAllController;
40
+ private subscription;
41
+ private compatibilityMode;
42
+ constructor({ throughputEstimator, requestQuic, compatibilityMode }: IParams);
43
+ private onHeadersReceived;
44
+ fetchManifest: (param_0: string) => Promise<string | null | undefined>;
45
+ fetch: (param_0: string, param_1: FetchParams) => Promise<ArrayBuffer | null | undefined>;
46
+ fetchRepresentation(segmentReference: SegmentReference, parser: GenericContainerParser<unknown>, priority?: Priority): Promise<RepresentationFetchResult | null>;
47
+ destroy(): void;
48
+ private fetchByteRangeRepresentation;
49
+ private fetchTemplateRepresentation;
50
+ }
51
+ export declare const suppressAbort: (e: Error | unknown) => void | never;
@@ -0,0 +1,3 @@
1
+ import { Manifest } from '../types';
2
+ export declare const replaceSegmentTemplate: (template: string, data: Partial<Record<'representationId' | 'segmentNumber' | 'bandwidth' | 'segmentTime', string>>) => string;
3
+ export declare const parse: (text: string, manifestUrl: string) => Manifest;
@@ -0,0 +1,20 @@
1
+ import { type Box } from '../../../../../providers/DashProvider/lib/parsers/mpeg/box';
2
+ /**
3
+ * Queryable object to get needed boxes from structure
4
+ */
5
+ export declare class BoxModel {
6
+ private readonly index;
7
+ constructor(initialSet: Box[]);
8
+ /**
9
+ * Processes index creation
10
+ */
11
+ private indexBoxLevel;
12
+ /**
13
+ * Returns first box of given type
14
+ */
15
+ find<T extends Box>(type: string): T | null;
16
+ /**
17
+ * Returns all boxes of given typoe
18
+ */
19
+ findAll<T extends Box>(type: string): T[];
20
+ }
@@ -0,0 +1,21 @@
1
+ import { type Box } from '../../../../../providers/DashProvider/lib/parsers/mpeg/box';
2
+ import { BoxTypeEnum } from '../../../../../providers/DashProvider/lib/parsers/mpeg/BoxTypeEnum';
3
+ export declare const BOX_TYPE_MAP: Record<BoxTypeEnum, typeof Box>;
4
+ export interface BoxParserOptions {
5
+ offset: number;
6
+ }
7
+ /**
8
+ * Box parsing object
9
+ */
10
+ export declare class BoxParser {
11
+ private options;
12
+ constructor(opts?: Partial<BoxParserOptions>);
13
+ /**
14
+ * Parses DataView into the set of boxes
15
+ */
16
+ parse(view: DataView): Box[];
17
+ /**
18
+ * Creates boxes from source DataView with exact type
19
+ */
20
+ private createBox;
21
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 'Known' box types
3
+ */
4
+ export declare enum BoxTypeEnum {
5
+ FtypBox = "ftyp",
6
+ MoovBox = "moov",
7
+ MoofBox = "moof",
8
+ MdatBox = "mdat",
9
+ SidxBox = "sidx",
10
+ TrakBox = "trak",
11
+ MdiaBox = "mdia",
12
+ MfhdBox = "mfhd",
13
+ TkhdBox = "tkhd",
14
+ TrafBox = "traf",
15
+ TfhdBox = "tfhd",
16
+ TfdtBox = "tfdt",
17
+ TrunBox = "trun",
18
+ MinfBox = "minf",
19
+ Sv3dBox = "sv3d",
20
+ St3dBox = "st3d",
21
+ PrhdBox = "prhd",
22
+ ProjBox = "proj",
23
+ EquiBox = "equi",
24
+ UuidBox = "uuid",
25
+ UnknownBox = "unknown"
26
+ }