@vkontakte/videoplayer-core 2.0.53 → 2.0.56

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.53",
3
+ "version": "2.0.56",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -1,8 +1,15 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
1
2
  import { IRepresentation } from '../types';
2
3
  interface IParams {
3
4
  videoElement: HTMLVideoElement;
4
5
  playerCallback: (...args: any) => void;
5
- config: any;
6
+ config: {
7
+ minBuffer: Milliseconds;
8
+ lowLatencyMinBuffer: Milliseconds;
9
+ minBufferSegments: number;
10
+ lowLatencyMinBufferSegments: number;
11
+ maxParallelRequests: number;
12
+ };
6
13
  logger: (...args: any[]) => void;
7
14
  }
8
15
  export default class LiveDashPlayer {
@@ -29,7 +29,6 @@ export declare class BufferManager {
29
29
  private downloadingRepresentationId;
30
30
  private switchingToRepresentationId;
31
31
  private sourceBuffer;
32
- private segmentDownloadPromise;
33
32
  private downloadAbortController;
34
33
  private destroyAbortController;
35
34
  private getCurrentPosition;
@@ -63,5 +62,6 @@ export declare class BufferManager {
63
62
  private pruneBuffer;
64
63
  private abortBuffer;
65
64
  private detectGaps;
65
+ private detectGapsWhenIdle;
66
66
  private checkEjectedSegments;
67
67
  }
@@ -10,10 +10,12 @@ 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;
17
19
  }
18
20
  export declare class Fetcher {
19
21
  private throughputEstimator;
@@ -27,7 +29,7 @@ export declare class Fetcher {
27
29
  private onHeadersReceived;
28
30
  fetchManifest: (param_0: string) => Promise<string | null | undefined>;
29
31
  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<{
32
+ fetchRepresentation: (param_0: Representation, param_1: GenericContainerParser<unknown>, param_2?: Priority | undefined, param_3?: number | undefined) => Promise<{
31
33
  segments: Segment[];
32
34
  dataView: DataView;
33
35
  } | null | undefined>;
@@ -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,3 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ declare const _default: (timeRanges: TimeRanges, position: Milliseconds) => boolean;
3
+ export default _default;
@@ -5,7 +5,6 @@ declare type Params = IProviderParams<IDashURLSource> & {
5
5
  config: {
6
6
  maxPausedTime: Milliseconds;
7
7
  chunkDuration: number;
8
- optimalBufferDuration: number;
9
8
  maxParallelRequests: number;
10
9
  };
11
10
  };
@@ -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 {};
@@ -20,6 +20,7 @@ export declare class Player {
20
20
  private tuning;
21
21
  private videoBufferManager;
22
22
  private audioBufferManager;
23
+ private bufferManagers;
23
24
  private throughputEstimator;
24
25
  private subscription;
25
26
  private fetcher;
@@ -35,7 +36,7 @@ export declare class Player {
35
36
  private destroyController;
36
37
  constructor(params: Params);
37
38
  initManifest: (param_0: HTMLVideoElement, param_1: string) => Promise<Manifest | null | undefined>;
38
- initRepresentations: (param_0: string, param_1: string) => Promise<void | undefined>;
39
+ initRepresentations: (param_0: string, param_1: string | undefined) => Promise<void | undefined>;
39
40
  switchRepresentation(kind: RepresentationKind, id: Representation['id']): Promise<void>;
40
41
  seek(requestedPosition: Milliseconds, forcePrecise: boolean): void;
41
42
  stop(): void;
@@ -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>;
@@ -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;
@@ -28,6 +28,13 @@ export declare type ITuningConfig = {
28
28
  representationSwitchForwardBufferGap: Milliseconds;
29
29
  enableSubSegmentBufferFeeding: boolean;
30
30
  segmentTimelineTolerance: Milliseconds;
31
+ useFetchPriorityHints: boolean;
32
+ };
33
+ live: {
34
+ minBuffer: Milliseconds;
35
+ minBufferSegments: number;
36
+ lowLatencyMinBuffer: Milliseconds;
37
+ lowLatencyMinBufferSegments: number;
31
38
  };
32
39
  enableTelemetryAtStart: boolean;
33
40
  formatsToAvoid: VideoFormat[];
@@ -1,128 +0,0 @@
1
- import { IRepresentation } from '../types';
2
- interface IParams {
3
- videoElement: HTMLVideoElement;
4
- playerCallback: (...args: any) => void;
5
- config: any;
6
- logger: (...args: any[]) => void;
7
- }
8
- export default class LiveDashPlayer {
9
- private paused;
10
- private autoQuality;
11
- private maxAutoQuality;
12
- private buffering;
13
- private destroyed;
14
- private videoPlayStarted;
15
- private lowLatency;
16
- private rep?;
17
- private bitrate;
18
- private manifest;
19
- private bitrateSwitcher?;
20
- private filesFetcher?;
21
- private sourceBuffer?;
22
- private mediaSource?;
23
- private currentManifestEntry?;
24
- private manifestRequest?;
25
- private manifestRefetchTimer?;
26
- private bufferStates;
27
- private downloadRate?;
28
- private sourceJitter;
29
- private chunkRateEstimator;
30
- private manifestUrl;
31
- private urlResolver;
32
- private params;
33
- constructor(params: IParams);
34
- attachSource(manifestUrl: string): void;
35
- /**
36
- * switch to auto quality
37
- */
38
- setAutoQualityEnabled(enabled: boolean): void;
39
- setMaxAutoQuality(height: number | undefined): void;
40
- /**
41
- * switch quality by name
42
- */
43
- switchByName(name: string): void;
44
- /**
45
- * seek to actual video position
46
- */
47
- catchUp(): void;
48
- stop(): void;
49
- pause(): void;
50
- play(onPlayNotAllowed?: () => void): void;
51
- startPlay(targetQ: IRepresentation, autoQuality: boolean): void;
52
- /**
53
- * destroy player
54
- */
55
- destroy(): void;
56
- reinit(newManifestUrl: string): void;
57
- /**
58
- * if all retries fail...
59
- */
60
- private _handleNetworkError;
61
- /**
62
- * Retry request
63
- */
64
- private _retryCallback;
65
- /**
66
- * how many seconds are there in the buffer
67
- */
68
- private _getBufferSizeSec;
69
- /**
70
- * send buffering notification to player
71
- */
72
- private _notifyBuffering;
73
- /**
74
- * initialize video tag, add necessary event listeners
75
- * @private
76
- */
77
- private _initVideo;
78
- /**
79
- * there may be small gaps of several milliseconds when switching quality
80
- * we jump over these gaps here
81
- */
82
- private _fixupStall;
83
- /**
84
- * return best quality for rate
85
- */
86
- private _selectQuality;
87
- private shouldPlay;
88
- /**
89
- * set video source
90
- */
91
- private _setVideoSrc;
92
- /**
93
- * initialize player with target quality
94
- */
95
- private _initPlayerWith;
96
- /**
97
- * represents specific quality stream
98
- */
99
- private _representation;
100
- /**
101
- * switch to quality
102
- * TODO: Если новое качество выше старого – переключиться сразу. Если хуже, доиграть буфер
103
- */
104
- private _switchToQuality;
105
- /**
106
- * check if quality is available
107
- */
108
- private _qualityAvailable;
109
- /**
110
- * analyze bitrate data and switch qualities accordingly
111
- */
112
- private _initBitrateSwitcher;
113
- /**
114
- * load and parse manifest file
115
- */
116
- private _fetchManifest;
117
- private _playVideoElement;
118
- /**
119
- * update internal state when manifest was received from remote
120
- */
121
- private _handleManifestUpdate;
122
- /**
123
- * schedule manifest update after delay
124
- */
125
- private _refetchManifest;
126
- private _initManifest;
127
- }
128
- export {};