@vkontakte/videoplayer-core 2.0.62 → 2.0.65
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/build/polyfills/runtime/idleCallback.d.ts +2 -0
- package/es2015.cjs.d.ts +11 -0
- package/es2015.cjs.js +4 -4
- package/es2015.esm.d.ts +11 -0
- package/es2015.esm.js +4 -4
- package/es2018.cjs.d.ts +11 -0
- package/es2018.cjs.js +4 -4
- package/es2018.esm.d.ts +11 -0
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.d.ts +11 -0
- package/esnext.esm.js +4 -4
- package/index.d.ts +1 -2
- package/package.json +2 -2
- package/packages/sdk/src/providers/DashVKProvider/lib/buffer.d.ts +3 -3
- package/packages/sdk/src/providers/DashVKProvider/lib/fetcher.d.ts +12 -8
- package/packages/sdk/src/providers/DashVKProvider/lib/mpd.d.ts +1 -1
- package/packages/sdk/src/providers/types.d.ts +4 -4
- package/packages/sdk/src/utils/buffer/types.d.ts +1 -2
- package/player/Player.d.ts +7 -5
- package/player/types.d.ts +24 -10
- package/player/utils/watchCoverage.d.ts +1 -2
- package/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +135 -0
- package/providers/DashProvider/utils/DashLite.d.ts +60 -0
- package/providers/DashVKProvider/lib/types.d.ts +34 -12
- package/providers/HlsProvider/qualityExtractor.d.ts +1 -2
- package/providers/ProviderContainer/index.d.ts +4 -4
- package/providers/utils/observableVideo.d.ts +4 -6
- package/utils/autoSelectVideoTrack.d.ts +1 -2
- package/utils/buffer/getBufferedRangeForPosition.d.ts +1 -2
- package/utils/buffer/isPositionBuffered.d.ts +3 -0
- package/utils/observeElementSize.d.ts +1 -2
- package/utils/quality/utils.d.ts +1 -1
- package/packages/sdk/src/utils/range.d.ts +0 -4
- package/packages/sdk/src/utils/rectangle.d.ts +0 -4
- package/providers/utils/firstBytesEventForVideoElement.d.ts +0 -3
- package/providers/utils/firstFrameEvent.d.ts +0 -3
package/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { VideoFormat, IMpegSource, IDashSource, IHLSSource, IDashURLSource, IHLS
|
|
|
2
2
|
import Player from "./player/Player";
|
|
3
3
|
import { IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, ChromecastState, HttpConnectionType, IExternalTextTrack, ITextTrack } from "./player/types";
|
|
4
4
|
import { VideoQuality, ExactVideoQuality } from "./utils/quality/types";
|
|
5
|
-
import { IRange } from
|
|
6
|
-
import type { ISubscription, IUnsubscriber, IEmitter, IObservable, IValueObservable, IValue, IOperator, IListener, ILogEntry } from '@vkontakte/videoplayer-shared';
|
|
5
|
+
import type { ISubscription, IUnsubscriber, IEmitter, IObservable, IValueObservable, IValue, IOperator, IListener, ILogEntry, IRange } from '@vkontakte/videoplayer-shared';
|
|
7
6
|
import { Subscription, Observable, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
8
7
|
/**
|
|
9
8
|
* Версия sdk
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.65",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Videoplayer core library based on the vk.com platform",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"**/*.d.ts"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vkontakte/videoplayer-shared": "^1.0.
|
|
17
|
+
"@vkontakte/videoplayer-shared": "^1.0.15",
|
|
18
18
|
"dashjs": "4.4.0",
|
|
19
19
|
"hls.js": "1.1.5",
|
|
20
20
|
"lodash": "4.17.21"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ITuningConfig } from "../../../utils/tuningConfig";
|
|
2
|
-
import { IError, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { IError, IRange, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
3
3
|
import type { Fetcher } from './fetcher';
|
|
4
|
-
import { Container,
|
|
4
|
+
import { Container, Representation, RepresentationKind } from './types';
|
|
5
5
|
export interface Dependencies {
|
|
6
6
|
fetcher: Fetcher;
|
|
7
7
|
tuning: ITuningConfig;
|
|
8
8
|
getCurrentPosition: () => Milliseconds | undefined;
|
|
9
9
|
}
|
|
10
|
-
export interface Gap extends
|
|
10
|
+
export interface Gap extends IRange<Milliseconds> {
|
|
11
11
|
representation: Representation['id'];
|
|
12
12
|
}
|
|
13
13
|
export declare class BufferManager {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpConnectionType } from "../../../player/types";
|
|
2
|
-
import { GenericContainerParser, Representation, Segment } from './types';
|
|
3
2
|
import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
|
|
4
|
-
import { Byte, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
3
|
+
import { Byte, IValueSubject, Milliseconds, IRange } from '@vkontakte/videoplayer-shared';
|
|
4
|
+
import { GenericContainerParser, Segment, SegmentReference } from './types';
|
|
5
5
|
export declare enum RangeMethod {
|
|
6
6
|
HEADER = 0,
|
|
7
7
|
PARAM = 1
|
|
@@ -12,12 +12,17 @@ export interface IParams {
|
|
|
12
12
|
}
|
|
13
13
|
export declare type Priority = 'high' | 'low' | 'auto';
|
|
14
14
|
export interface FetchParams {
|
|
15
|
-
|
|
15
|
+
range?: IRange<Byte>;
|
|
16
|
+
rangeMethod?: RangeMethod;
|
|
16
17
|
onProgress?: (view: DataView, loaded: Byte) => void;
|
|
17
18
|
signal?: AbortSignal;
|
|
18
19
|
priority?: Priority;
|
|
19
20
|
measureThroughput?: boolean;
|
|
20
21
|
}
|
|
22
|
+
export declare type RepresentationFetchResult = {
|
|
23
|
+
segments: Segment[];
|
|
24
|
+
dataView: DataView;
|
|
25
|
+
};
|
|
21
26
|
export declare class Fetcher {
|
|
22
27
|
private throughputEstimator;
|
|
23
28
|
private requestQuic;
|
|
@@ -29,11 +34,10 @@ export declare class Fetcher {
|
|
|
29
34
|
constructor({ throughputEstimator, requestQuic }: IParams);
|
|
30
35
|
private onHeadersReceived;
|
|
31
36
|
fetchManifest: (param_0: string) => Promise<string | null | undefined>;
|
|
32
|
-
|
|
33
|
-
fetchRepresentation
|
|
34
|
-
segments: Segment[];
|
|
35
|
-
dataView: DataView;
|
|
36
|
-
} | null | undefined>;
|
|
37
|
+
fetch: (param_0: string, param_1: FetchParams) => Promise<ArrayBuffer | null | undefined>;
|
|
38
|
+
fetchRepresentation(segmentReference: SegmentReference, parser: GenericContainerParser<unknown>, priority?: Priority): Promise<RepresentationFetchResult | null>;
|
|
37
39
|
destroy(): void;
|
|
40
|
+
private fetchByteRangeRepresentation;
|
|
41
|
+
private fetchTemplateRepresentation;
|
|
38
42
|
}
|
|
39
43
|
export declare const suppressAbort: (e: Error | unknown) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Manifest } from './types';
|
|
2
|
-
export declare const parse: (text: string,
|
|
2
|
+
export declare const parse: (text: string, manifestUrl: string) => Manifest;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { QualityLimits } from "../utils/quality/types";
|
|
2
2
|
import { ITuningConfig } from "../utils/tuningConfig";
|
|
3
|
-
import { ILogger, ISubject, IValueSubject, Milliseconds, Seconds, IError } from '@vkontakte/videoplayer-shared';
|
|
3
|
+
import { ILogger, ISubject, IValueSubject, Milliseconds, Seconds, IRange, IError } from '@vkontakte/videoplayer-shared';
|
|
4
4
|
import { IChromecastInitializer } from "./ChromecastProvider/ChromecastInitializer/types";
|
|
5
5
|
import { HttpConnectionType, ICueSettings, SeekState } from "../player/types";
|
|
6
6
|
import { IExternalTextTrack, ITextTrack, IVideoTrack, IVolumeState, PlaybackState } from "../player/types";
|
|
7
|
-
import { IRange } from "../utils/range";
|
|
8
7
|
import { IStateMachine } from "../utils/StateMachine/types";
|
|
9
8
|
import ThroughputEstimator from "../utils/ThroughputEstimator";
|
|
10
9
|
export interface IProvider {
|
|
@@ -58,6 +57,7 @@ export interface IProviderOutput {
|
|
|
58
57
|
error$: ISubject<IError>;
|
|
59
58
|
endedEvent$: ISubject<void>;
|
|
60
59
|
loopedEvent$: ISubject<Seconds>;
|
|
61
|
-
firstBytesEvent$: ISubject<
|
|
62
|
-
firstFrameEvent$: ISubject<
|
|
60
|
+
firstBytesEvent$: ISubject<void>;
|
|
61
|
+
firstFrameEvent$: ISubject<void>;
|
|
62
|
+
canplay$: ISubject<void>;
|
|
63
63
|
}
|
package/player/Player.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { HttpConnectionType, ICueSettings } from "./types";
|
|
1
|
+
import { HttpConnectionType, ICueSettings, StartEnd } from "./types";
|
|
2
2
|
import { QualityLimits, VideoQuality } from "../utils/quality/types";
|
|
3
|
-
import { IRange } from "../utils/range";
|
|
4
3
|
import { IOptionalTuningConfig } from "../utils/tuningConfig";
|
|
5
4
|
import { IError, ILogEntry, Seconds, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
6
5
|
import { ChromecastState, IConfig, IExternalTextTrack, IPlayer, ISeekRequest, ITextTrack, PlaybackState, StartStatus, VideoFormat } from './types';
|
|
@@ -15,6 +14,7 @@ export default class Player implements IPlayer {
|
|
|
15
14
|
private tuning;
|
|
16
15
|
private throughputEstimator;
|
|
17
16
|
private isPlaybackStarted;
|
|
17
|
+
private initedAt;
|
|
18
18
|
private desiredState;
|
|
19
19
|
info: {
|
|
20
20
|
playbackState$: ValueSubject<PlaybackState>;
|
|
@@ -28,7 +28,7 @@ export default class Player implements IPlayer {
|
|
|
28
28
|
isAutoQualityEnabled$: ValueSubject<boolean>;
|
|
29
29
|
autoQualityLimitingAvailable$: ValueSubject<boolean>;
|
|
30
30
|
autoQualityLimits$: ValueSubject<QualityLimits>;
|
|
31
|
-
currentBuffer$: ValueSubject<
|
|
31
|
+
currentBuffer$: ValueSubject<StartEnd<number> | undefined>;
|
|
32
32
|
isBuffering$: ValueSubject<boolean>;
|
|
33
33
|
isStalled$: ValueSubject<boolean>;
|
|
34
34
|
isEnded$: ValueSubject<boolean>;
|
|
@@ -52,13 +52,14 @@ export default class Player implements IPlayer {
|
|
|
52
52
|
} | undefined>;
|
|
53
53
|
};
|
|
54
54
|
events: {
|
|
55
|
+
inited$: Subject<void>;
|
|
55
56
|
started$: Subject<boolean>;
|
|
56
57
|
startAttempt$: Subject<StartStatus>;
|
|
57
58
|
willPause$: Subject<void>;
|
|
58
59
|
willResume$: Subject<void>;
|
|
59
60
|
willDestruct$: Subject<void>;
|
|
60
|
-
watchCoverageRecord$: Subject<
|
|
61
|
-
watchCoverageLive$: Subject<
|
|
61
|
+
watchCoverageRecord$: Subject<StartEnd<number>>;
|
|
62
|
+
watchCoverageLive$: Subject<StartEnd<number>>;
|
|
62
63
|
managedError$: Subject<IError>;
|
|
63
64
|
fatalError$: Subject<IError>;
|
|
64
65
|
ended$: Subject<void>;
|
|
@@ -67,6 +68,7 @@ export default class Player implements IPlayer {
|
|
|
67
68
|
willSeek$: Subject<ISeekRequest>;
|
|
68
69
|
firstBytes$: Subject<number>;
|
|
69
70
|
firstFrame$: Subject<number>;
|
|
71
|
+
canplay$: Subject<number>;
|
|
70
72
|
log$: Subject<ILogEntry>;
|
|
71
73
|
};
|
|
72
74
|
experimental: {
|
package/player/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { IObservable, IValueObservable, IValueSubject, ILogEntry, Kbps, Milliseconds, Seconds, IError } from '@vkontakte/videoplayer-shared';
|
|
1
|
+
import { IObservable, IValueObservable, IValueSubject, ILogEntry, Kbps, Milliseconds, Seconds, IRectangle, IError } from '@vkontakte/videoplayer-shared';
|
|
2
2
|
import { QualityLimits, VideoQuality } from "../utils/quality/types";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface StartEnd<Unit extends number> {
|
|
4
|
+
start: Unit;
|
|
5
|
+
end: Unit;
|
|
6
|
+
}
|
|
5
7
|
export interface IPlayer {
|
|
6
8
|
info: IPlayerInfo;
|
|
7
9
|
events: IPlayerEvents;
|
|
@@ -66,6 +68,10 @@ export interface IPlayer {
|
|
|
66
68
|
* остальные - в момент окончания действия.
|
|
67
69
|
*/
|
|
68
70
|
export interface IPlayerEvents {
|
|
71
|
+
/**
|
|
72
|
+
* Плеер получил ссылку и готов к взаимодействию
|
|
73
|
+
*/
|
|
74
|
+
inited$: IObservable<void>;
|
|
69
75
|
/**
|
|
70
76
|
* Видео начало воспроизведение в первый раз
|
|
71
77
|
* Соответствует первому для видео внешнему запуску воспроизведения
|
|
@@ -92,12 +98,12 @@ export interface IPlayerEvents {
|
|
|
92
98
|
* Просмотрен промежуток видео.
|
|
93
99
|
* Параметр содержит диапазон: начальная и конечная позиция просмотра (в секундах от начала ролика).
|
|
94
100
|
*/
|
|
95
|
-
watchCoverageRecord$: IObservable<
|
|
101
|
+
watchCoverageRecord$: IObservable<StartEnd<Seconds>>;
|
|
96
102
|
/**
|
|
97
103
|
* Просмотрен промежуток видео. Промежуток видео, которые были просмотрены пользователем.
|
|
98
104
|
* Параметр содержит диапазон: начальный и конечный UTC tipestamp?
|
|
99
105
|
*/
|
|
100
|
-
watchCoverageLive$: IObservable<
|
|
106
|
+
watchCoverageLive$: IObservable<StartEnd<Milliseconds>>;
|
|
101
107
|
/**
|
|
102
108
|
* Ошибка в работе после которой воспроизведение было восстановлено
|
|
103
109
|
*/
|
|
@@ -126,15 +132,21 @@ export interface IPlayerEvents {
|
|
|
126
132
|
* Получен первый кусок контента от сервера раздачи видео
|
|
127
133
|
* Событие поддерживается не во всех провайдерах (т.к. не все способы проигрывания видео поддерживают такой интерфейс)
|
|
128
134
|
*
|
|
129
|
-
* Содержит время в миллисекундах: сколько прошло с момента
|
|
135
|
+
* Содержит время в миллисекундах: сколько прошло с момента инициализации
|
|
130
136
|
*/
|
|
131
|
-
firstBytes$: IObservable<
|
|
137
|
+
firstBytes$: IObservable<Milliseconds>;
|
|
132
138
|
/**
|
|
133
139
|
* Показан первый кадр
|
|
134
140
|
*
|
|
135
|
-
* Содержит время в миллисекундах: сколько прошло времени с
|
|
141
|
+
* Содержит время в миллисекундах: сколько прошло времени с инициализации
|
|
142
|
+
*/
|
|
143
|
+
firstFrame$: IObservable<Milliseconds>;
|
|
144
|
+
/**
|
|
145
|
+
* Плеер готов начать воспроизведение
|
|
146
|
+
*
|
|
147
|
+
* Содержит время в миллисекундах: сколько прошло времени с инициализации
|
|
136
148
|
*/
|
|
137
|
-
|
|
149
|
+
canplay$: IObservable<Milliseconds>;
|
|
138
150
|
/**
|
|
139
151
|
* Логи для отладки
|
|
140
152
|
*/
|
|
@@ -199,7 +211,7 @@ export interface IPlayerInfo {
|
|
|
199
211
|
*
|
|
200
212
|
* default value: `undefined`
|
|
201
213
|
*/
|
|
202
|
-
currentBuffer$: IValueObservable<
|
|
214
|
+
currentBuffer$: IValueObservable<StartEnd<Seconds> | undefined>;
|
|
203
215
|
/**
|
|
204
216
|
* Статус буферизации видео. true если буфер пустой и воспроизведение прервано
|
|
205
217
|
* В отличии от isStalled показывает и буферизации на старте и после перемотки
|
|
@@ -304,6 +316,7 @@ export interface ISources {
|
|
|
304
316
|
[VideoFormat.DASH_WEBM_VK]?: IDashURLSource;
|
|
305
317
|
[VideoFormat.DASH_WEBM]?: IDashURLSource;
|
|
306
318
|
[VideoFormat.DASH_ONDEMAND]?: IDashURLSource;
|
|
319
|
+
[VideoFormat.DASH_ONDEMAND_VK]?: IDashURLSource;
|
|
307
320
|
[VideoFormat.DASH_LIVE]?: IDashURLSource;
|
|
308
321
|
[VideoFormat.DASH_LIVE_WEBM]?: IDashURLSource;
|
|
309
322
|
[VideoFormat.HLS]?: IHLSSource;
|
|
@@ -341,6 +354,7 @@ export declare enum VideoFormat {
|
|
|
341
354
|
DASH_WEBM = "DASH_WEBM",
|
|
342
355
|
DASH_WEBM_VK = "DASH_WEBM_VK",
|
|
343
356
|
DASH_ONDEMAND = "DASH_ONDEMAND",
|
|
357
|
+
DASH_ONDEMAND_VK = "DASH_ONDEMAND_VK",
|
|
344
358
|
DASH_LIVE = "DASH_LIVE",
|
|
345
359
|
DASH_LIVE_WEBM = "DASH_LIVE_WEBM",
|
|
346
360
|
HLS = "HLS",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IObservable, IValueObservable, Seconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { IRange } from "../../utils/range";
|
|
1
|
+
import { IObservable, IValueObservable, Seconds, IRange } from '@vkontakte/videoplayer-shared';
|
|
3
2
|
import { IStateMachine } from "../../utils/StateMachine/types";
|
|
4
3
|
import { PlaybackState, SeekState } from "../types";
|
|
5
4
|
interface IParams {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { IRepresentation } from '../types';
|
|
3
|
+
interface IParams {
|
|
4
|
+
videoElement: HTMLVideoElement;
|
|
5
|
+
playerCallback: (...args: any) => void;
|
|
6
|
+
config: {
|
|
7
|
+
minBuffer: Milliseconds;
|
|
8
|
+
lowLatencyMinBuffer: Milliseconds;
|
|
9
|
+
minBufferSegments: number;
|
|
10
|
+
lowLatencyMinBufferSegments: number;
|
|
11
|
+
maxParallelRequests: number;
|
|
12
|
+
};
|
|
13
|
+
logger: (...args: any[]) => void;
|
|
14
|
+
}
|
|
15
|
+
export default class LiveDashPlayer {
|
|
16
|
+
private paused;
|
|
17
|
+
private autoQuality;
|
|
18
|
+
private maxAutoQuality;
|
|
19
|
+
private buffering;
|
|
20
|
+
private destroyed;
|
|
21
|
+
private videoPlayStarted;
|
|
22
|
+
private lowLatency;
|
|
23
|
+
private rep?;
|
|
24
|
+
private bitrate;
|
|
25
|
+
private manifest;
|
|
26
|
+
private bitrateSwitcher?;
|
|
27
|
+
private filesFetcher?;
|
|
28
|
+
private sourceBuffer?;
|
|
29
|
+
private mediaSource?;
|
|
30
|
+
private currentManifestEntry?;
|
|
31
|
+
private manifestRequest?;
|
|
32
|
+
private manifestRefetchTimer?;
|
|
33
|
+
private bufferStates;
|
|
34
|
+
private downloadRate?;
|
|
35
|
+
private sourceJitter;
|
|
36
|
+
private chunkRateEstimator;
|
|
37
|
+
private manifestUrl;
|
|
38
|
+
private urlResolver;
|
|
39
|
+
private params;
|
|
40
|
+
constructor(params: IParams);
|
|
41
|
+
attachSource(manifestUrl: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* switch to auto quality
|
|
44
|
+
*/
|
|
45
|
+
setAutoQualityEnabled(enabled: boolean): void;
|
|
46
|
+
setMaxAutoQuality(height: number | undefined): void;
|
|
47
|
+
/**
|
|
48
|
+
* switch quality by name
|
|
49
|
+
*/
|
|
50
|
+
switchByName(name: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* seek to actual video position
|
|
53
|
+
*/
|
|
54
|
+
catchUp(): void;
|
|
55
|
+
stop(): void;
|
|
56
|
+
pause(): void;
|
|
57
|
+
play(onPlayNotAllowed?: () => void): void;
|
|
58
|
+
startPlay(targetQ: IRepresentation, autoQuality: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* destroy player
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
63
|
+
reinit(newManifestUrl: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* if all retries fail...
|
|
66
|
+
*/
|
|
67
|
+
private _handleNetworkError;
|
|
68
|
+
/**
|
|
69
|
+
* Retry request
|
|
70
|
+
*/
|
|
71
|
+
private _retryCallback;
|
|
72
|
+
/**
|
|
73
|
+
* how many seconds are there in the buffer
|
|
74
|
+
*/
|
|
75
|
+
private _getBufferSizeSec;
|
|
76
|
+
/**
|
|
77
|
+
* send buffering notification to player
|
|
78
|
+
*/
|
|
79
|
+
private _notifyBuffering;
|
|
80
|
+
/**
|
|
81
|
+
* initialize video tag, add necessary event listeners
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private _initVideo;
|
|
85
|
+
/**
|
|
86
|
+
* there may be small gaps of several milliseconds when switching quality
|
|
87
|
+
* we jump over these gaps here
|
|
88
|
+
*/
|
|
89
|
+
private _fixupStall;
|
|
90
|
+
/**
|
|
91
|
+
* return best quality for rate
|
|
92
|
+
*/
|
|
93
|
+
private _selectQuality;
|
|
94
|
+
private shouldPlay;
|
|
95
|
+
/**
|
|
96
|
+
* set video source
|
|
97
|
+
*/
|
|
98
|
+
private _setVideoSrc;
|
|
99
|
+
/**
|
|
100
|
+
* initialize player with target quality
|
|
101
|
+
*/
|
|
102
|
+
private _initPlayerWith;
|
|
103
|
+
/**
|
|
104
|
+
* represents specific quality stream
|
|
105
|
+
*/
|
|
106
|
+
private _representation;
|
|
107
|
+
/**
|
|
108
|
+
* switch to quality
|
|
109
|
+
* TODO: Если новое качество выше старого – переключиться сразу. Если хуже, доиграть буфер
|
|
110
|
+
*/
|
|
111
|
+
private _switchToQuality;
|
|
112
|
+
/**
|
|
113
|
+
* check if quality is available
|
|
114
|
+
*/
|
|
115
|
+
private _qualityAvailable;
|
|
116
|
+
/**
|
|
117
|
+
* analyze bitrate data and switch qualities accordingly
|
|
118
|
+
*/
|
|
119
|
+
private _initBitrateSwitcher;
|
|
120
|
+
/**
|
|
121
|
+
* load and parse manifest file
|
|
122
|
+
*/
|
|
123
|
+
private _fetchManifest;
|
|
124
|
+
private _playVideoElement;
|
|
125
|
+
/**
|
|
126
|
+
* update internal state when manifest was received from remote
|
|
127
|
+
*/
|
|
128
|
+
private _handleManifestUpdate;
|
|
129
|
+
/**
|
|
130
|
+
* schedule manifest update after delay
|
|
131
|
+
*/
|
|
132
|
+
private _refetchManifest;
|
|
133
|
+
private _initManifest;
|
|
134
|
+
}
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import HttpVideoBuffer from "../../../utils/buffer/HttpVideoBuffer";
|
|
3
|
+
import { IDashConfig, IRef, IRepresentation } from '../types';
|
|
4
|
+
interface IParams {
|
|
5
|
+
video: HTMLVideoElement;
|
|
6
|
+
buffer: HttpVideoBuffer;
|
|
7
|
+
selectRepresentation: (representations: IRepresentation[]) => IRepresentation;
|
|
8
|
+
onManifestReady: (representations: IRepresentation[]) => void;
|
|
9
|
+
onIdxRequestPing: (ping: Milliseconds) => void;
|
|
10
|
+
onResponseHeaders: (headers: Headers) => void;
|
|
11
|
+
onBandwidthChange: (payload: {
|
|
12
|
+
size: number;
|
|
13
|
+
duration: number;
|
|
14
|
+
speed: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
onRepresentationPlay: (representation: IRepresentation) => void;
|
|
17
|
+
onError: (id: string, message: string, thrown?: Error | unknown) => void;
|
|
18
|
+
config: IDashConfig;
|
|
19
|
+
onDashCallback?: (eventName: string, param?: any) => any;
|
|
20
|
+
}
|
|
21
|
+
export default class DashLite {
|
|
22
|
+
private _params;
|
|
23
|
+
private _representations;
|
|
24
|
+
private _appendVector;
|
|
25
|
+
private _currentRepresentation?;
|
|
26
|
+
private _stream;
|
|
27
|
+
private _lastLoadOffset?;
|
|
28
|
+
private _loopTimeout?;
|
|
29
|
+
private _cachingPaused;
|
|
30
|
+
private _duration;
|
|
31
|
+
private STREAM_END_THRESHOLD;
|
|
32
|
+
private _video;
|
|
33
|
+
private _buffer;
|
|
34
|
+
private _onDashCallback;
|
|
35
|
+
private _config;
|
|
36
|
+
constructor(params: IParams);
|
|
37
|
+
/**
|
|
38
|
+
* Parse duration from ISO8601 string.
|
|
39
|
+
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|
40
|
+
* @see https://github.com/moment/moment/blob/develop/src/lib/duration/create.js#L13
|
|
41
|
+
*/
|
|
42
|
+
_parseDurationFromISO8601(input: string): number;
|
|
43
|
+
getRepresentations(): IRepresentation[];
|
|
44
|
+
attachSource(manifestUrl: string, failoverHosts?: string[]): void;
|
|
45
|
+
attachManifest(manifestString: string, failoverHosts?: string[], origin?: string): void;
|
|
46
|
+
_loadInitAndSidx(representation: IRepresentation, cb?: () => void): void;
|
|
47
|
+
startPlay(representation: IRepresentation): void;
|
|
48
|
+
_loadRef(representation: IRepresentation, fromTime: number, needToSeek?: boolean, forcePrecise?: boolean): void;
|
|
49
|
+
setQualityByRepresentation(newRepresentation: IRepresentation, force?: boolean): void;
|
|
50
|
+
setQuality(index: number): void;
|
|
51
|
+
pauseCaching(): void;
|
|
52
|
+
resumeCaching(): void;
|
|
53
|
+
seek(time: number, forcePrecise?: boolean): void;
|
|
54
|
+
updateRefsForCurrentTime(): void;
|
|
55
|
+
_findRef(time: number): IRef | undefined;
|
|
56
|
+
_isLastRef(ref: IRef): boolean;
|
|
57
|
+
_findBufferRangeEnd(time: number): number;
|
|
58
|
+
destroy(): void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Byte, Kbps, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
1
|
+
import { Byte, Kbps, Milliseconds, IRange } from '@vkontakte/videoplayer-shared';
|
|
2
2
|
export declare enum RepresentationKind {
|
|
3
3
|
VIDEO = "video",
|
|
4
4
|
AUDIO = "audio",
|
|
@@ -8,31 +8,52 @@ export declare enum Profile {
|
|
|
8
8
|
WEBM_AS_IN_SPEC = "urn:mpeg:dash:profile:webm-on-demand:2012",
|
|
9
9
|
WEBM_AS_IN_FFMPEG = "urn:webm:dash:profile:webm-on-demand:2012"
|
|
10
10
|
}
|
|
11
|
-
export interface Range<Unit extends number> {
|
|
12
|
-
from: Unit;
|
|
13
|
-
to: Unit;
|
|
14
|
-
}
|
|
15
11
|
export interface Representation {
|
|
16
12
|
id: string;
|
|
17
13
|
kind: RepresentationKind;
|
|
14
|
+
segmentReference: SegmentReference;
|
|
18
15
|
profiles: Array<Profile | string>;
|
|
19
|
-
initRange: Range<Byte>;
|
|
20
|
-
indexRange?: Range<Byte>;
|
|
21
16
|
duration?: Milliseconds;
|
|
22
17
|
bitrate: Kbps;
|
|
23
18
|
mime: string;
|
|
24
19
|
codecs: string;
|
|
25
20
|
width: number;
|
|
26
21
|
height: number;
|
|
27
|
-
url: string;
|
|
28
22
|
fps?: number;
|
|
29
23
|
quality?: string;
|
|
30
24
|
}
|
|
31
|
-
export
|
|
25
|
+
export declare enum SegmentReferencingType {
|
|
26
|
+
BYTE_RANGE = "byteRange",
|
|
27
|
+
TEMPLATE = "template"
|
|
28
|
+
}
|
|
29
|
+
export declare type ByteRangeSegmentReference = {
|
|
30
|
+
type: SegmentReferencingType.BYTE_RANGE;
|
|
31
|
+
url: string;
|
|
32
|
+
initRange: IRange<Byte>;
|
|
33
|
+
indexRange?: IRange<Byte>;
|
|
34
|
+
};
|
|
35
|
+
export declare type TemplateSegmentReference = {
|
|
36
|
+
type: SegmentReferencingType.TEMPLATE;
|
|
37
|
+
baseUrl: string;
|
|
38
|
+
initUrl: string;
|
|
39
|
+
segments: {
|
|
40
|
+
url: string;
|
|
41
|
+
time: IRange<Milliseconds>;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
export declare type SegmentReference = ByteRangeSegmentReference | TemplateSegmentReference;
|
|
45
|
+
export interface ByteRangeSegment {
|
|
32
46
|
status: SegmentStatus;
|
|
33
|
-
time:
|
|
34
|
-
byte:
|
|
47
|
+
time: IRange<Milliseconds>;
|
|
48
|
+
byte: IRange<Byte>;
|
|
49
|
+
}
|
|
50
|
+
export interface TemplateSegment {
|
|
51
|
+
status: SegmentStatus;
|
|
52
|
+
time: IRange<Milliseconds>;
|
|
53
|
+
size: Byte | undefined;
|
|
54
|
+
url: string;
|
|
35
55
|
}
|
|
56
|
+
export declare type Segment = ByteRangeSegment | TemplateSegment;
|
|
36
57
|
export declare enum SegmentStatus {
|
|
37
58
|
NONE = "none",
|
|
38
59
|
DOWNLOADING = "downloading",
|
|
@@ -41,6 +62,7 @@ export declare enum SegmentStatus {
|
|
|
41
62
|
FED = "fed"
|
|
42
63
|
}
|
|
43
64
|
export interface Manifest {
|
|
65
|
+
duration: Milliseconds | undefined;
|
|
44
66
|
container: Container;
|
|
45
67
|
representations: {
|
|
46
68
|
[key in RepresentationKind]: Representation[];
|
|
@@ -52,7 +74,7 @@ export declare enum Container {
|
|
|
52
74
|
}
|
|
53
75
|
export interface GenericContainerParser<InitData> {
|
|
54
76
|
validateData(data: DataView): boolean;
|
|
55
|
-
getIndexRange(init: InitData):
|
|
77
|
+
getIndexRange(init: InitData): IRange<Byte> | undefined;
|
|
56
78
|
parseInit(data: DataView): InitData;
|
|
57
79
|
parseSegments(data: DataView, init: InitData): Segment[];
|
|
58
80
|
parseFeedableSegmentChunk(data: DataView): DataView | null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Kbps } from '@vkontakte/videoplayer-shared';
|
|
1
|
+
import { Kbps, IRectangle } from '@vkontakte/videoplayer-shared';
|
|
2
2
|
import { VideoQuality } from "../../utils/quality/types";
|
|
3
|
-
import { IRectangle } from "../../utils/rectangle";
|
|
4
3
|
export declare type ManifestUrl = {
|
|
5
4
|
id: string;
|
|
6
5
|
quality: VideoQuality;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IMetadata, ISources, IVideoTrack, IVolumeState, VideoFormat } from "../../player/types";
|
|
2
|
-
import { IRange } from "../../utils/range";
|
|
3
2
|
import { ITuningConfig } from "../../utils/tuningConfig";
|
|
4
|
-
import { IError, ISubject, IValueSubject, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
3
|
+
import { IError, ISubject, IValueSubject, Subject, ValueSubject, IRange } from '@vkontakte/videoplayer-shared';
|
|
5
4
|
import { IDesiredState, IProviderDependencies } from '../types';
|
|
6
5
|
import { IProviderContainer, IProviderEntry } from './types';
|
|
7
6
|
interface IParams extends IProviderDependencies {
|
|
@@ -31,8 +30,9 @@ export default class ProviderContainer implements IProviderContainer {
|
|
|
31
30
|
seekedEvent$: Subject<void>;
|
|
32
31
|
loopedEvent$: Subject<number>;
|
|
33
32
|
endedEvent$: Subject<void>;
|
|
34
|
-
firstBytesEvent$: Subject<
|
|
35
|
-
firstFrameEvent$: Subject<
|
|
33
|
+
firstBytesEvent$: Subject<void>;
|
|
34
|
+
firstFrameEvent$: Subject<void>;
|
|
35
|
+
canplay$: Subject<void>;
|
|
36
36
|
isLive$: ValueSubject<undefined>;
|
|
37
37
|
liveTime$: ValueSubject<undefined>;
|
|
38
38
|
availableTextTracks$: ValueSubject<never[]>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Seconds, IRange, IObservable, IError } from '@vkontakte/videoplayer-shared';
|
|
2
2
|
import { IVolumeState } from "../../player/types";
|
|
3
|
-
import { IRange } from "../../utils/range";
|
|
4
3
|
interface IObservableVideo {
|
|
5
4
|
playing$: IObservable<undefined>;
|
|
6
5
|
pause$: IObservable<undefined>;
|
|
@@ -11,15 +10,14 @@ interface IObservableVideo {
|
|
|
11
10
|
seeked$: IObservable<undefined>;
|
|
12
11
|
seeking$: IObservable<undefined>;
|
|
13
12
|
progress$: IObservable<undefined>;
|
|
14
|
-
loadedMetadata$: IObservable<undefined>;
|
|
15
|
-
loadedData$: IObservable<undefined>;
|
|
16
13
|
timeUpdate$: IObservable<Seconds>;
|
|
17
14
|
durationChange$: IObservable<Seconds>;
|
|
15
|
+
loadStart$: IObservable<void>;
|
|
16
|
+
loadedMetadata$: IObservable<undefined>;
|
|
17
|
+
loadedData$: IObservable<undefined>;
|
|
18
18
|
isBuffering$: IObservable<boolean>;
|
|
19
19
|
currentBuffer$: IObservable<IRange<Seconds>>;
|
|
20
20
|
volumeState$: IObservable<IVolumeState>;
|
|
21
|
-
firstBytes$: IObservable<Milliseconds>;
|
|
22
|
-
firstFrame$: IObservable<Milliseconds>;
|
|
23
21
|
}
|
|
24
22
|
export declare const observe: (video: HTMLVideoElement) => IObservableVideo;
|
|
25
23
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ITuningConfig } from "./tuningConfig";
|
|
2
|
-
import { Kbps, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
+
import { Kbps, Milliseconds, IRectangle } from '@vkontakte/videoplayer-shared';
|
|
3
3
|
import { IVideoTrack } from "../player/types";
|
|
4
4
|
import { QualityLimits } from "./quality/types";
|
|
5
|
-
import { IRectangle } from "./rectangle";
|
|
6
5
|
export interface Constraints {
|
|
7
6
|
container?: IRectangle;
|
|
8
7
|
throughput?: Kbps;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Seconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { IRange } from "../range";
|
|
1
|
+
import { Seconds, IRange } from '@vkontakte/videoplayer-shared';
|
|
3
2
|
declare const _default: (timeRanges: TimeRanges, position: Seconds, gapTolerance?: number) => IRange<Seconds>;
|
|
4
3
|
export default _default;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IObservable, Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { IRectangle } from "./rectangle";
|
|
1
|
+
import { IObservable, Milliseconds, IRectangle } from '@vkontakte/videoplayer-shared';
|
|
3
2
|
declare const observeElementSize: (element: Element, debounceTime?: Milliseconds) => IObservable<IRectangle>;
|
|
4
3
|
export default observeElementSize;
|
package/utils/quality/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRectangle } from '
|
|
1
|
+
import { IRectangle } from '@vkontakte/videoplayer-shared';
|
|
2
2
|
import { ExactVideoQuality, VideoQuality } from './types';
|
|
3
3
|
export declare const isHigher: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
|
|
4
4
|
export declare const isHigherOrEqual: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
|