@vkontakte/videoplayer-core 2.0.117-dev.85ef0d1b.0 → 2.0.117-dev.d9cc3d97.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.117-dev.85ef0d1b.0",
3
+ "version": "2.0.117-dev.d9cc3d97.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.49-dev.6764e3ce.0",
52
+ "@vkontakte/videoplayer-shared": "1.0.49-dev.ed1df4eb.0",
53
53
  "hls.js": "~1.4.7"
54
54
  }
55
55
  }
@@ -16,6 +16,8 @@ export default class Player implements IPlayer {
16
16
  private initedAt;
17
17
  private hasLiveOffsetByPaused;
18
18
  private hasLiveOffsetByPausedTimer;
19
+ private explicitInitialQuality;
20
+ private wasSetStartedQuality;
19
21
  private desiredState;
20
22
  info: {
21
23
  playbackState$: ValueSubject<PlaybackState>;
@@ -100,6 +102,7 @@ export default class Player implements IPlayer {
100
102
  tuningConfigName$: ValueSubject<string[]>;
101
103
  enableDebugTelemetry$: ValueSubject<boolean>;
102
104
  dumpTelemetry: (receiver: (value: Record<string, any>) => void) => void;
105
+ getCurrentTime$: ValueSubject<null>;
103
106
  };
104
107
  constructor(tuning?: IOptionalTuningConfig, tracer?: ITracer);
105
108
  initVideo(config: IConfig): IPlayer;
@@ -125,6 +128,7 @@ export default class Player implements IPlayer {
125
128
  setExternalTextTracks(tracks: Omit<IExternalTextTrack, 'type'>[]): IPlayer;
126
129
  selectTextTrack(id: ITextTrack['id'] | undefined): IPlayer;
127
130
  setTextTrackCueSettings(settings: ICueSettings): IPlayer;
131
+ setLiveLowLatency(isLowLatency: boolean): IPlayer;
128
132
  setLooped(isLooped: boolean): IPlayer;
129
133
  toggleChromecast(): void;
130
134
  /**
@@ -48,6 +48,7 @@ export interface IPlayer {
48
48
  setExternalTextTracks(tracks: Omit<IExternalTextTrack, 'type'>[]): IPlayer;
49
49
  selectTextTrack(id: ITextTrack['id'] | undefined): IPlayer;
50
50
  setTextTrackCueSettings(settings: ICueSettings): IPlayer;
51
+ setLiveLowLatency(isLowLatency: boolean): IPlayer;
51
52
  /**
52
53
  * Включает или отключает Chromecast
53
54
  */
@@ -70,6 +71,8 @@ export interface IPlayer {
70
71
  tuningConfigName$: IValueSubject<string[]>;
71
72
  enableDebugTelemetry$: IValueSubject<boolean>;
72
73
  dumpTelemetry: (receiver: (value: Record<string, any>) => void) => void;
74
+ /** функция вычисления текущей позиции проигрывания из под провадера (если расчет нестандартный) */
75
+ getCurrentTime$: IValueSubject<(() => number) | null>;
73
76
  };
74
77
  }
75
78
  /**
@@ -9,6 +9,7 @@ import { ILiveOffset } from '../utils/LiveOffset/types';
9
9
  import { Scene3D } from '../../utils/3d/Scene3D';
10
10
  import DroppedFramesManager from '../../providers/utils/HTMLVideoElement/DroppedFramesManager';
11
11
  import TextTrackManager from '../../providers/utils/HTMLVideoElement/TextTrackManager';
12
+ import StallsManager from '../../providers/utils/StallsManager';
12
13
  type IParams = IProviderParams<IDashURLSource> & {
13
14
  sourceHls?: IHLSSource;
14
15
  };
@@ -23,6 +24,7 @@ export default abstract class BaseDashProvider implements IProvider {
23
24
  protected elementSize$: ValueSubject<IRectangle<number> | undefined>;
24
25
  protected textTracksManager: TextTrackManager | null;
25
26
  protected droppedFramesManager: DroppedFramesManager;
27
+ protected stallsManager: StallsManager;
26
28
  protected videoTracksMap: Map<IVideoTrack, {
27
29
  stream: Stream;
28
30
  representation: Representation;
@@ -1,3 +1,3 @@
1
1
  export declare const DASH_LIVE_UPDATE_INTERVAL_MS = 1000;
2
- export declare const DASH_STALL_UPDATE_INTERVAL_MS = 1000;
2
+ export declare const DASH_STALL_UPDATE_INTERVAL_MS = 50;
3
3
  export declare const DASH_LIVE_STALL_REINIT_INTERVAL_MS = 5000;
@@ -48,9 +48,11 @@ export declare class Player {
48
48
  bufferLength$: IValueSubject<Milliseconds>;
49
49
  liveLoadBufferLength$: IValueSubject<Milliseconds>;
50
50
  livePositionFromPlayer$: IValueSubject<number>;
51
+ isLowLatency$: IValueSubject<boolean>;
51
52
  isActiveLowLatency$: IValueSubject<boolean>;
53
+ currentStallDuration$: IValueSubject<Milliseconds>;
54
+ videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds>;
52
55
  private liveEstimatedDelay;
53
- private timeInWaiting;
54
56
  private isUpdatingLive;
55
57
  private isJumpGapAfterSeekLive;
56
58
  private liveLastSeekOffset;
@@ -0,0 +1,42 @@
1
+ import { IInternalTextTrack } from '../../player/types';
2
+ import { IValueSubject, Milliseconds, IError, ISubject } from '@vkontakte/videoplayer-shared';
3
+ import { HLSManifestData } from '../HlsProvider/manifestDataExtractor';
4
+ type FetchManifestData = (url: string, init?: RequestInit) => Promise<HLSManifestData>;
5
+ export declare class LiveTextManager {
6
+ private readonly logger;
7
+ private readonly log;
8
+ private readonly params;
9
+ private readonly subscription;
10
+ private readonly abortControllers;
11
+ private readonly numberFormat;
12
+ /** в случае перемотки будет сохранена актуальная ссылка "наконечника" стрима */
13
+ private prepareUrl;
14
+ private currentTextTrackData;
15
+ availableTextTracks$: IValueSubject<IInternalTextTrack[] | null>;
16
+ getCurrentTime$: IValueSubject<(() => number) | null>;
17
+ error$: ISubject<IError>;
18
+ constructor(liveTime$: IValueSubject<Milliseconds | undefined>, video: HTMLVideoElement, fetchManifestData: FetchManifestData, sourceUrl: string);
19
+ destroy(): void;
20
+ /**
21
+ * одноименный метод из провайдера, который дергаем на перемотке,
22
+ * чтобы синхронизировать субтитры с видео\аудио дорожками
23
+ */
24
+ prepare(url: string): Promise<void>;
25
+ /** тут, на самом деле, мы получаем ссылку на плейлисты для текстовых треков */
26
+ processTextTracks(textTracks: IInternalTextTrack[], baseUrl: string): Promise<void>;
27
+ /**
28
+ * @todo - пока только с 1 стримом работает
29
+ */
30
+ private parseTextTracks;
31
+ /** парсим плейлист и получаем список треков */
32
+ private parsePlaylist;
33
+ /** забирает значение (value) строки в плейлисте */
34
+ private extractPlaylistRowValue;
35
+ /** обновляет ссылку на текущий сегмент субтитров для UI */
36
+ private processLiveTime;
37
+ /** догружает актуальные сабы */
38
+ private fetchNextManifestData;
39
+ private fetchManifestData;
40
+ private error;
41
+ }
42
+ export {};
@@ -13,6 +13,7 @@ export default class HlsLiveProvider implements IProvider {
13
13
  private video;
14
14
  private params;
15
15
  private textTracksManager;
16
+ private liveTextManager;
16
17
  private masterManifest;
17
18
  private manifests$;
18
19
  private maxSeekBackTime$;
@@ -26,5 +27,6 @@ export default class HlsLiveProvider implements IProvider {
26
27
  private playIfAllowed;
27
28
  private seek;
28
29
  private syncPlayback;
30
+ private generateLiveUrl;
29
31
  }
30
32
  export {};
@@ -17,5 +17,5 @@ type ExtractHLSManifestDataConfig = {
17
17
  manifestRetryInterval: number;
18
18
  manifestRetryMaxInterval: number;
19
19
  };
20
- declare const extractHLSManifestData: (masterManifestUrl: string, baseUrl: string | undefined, config: ExtractHLSManifestDataConfig) => Promise<HLSManifestData>;
20
+ declare const extractHLSManifestData: (masterManifestUrl: string, baseUrl: string | undefined, config: ExtractHLSManifestDataConfig, init?: RequestInit) => Promise<HLSManifestData>;
21
21
  export default extractHLSManifestData;
@@ -33,6 +33,7 @@ export interface IDesiredState {
33
33
  volume: IStateMachine<IVolumeState>;
34
34
  playbackRate: IStateMachine<PlaybackRate>;
35
35
  isLooped: IStateMachine<boolean>;
36
+ isLowLatency: IStateMachine<boolean>;
36
37
  videoStream: IStateMachine<IVideoStream | undefined>;
37
38
  videoTrack: IStateMachine<IVideoTrack | undefined>;
38
39
  audioStream: IStateMachine<IAudioStream | undefined>;
@@ -90,4 +91,5 @@ export interface IProviderOutput {
90
91
  inPiP$: IValueSubject<boolean>;
91
92
  inFullscreen$: IValueSubject<boolean>;
92
93
  playbackState$: IValueSubject<PlaybackState | string>;
94
+ getCurrentTime$: IValueSubject<(() => number) | null>;
93
95
  }
@@ -0,0 +1,34 @@
1
+ import { ExactVideoQuality, IObservable, IValueSubject, Milliseconds, Kbps } from '@vkontakte/videoplayer-shared';
2
+ import { IVideoTrack } from '../../player/types';
3
+ import { ITuningConfig } from '../../utils/tuningConfig';
4
+ interface IConnectData {
5
+ videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds>;
6
+ throughput$: IValueSubject<number>;
7
+ rtt$: IValueSubject<Milliseconds>;
8
+ isBuffering$: IObservable<boolean>;
9
+ isSeeked$: IObservable<boolean>;
10
+ currentStallDuration$: IObservable<Milliseconds>;
11
+ qualityLimitsOnStall: ITuningConfig['dash']['qualityLimitsOnStall'];
12
+ }
13
+ declare class StallsManager {
14
+ private currentStallDuration$;
15
+ private videoLastDataObtainedTimestamp$;
16
+ private throughput$;
17
+ private rtt$;
18
+ private qualityLimitsOnStall;
19
+ private isSeeked$;
20
+ private isBuffering$;
21
+ private currentStallsCount;
22
+ private maxQualityLimit;
23
+ private lastUniqueVideoTrackSelected;
24
+ private lastUniqueVideoTrackSelectedTimestamp;
25
+ private predictedThroughputWithoutData;
26
+ private qualityRestrictionTimer;
27
+ private subscription;
28
+ connect(data: IConnectData): void;
29
+ get videoMaxQualityLimit(): ExactVideoQuality | undefined;
30
+ get predictedThroughput(): Kbps;
31
+ set lastVideoTrackSelected(lastUniqueVideoTrackSelected: IVideoTrack);
32
+ destroy(): void;
33
+ }
34
+ export default StallsManager;
@@ -3,7 +3,7 @@ import { Kbps, Milliseconds, IRectangle, type ExactVideoQuality, QualityLimits,
3
3
  import { IAudioTrack, IBaseTrack, IVideoTrack } from '../player/types';
4
4
  interface IConstraints<T extends IBaseTrack> {
5
5
  container?: IRectangle;
6
- throughput?: Kbps;
6
+ estimatedThroughput?: Kbps;
7
7
  tuning: ITuningConfig['autoTrackSelection'];
8
8
  limits?: QualityLimits;
9
9
  reserve?: Kbps;
@@ -13,6 +13,8 @@ interface IConstraints<T extends IBaseTrack> {
13
13
  visible?: boolean;
14
14
  history?: TrackHistory<T>;
15
15
  droppedVideoMaxQualityLimit?: ExactVideoQuality;
16
+ stallsVideoMaxQualityLimit?: ExactVideoQuality;
17
+ stallsPredictedThroughput?: Kbps;
16
18
  abrLogger: IComponentLogger;
17
19
  }
18
20
  export declare class TrackHistory<T extends IBaseTrack> {
@@ -24,6 +26,6 @@ export declare class TrackHistory<T extends IBaseTrack> {
24
26
  }
25
27
  export declare const defaultEmptyArrayErrorMessage = "Assertion \"ABR Tracks is empty array\" failed";
26
28
  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 declare const autoSelectVideoTrack: (videoTracks: IVideoTrack[], { container, estimatedThroughput, tuning, limits, reserve, forwardBufferHealth, playbackRate, current, history, visible, droppedVideoMaxQualityLimit, stallsVideoMaxQualityLimit, stallsPredictedThroughput, abrLogger, }: IConstraints<IVideoTrack>) => IVideoTrack;
30
+ export declare const autoSelectAudioTrackForVideo: (selectedVideoTrack: IVideoTrack, videoTracks: IVideoTrack[], audioTracks: IAudioTrack[], { estimatedThroughput, tuning, playbackRate, forwardBufferHealth, history, abrLogger, stallsPredictedThroughput, }: IConstraints<IAudioTrack>) => IAudioTrack | undefined;
29
31
  export {};
@@ -33,7 +33,8 @@ export type ITuningConfig = {
33
33
  usePixelRatio: boolean;
34
34
  /** @deprecated */
35
35
  pixelRatioMultiplier?: number;
36
- pixelRatioPolynome: number[];
36
+ pixelRatioLogBase: number;
37
+ pixelRatioLogCoefficients: number[];
37
38
  containerSizeFactor: number;
38
39
  lazyQualitySwitch: boolean;
39
40
  minBufferToSwitchUp: number;
@@ -70,8 +71,14 @@ export type ITuningConfig = {
70
71
  useFetchPriorityHints: boolean;
71
72
  accumulationBufferStallSize: {
72
73
  shortVideoDuration: Milliseconds;
73
- shortVideoBufferStallSizeMs: Milliseconds;
74
- longVideoBufferStallSizeMs: Milliseconds;
74
+ shortVideoBufferStallSize: Milliseconds;
75
+ longVideoBufferStallSize: Milliseconds;
76
+ };
77
+ qualityLimitsOnStall: {
78
+ stallDurationBeforeQualityDecrease: Milliseconds;
79
+ stallDurationNoDataBeforeQualityDecrease: Milliseconds;
80
+ stallCountBeforeQualityDecrease: Milliseconds;
81
+ resetQualityRestrictionTimeout: Milliseconds;
75
82
  };
76
83
  enableBaseUrlSupport: boolean;
77
84
  maxSegmentRetryCount: number;
@@ -86,7 +93,7 @@ export type ITuningConfig = {
86
93
  maxTargetOffset: Milliseconds;
87
94
  maxTargetOffsetDeviation: Milliseconds;
88
95
  playbackCatchupSpeedup: number;
89
- isActive: boolean;
96
+ isActiveOnDefault: boolean;
90
97
  delayEstimator: {
91
98
  emaAlpha: number;
92
99
  changeThreshold: number;
@@ -183,6 +190,7 @@ export type ITuningConfig = {
183
190
  ignoreAudioRendererError: boolean;
184
191
  useEnableSubtitlesParam: boolean;
185
192
  useOldMSEDetection: boolean;
193
+ useHlsLiveNewTextManager: boolean;
186
194
  };
187
195
  export type IOptionalTuningConfig = RecursivePartial<ITuningConfig> & {
188
196
  configName: ITuningConfig['configName'];