@vkontakte/videoplayer-core 2.0.165 → 2.0.166-dev.02230ed18.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.02230ed18.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.02230ed18.0"
46
46
  }
47
47
  }
@@ -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 показывает и буферизации на старте и после перемотки
@@ -40,8 +40,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
40
40
  protected currentVirtualBufferSize: Byte;
41
41
  private baseUrls;
42
42
  private baseUrlsIndex;
43
- protected maintainPlaybackBufferMutex: boolean;
44
- protected maintainNativeBufferMutex: boolean;
43
+ protected maintainMutex: boolean;
45
44
  protected bufferClearingMutex: boolean;
46
45
  protected abortNativeBufferMutex: boolean;
47
46
  protected switchMutex: boolean;
@@ -91,7 +90,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
91
90
  protected maintainPlaybackBuffer(position: Milliseconds): Promise<void>;
92
91
  protected actualizeLastSegmentInfo(currentPosition: Milliseconds): void;
93
92
  protected selectDownloadingItems(position: Milliseconds, segments: T[]): IBufferPlaybackQueueItem<T>[];
94
- protected processCachedItems(): Promise<void>;
93
+ protected processCachedItems(): void;
95
94
  protected withinInterval(currentPosition: Milliseconds | undefined, { from, to }: IRange<Milliseconds>, leftTolerance?: Milliseconds, rightTolerance?: Milliseconds): boolean;
96
95
  protected withinAppendInterval(currentPosition: Milliseconds | undefined, { from, to }: IRange<Milliseconds>): boolean;
97
96
  protected withinRemoveInterval(currentPosition: Milliseconds | undefined, { to }: IRange<Milliseconds>): boolean;
@@ -103,7 +102,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
103
102
  protected onItemFullyDownloaded(downloadedItem: IBufferPlaybackQueueItem<T>): void;
104
103
  protected onItemFullyAppended(appendedItem: IBufferPlaybackQueueItem<T>): void;
105
104
  protected removeSegment(nextRemoveItem: IBufferPlaybackQueueItem<T>, signal: AbortSignal): Promise<void>;
106
- protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): Promise<void>;
105
+ protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): void;
107
106
  protected pruneVirtualBuffer(currentPosition: Milliseconds): void;
108
107
  protected updateRepresentationsBaseUrlIfNeeded(): void;
109
108
  }
@@ -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.
@@ -175,9 +181,9 @@ export type ITuningConfig = {
175
181
  minNativeBufferSize: Milliseconds;
176
182
  removeTimeShiftFromSegment: Milliseconds;
177
183
  tickMaintainInterval: Milliseconds;
184
+ tickMaintainThrottle: Milliseconds;
178
185
  minSafeBufferToPlay: Milliseconds;
179
186
  useBufferHoldingOnlyOnStall: boolean;
180
- useAbortResetNativeBufferMutex: boolean;
181
187
  useNewAbr: boolean;
182
188
  useAbrPhases: boolean;
183
189
  abrVideoRules: VideoRuleName[];
@@ -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
  * Разрешает ядру автостарт только если страница, на которой находится плеер активна