@vkontakte/videoplayer-core 2.0.55 → 2.0.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.55",
3
+ "version": "2.0.58",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -23,6 +23,7 @@ export declare class BufferManager {
23
23
  private initData;
24
24
  private representations;
25
25
  private segments;
26
+ private allInitsLoaded;
26
27
  private activeSegments;
27
28
  private mediaSource;
28
29
  private playingRepresentationId;
@@ -32,19 +33,20 @@ export declare class BufferManager {
32
33
  private downloadAbortController;
33
34
  private destroyAbortController;
34
35
  private getCurrentPosition;
35
- private loadAllInitsPromise;
36
- private allInitsLoaded;
37
36
  private tuning;
37
+ private forwardBufferTarget;
38
38
  private fetcher;
39
39
  private bufferLimit;
40
40
  private sourceBufferTaskQueue;
41
41
  private gapDetectionIdleCallback;
42
+ private initLoadIdleCallback;
42
43
  constructor(kind: RepresentationKind, mediaSource: MediaSource, container: Container, representations: Representation[], { fetcher, tuning, getCurrentPosition }: Dependencies);
43
44
  startWith: (param_0: string) => Promise<void | undefined>;
44
45
  switchTo: (param_0: string) => Promise<void | undefined>;
45
46
  abort(): void;
46
47
  maintain(currentPosition: Milliseconds): void;
47
48
  findSegmentStartTime(position: Milliseconds): Milliseconds | undefined;
49
+ setTarget(time: Milliseconds): void;
48
50
  destroy(): void;
49
51
  private selectForwardBufferSegments;
50
52
  private loadSegments;
@@ -58,7 +60,8 @@ export declare class BufferManager {
58
60
  */
59
61
  private onSomeDataLoaded;
60
62
  private abortSegment;
61
- private loadAllInits;
63
+ private loadNextInit;
64
+ private loadInit;
62
65
  private pruneBuffer;
63
66
  private abortBuffer;
64
67
  private detectGaps;
@@ -10,10 +10,13 @@ export interface IParams {
10
10
  throughputEstimator?: ThroughputEstimator;
11
11
  requestQuic: boolean;
12
12
  }
13
+ export declare type Priority = 'high' | 'low' | 'auto';
13
14
  export interface FetchParams {
14
15
  method?: RangeMethod;
15
16
  onProgress?: (view: DataView, loaded: Byte) => void;
16
17
  signal?: AbortSignal;
18
+ priority?: Priority;
19
+ measureThroughput?: boolean;
17
20
  }
18
21
  export declare class Fetcher {
19
22
  private throughputEstimator;
@@ -27,7 +30,7 @@ export declare class Fetcher {
27
30
  private onHeadersReceived;
28
31
  fetchManifest: (param_0: string) => Promise<string | null | undefined>;
29
32
  fetchRange: (param_0: string, param_1: number, param_2: number, param_3: FetchParams) => Promise<ArrayBuffer | null | undefined>;
30
- fetchRepresentation: (param_0: Representation, param_1: GenericContainerParser<unknown>, param_2?: number | undefined) => Promise<{
33
+ fetchRepresentation: (param_0: Representation, param_1: GenericContainerParser<unknown>, param_2?: Priority | undefined, param_3?: number | undefined) => Promise<{
31
34
  segments: Segment[];
32
35
  dataView: DataView;
33
36
  } | null | undefined>;
@@ -8,8 +8,9 @@ declare class SourceBufferTaskQueue {
8
8
  constructor(buffer: SourceBuffer);
9
9
  append(data: BufferSource, signal?: AbortSignal): Promise<boolean>;
10
10
  remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
11
+ abort(): Promise<boolean>;
11
12
  destroy(): void;
12
- private onUpdateEnd;
13
+ private completeTask;
13
14
  private pull;
14
15
  private execute;
15
16
  }
@@ -43,7 +43,7 @@ export interface IProviderOutput {
43
43
  currentVideoTrack$: IValueSubject<IVideoTrack | undefined>;
44
44
  availableVideoTracks$: IValueSubject<IVideoTrack[]>;
45
45
  autoVideoTrackLimitingAvailable$: IValueSubject<boolean>;
46
- currentBuffer$: IValueSubject<IRange | undefined>;
46
+ currentBuffer$: IValueSubject<IRange<Seconds> | undefined>;
47
47
  isBuffering$: IValueSubject<boolean>;
48
48
  isLive$: IValueSubject<boolean | undefined>;
49
49
  liveTime$: IValueSubject<Milliseconds | undefined>;
@@ -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 {};
@@ -40,6 +40,7 @@ export declare class Player {
40
40
  switchRepresentation(kind: RepresentationKind, id: Representation['id']): Promise<void>;
41
41
  seek(requestedPosition: Milliseconds, forcePrecise: boolean): void;
42
42
  stop(): void;
43
+ setBufferTarget(time: Milliseconds): void;
43
44
  destroy(): void;
44
45
  private tick;
45
46
  private jumGap;
@@ -5,6 +5,7 @@ declare class ThroughputEstimator {
5
5
  private rtt;
6
6
  private subscription;
7
7
  private tuningConfig;
8
+ private concurrentDownloads;
8
9
  throughput$: IValueSubject<Kbps>;
9
10
  rtt$: IValueSubject<Milliseconds>;
10
11
  rttAdjustedThroughput$: IValueSubject<Kbps>;
@@ -12,7 +13,7 @@ declare class ThroughputEstimator {
12
13
  destroy(): void;
13
14
  trackXHR(xhr: XMLHttpRequest): void;
14
15
  trackStream(stream: ReadableStream): void;
15
- addRawSpeed(size: Byte, time: Milliseconds): void;
16
+ addRawSpeed(size: Byte, time: Milliseconds, concurrency?: number): void;
16
17
  /**
17
18
  * Стоит использовать только когда другие методы совсем не получается
18
19
  */
@@ -8,6 +8,7 @@ export interface Constraints {
8
8
  throughput?: Kbps;
9
9
  tuning: ITuningConfig['autoTrackSelection'];
10
10
  limits?: QualityLimits;
11
+ reserve?: Kbps;
11
12
  playbackRate?: number;
12
13
  forwardBufferHealth?: number;
13
14
  current?: IVideoTrack;
@@ -20,5 +21,5 @@ export declare class TrackHistory {
20
21
  recordSwitch(track: IVideoTrack): void;
21
22
  clear(): void;
22
23
  }
23
- declare const autoSelectVideoTrack: (tracks: IVideoTrack[], { container, throughput, tuning, limits, forwardBufferHealth, playbackRate, current, history, }: Constraints) => IVideoTrack;
24
+ declare const autoSelectVideoTrack: (tracks: IVideoTrack[], { container, throughput, tuning, limits, reserve, forwardBufferHealth, playbackRate, current, history, }: Constraints) => IVideoTrack;
24
25
  export default autoSelectVideoTrack;
@@ -5,6 +5,8 @@ interface IParams {
5
5
  emaAlphaFast: number;
6
6
  changeThreshold: number;
7
7
  fastDirection: 1 | -1;
8
+ deviationDepth: number;
9
+ deviationFactor: number;
8
10
  label?: string;
9
11
  }
10
12
  export declare class SmoothedValue {
@@ -12,6 +14,8 @@ export declare class SmoothedValue {
12
14
  private slow;
13
15
  private fast;
14
16
  private smoothed;
17
+ private pastMeasures;
18
+ private measuresCursor;
15
19
  private params;
16
20
  private rawSeries$;
17
21
  private smoothedSeries$;
@@ -9,6 +9,8 @@ export declare type ITuningConfig = {
9
9
  rttPenaltyRequestSize: Byte;
10
10
  streamMinSampleSize: Byte;
11
11
  streamMinSampleTime: Milliseconds;
12
+ deviationDepth: number;
13
+ deviationFactor: number;
12
14
  };
13
15
  autoTrackSelection: {
14
16
  bitrateFactorAtEmptyBuffer: number;
@@ -17,17 +19,20 @@ export declare type ITuningConfig = {
17
19
  usePixelRatio: boolean;
18
20
  containerSizeFactor: number;
19
21
  lazyQualitySwitch: boolean;
22
+ minBufferToSwitchUp: number;
20
23
  considerPlaybackRate: boolean;
21
24
  trackCooldown: Milliseconds;
22
25
  };
23
26
  dash: {
24
27
  /** @deprecated */
25
- extraInitSize: Milliseconds;
26
28
  forwardBufferTarget: Milliseconds;
29
+ forwardBufferTargetAuto: Milliseconds;
30
+ forwardBufferTargetManual: Milliseconds;
27
31
  segmentRequestSize: Byte;
28
32
  representationSwitchForwardBufferGap: Milliseconds;
29
33
  enableSubSegmentBufferFeeding: boolean;
30
34
  segmentTimelineTolerance: Milliseconds;
35
+ useFetchPriorityHints: boolean;
31
36
  };
32
37
  live: {
33
38
  minBuffer: Milliseconds;