@vkontakte/videoplayer-core 2.0.108-dev.7ca5c32c.0 → 2.0.108-dev.9969cb23.0

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.108-dev.7ca5c32c.0",
3
+ "version": "2.0.108-dev.9969cb23.0",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -49,7 +49,7 @@
49
49
  "**/*.d.ts"
50
50
  ],
51
51
  "dependencies": {
52
- "@vkontakte/videoplayer-shared": "1.0.40-dev.85b25f2f.0",
52
+ "@vkontakte/videoplayer-shared": "1.0.40-beta.0",
53
53
  "hls.js": "~1.4.7"
54
54
  }
55
55
  }
@@ -1,6 +1,6 @@
1
1
  import { IOptionalTuningConfig } from '../utils/tuningConfig';
2
2
  import { IError, ILogEntry, Seconds, Subject, ValueSubject, QualityLimits, VideoQuality, ITracer } from '@vkontakte/videoplayer-shared';
3
- import { ChromecastState, HttpConnectionType, IAudioStream, IAudioTrack, IConfig, ICueSettings, IExternalTextTrack, IPlayer, ISeekRequest, ISources, ITextTrack, IVideoStream, PlaybackRate, PlaybackState, StartEnd, Surface, VideoFormat } from './types';
3
+ import { ChromecastState, HttpConnectionType, IAudioStream, IConfig, ICueSettings, IExternalTextTrack, IPlayer, ISeekRequest, ISources, ITextTrack, IVideoStream, PlaybackRate, PlaybackState, StartEnd, Surface, VideoFormat } from './types';
4
4
  export default class Player implements IPlayer {
5
5
  private subscription;
6
6
  private domContainer;
@@ -33,7 +33,7 @@ export default class Player implements IPlayer {
33
33
  autoQualityLimits$: ValueSubject<QualityLimits>;
34
34
  availableAudioStreams$: ValueSubject<IAudioStream[]>;
35
35
  currentAudioStream$: ValueSubject<IVideoStream | undefined>;
36
- availableAudioTracks$: ValueSubject<IAudioTrack[]>;
36
+ availableAudioTracks$: ValueSubject<import("./types").IBaseTrack[]>;
37
37
  isAudioAvailable$: ValueSubject<boolean>;
38
38
  currentPlaybackRate$: ValueSubject<number>;
39
39
  currentBuffer$: ValueSubject<StartEnd<number>>;
@@ -100,7 +100,7 @@ export default class Player implements IPlayer {
100
100
  enableDebugTelemetry$: ValueSubject<boolean>;
101
101
  dumpTelemetry: (receiver: (value: Record<string, any>) => void) => void;
102
102
  };
103
- constructor(tuning: IOptionalTuningConfig | undefined, tracer: ITracer);
103
+ constructor(tuning?: IOptionalTuningConfig, tracer?: ITracer);
104
104
  initVideo(config: IConfig): IPlayer;
105
105
  destroy(): void;
106
106
  prepare(): IPlayer;
@@ -475,10 +475,12 @@ export interface IVideoStream {
475
475
  codec?: string;
476
476
  label?: string;
477
477
  }
478
- export interface IVideoTrack {
478
+ export interface IBaseTrack {
479
479
  id: string;
480
- quality: VideoQuality;
481
480
  bitrate?: Kbps;
481
+ }
482
+ export interface IVideoTrack extends IBaseTrack {
483
+ quality: VideoQuality;
482
484
  size?: IRectangle;
483
485
  fps?: number;
484
486
  }
@@ -489,10 +491,7 @@ export interface IAudioStream {
489
491
  codec?: string;
490
492
  isDefault?: boolean;
491
493
  }
492
- export interface IAudioTrack {
493
- id: string;
494
- bitrate?: Kbps;
495
- }
494
+ export type IAudioTrack = IBaseTrack;
496
495
  interface ITextTrackBase {
497
496
  type: 'external' | 'internal';
498
497
  id: string;
@@ -2,7 +2,7 @@ import { IAudioTrack, IDashURLSource, IHLSSource, IInternalTextTrack, IVideoTrac
2
2
  import { CommonInit, IProviderSubscriptionInfo, ProviderState, Representation, Stream } from './lib/types';
3
3
  import { IProvider, IProviderParams } from '../../providers/types';
4
4
  import TextTrackManager from '../../providers/utils/HTMLVideoElement/TextTrackManager';
5
- import { TrackHistory } from '../../utils/autoSelectVideoTrack';
5
+ import { TrackHistory } from '../../utils/autoSelectTrack';
6
6
  import { IStateMachine } from '../../utils/StateMachine/types';
7
7
  import { IRectangle, ISubscription, Milliseconds, ValueSubject, ITracer } from '@vkontakte/videoplayer-shared';
8
8
  import { Player } from './lib/player';
@@ -37,7 +37,8 @@ export default abstract class BaseDashProvider implements IProvider {
37
37
  }>;
38
38
  protected videoStreamsMap: Map<Stream, IVideoTrack[]>;
39
39
  protected audioStreamsMap: Map<Stream, IAudioTrack[]>;
40
- protected videoTrackSwitchHistory: TrackHistory;
40
+ protected videoTrackSwitchHistory: TrackHistory<IVideoTrack>;
41
+ protected audioTrackSwitchHistory: TrackHistory<import("../../player/types").IBaseTrack>;
41
42
  protected textTracks: {
42
43
  track: IInternalTextTrack;
43
44
  representation: Representation;
@@ -0,0 +1,22 @@
1
+ import { IValueSubject, Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ import { Dependencies } from './buffer';
3
+ import { Manifest, Stream, TextRepresentation } from './types';
4
+ export declare class LiveTextManager {
5
+ currentRepresentation$: IValueSubject<TextRepresentation | null>;
6
+ private representations;
7
+ private readonly getCurrentPosition;
8
+ private currentSegment;
9
+ private currentSegmentId;
10
+ constructor(streams: Stream[], deps: Pick<Dependencies, 'getCurrentPosition'>);
11
+ updateLive(manifest: Manifest | null): void;
12
+ seekLive(streams?: Stream[]): void;
13
+ maintain(currentPosition?: Milliseconds | undefined): void;
14
+ destroy(): void;
15
+ /**
16
+ * @todo support multi-streams
17
+ * @see https://jira.mvk.com/browse/VP-2420
18
+ */
19
+ private processStreams;
20
+ static isSupported(streams?: Stream[]): boolean;
21
+ private static filterRepresentations;
22
+ }
@@ -48,6 +48,7 @@ export declare class BufferManager {
48
48
  private failedDownloads;
49
49
  private compatibilityMode;
50
50
  private preloadOnly;
51
+ private bufferAccumulation;
51
52
  private isLive;
52
53
  private liveUpdateSegmentIndex;
53
54
  private liveInitialAdditionalOffset;
@@ -65,6 +66,8 @@ export declare class BufferManager {
65
66
  seekLive: (param_0: Stream[] | undefined) => Promise<void | undefined>;
66
67
  updateLive(manifest: Manifest | null): void;
67
68
  proceedLowLatencyLive(): void;
69
+ startAccumulateBuffer(): void;
70
+ private resetAccumulateBufferAfterStall;
68
71
  private updateLowLatencyLiveIfNeeded;
69
72
  findSegmentStartTime(position: Milliseconds): Milliseconds | undefined;
70
73
  setTarget(time: Milliseconds): void;
@@ -1,5 +1,5 @@
1
1
  import { HttpConnectionType } from '../../../player/types';
2
- import { CommonInit, Manifest, Representation, StreamKind } from './types';
2
+ import { CommonInit, Manifest, Representation, StreamKind, TextRepresentation } from './types';
3
3
  import StateMachine from '../../../utils/StateMachine/StateMachine';
4
4
  import type ThroughputEstimator from '../../../utils/ThroughputEstimator';
5
5
  import { ITuningConfig } from '../../../utils/tuningConfig';
@@ -27,6 +27,7 @@ export declare class Player {
27
27
  private videoBufferManager;
28
28
  private audioBufferManager;
29
29
  private bufferManagers;
30
+ private liveTextManager;
30
31
  private throughputEstimator;
31
32
  private subscription;
32
33
  private representationSubscription;
@@ -41,6 +42,7 @@ export declare class Player {
41
42
  lastConnectionType$: IValueSubject<HttpConnectionType | undefined>;
42
43
  lastConnectionReused$: IValueSubject<boolean | undefined>;
43
44
  lastRequestFirstBytes$: IValueSubject<Milliseconds | undefined>;
45
+ currentLiveTextRepresentation$: IValueSubject<TextRepresentation | null>;
44
46
  isLive$: IValueSubject<boolean>;
45
47
  liveDuration$: IValueSubject<Milliseconds>;
46
48
  liveAvailabilityStartTime$: IValueSubject<Seconds | undefined>;
@@ -31,6 +31,12 @@ export interface Representation {
31
31
  fps?: number;
32
32
  quality?: string;
33
33
  }
34
+ export interface TextRepresentation extends Representation {
35
+ language: string;
36
+ label: string;
37
+ url: string;
38
+ isAuto: boolean;
39
+ }
34
40
  export declare enum SegmentReferencingType {
35
41
  BYTE_RANGE = "byteRange",
36
42
  TEMPLATE = "template"
@@ -1,14 +1,12 @@
1
- import { Representation, Segment, SegmentReference, Stream, TemplateSegment, TemplateSegmentReference } from '../../../providers/DashProvider/lib/types';
1
+ import { Representation, Segment, SegmentReference, Stream, TemplateSegment, TemplateSegmentReference, TextRepresentation } from '../../../providers/DashProvider/lib/types';
2
2
  import { IAudioStream, IAudioTrack, IInternalTextTrack, IVideoStream, IVideoTrack } from '../../../player/types';
3
3
  export declare const representationToVideoTrack: ({ id, width, height, bitrate, fps, quality: qualityString }: Representation) => IVideoTrack | undefined;
4
4
  export declare const representationToAudioTrack: ({ id, bitrate }: Representation) => IAudioTrack;
5
5
  export declare const selectAudioForVideo: (videoTrack: IVideoTrack, videoTracks: IVideoTrack[], audioTracks: IAudioTrack[]) => IAudioTrack | undefined;
6
- export declare const representationToTextTrack: ({ language, label }: Stream, { id, url, isAuto }: Representation & {
7
- url: string;
8
- isAuto: boolean;
9
- }) => IInternalTextTrack;
6
+ export declare const representationToTextTrack: ({ language, label }: Pick<Stream, "label" | "language">, { id, url, isAuto }: TextRepresentation) => IInternalTextTrack;
10
7
  export declare const streamToIAudioStream: ({ id, language, label, codecs, isDefault }: Stream) => IAudioStream;
11
8
  export declare const streamToIVideoStream: ({ id, language, label, hdr, codecs }: Stream) => IVideoStream;
12
9
  export declare const isTemplateSegment: (segment: Segment) => segment is TemplateSegment;
13
10
  export declare const isTemplateSegmentReference: (segmentReference: SegmentReference) => segmentReference is TemplateSegmentReference;
14
11
  export declare const isAbortError: (e: Error | unknown) => boolean;
12
+ export declare const isTextRepresentation: (representation: Representation | TextRepresentation) => representation is TextRepresentation;
@@ -0,0 +1,29 @@
1
+ import { ITuningConfig } from '../utils/tuningConfig';
2
+ import { Kbps, Milliseconds, IRectangle, type ExactVideoQuality, QualityLimits, IComponentLogger } from '@vkontakte/videoplayer-shared';
3
+ import { IAudioTrack, IBaseTrack, IVideoTrack } from '../player/types';
4
+ interface IConstraints<T extends IBaseTrack> {
5
+ container?: IRectangle;
6
+ throughput?: Kbps;
7
+ tuning: ITuningConfig['autoTrackSelection'];
8
+ limits?: QualityLimits;
9
+ reserve?: Kbps;
10
+ playbackRate?: number;
11
+ forwardBufferHealth?: number;
12
+ current?: T;
13
+ visible?: boolean;
14
+ history?: TrackHistory<T>;
15
+ droppedVideoMaxQualityLimit?: ExactVideoQuality;
16
+ abrLogger: IComponentLogger;
17
+ }
18
+ export declare class TrackHistory<T extends IBaseTrack> {
19
+ last: T | undefined;
20
+ history: Record<IBaseTrack['id'], Milliseconds>;
21
+ recordSelection(track: T): void;
22
+ recordSwitch(track: T | undefined): void;
23
+ clear(): void;
24
+ }
25
+ export declare const defaultEmptyArrayErrorMessage = "Assertion \"ABR Tracks is empty array\" failed";
26
+ export declare const getMinPossibleAudioForVideo: (videoTrack: IVideoTrack, videoTracks: IVideoTrack[], audioTracks: IAudioTrack[], minVideoAudioRatio: number) => IAudioTrack | undefined;
27
+ export declare const autoSelectVideoTrack: (videoTracks: IVideoTrack[], { container, throughput, tuning, limits, reserve, forwardBufferHealth, playbackRate, current, history, visible, droppedVideoMaxQualityLimit, abrLogger, }: IConstraints<IVideoTrack>) => IVideoTrack;
28
+ export declare const autoSelectAudioTrackForVideo: (selectedVideoTrack: IVideoTrack, videoTracks: IVideoTrack[], audioTracks: IAudioTrack[], { throughput, tuning, playbackRate, forwardBufferHealth, history, abrLogger, }: IConstraints<IAudioTrack>) => IAudioTrack | undefined;
29
+ export {};
@@ -24,7 +24,11 @@ export type ITuningConfig = {
24
24
  };
25
25
  autoTrackSelection: {
26
26
  bitrateFactorAtEmptyBuffer: number;
27
+ bitrateAudioFactorAtEmptyBuffer: number;
27
28
  bitrateFactorAtFullBuffer: number;
29
+ bitrateAudioFactorAtFullBuffer: number;
30
+ minVideoAudioRatio: number;
31
+ minAvailableThroughputAudioRatio: number;
28
32
  limitByContainer: boolean;
29
33
  usePixelRatio: boolean;
30
34
  containerSizeFactor: number;
@@ -126,6 +130,7 @@ export type ITuningConfig = {
126
130
  endGapTolerance: Milliseconds;
127
131
  stallIgnoreThreshold: Milliseconds;
128
132
  gapWatchdogInterval: Milliseconds;
133
+ accumulationBufferStallSizeMs: Milliseconds;
129
134
  requestQuick: boolean;
130
135
  useHlsJs: boolean;
131
136
  useDashAbortPartiallyFedSegment: boolean;
@@ -133,6 +138,7 @@ export type ITuningConfig = {
133
138
  useManagedMediaSource: boolean;
134
139
  useNewPruneBufferStrategy: boolean;
135
140
  useNewPartialSegmentFeeding: boolean;
141
+ useSeparateAudioVideoABR: boolean;
136
142
  isAudioDisabled: boolean;
137
143
  autoplayOnlyInActiveTab: boolean;
138
144
  dynamicImportTimeout: Milliseconds;
@@ -1,26 +0,0 @@
1
- import { ITuningConfig } from '../utils/tuningConfig';
2
- import { Kbps, Milliseconds, IRectangle, type ExactVideoQuality, QualityLimits, IComponentLogger } from '@vkontakte/videoplayer-shared';
3
- import { IVideoTrack } from '../player/types';
4
- export interface Constraints {
5
- container?: IRectangle;
6
- throughput?: Kbps;
7
- tuning: ITuningConfig['autoTrackSelection'];
8
- limits?: QualityLimits;
9
- reserve?: Kbps;
10
- playbackRate?: number;
11
- forwardBufferHealth?: number;
12
- current?: IVideoTrack;
13
- history?: TrackHistory;
14
- droppedVideoMaxQualityLimit?: ExactVideoQuality;
15
- abrLogger: IComponentLogger;
16
- }
17
- export declare class TrackHistory {
18
- last: IVideoTrack | undefined;
19
- history: Record<IVideoTrack['id'], Milliseconds>;
20
- recordSelection(track: IVideoTrack): void;
21
- recordSwitch(track: IVideoTrack): void;
22
- clear(): void;
23
- }
24
- export declare const defaultEmptyArrayErrorMessage = "Assertion \"ABR Tracks is empty array\" failed";
25
- declare const autoSelectVideoTrack: (tracks: IVideoTrack[], { container, throughput, tuning, limits, reserve, forwardBufferHealth, playbackRate, current, history, droppedVideoMaxQualityLimit, abrLogger, }: Constraints) => IVideoTrack;
26
- export default autoSelectVideoTrack;