@vkontakte/videoplayer-core 2.0.69 → 2.0.71
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.d.ts +2 -2
- package/es2015.cjs.js +4 -4
- package/es2015.esm.d.ts +2 -2
- package/es2015.esm.js +4 -4
- package/es2018.cjs.d.ts +2 -2
- package/es2018.cjs.js +4 -4
- package/es2018.esm.d.ts +2 -2
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.d.ts +2 -2
- package/esnext.esm.js +4 -4
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/packages/core/src/providers/WebRTCLiveProvider/interface/WebRTCLiveClientOptions.d.ts +9 -0
- package/packages/core/src/providers/types.d.ts +2 -1
- package/player/Player.d.ts +3 -1
- package/player/types.d.ts +9 -1
- package/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +135 -0
- package/providers/WebRTCLiveProvider/WebRTCLiveClient.d.ts +188 -0
- package/providers/WebRTCLiveProvider/WebRTCLiveProvider.d.ts +60 -0
- package/providers/utils/observableVideo.d.ts +2 -1
- package/providers/utils/syncDesiredState.d.ts +2 -1
- package/utils/buffer/isPositionBuffered.d.ts +3 -0
- package/utils/tuningConfig.d.ts +3 -0
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VideoFormat, IMpegSource, IDashSource, IHLSSource, IDashURLSource, IHLSLiveSource, StartStatus, ISeekRequest, URLSource, RawSource, URLSourceWithSeek } from "./player/types";
|
|
2
2
|
import Player from "./player/Player";
|
|
3
|
-
import { IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, ChromecastState, HttpConnectionType, IExternalTextTrack, ITextTrack } from "./player/types";
|
|
3
|
+
import { IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, ChromecastState, HttpConnectionType, IExternalTextTrack, ITextTrack, PlaybackRate } from "./player/types";
|
|
4
4
|
import { VideoQuality, ExactVideoQuality } from "./utils/quality/types";
|
|
5
5
|
import type { ISubscription, IUnsubscriber, IEmitter, IObservable, IValueObservable, IValue, IOperator, IListener, ILogEntry, IRange } from '@vkontakte/videoplayer-shared';
|
|
6
6
|
import { Subscription, Observable, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
@@ -8,4 +8,4 @@ import { Subscription, Observable, Subject, ValueSubject } from '@vkontakte/vide
|
|
|
8
8
|
* Версия sdk
|
|
9
9
|
*/
|
|
10
10
|
declare const SDK_VERSION: string;
|
|
11
|
-
export { Player, IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ILogEntry, ISources, IExternalTextTrack, ITextTrack, ChromecastState, HttpConnectionType, Subscription, ISubscription, IUnsubscriber, IObservable, IEmitter, IValueObservable, IValue, IOperator, IListener, VideoFormat, IMpegSource, IDashSource, IDashURLSource, IHLSSource, IHLSLiveSource, URLSource, RawSource, URLSourceWithSeek, VideoQuality, ExactVideoQuality, Observable, Subject, ValueSubject, IRange, StartStatus, ISeekRequest, ICueSettings, SDK_VERSION, };
|
|
11
|
+
export { Player, IPlayer, PlaybackState, IPlayerInfo, IPlayerEvents, IConfig, ILogEntry, ISources, IExternalTextTrack, ITextTrack, ChromecastState, HttpConnectionType, Subscription, ISubscription, IUnsubscriber, IObservable, IEmitter, IValueObservable, IValue, IOperator, IListener, VideoFormat, IMpegSource, IDashSource, IDashURLSource, IHLSSource, IHLSLiveSource, URLSource, RawSource, URLSourceWithSeek, VideoQuality, ExactVideoQuality, Observable, Subject, ValueSubject, IRange, StartStatus, ISeekRequest, ICueSettings, SDK_VERSION, PlaybackRate, };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { ITuningConfig } from "../utils/tuningConfig";
|
|
|
3
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
|
-
import { IExternalTextTrack, ITextTrack, IVideoTrack, IVolumeState, PlaybackState } from "../player/types";
|
|
6
|
+
import { IExternalTextTrack, ITextTrack, IVideoTrack, IVolumeState, PlaybackState, PlaybackRate } from "../player/types";
|
|
7
7
|
import { IStateMachine } from "../utils/StateMachine/types";
|
|
8
8
|
import ThroughputEstimator from "../utils/ThroughputEstimator";
|
|
9
9
|
export interface IProvider {
|
|
@@ -27,6 +27,7 @@ export interface IDesiredState {
|
|
|
27
27
|
playbackState: IStateMachine<PlaybackState>;
|
|
28
28
|
seekState: IStateMachine<SeekState>;
|
|
29
29
|
volume: IStateMachine<IVolumeState>;
|
|
30
|
+
playbackRate: IStateMachine<PlaybackRate>;
|
|
30
31
|
videoTrack: IStateMachine<IVideoTrack['id'] | undefined>;
|
|
31
32
|
autoVideoTrackSwitching: IStateMachine<boolean>;
|
|
32
33
|
autoVideoTrackLimits: IStateMachine<QualityLimits>;
|
package/player/Player.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpConnectionType, ICueSettings, StartEnd } from "./types";
|
|
1
|
+
import { HttpConnectionType, ICueSettings, StartEnd, PlaybackRate } from "./types";
|
|
2
2
|
import { QualityLimits, VideoQuality } from "../utils/quality/types";
|
|
3
3
|
import { IOptionalTuningConfig } from "../utils/tuningConfig";
|
|
4
4
|
import { IError, ILogEntry, Seconds, Subject, ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
@@ -28,6 +28,7 @@ export default class Player implements IPlayer {
|
|
|
28
28
|
isAutoQualityEnabled$: ValueSubject<boolean>;
|
|
29
29
|
autoQualityLimitingAvailable$: ValueSubject<boolean>;
|
|
30
30
|
autoQualityLimits$: ValueSubject<QualityLimits>;
|
|
31
|
+
currentPlaybackRate$: ValueSubject<number>;
|
|
31
32
|
currentBuffer$: ValueSubject<StartEnd<number>>;
|
|
32
33
|
isBuffering$: ValueSubject<boolean>;
|
|
33
34
|
isStalled$: ValueSubject<boolean>;
|
|
@@ -93,6 +94,7 @@ export default class Player implements IPlayer {
|
|
|
93
94
|
setQuality(quality: VideoQuality): IPlayer;
|
|
94
95
|
setAutoQuality(enable: boolean): IPlayer;
|
|
95
96
|
setAutoQualityLimits(limits: QualityLimits): IPlayer;
|
|
97
|
+
setPlaybackRate(playbackRate: PlaybackRate): IPlayer;
|
|
96
98
|
setExternalTextTracks(tracks: Omit<IExternalTextTrack, 'type'>[]): IPlayer;
|
|
97
99
|
selectTextTrack(id: ITextTrack['id'] | undefined): IPlayer;
|
|
98
100
|
setTextTrackCueSettings(settings: ICueSettings): IPlayer;
|
package/player/types.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface IPlayer {
|
|
|
35
35
|
setQuality(quality: VideoQuality): IPlayer;
|
|
36
36
|
setAutoQuality(enable: boolean): IPlayer;
|
|
37
37
|
setAutoQualityLimits(limit: QualityLimits): IPlayer;
|
|
38
|
+
setPlaybackRate(playbackRate: PlaybackRate): IPlayer;
|
|
38
39
|
setLooped(isLooped: boolean): IPlayer;
|
|
39
40
|
setExternalTextTracks(tracks: Omit<IExternalTextTrack, 'type'>[]): IPlayer;
|
|
40
41
|
selectTextTrack(id: ITextTrack['id'] | undefined): IPlayer;
|
|
@@ -206,6 +207,10 @@ export interface IPlayerInfo {
|
|
|
206
207
|
* Текущие лимиты авто-качества
|
|
207
208
|
*/
|
|
208
209
|
autoQualityLimits$: IValueObservable<QualityLimits>;
|
|
210
|
+
/**
|
|
211
|
+
* Текущая скорость воспроизведения
|
|
212
|
+
*/
|
|
213
|
+
currentPlaybackRate$: IValueObservable<PlaybackRate>;
|
|
209
214
|
/**
|
|
210
215
|
* Текущий буффер (тот, который содержит текущую позицию воспроизведения)
|
|
211
216
|
*
|
|
@@ -319,6 +324,7 @@ export interface ISources {
|
|
|
319
324
|
[VideoFormat.HLS]?: IHLSSource;
|
|
320
325
|
[VideoFormat.HLS_ONDEMAND]?: IHLSSource;
|
|
321
326
|
[VideoFormat.HLS_LIVE]?: IHLSLiveSource;
|
|
327
|
+
[VideoFormat.WEB_RTC_LIVE]?: URLSource;
|
|
322
328
|
}
|
|
323
329
|
export interface IMetadata {
|
|
324
330
|
title?: string;
|
|
@@ -361,7 +367,8 @@ export declare enum VideoFormat {
|
|
|
361
367
|
HLS_ONDEMAND = "HLS_ONDEMAND",
|
|
362
368
|
/** @deprecated Используйте HLS */
|
|
363
369
|
HLS_JS = "HLS",
|
|
364
|
-
HLS_LIVE = "HLS_LIVE"
|
|
370
|
+
HLS_LIVE = "HLS_LIVE",
|
|
371
|
+
WEB_RTC_LIVE = "WEB_RTC_LIVE"
|
|
365
372
|
}
|
|
366
373
|
export interface IVideoTrack {
|
|
367
374
|
id: string;
|
|
@@ -430,4 +437,5 @@ declare type SeekStateNotNone = {
|
|
|
430
437
|
};
|
|
431
438
|
export declare type SeekState = SeekStateNone | SeekStateNotNone;
|
|
432
439
|
export declare type FpsByQuality = Partial<Record<VideoQuality, number>>;
|
|
440
|
+
export declare type PlaybackRate = number;
|
|
433
441
|
export {};
|
|
@@ -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,188 @@
|
|
|
1
|
+
import { WebRTCLiveClientOptions } from "./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 "../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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Seconds, IRange, IObservable, IError } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { IVolumeState } from "../../player/types";
|
|
2
|
+
import { IVolumeState, PlaybackRate } from "../../player/types";
|
|
3
3
|
interface IObservableVideo {
|
|
4
4
|
playing$: IObservable<undefined>;
|
|
5
5
|
pause$: IObservable<undefined>;
|
|
@@ -18,6 +18,7 @@ interface IObservableVideo {
|
|
|
18
18
|
isBuffering$: IObservable<boolean>;
|
|
19
19
|
currentBuffer$: IObservable<IRange<Seconds>>;
|
|
20
20
|
volumeState$: IObservable<IVolumeState>;
|
|
21
|
+
playbackRateState$: IObservable<PlaybackRate>;
|
|
21
22
|
}
|
|
22
23
|
export declare const observe: (video: HTMLVideoElement) => IObservableVideo;
|
|
23
24
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IListener, IObservable, ISubscription } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { IVolumeState } from "../../player/types";
|
|
2
|
+
import { IVolumeState, PlaybackRate } from "../../player/types";
|
|
3
3
|
import { IStateMachine } from "../../utils/StateMachine/types";
|
|
4
4
|
declare const syncDesiredState: <Value>(desiredState: IStateMachine<Value | undefined>, get: () => Value | undefined, set: (value: Value | undefined) => void, { equal, changed$, onError, }?: {
|
|
5
5
|
equal?: ((a: Value | undefined, b: Value | undefined) => boolean) | undefined;
|
|
@@ -8,4 +8,5 @@ declare const syncDesiredState: <Value>(desiredState: IStateMachine<Value | unde
|
|
|
8
8
|
}) => ISubscription;
|
|
9
9
|
export declare const syncVideoLooped: (video: HTMLVideoElement, desiredState: IStateMachine<boolean>, onError?: IListener<Error | unknown>) => ISubscription;
|
|
10
10
|
export declare const syncVideoVolumeState: (video: HTMLVideoElement, desiredState: IStateMachine<IVolumeState>, changed$: IObservable<IVolumeState>, onError?: IListener<Error | unknown>) => ISubscription;
|
|
11
|
+
export declare const syncVideoPlaybackRate: (video: HTMLVideoElement, desiredState: IStateMachine<PlaybackRate>, changed$: IObservable<PlaybackRate>, onError?: IListener<Error | unknown>) => ISubscription;
|
|
11
12
|
export default syncDesiredState;
|
package/utils/tuningConfig.d.ts
CHANGED
|
@@ -65,6 +65,9 @@ export declare type ITuningConfig = {
|
|
|
65
65
|
requestQuick: boolean;
|
|
66
66
|
useDashJs: boolean;
|
|
67
67
|
useHlsJs: boolean;
|
|
68
|
+
webrtc: {
|
|
69
|
+
connectionRetryMaxNumber: number;
|
|
70
|
+
};
|
|
68
71
|
};
|
|
69
72
|
export declare type IOptionalTuningConfig = {
|
|
70
73
|
[key in keyof ITuningConfig]?: Partial<ITuningConfig[key]>;
|