@vkontakte/videoplayer-core 2.0.32 → 2.0.33

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.32",
3
+ "version": "2.0.33",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
package/player/types.d.ts CHANGED
@@ -251,6 +251,7 @@ export interface ISources {
251
251
  [VideoFormat.MPEG]?: IMpegSource;
252
252
  [VideoFormat.DASH]?: IDashSource;
253
253
  [VideoFormat.DASH_SEP]?: IDashURLSource;
254
+ [VideoFormat.DASH_WEBM_VK]?: IDashURLSource;
254
255
  [VideoFormat.DASH_WEBM]?: IDashURLSource;
255
256
  [VideoFormat.DASH_ONDEMAND]?: IDashURLSource;
256
257
  [VideoFormat.DASH_LIVE]?: IDashURLSource;
@@ -287,6 +288,7 @@ export declare enum VideoFormat {
287
288
  DASH = "DASH",
288
289
  DASH_SEP = "DASH_SEP",
289
290
  DASH_WEBM = "DASH_WEBM",
291
+ DASH_WEBM_VK = "DASH_WEBM_VK",
290
292
  DASH_ONDEMAND = "DASH_ONDEMAND",
291
293
  DASH_LIVE = "DASH_LIVE",
292
294
  DASH_LIVE_WEBM = "DASH_LIVE_WEBM",
@@ -0,0 +1,22 @@
1
+ import { IDashURLSource } from "../../player/types";
2
+ import { IProvider, IProviderParams } from "../types";
3
+ declare type IParams = IProviderParams<IDashURLSource>;
4
+ export default class DashVKProvider implements IProvider {
5
+ private subscription;
6
+ private videoState;
7
+ private video;
8
+ private player;
9
+ private params;
10
+ private elementSize$;
11
+ private textTracksManager;
12
+ private videoTracks;
13
+ private audioRepresentations;
14
+ constructor(params: IParams);
15
+ private subscribe;
16
+ private prepare;
17
+ private seek;
18
+ private syncPlayback;
19
+ destroy(): void;
20
+ private playIfAllowed;
21
+ }
22
+ export {};
@@ -0,0 +1,35 @@
1
+ import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
2
+ import { IError, ISubject, IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
3
+ import { Representation, RepresentationKind } from './types';
4
+ export interface Dependencies {
5
+ throughputEstimator: ThroughputEstimator;
6
+ }
7
+ export declare class BufferManager {
8
+ ended$: IValueSubject<boolean>;
9
+ playingRepresentation$: IValueSubject<Representation['id'] | undefined>;
10
+ error$: ISubject<IError>;
11
+ private subscription;
12
+ private kind;
13
+ private initData;
14
+ private representations;
15
+ private segments;
16
+ private mediaSource;
17
+ private playingRepresentationId;
18
+ private downloadingRepresentationId;
19
+ private sourceBuffer;
20
+ private segmentDownloadPromise;
21
+ private abortController;
22
+ private loadAllInitsPromise;
23
+ private throughputEstimator;
24
+ constructor(kind: RepresentationKind, mediaSource: MediaSource, representations: Representation[], { throughputEstimator }: Dependencies);
25
+ startWith(id: Representation['id']): Promise<void>;
26
+ switchTo(newRepresentationId: Representation['id']): Promise<void>;
27
+ maintain(currentPosition: Milliseconds): Promise<void>;
28
+ destroy(): void;
29
+ private selectForwardBufferSegments;
30
+ private loadSegments;
31
+ private loadAllInits;
32
+ private appendDataToBuffer;
33
+ private checkEjectedSegments;
34
+ private static waitForBufferUpdate;
35
+ }
@@ -0,0 +1,61 @@
1
+ import { Byte, Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ export declare enum Tag {
3
+ EBML = 440786851,
4
+ EBMLVersion = 17030,
5
+ EBMLReadVersion = 17143,
6
+ EBMLMaxIDLength = 17138,
7
+ EBMLMaxSizeLength = 17139,
8
+ DocType = 17026,
9
+ DocTypeVersion = 17031,
10
+ DocTypeReadVersion = 17029,
11
+ Void = 236,
12
+ Segment = 408125543,
13
+ SeekHead = 290298740,
14
+ Seek = 19899,
15
+ SeekID = 21419,
16
+ SeekPosition = 21420,
17
+ Info = 357149030,
18
+ TimestampScale = 2807729,
19
+ Duration = 17545,
20
+ Tracks = 374648427,
21
+ Chapters = 272869232,
22
+ Cluster = 524531317,
23
+ Attachments = 423732329,
24
+ Tags = 307544935,
25
+ Cues = 475249515,
26
+ CuePoint = 187,
27
+ CueTime = 179,
28
+ CueTrackPositions = 183,
29
+ CueTrack = 247,
30
+ CueClusterPosition = 241,
31
+ CueRelativePosition = 240,
32
+ CueDuration = 178,
33
+ CueBlockNumber = 21368,
34
+ CueCodecState = 234,
35
+ CueReference = 219,
36
+ CueRefTime = 150
37
+ }
38
+ export declare type UnknownTag = string;
39
+ export declare enum Type {
40
+ SignedInteger = "int",
41
+ UnsignedInteger = "uint",
42
+ Float = "float",
43
+ String = "string",
44
+ UTF8 = "utf8",
45
+ Date = "date",
46
+ Master = "master",
47
+ Binary = "binary"
48
+ }
49
+ declare type TagValue<ExactType extends Type> = ExactType extends Type.SignedInteger ? number : ExactType extends Type.UnsignedInteger ? number : ExactType extends Type.Float ? number : ExactType extends Type.String ? string : ExactType extends Type.UTF8 ? string : ExactType extends Type.Date ? Milliseconds : ExactType extends Type.Master ? DataView : ExactType extends Type.Binary ? DataView : never;
50
+ export declare type ParsedTag = {
51
+ tag: Tag | UnknownTag;
52
+ type: Type;
53
+ value: DataView;
54
+ valueSize: Byte;
55
+ };
56
+ export declare const parseTag: (view: DataView) => ParsedTag;
57
+ export declare const parseUint: (view: DataView, size?: Byte) => number;
58
+ export declare const parseValue: <T extends Type>(view: DataView, type: T) => TagValue<T>;
59
+ export declare const parseRecursively: (view: DataView, onTag: (tag: ParsedTag) => boolean) => void;
60
+ export declare const validateHeader: (view: DataView) => boolean;
61
+ export {};
@@ -0,0 +1,13 @@
1
+ import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
2
+ import { Byte } from '@vkontakte/videoplayer-shared';
3
+ export declare enum RangeMethod {
4
+ HEADER = 0,
5
+ PARAM = 1
6
+ }
7
+ export interface Params {
8
+ throughputEstimator?: ThroughputEstimator;
9
+ fetchInit?: RequestInit;
10
+ }
11
+ export declare const fetchManifest: (url: string, params?: Params | undefined) => Promise<string>;
12
+ export declare const fetchRange: (originalUrl: string, from: Byte, to: Byte, method?: RangeMethod, onProgress?: ((view: DataView, loaded: Byte) => void) | undefined, params?: Params | undefined) => Promise<ArrayBuffer>;
13
+ export declare const suppressAbort: (e: Error | unknown) => void;
@@ -0,0 +1,7 @@
1
+ import { RepresentationKind, Representation } from './types';
2
+ export interface Manifest {
3
+ representations: {
4
+ [key in RepresentationKind]: Representation[];
5
+ };
6
+ }
7
+ export declare const parse: (text: string, url: string) => Manifest;
@@ -0,0 +1,32 @@
1
+ import { Representation, RepresentationKind } from "./types";
2
+ import StateMachine from "../../../utils/StateMachine/StateMachine";
3
+ import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
4
+ import { IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
5
+ import { Manifest } from './mpd';
6
+ export declare enum State {
7
+ NONE = "none",
8
+ MANIFEST_LOADED = "manifest_loaded",
9
+ REPRESENTATION_SELECTED = "representation_selected"
10
+ }
11
+ export interface Params {
12
+ throughputEstimator: ThroughputEstimator;
13
+ }
14
+ export declare class Player {
15
+ private element;
16
+ private source;
17
+ private manifest;
18
+ private videoBufferManager;
19
+ private audioBufferManager;
20
+ private throughputEstimator;
21
+ private subscription;
22
+ state$: StateMachine<State>;
23
+ currentVideoRepresentation$: IValueSubject<Representation['id'] | undefined>;
24
+ constructor(params: Params);
25
+ initManifest(element: HTMLVideoElement, manifestUrl: string): Promise<Manifest>;
26
+ initRepresentations(initialVideo: Representation['id'], initialAudio: Representation['id']): Promise<void>;
27
+ switchRepresentation(kind: RepresentationKind, id: Representation['id']): Promise<void>;
28
+ seek(position: Milliseconds): void;
29
+ stop(): void;
30
+ destroy(): void;
31
+ private tick;
32
+ }
@@ -0,0 +1,33 @@
1
+ import { Byte, Kbps, Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ export declare enum RepresentationKind {
3
+ VIDEO = "video",
4
+ AUDIO = "audio",
5
+ TEXT = "text"
6
+ }
7
+ export interface Range<Unit extends number> {
8
+ from: Unit;
9
+ to: Unit;
10
+ }
11
+ export interface Representation {
12
+ id: string;
13
+ kind: RepresentationKind;
14
+ initRange: Range<Byte>;
15
+ indexRange?: Range<Byte>;
16
+ bitrate: Kbps;
17
+ mime: string;
18
+ codecs: string;
19
+ width: number;
20
+ height: number;
21
+ url: string;
22
+ }
23
+ export interface Segment {
24
+ status: SegmentStatus;
25
+ time: Range<Milliseconds>;
26
+ byte: Range<Byte>;
27
+ }
28
+ export declare enum SegmentStatus {
29
+ NONE = "none",
30
+ DOWNLOADING = "downloading",
31
+ DOWNLOADED = "downloaded",
32
+ FED = "fed"
33
+ }
@@ -0,0 +1,15 @@
1
+ import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
2
+ import { Byte } from '@vkontakte/videoplayer-shared';
3
+ import { Representation, Segment } from './types';
4
+ export interface Init {
5
+ segmentStart: Byte;
6
+ segmentEnd: Byte;
7
+ timeScale: number;
8
+ segmentDuration: number;
9
+ cuesSeekPosition?: Byte;
10
+ }
11
+ export declare const loadInitAndSegments: (representation: Representation, extraBytes?: Byte, throughputEstimator?: ThroughputEstimator | undefined) => Promise<{
12
+ init: Init;
13
+ segments: Segment[];
14
+ dataView: DataView;
15
+ }>;
@@ -1,7 +1,9 @@
1
1
  import { Subject, ValueSubject, Byte, Kbps, Milliseconds, ISubject } from '@vkontakte/videoplayer-shared';
2
2
  import { ITuningConfig } from "./tuningConfig";
3
3
  declare class ThroughputEstimator {
4
- private throughput;
4
+ private smoothedCombination;
5
+ private smoothedFast;
6
+ private smoothedSlow;
5
7
  private subscription;
6
8
  private rawSeries$;
7
9
  private smoothedSeries$;
@@ -3,6 +3,8 @@ import { Byte, Milliseconds } from '@vkontakte/videoplayer-shared';
3
3
  export declare type ITuningConfig = {
4
4
  throughputEstimator: {
5
5
  emaAlpha: number;
6
+ emaAlphaSlow: number;
7
+ emaAlphaFast: number;
6
8
  changeThreshold: number;
7
9
  useBrowserEstimation: boolean;
8
10
  streamMinSampleSize: Byte;