@vkontakte/videoplayer-core 2.0.165 → 2.0.166-dev.2bfbc0980.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.165",
3
+ "version": "2.0.166-dev.2bfbc0980.0",
4
4
  "author": "vk.com",
5
5
  "description": "Videoplayer core library based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -42,6 +42,6 @@
42
42
  "**/*.d.ts"
43
43
  ],
44
44
  "dependencies": {
45
- "@vkontakte/videoplayer-shared": "1.0.94"
45
+ "@vkontakte/videoplayer-shared": "1.0.95-dev.2bfbc0980.0"
46
46
  }
47
47
  }
@@ -126,6 +126,7 @@ export default class Player implements IPlayer {
126
126
  private initDebugTelemetry;
127
127
  private initTracerSubscription;
128
128
  private initWakeLock;
129
+ private initRenderingRecovery;
129
130
  private setVideoTrackIdByQuality;
130
131
  private getActiveLiveDelay;
131
132
  private isNotActiveTabCase;
@@ -328,6 +328,8 @@ export interface PlayerInfoValues {
328
328
  * default value: `undefined`
329
329
  */
330
330
  currentNativeBuffer$: StartEnd<Seconds> | undefined;
331
+ /** Суммарная длительность всех буферизованных диапазонов в миллисекундах */
332
+ totalBufferDuration$: Milliseconds | undefined;
331
333
  /**
332
334
  * Статус буферизации видео. true если буфер пустой и воспроизведение прервано
333
335
  * В отличии от isStalled показывает и буферизации на старте и после перемотки
@@ -0,0 +1,21 @@
1
+ import type { IError } from "@vkontakte/videoplayer-shared";
2
+ import type { IMaydayDeps, IRecommendation } from "./types";
3
+ export declare class MaydayService {
4
+ private deps;
5
+ private heuristics;
6
+ private tracer;
7
+ private providerFailures;
8
+ private failoverUrlIndex;
9
+ constructor(deps: IMaydayDeps);
10
+ get currentFailoverUrlIndex(): number | undefined;
11
+ getRecommendation(error: IError): IRecommendation;
12
+ private validateRecommendation;
13
+ private hasAvailableFailoverHost;
14
+ /**
15
+ * Если рекомендаций от эвристик нету, то идем по общему сценарию.
16
+ */
17
+ private computeFallbackRecommendation;
18
+ private applyStateChange;
19
+ reset(): void;
20
+ destroy(): void;
21
+ }
@@ -0,0 +1,25 @@
1
+ import type { IObservable, IValueSubject } from "@vkontakte/videoplayer-shared";
2
+ import { PlaybackState } from "../../../player/types";
3
+ import type { IReinitHistory } from "./types";
4
+ interface IMaydayStatisticsDeps {
5
+ firstFrameEvent$: IObservable<void>;
6
+ playbackState$: IValueSubject<PlaybackState | string>;
7
+ }
8
+ export declare class MaydayStatistics {
9
+ private deps;
10
+ private providerInitiatedAt;
11
+ private reinitTimestamps;
12
+ private reinitReachedPlaying;
13
+ private playingStartTime;
14
+ private accumulatedPlayingTime;
15
+ private firstFrameReceived;
16
+ private subscription;
17
+ constructor(deps: IMaydayStatisticsDeps);
18
+ recordReinit(): void;
19
+ recordProviderSwitch(): void;
20
+ getInitiatedAt(): number;
21
+ getAccumulatedPlayingTime(): number;
22
+ getReinitHistory(): IReinitHistory;
23
+ destroy(): void;
24
+ }
25
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ITracer } from "@vkontakte/videoplayer-shared";
2
+ import type { IMaydayDeps, IHeuristicDeps } from "./types";
3
+ export declare function createHeuristicDeps(deps: IMaydayDeps, tracer: ITracer): IHeuristicDeps;
@@ -0,0 +1,9 @@
1
+ import type { IError } from "@vkontakte/videoplayer-shared";
2
+ import type { IRecommendation, IHeuristicDeps } from "../types";
3
+ import type { IHeuristic } from "./IHeuristic";
4
+ export declare class FetcherErrorHeuristic implements IHeuristic {
5
+ private _deps;
6
+ static readonly heuristicName = "FetcherErrorHeuristic";
7
+ constructor(_deps: IHeuristicDeps);
8
+ analyze(error: IError): IRecommendation | null;
9
+ }
@@ -0,0 +1,7 @@
1
+ import type { IError } from "@vkontakte/videoplayer-shared";
2
+ import type { IRecommendation } from "../types";
3
+ export interface IHeuristic {
4
+ analyze(error: IError): IRecommendation | null;
5
+ reset?(): void;
6
+ destroy?(): void;
7
+ }
@@ -0,0 +1,9 @@
1
+ import type { IError } from "@vkontakte/videoplayer-shared";
2
+ import type { IRecommendation, IHeuristicDeps } from "../types";
3
+ import type { IHeuristic } from "./IHeuristic";
4
+ export declare class MediaErrorHeuristic implements IHeuristic {
5
+ private deps;
6
+ static readonly heuristicName = "MediaErrorHeuristic";
7
+ constructor(deps: IHeuristicDeps);
8
+ analyze(error: IError): IRecommendation | null;
9
+ }
@@ -0,0 +1,6 @@
1
+ export { MaydayService } from "./MaydayService";
2
+ export type { IMaydayDeps, IFallbackContext, IRecommendation, RecoveryAction } from "./types";
3
+ export type { IHeuristic } from "./heuristics/IHeuristic";
4
+ export { MediaErrorHeuristic } from "./heuristics/MediaErrorHeuristic";
5
+ export { FetcherErrorHeuristic } from "./heuristics/FetcherErrorHeuristic";
6
+ export { MaydayStatistics } from "./MaydayStatistics";
@@ -0,0 +1,53 @@
1
+ import type { IVideoTrack, IVideoStream, IAudioStream } from "../../../player/types";
2
+ import type { IValueSubject, Milliseconds, Seconds, IRange, ITracer } from "@vkontakte/videoplayer-shared";
3
+ import type { ITuningConfig } from "../../../utils/tuningConfig";
4
+ export interface IFallbackContext {
5
+ hasProviderStarted: boolean;
6
+ canSwitchCodec: boolean;
7
+ }
8
+ export interface IReinitHistory {
9
+ reachedPlaying: boolean[];
10
+ deltas: number[];
11
+ }
12
+ export interface IMaydayProviderOutput {
13
+ position$: IValueSubject<number>;
14
+ currentVideoTrack$: IValueSubject<IVideoTrack | undefined>;
15
+ totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
16
+ currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
17
+ bufferRangeCount$: IValueSubject<number | undefined>;
18
+ availableVideoStreams$: IValueSubject<IVideoStream[]>;
19
+ currentAudioStream$: IValueSubject<IAudioStream | undefined>;
20
+ }
21
+ export interface IMaydayDeps {
22
+ tuning: ITuningConfig;
23
+ failoverHosts: string[];
24
+ providerOutput: IMaydayProviderOutput;
25
+ maydayStatistics: {
26
+ getInitiatedAt: () => number;
27
+ getReinitHistory: () => IReinitHistory;
28
+ getAccumulatedPlayingTime: () => number;
29
+ };
30
+ getFallbackContext: () => IFallbackContext;
31
+ tracer: ITracer;
32
+ }
33
+ export interface IHeuristicDeps {
34
+ tuning: ITuningConfig;
35
+ getFallbackContext: () => IFallbackContext;
36
+ tracer: ITracer;
37
+ getPosition: () => number;
38
+ getCurrentVideoTrack: () => IVideoTrack | undefined;
39
+ getInitiatedAt: () => number;
40
+ getBufferLength: () => number;
41
+ getBufferAhead: () => number;
42
+ getBufferRangeCount: () => number;
43
+ getReinitHistory: () => IReinitHistory;
44
+ getAccumulatedPlayingTime: () => number;
45
+ getVideoCodec: () => string | undefined;
46
+ getAudioCodec: () => string | undefined;
47
+ getVisibilityState: () => DocumentVisibilityState | undefined;
48
+ }
49
+ export type RecoveryAction = "reinit" | "failover_host" | "switch_codec" | "switch_provider";
50
+ export interface IRecommendation {
51
+ action: RecoveryAction;
52
+ reason: string;
53
+ }
@@ -34,11 +34,14 @@ export default class ProviderContainer implements IProviderContainer {
34
34
  private log;
35
35
  private tracer;
36
36
  private params;
37
- private failoverIndex;
37
+ private currentProviderStarted;
38
38
  private currentFailedVideoTrack;
39
39
  private volumeMultiplierManager;
40
40
  private dashMaxTvVideoQuality;
41
+ private mayday;
42
+ private maydayStatistics;
41
43
  constructor(params: IParams);
44
+ private getFallbackContext;
42
45
  init(): void;
43
46
  destroy(): void;
44
47
  private initProvider;
@@ -46,6 +49,8 @@ export default class ProviderContainer implements IProviderContainer {
46
49
  private switchToNextProvider;
47
50
  private switchToNextVideoCodec;
48
51
  private destroyProvider;
52
+ private handleMaydayRecommendation;
53
+ private applyErrorSideEffects;
49
54
  private createProvider;
50
55
  private createScreenProvider;
51
56
  private createChromecastProvider;
@@ -87,6 +87,8 @@ export interface IProviderOutput {
87
87
  canChangePlaybackSpeed$: IValueSubject<boolean | undefined>;
88
88
  currentBuffer$: IValueSubject<IRange<Seconds> | undefined>;
89
89
  currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
90
+ totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
91
+ bufferRangeCount$: IValueSubject<number | undefined>;
90
92
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
91
93
  isBuffering$: IValueSubject<boolean>;
92
94
  isLive$: IValueSubject<boolean | undefined>;
@@ -12,6 +12,12 @@ interface IConnectData {
12
12
  playing$: IObservable<undefined>;
13
13
  pause$: IObservable<undefined>;
14
14
  }
15
+ interface IDecoderMetrics {
16
+ totalVideoFrames: number;
17
+ droppedVideoFrames: number;
18
+ droppedPercent: number;
19
+ stalledFrames: number;
20
+ }
15
21
  declare class DroppedFramesManager {
16
22
  onDroopedVideoFramesLimit$: Subject<void>;
17
23
  private subscription;
@@ -32,6 +38,10 @@ declare class DroppedFramesManager {
32
38
  connect(data: IConnectData): void;
33
39
  destroy(): void;
34
40
  get droppedVideoMaxQualityLimit(): ExactVideoQuality | undefined;
41
+ /**
42
+ * Получить текущие метрики декодера
43
+ */
44
+ getMetrics(): IDecoderMetrics;
35
45
  private subscribe;
36
46
  private handleChangeVideoQuality;
37
47
  private onChangeQuality;
@@ -1,4 +1,4 @@
1
- import type { Seconds, IRange, IObservable, IError, IValueObservable } from "@vkontakte/videoplayer-shared";
1
+ import type { Seconds, IRange, IObservable, IError, IValueObservable, Milliseconds } from "@vkontakte/videoplayer-shared";
2
2
  import type { IVolumeState, PlaybackRate } from "../../../player/types";
3
3
  export interface IObservableVideo {
4
4
  playing$: IObservable<undefined>;
@@ -18,6 +18,8 @@ export interface IObservableVideo {
18
18
  loadedData$: IObservable<undefined>;
19
19
  isBuffering$: IObservable<boolean>;
20
20
  currentBuffer$: IObservable<IRange<Seconds>>;
21
+ totalBufferDuration$: IObservable<Milliseconds>;
22
+ bufferRangeCount$: IObservable<number>;
21
23
  volumeState$: IObservable<IVolumeState>;
22
24
  playbackRateState$: IObservable<PlaybackRate>;
23
25
  inPiP$: IValueObservable<boolean>;
@@ -8,6 +8,12 @@ import { AudioRuleName, VideoRuleName } from "../providers/utils/Abr/types";
8
8
  export type ITuningConfig = {
9
9
  /** @deprecated */
10
10
  configName?: string[];
11
+ mayday: {
12
+ /** Порог суммарного времени проигрывания, при котором провайдер считается нестабильным после реинита (MediaError#3) */
13
+ playingUnstableThresholdMs: Milliseconds;
14
+ /** Список имён включённых эвристик. Пустой массив = все эвристики выключены */
15
+ heuristics: string[];
16
+ };
11
17
  /**
12
18
  * Если true, внутренний video элемент не будет уничтожаться при реините провайдера
13
19
  * и при создании нового экземляра Player.
@@ -329,6 +335,16 @@ export type ITuningConfig = {
329
335
  useDashProviderVirtualMobile: boolean;
330
336
  useNewAutoSelectVideoTrack: boolean;
331
337
  useSafariEndlessRequestBugfix: boolean;
338
+ /**
339
+ * Ручка для фикса сброса playbackRate при перемотке live-трансляции на Safari.
340
+ *
341
+ * На WebKit/Safari в момент applying seek video.currentTime может кратко отдавать
342
+ * неверное значение (например, 0). Без фикса это проходит в условие
343
+ * atLiveDurationEdge и tap сбрасывает playbackRate в 1, перетирая пользовательскую скорость.
344
+ * С фиксом позиция берётся из optimisticPosition (seek target во время seek), и ложного
345
+ * срабатывания не происходит. Для VOD нейтрально (isLive=false).
346
+ */
347
+ useSafariOptimisticPositionForLiveEdgeBugfix: boolean;
332
348
  isAudioDisabled: boolean;
333
349
  /**
334
350
  * Разрешает ядру автостарт только если страница, на которой находится плеер активна
@@ -340,6 +356,13 @@ export type ITuningConfig = {
340
356
  * использует requestAnimationFrame
341
357
  */
342
358
  autoplayOnlyIfVisible: boolean;
359
+ /**
360
+ * Восстанавливает отрисовку <video> при возврате из фоновой вкладки.
361
+ * WebKit на скрытых вкладках останавливает композитинг кадра и не всегда
362
+ * возобновляет его сам — после детекта «залипшего» кадра делается микросик
363
+ * в текущую позицию, заставляющий декодер переинициализировать текстуру.
364
+ */
365
+ recoverRenderingOnTabVisible: boolean;
343
366
  dynamicImportTimeout: Milliseconds;
344
367
  maxPlaybackTransitionInterval: Milliseconds;
345
368
  providerErrorLimit: number;