@vkontakte/videoplayer-core 2.0.171-dev.881304e5f.0 → 2.0.171-dev.a5a2d3fc3.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.
Files changed (55) hide show
  1. package/es2015.cjs +38 -140
  2. package/es2015.esm.js +23 -125
  3. package/esnext.cjs +26 -128
  4. package/esnext.esm.js +24 -126
  5. package/evergreen.esm.js +24 -126
  6. package/package.json +2 -2
  7. package/types/player/types.d.ts +16 -4
  8. package/types/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +2 -1
  9. package/types/providers/DashProvider/lib/buffer.d.ts +4 -0
  10. package/types/providers/DashProvider/lib/fetcher.d.ts +6 -4
  11. package/types/providers/DashProvider/lib/player.d.ts +1 -0
  12. package/types/providers/DashProviderVirtual/lib/buffer/types.d.ts +2 -0
  13. package/types/providers/DashProviderVirtual/lib/buffer/virtualBuffer/baseVirtualBufferManager.versionA.d.ts +5 -1
  14. package/types/providers/DashProviderVirtual/lib/buffer/virtualBuffer/byteRangeVirtualBufferManager.versionA.d.ts +1 -0
  15. package/types/providers/DashProviderVirtual/lib/fetcher.d.ts +6 -4
  16. package/types/providers/DashProviderVirtual/lib/player/basePlayer.d.ts +5 -1
  17. package/types/providers/ProviderContainer/Mayday/GraceTimeout.d.ts +17 -0
  18. package/types/providers/ProviderContainer/Mayday/heuristics/SegmentAppendHeuristic.d.ts +10 -0
  19. package/types/providers/ProviderContainer/Mayday/heuristics/StartupHangupHeuristic.d.ts +46 -0
  20. package/types/providers/ProviderContainer/Mayday/index.d.ts +1 -1
  21. package/types/providers/ProviderContainer/Mayday/types.d.ts +2 -1
  22. package/types/providers/ProviderContainer/index.d.ts +3 -0
  23. package/types/providers/ProviderContainer/utils/playbackHangup.d.ts +6 -2
  24. package/types/providers/types.d.ts +4 -2
  25. package/types/providers/utils/Abr/abrController.d.ts +4 -1
  26. package/types/providers/utils/Abr/abrManager.d.ts +1 -0
  27. package/types/providers/utils/Abr/controllers/stallsController.d.ts +8 -1
  28. package/types/providers/utils/Abr/rules/audio/audioThroughputRule.d.ts +2 -2
  29. package/types/providers/utils/Abr/rules/audio/minAudioForVideoRule.d.ts +2 -2
  30. package/types/providers/utils/Abr/rules/baseRule.d.ts +2 -2
  31. package/types/providers/utils/Abr/rules/video/abandonRequestRule.d.ts +2 -2
  32. package/types/providers/utils/Abr/rules/video/bolaRule.d.ts +2 -2
  33. package/types/providers/utils/Abr/rules/video/bufferRule.d.ts +2 -2
  34. package/types/providers/utils/Abr/rules/video/fitsContainerRule.d.ts +2 -2
  35. package/types/providers/utils/Abr/rules/video/insufficientBufferRule.d.ts +2 -2
  36. package/types/providers/utils/Abr/rules/video/lowerLimitRule.d.ts +2 -2
  37. package/types/providers/utils/Abr/rules/video/stallsRule.d.ts +6 -2
  38. package/types/providers/utils/Abr/rules/video/throughputRule.d.ts +2 -2
  39. package/types/providers/utils/Abr/rules/video/tvDisabledVideoTrackRule.d.ts +2 -2
  40. package/types/providers/utils/Abr/rules/video/upperLimitRule.d.ts +2 -2
  41. package/types/providers/utils/Abr/types.d.ts +5 -2
  42. package/types/providers/utils/HTMLVideoElement/observable.d.ts +1 -1
  43. package/types/providers/utils/segmentCache/IndexedDbSegmentCacheStorage.d.ts +52 -0
  44. package/types/providers/utils/segmentCache/SegmentCache.d.ts +40 -0
  45. package/types/providers/utils/segmentCache/constants.d.ts +20 -0
  46. package/types/providers/utils/segmentCache/index.d.ts +8 -0
  47. package/types/providers/utils/segmentCache/segmentCacheDb.d.ts +25 -0
  48. package/types/providers/utils/segmentCache/segmentCacheUtils.d.ts +25 -0
  49. package/types/providers/utils/segmentCache/types.d.ts +74 -0
  50. package/types/utils/buffer/isBrokenSegmentAppend.d.ts +3 -0
  51. package/types/utils/buffer/timeRangesToIntervals.d.ts +3 -0
  52. package/types/utils/tuningConfig.d.ts +16 -9
  53. package/types/providers/DashProvider/lib/urlsCache.d.ts +0 -23
  54. package/types/providers/DashProviderVirtual/lib/urlsCache.d.ts +0 -22
  55. package/types/providers/ProviderContainer/Mayday/heuristics/HangupHeuristic.d.ts +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.171-dev.881304e5f.0",
3
+ "version": "2.0.171-dev.a5a2d3fc3.0",
4
4
  "author": "vk.ru",
5
5
  "description": "Videoplayer core library based on the vk.ru platform",
6
6
  "homepage": "https://vk.ru",
@@ -42,6 +42,6 @@
42
42
  "**/*.d.ts"
43
43
  ],
44
44
  "dependencies": {
45
- "@vkontakte/videoplayer-shared": "1.0.100-dev.881304e5f.0"
45
+ "@vkontakte/videoplayer-shared": "1.0.100-dev.a5a2d3fc3.0"
46
46
  }
47
47
  }
@@ -311,17 +311,29 @@ export interface PlayerInfoValues {
311
311
  */
312
312
  currentPlaybackRate$: PlaybackRate;
313
313
  /**
314
- * Текущий буффер плеера (тот; который содержит текущую позицию воспроизведения)
314
+ * Текущий видео буффер-плеера (тот; который содержит текущую позицию воспроизведения)
315
315
  *
316
316
  * default value: `undefined`
317
317
  */
318
- currentBuffer$: StartEnd<Seconds> | undefined;
318
+ currentVideoBuffer$: StartEnd<Seconds> | undefined;
319
319
  /**
320
- * Текущий браузерный буффер (тот; который содержит текущую позицию воспроизведения)
320
+ * Текущий аудио-буффер плеера (тот; который содержит текущую позицию воспроизведения)
321
321
  *
322
322
  * default value: `undefined`
323
323
  */
324
- currentNativeBuffer$: StartEnd<Seconds> | undefined;
324
+ currentAudioBuffer$: StartEnd<Seconds> | undefined;
325
+ /**
326
+ * Текущий браузерный видео-буффер (тот; который содержит текущую позицию воспроизведения)
327
+ *
328
+ * default value: `undefined`
329
+ */
330
+ currentNativeVideoBuffer$: StartEnd<Seconds> | undefined;
331
+ /**
332
+ * Текущий браузерный аудио-буффер (тот; который содержит текущую позицию воспроизведения)
333
+ *
334
+ * default value: `undefined`
335
+ */
336
+ currentNativeAudioBuffer$: StartEnd<Seconds> | undefined;
325
337
  /** Суммарная длительность всех буферизованных диапазонов в миллисекундах */
326
338
  totalBufferDuration$: Milliseconds | undefined;
327
339
  /**
@@ -49,8 +49,9 @@ export default class LiveDashPlayer {
49
49
  private bufferStates;
50
50
  private downloadRate?;
51
51
  private sourceJitter;
52
- /** Токен для защиты от устаревших callback'ов sourceopen при многократных вызовах _setVideoSrc */
53
52
  private srcToken;
53
+ private videoListeners;
54
+ private objectUrl;
54
55
  private chunkRateEstimator;
55
56
  private manifestUrl;
56
57
  private urlResolver;
@@ -41,6 +41,7 @@ export declare class BufferManager {
41
41
  private parsedInitData;
42
42
  private representations;
43
43
  private segments;
44
+ private segmentIndexMap;
44
45
  private allInitsLoaded;
45
46
  private activeSegments;
46
47
  private forwardBufferRepresentations;
@@ -75,6 +76,7 @@ export declare class BufferManager {
75
76
  private lastDataObtainedTimestampMs;
76
77
  private loadByteRangeSegmentsTimeoutId;
77
78
  private preDownloadedFirstSegment;
79
+ private brokenSegmentAppendDetected;
78
80
  constructor(kind: StreamKind, mediaSource: MediaSource, representations: Representation[], { fetcher, tuning, getCurrentPosition, isActiveLowLatency, compatibilityMode, manifest }: Dependencies);
79
81
  startWith: ReturnType<typeof abortable<[Representation["id"]]>>;
80
82
  switchToWithPreviousAbort(newRepresentationId: Representation["id"], dropBuffer?: boolean): Promise<void | undefined>;
@@ -106,6 +108,7 @@ export declare class BufferManager {
106
108
  private feedPreDownloadedFirstSegment;
107
109
  private loadByteRangeSegments;
108
110
  private prepareByteRangeFetchSegmentParams;
111
+ private buildCacheMetadata;
109
112
  private prepareTemplateFetchSegmentParams;
110
113
  private abortActiveSegments;
111
114
  private onSomeTemplateDataLoaded;
@@ -119,6 +122,7 @@ export declare class BufferManager {
119
122
  */
120
123
  private onSomeByteRangesDataLoaded;
121
124
  private onSegmentFullyAppended;
125
+ private detectBrokenSegmentAppend;
122
126
  private abortSegment;
123
127
  private loadNextInit;
124
128
  private loadInit;
@@ -4,6 +4,7 @@ import type { Byte, IValueSubject, ISubject, Milliseconds, IRange, ITracer, IErr
4
4
  import { abortable } from "@vkontakte/videoplayer-shared";
5
5
  import type { ExactVideoQuality } from "@vkontakte/videoplayer-shared";
6
6
  import type { CommonInit, GenericContainerParser, Segment, SegmentReference } from "../../utils/parsers/types";
7
+ import type { ISegmentCacheStorage, CacheMetadata } from "../../utils/segmentCache";
7
8
  declare global {
8
9
  interface Navigator {
9
10
  connection: {
@@ -24,11 +25,11 @@ export interface IParams {
24
25
  tracer: ITracer;
25
26
  useEnableSubtitlesParam?: boolean;
26
27
  handleExtendedNetworkErrorsSet?: boolean;
27
- useUrlCacheMechanism?: boolean;
28
28
  measureNonSegmentRequests?: boolean;
29
29
  measureFastSamples?: boolean;
30
30
  preloadFirstSegment?: boolean;
31
31
  maxQualityForFirstSegmentPreload?: ExactVideoQuality;
32
+ segmentCacheService?: ISegmentCacheStorage;
32
33
  }
33
34
  export type Priority = "high" | "low" | "auto";
34
35
  export interface FetchParamsWithUrl extends FetchParams {
@@ -45,8 +46,8 @@ export interface FetchParams {
45
46
  isLowLatency?: boolean;
46
47
  bufferOptimisation?: boolean;
47
48
  ignoreNetworkErrors?: boolean;
48
- urlCacheMechanismEnabled?: boolean;
49
49
  representationHeight?: number;
50
+ cacheMetadata?: CacheMetadata;
50
51
  }
51
52
  export type RepresentationFetchResult = {
52
53
  init: CommonInit | null;
@@ -73,16 +74,17 @@ export declare class Fetcher {
73
74
  private readonly subscription;
74
75
  private compatibilityMode;
75
76
  private useEnableSubtitlesParam;
76
- private useUrlCacheMechanism;
77
77
  private measureNonSegmentRequests;
78
78
  private measureFastSamples;
79
79
  private preloadFirstSegment;
80
80
  private maxQualityForFirstSegmentPreload;
81
+ private segmentCacheService;
82
+ private segmentCache;
81
83
  private startupPhase;
82
84
  private performanceObserver;
83
85
  private pendingConnectionMetrics;
84
86
  private handleExtendedNetworkErrorsSet;
85
- constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, useUrlCacheMechanism, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload }: IParams);
87
+ constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload, segmentCacheService }: IParams);
86
88
  private onHeadersReceived;
87
89
  private setupPerformanceObserver;
88
90
  private processPerformanceResourceTiming;
@@ -40,6 +40,7 @@ export declare class Player {
40
40
  private subscriptionRemovable;
41
41
  private representationSubscription;
42
42
  private fetcher;
43
+ private segmentCacheService;
43
44
  state$: StateMachine<State>;
44
45
  currentVideoRepresentation$: IValueSubject<Representation["id"] | undefined>;
45
46
  currentVideoRepresentationInit$: IValueSubject<CommonInit | undefined>;
@@ -3,6 +3,7 @@ import type { CommonInit, Manifest, Representation, Segment } from "../../../uti
3
3
  import type { Fetcher } from "../fetcher";
4
4
  import type { ITuningConfig } from "../../../../utils/tuningConfig";
5
5
  import type { VideoSegmentLoadProgress } from "../../../utils/Abr/types";
6
+ import type { ISegmentCacheStorage } from "../../../utils/segmentCache";
6
7
  export type TRepresentationSwitchMode = "lazy" | "force";
7
8
  export declare enum SwithRepresentationMode {
8
9
  Lazy = "lazy",
@@ -15,6 +16,7 @@ export interface Dependencies {
15
16
  tuning: ITuningConfig;
16
17
  compatibilityMode?: boolean;
17
18
  manifest: Manifest | null;
19
+ segmentCacheService?: ISegmentCacheStorage;
18
20
  getCurrentPosition(): Milliseconds | undefined;
19
21
  getCurrentStallDuration(): Milliseconds;
20
22
  isActiveLowLatency(): boolean;
@@ -2,6 +2,7 @@ import type { Fetcher, FetchParamsWithUrl, Priority, RepresentationFetchResult }
2
2
  import type { CommonInit, ContainerParser, Representation, Segment } from "../../../../utils/parsers/types";
3
3
  import { StreamKind } from "../../../../utils/parsers/types";
4
4
  import type { ITuningConfig } from "../../../../../utils/tuningConfig";
5
+ import type { ISegmentCacheStorage } from "../../../../utils/segmentCache";
5
6
  import type { Byte, IError, IRange, ISubject, ITracer, IValueSubject, Milliseconds, Seconds } from "@vkontakte/videoplayer-shared";
6
7
  import { abortable, Subscription } from "@vkontakte/videoplayer-shared";
7
8
  import type { NativeBufferManager } from "../nativeBufferManager";
@@ -19,6 +20,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
19
20
  protected readonly fetcher: Fetcher;
20
21
  protected readonly tracer: ITracer;
21
22
  protected readonly tuning: ITuningConfig;
23
+ protected readonly segmentCacheService: ISegmentCacheStorage | undefined;
22
24
  protected representations: Map<Representation["id"], Representation>;
23
25
  protected playingRepresentationId: Representation["id"] | undefined;
24
26
  protected downloadingRepresentationId: Representation["id"] | undefined;
@@ -52,7 +54,8 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
52
54
  protected subscription: Subscription;
53
55
  protected readonly getCurrentPosition: () => Milliseconds | undefined;
54
56
  protected readonly getCurrentStallDuration: () => Milliseconds | undefined;
55
- protected constructor(kind: StreamKind, nativeBufferManager: NativeBufferManager, representations: Representation[], { fetcher, tracer, tuning, getCurrentPosition, getCurrentStallDuration, manifest }: Dependencies);
57
+ protected brokenSegmentAppendDetected: boolean;
58
+ protected constructor(kind: StreamKind, nativeBufferManager: NativeBufferManager, representations: Representation[], { fetcher, tracer, tuning, getCurrentPosition, getCurrentStallDuration, manifest, segmentCacheService }: Dependencies);
56
59
  protected abstract loadItems(itemsToLoad: IBufferPlaybackQueueItem<T>[], representation: Representation, priority?: Priority): Promise<void>;
57
60
  protected abstract selectItemsToLoad(): IBufferPlaybackQueueItem<T>[];
58
61
  protected abstract prepareFetchParams(items: IBufferPlaybackQueueItem<T>[], representation: Representation): FetchParamsWithUrl;
@@ -120,6 +123,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
120
123
  protected parseFeedableSegmentChunk(chunk: DataView): DataView | null;
121
124
  protected onItemFullyDownloaded(downloadedItem: IBufferPlaybackQueueItem<T>): void;
122
125
  protected onItemFullyAppended(appendedItem: IBufferPlaybackQueueItem<T>): void;
126
+ private detectBrokenSegmentAppend;
123
127
  protected removeSegment(nextRemoveItem: IBufferPlaybackQueueItem<T>, signal: AbortSignal): Promise<void>;
124
128
  protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): void;
125
129
  protected pruneVirtualBuffer(currentPosition: Milliseconds): void;
@@ -8,6 +8,7 @@ export declare class ByteRangeVirtualBufferManager extends BaseVirtualBufferMana
8
8
  protected override loadItems(itemsToLoad: IBufferPlaybackQueueItem<ByteRangeSegment>[], representation: Representation, priority?: Priority): Promise<void>;
9
9
  protected override selectItemsToLoad(): IBufferPlaybackQueueItem<ByteRangeSegment>[];
10
10
  protected override prepareFetchParams(items: IBufferPlaybackQueueItem<ByteRangeSegment>[], representation: Representation): FetchParamsWithUrl;
11
+ private buildCacheMetadata;
11
12
  /**
12
13
  * Закидываем в буфер сегменты атомарнее чем сегмент целиком. Например, по боксам в мпеге и по блокам в вебме.
13
14
  * Таким образом не ждём его полной загрузки и готовы играть его намного быстрее
@@ -4,6 +4,7 @@ import type { Byte, IError, IRange, ISubject, ITracer, IValueSubject, Millisecon
4
4
  import { abortable } from "@vkontakte/videoplayer-shared";
5
5
  import type { ExactVideoQuality } from "@vkontakte/videoplayer-shared";
6
6
  import type { CommonInit, GenericContainerParser, Segment, SegmentReference, StreamKind } from "../../utils/parsers/types";
7
+ import type { ISegmentCacheStorage, CacheMetadata } from "../../utils/segmentCache";
7
8
  declare global {
8
9
  interface Navigator {
9
10
  connection: {
@@ -24,11 +25,11 @@ export interface IParams {
24
25
  tracer: ITracer;
25
26
  useEnableSubtitlesParam?: boolean;
26
27
  handleExtendedNetworkErrorsSet?: boolean;
27
- useUrlCacheMechanism?: boolean;
28
28
  measureNonSegmentRequests?: boolean;
29
29
  measureFastSamples?: boolean;
30
30
  preloadFirstSegment?: boolean;
31
31
  maxQualityForFirstSegmentPreload?: ExactVideoQuality;
32
+ segmentCacheService?: ISegmentCacheStorage;
32
33
  }
33
34
  export type Priority = "high" | "low" | "auto";
34
35
  export interface FetchParamsWithUrl extends FetchParams {
@@ -44,8 +45,8 @@ export interface FetchParams {
44
45
  measureThroughput?: boolean;
45
46
  isLowLatency?: boolean;
46
47
  bufferOptimisation?: boolean;
47
- urlCacheMechanismEnabled?: boolean;
48
48
  kind: StreamKind;
49
+ cacheMetadata?: CacheMetadata;
49
50
  }
50
51
  export type RepresentationFetchResult<T extends Segment> = {
51
52
  initMetadata: CommonInit | null;
@@ -72,16 +73,17 @@ export declare class Fetcher {
72
73
  private subscription;
73
74
  private compatibilityMode;
74
75
  private useEnableSubtitlesParam;
75
- private useUrlCacheMechanism;
76
76
  private measureNonSegmentRequests;
77
77
  private measureFastSamples;
78
78
  private preloadFirstSegment;
79
79
  private maxQualityForFirstSegmentPreload;
80
+ private segmentCacheService;
81
+ private segmentCache;
80
82
  private startupPhase;
81
83
  private performanceObserver;
82
84
  private pendingConnectionMetrics;
83
85
  private handleExtendedNetworkErrorsSet;
84
- constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, useUrlCacheMechanism, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload }: IParams);
86
+ constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload, segmentCacheService }: IParams);
85
87
  private onHeadersReceived;
86
88
  private setupPerformanceObserver;
87
89
  private processResourceTiming;
@@ -9,6 +9,7 @@ import type { IError, IRange, ISubject, ISubscription, ITracer, IValueSubject, M
9
9
  import { abortable, Subject, Subscription, SubscriptionRemovable } from "@vkontakte/videoplayer-shared";
10
10
  import type { VideoSegmentLoadProgress } from "../../../utils/Abr/types";
11
11
  import { Fetcher } from "../fetcher";
12
+ import type { ISegmentCacheStorage } from "../../../utils/segmentCache";
12
13
  import type { Dependencies, IVirtualBufferManager, SwithRepresentationMode } from "../buffer/types";
13
14
  import type { Params } from "./types";
14
15
  import { State } from "./types";
@@ -35,6 +36,7 @@ export declare abstract class BasePlayer {
35
36
  protected subscriptionRemovable: SubscriptionRemovable;
36
37
  protected representationSubscription: Subscription;
37
38
  protected fetcher: Fetcher;
39
+ protected segmentCacheService: ISegmentCacheStorage | undefined;
38
40
  protected forceEnded$: ISubject<void>;
39
41
  protected stallWatchdogSubscription: ISubscription | undefined;
40
42
  protected destroyController: AbortController;
@@ -63,9 +65,11 @@ export declare abstract class BasePlayer {
63
65
  liveSeekableDuration$: IValueSubject<Milliseconds>;
64
66
  liveAvailabilityStartTime$: IValueSubject<Milliseconds>;
65
67
  liveStreamStatus$: IValueSubject<LiveStreamStatus | undefined>;
66
- currentBuffer$: IValueSubject<IRange<Seconds>>;
68
+ currentVideoBuffer$: IValueSubject<IRange<Seconds>>;
69
+ currentAudioBuffer$: IValueSubject<IRange<Seconds>>;
67
70
  bufferLength$: IValueSubject<Milliseconds>;
68
71
  nativeBufferLength$: IValueSubject<Milliseconds>;
72
+ nativeAudioBufferLength$: IValueSubject<IRange<Seconds>>;
69
73
  liveLatency$: IValueSubject<Milliseconds | undefined>;
70
74
  liveLoadBufferLength$: IValueSubject<Milliseconds>;
71
75
  livePositionFromPlayer$: IValueSubject<number>;
@@ -0,0 +1,17 @@
1
+ import type { Milliseconds } from "@vkontakte/videoplayer-shared";
2
+ /**
3
+ * Декрементный grace-таймаут: каждый вызов `decay()` уменьшает оставшееся время.
4
+ *
5
+ * После создания `current` возвращает начальное значение.
6
+ * Каждый вызов `decay()` умножает `remaining` на `decayFactor`, но не меньше `minTimeout`.
7
+ * Когда `remaining` достигает `minTimeout` — следующий `decay()` возвращает 0 (expire).
8
+ */
9
+ export declare class GraceTimeout {
10
+ private remaining;
11
+ private readonly decayFactor;
12
+ private readonly minTimeout;
13
+ constructor(initialTimeout: Milliseconds, decayFactor: number, minTimeout: Milliseconds);
14
+ get current(): Milliseconds;
15
+ decay(): Milliseconds;
16
+ reset(initialTimeout: Milliseconds): void;
17
+ }
@@ -0,0 +1,10 @@
1
+ import type { IError } from "@vkontakte/videoplayer-shared";
2
+ import type { IHeuristicDeps } from "../types";
3
+ import type { ISyncHeuristic, HeuristicResult } from "./IHeuristic";
4
+ export declare class SegmentAppendHeuristic implements ISyncHeuristic {
5
+ private deps;
6
+ static readonly heuristicName = "SegmentAppendHeuristic";
7
+ readonly type = "sync";
8
+ constructor(deps: IHeuristicDeps);
9
+ analyze(error: IError): HeuristicResult;
10
+ }
@@ -0,0 +1,46 @@
1
+ import { Subject } from "@vkontakte/videoplayer-shared";
2
+ import type { IError } from "@vkontakte/videoplayer-shared";
3
+ import type { IHeuristicDeps, IMaydayEvent } from "../types";
4
+ import type { IAsyncHeuristic, HeuristicResult } from "./IHeuristic";
5
+ /**
6
+ * Эвристика зависания перехода stopped-*.
7
+ *
8
+ * В зависимости от видимости вкладки и наличия звука выбирает стратегию
9
+ * и эмитит одну из рекомендаций:
10
+ *
11
+ * Visible-вкладка: grace-таймаут с уменьшением таймаута на поступление данных.
12
+ * — данные поступают → таймер продлевается.
13
+ * — grace истёк без прогресса → emit switch_codec (или switch_provider).
14
+ *
15
+ * Hidden-вкладка (audible): та же grace-модель с таймаутом (таймеры в воркере не тротлятся).
16
+ * — данные поступают → таймер продлевается.
17
+ * — grace истёк без прогресса → emit switch_codec.
18
+ *
19
+ * Hidden-вкладка (muted/deferred): молча ждём возврата на visible, desired state не трогаем.
20
+ * — вкладка стала visible → emit reinit (полный реинит сам восстановит воспроизведение).
21
+ * — переход всё-таки завершился в фоне (видео заиграло) → отмена, reinit не нужен.
22
+ */
23
+ export declare class StartupHangupHeuristic implements IAsyncHeuristic {
24
+ private deps;
25
+ static readonly heuristicName = "StartupHangupHeuristic";
26
+ readonly type = "async";
27
+ readonly recommendation$: Subject<IMaydayEvent>;
28
+ private timerId;
29
+ private subscription;
30
+ private error;
31
+ private grace;
32
+ private hangupStartedAt;
33
+ private dataArrivals;
34
+ private hiddenWaitActive;
35
+ constructor(deps: IHeuristicDeps);
36
+ analyze(error: IError): HeuristicResult;
37
+ private startMonitoring;
38
+ private waitForVisible;
39
+ private restartTimer;
40
+ private recommendSwitch;
41
+ private isTabHidden;
42
+ private logOutcome;
43
+ private cancel;
44
+ reset(): void;
45
+ destroy(): void;
46
+ }
@@ -4,5 +4,5 @@ export type { ISyncHeuristic, IAsyncHeuristic, HeuristicResult } from "./heurist
4
4
  export { MediaErrorHeuristic } from "./heuristics/MediaErrorHeuristic";
5
5
  export { FetcherErrorHeuristic } from "./heuristics/FetcherErrorHeuristic";
6
6
  export { TvFetcherErrorHeuristic } from "./heuristics/TvFetcherErrorHeuristic";
7
- export { HangupHeuristic } from "./heuristics/HangupHeuristic";
7
+ export { StartupHangupHeuristic } from "./heuristics/StartupHangupHeuristic";
8
8
  export { MaydayStatistics } from "./MaydayStatistics";
@@ -14,7 +14,7 @@ export interface IMaydayProviderOutput {
14
14
  position$: IValueSubject<number>;
15
15
  currentVideoTrack$: IValueSubject<IVideoTrack | undefined>;
16
16
  totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
17
- currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
17
+ currentNativeVideoBuffer$: IValueSubject<IRange<Seconds> | undefined>;
18
18
  bufferRangeCount$: IValueSubject<number | undefined>;
19
19
  availableVideoStreams$: IValueSubject<IVideoStream[]>;
20
20
  currentAudioStream$: IValueSubject<IAudioStream | undefined>;
@@ -54,6 +54,7 @@ export interface IHeuristicDeps {
54
54
  getVisibilityState: () => DocumentVisibilityState | undefined;
55
55
  getReadyState: () => number | undefined;
56
56
  getVideoPaused: () => boolean | undefined;
57
+ getIsMuted: () => boolean;
57
58
  currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
58
59
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
59
60
  desiredPlaybackState$: IStateMachine<PlaybackState>;
@@ -37,6 +37,7 @@ export default class ProviderContainer implements IProviderContainer {
37
37
  private currentProviderStarted;
38
38
  private volumeMultiplierManager;
39
39
  private dashMaxTvVideoQuality;
40
+ private segmentCacheCleared;
40
41
  private mayday;
41
42
  private maydayStatistics;
42
43
  constructor(params: IParams);
@@ -50,6 +51,8 @@ export default class ProviderContainer implements IProviderContainer {
50
51
  private destroyProvider;
51
52
  private handleMaydayRecommendation;
52
53
  private applyErrorSideEffects;
54
+ /** Битые данные в кэше могут вызывать повторные ошибки после реинита — очищаем кэш целиком. */
55
+ private clearSegmentCacheOnError;
53
56
  private createProvider;
54
57
  private createScreenProvider;
55
58
  private createChromecastProvider;
@@ -1,6 +1,5 @@
1
1
  import type { IProviderEntry } from "../types";
2
2
  import type { IObservable, Milliseconds } from "@vkontakte/videoplayer-shared";
3
- import { Observable } from "@vkontakte/videoplayer-shared";
4
3
  import type { IStateMachine } from "../../../utils/StateMachine/types";
5
4
  import { PlaybackState } from "../../../player/types";
6
5
  interface IParams {
@@ -12,5 +11,10 @@ interface IParams {
12
11
  playbackHangupNoDataThreshold: Milliseconds;
13
12
  useDelayedPlaybackHangupWithData: boolean;
14
13
  }
15
- declare const _default: (params: IParams) => Observable<string>;
14
+ export interface IPlaybackHangupInfo {
15
+ from: PlaybackState;
16
+ to: PlaybackState;
17
+ label: string;
18
+ }
19
+ declare const _default: (params: IParams) => IObservable<IPlaybackHangupInfo>;
16
20
  export default _default;
@@ -81,8 +81,10 @@ export interface IProviderOutput {
81
81
  autoVideoTrackLimits$: IValueSubject<QualityLimits | undefined>;
82
82
  autoVideoTrackLimitingAvailable$: IValueSubject<boolean>;
83
83
  canChangePlaybackSpeed$: IValueSubject<boolean | undefined>;
84
- currentBuffer$: IValueSubject<IRange<Seconds> | undefined>;
85
- currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
84
+ currentVideoBuffer$: IValueSubject<IRange<Seconds> | undefined>;
85
+ currentAudioBuffer$: IValueSubject<IRange<Seconds> | undefined>;
86
+ currentNativeVideoBuffer$: IValueSubject<IRange<Seconds> | undefined>;
87
+ currentNativeAudioBuffer$: IValueSubject<IRange<Seconds> | undefined>;
86
88
  totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
87
89
  bufferRangeCount$: IValueSubject<number | undefined>;
88
90
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
@@ -1,5 +1,6 @@
1
- import type { IAbrController, IAbrRule, IBaseAbrControllerContext, IRuleInitContext } from "./types";
1
+ import type { IAbrController, IAbrRule, IBaseAbrControllerContext, IRuleInitContext, RuleLogData } from "./types";
2
2
  import type { IBaseTrack } from "../../../player/types";
3
+ export declare const formatRuleLog: ({ name, ...logData }: RuleLogData) => string;
3
4
  export default class AbrController<
4
5
  T extends IBaseTrack,
5
6
  C extends IBaseAbrControllerContext
@@ -12,6 +13,8 @@ export default class AbrController<
12
13
  destroy(): void;
13
14
  updateContext(context: C): void;
14
15
  autoSelectTrack(rules?: IAbrRule<T, C>[]): T;
16
+ private traceQualitySwitch;
17
+ private isLowQuality;
15
18
  private selectTrackBasedOnHistory;
16
19
  /** при переключении аудио стрима очищаем историю для предотвращения залипания в `onCooldown` */
17
20
  historyReset(): void;
@@ -10,6 +10,7 @@ export declare class AbrManager {
10
10
  private context;
11
11
  private phaseController;
12
12
  private allVideoRules;
13
+ private tracer;
13
14
  init(context: IInitAbrManagerContext): void;
14
15
  updateContext(updateContext: IUpdatableAbrManagerContext): void;
15
16
  autoSelectTrack<T extends IVideoTrack | IAudioTrack>(kind: Exclude<StreamKind, StreamKind.TEXT>): T;
@@ -1,4 +1,4 @@
1
- import type { IObservable, IValueSubject, Milliseconds } from "@vkontakte/videoplayer-shared";
1
+ import type { IObservable, ITracer, IValueSubject, Milliseconds } from "@vkontakte/videoplayer-shared";
2
2
  import type { ITuningConfig } from "../../../../utils/tuningConfig";
3
3
  import type { IVideoTrack } from "../../../../player/types";
4
4
  import type { IObservableVideo } from "../../HTMLVideoElement/observable";
@@ -10,6 +10,7 @@ interface IConnectData {
10
10
  observableVideo: IObservableVideo;
11
11
  currentStallDuration$: IValueSubject<Milliseconds>;
12
12
  tuning: ITuningConfig["stallsManager"];
13
+ tracer: ITracer;
13
14
  }
14
15
  export declare class StallsController {
15
16
  private currentStallDuration$;
@@ -20,6 +21,9 @@ export declare class StallsController {
20
21
  private lastUniqueVideoTrackSelectedTimestamp;
21
22
  private lastUniqueVideoTrackSelected;
22
23
  private providerStartWatchingTimestamp;
24
+ private tracer;
25
+ private severeStallTracer;
26
+ private severeStallStartedAt;
23
27
  private subscription;
24
28
  severeStallOccurred$: IValueSubject<boolean>;
25
29
  totalStallsCount$: IValueSubject<number>;
@@ -28,6 +32,9 @@ export declare class StallsController {
28
32
  lastStallDuration$: IValueSubject<Milliseconds>;
29
33
  init(data: IConnectData): void;
30
34
  destroy(): void;
35
+ private startSevereStallTracer;
36
+ private endSevereStallTracer;
37
+ private traceUpdateStallData;
31
38
  private updateStallData;
32
39
  }
33
40
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IAudioAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IAudioAbrContext, RuleLogData } from "../../types";
2
2
  import type { IAudioTrack, IVideoTrack } from "../../../../../player/types";
3
3
  import { LimitAboveRule } from "../limitAboveRule";
4
4
  import type { Kbps, Nullable } from "@vkontakte/videoplayer-shared";
@@ -8,6 +8,6 @@ type AudioThroughputLogsArgs = [forwardBufferHealth: Nullable<number>, playbackR
8
8
  export declare class AudioThroughputRule extends LimitAboveRule<IAudioTrack, IAudioAbrContext, AudioThroughputLogsArgs> implements IAbrRule<IAudioTrack, IAudioAbrContext> {
9
9
  constructor(phaseConfig: RulePhaseConfig);
10
10
  execute(context: IAudioAbrContext): IAbrRuleResolution<IAudioTrack>;
11
- protected createLogMessage(selectedTrack: IVideoTrack, forwardBufferHealth: number | undefined, playbackRate: number, reserve: Kbps, playbackRateFactor: number, bitrateFactor: number, estimatedThroughput: Kbps, tuning: ITuningConfig): string;
11
+ protected createLogData(selectedTrack: IVideoTrack, forwardBufferHealth: number | undefined, playbackRate: number, reserve: Kbps, playbackRateFactor: number, bitrateFactor: number, estimatedThroughput: Kbps, tuning: ITuningConfig): RuleLogData;
12
12
  }
13
13
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IAudioAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IAudioAbrContext, RuleLogData } from "../../types";
2
2
  import type { IAudioTrack, IVideoTrack } from "../../../../../player/types";
3
3
  import { LimitBelowRule } from "../limitBelowRule";
4
4
  import type { ITuningConfig } from "../../../../../utils/tuningConfig";
@@ -8,6 +8,6 @@ type MinAudioForVideoLogsArgs = [lastVideoTrackSelected: Nullable<IVideoTrack>,
8
8
  export declare class MinAudioForVideoRule extends LimitBelowRule<IAudioTrack, IAudioAbrContext, MinAudioForVideoLogsArgs> implements IAbrRule<IAudioTrack, IAudioAbrContext> {
9
9
  constructor(phaseConfig: RulePhaseConfig);
10
10
  execute(context: IAudioAbrContext): IAbrRuleResolution<IAudioTrack>;
11
- protected createLogMessage(selectedTrack: IVideoTrack, lastVideoTrackSelected: Nullable<IVideoTrack>, tuning: ITuningConfig): string;
11
+ protected createLogData(selectedTrack: IVideoTrack, lastVideoTrackSelected: Nullable<IVideoTrack>, tuning: ITuningConfig): RuleLogData;
12
12
  }
13
13
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IBaseAbrControllerContext, IRuleInitContext, RuleConfidence, RuleType } from "../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IBaseAbrControllerContext, IRuleInitContext, RuleConfidence, RuleLogData, RuleType } from "../types";
2
2
  import type { IBaseTrack } from "../../../../player/types";
3
3
  import { Subscription } from "@vkontakte/videoplayer-shared";
4
4
  import type { AbrPhase } from "../controllers/abrPhaseController";
@@ -19,5 +19,5 @@ export declare abstract class BaseRule<
19
19
  destroy(): void;
20
20
  abstract execute(context: C): IAbrRuleResolution<T>;
21
21
  protected createResolution(context: C, selectedTrack: T, ...params: LogsArgs): IAbrRuleResolution<T>;
22
- protected abstract createLogMessage(selectedTrack: T, ...params: LogsArgs): string;
22
+ protected abstract createLogData(selectedTrack: T, ...params: LogsArgs): RuleLogData;
23
23
  }
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext, RuleLogData } from "../../types";
2
2
  import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { Milliseconds } from "@vkontakte/videoplayer-shared";
4
4
  import { LimitAboveRule } from "../limitAboveRule";
@@ -7,6 +7,6 @@ type LogsArgs = [elapsedMs: Milliseconds, loadedFraction: number, estimatedRemai
7
7
  export declare class AbandonRequestRule extends LimitAboveRule<IVideoTrack, IVideoAbrContext, LogsArgs> implements IAbrRule<IVideoTrack, IVideoAbrContext> {
8
8
  constructor(phaseConfig: RulePhaseConfig);
9
9
  execute(context: IVideoAbrContext): IAbrRuleResolution<IVideoTrack>;
10
- protected createLogMessage(selectedTrack: IVideoTrack, elapsedMs: Milliseconds, loadedFraction: number, estimatedRemainingMs: Milliseconds, bufferLimitMs: Milliseconds, triggered: boolean): string;
10
+ protected createLogData(selectedTrack: IVideoTrack, elapsedMs: Milliseconds, loadedFraction: number, estimatedRemainingMs: Milliseconds, bufferLimitMs: Milliseconds, triggered: boolean): RuleLogData;
11
11
  }
12
12
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IRuleInitContext, IVideoAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IRuleInitContext, IVideoAbrContext, RuleLogData } from "../../types";
2
2
  import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { Kbps, Seconds } from "@vkontakte/videoplayer-shared";
4
4
  import { LimitAboveRule } from "../limitAboveRule";
@@ -26,6 +26,6 @@ export declare class BolaRule extends LimitAboveRule<IVideoTrack, IVideoAbrConte
26
26
  private resolveSegmentDurationS;
27
27
  private applyBolaOSafeguard;
28
28
  private resetPlaceholder;
29
- protected createLogMessage(selectedTrack: IVideoTrack, bufferLevelS: Seconds, placeholderBufferS: Seconds, segmentDurationS: Seconds, Vp: number, gp: number, validBitrates: Kbps[], selectedIndex: number, phase: AbrPhase | undefined): string;
29
+ protected createLogData(selectedTrack: IVideoTrack, bufferLevelS: Seconds, placeholderBufferS: Seconds, segmentDurationS: Seconds, Vp: number, gp: number, validBitrates: Kbps[], selectedIndex: number, phase: AbrPhase | undefined): RuleLogData;
30
30
  }
31
31
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext, RuleLogData } from "../../types";
2
2
  import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { Nullable } from "@vkontakte/videoplayer-shared";
4
4
  import { LimitAboveRule } from "../limitAboveRule";
@@ -12,6 +12,6 @@ type BufferRuleLogsArgs = [currentVideoTrack: Nullable<IVideoTrack>, lastVideoTr
12
12
  export declare class BufferRule extends LimitAboveRule<IVideoTrack, IVideoAbrContext, BufferRuleLogsArgs> implements IAbrRule<IVideoTrack, IVideoAbrContext> {
13
13
  constructor(phaseConfig: RulePhaseConfig);
14
14
  execute(context: IVideoAbrContext): IAbrRuleResolution<IVideoTrack>;
15
- protected createLogMessage(selectedTrack: IVideoTrack, currentVideoTrack: Nullable<IVideoTrack>, lastVideoTrackSelected: Nullable<IVideoTrack>, forwardBufferHealth: Nullable<number>, abrTuning: ITuningConfig["autoTrackSelection"]): string;
15
+ protected createLogData(selectedTrack: IVideoTrack, currentVideoTrack: Nullable<IVideoTrack>, lastVideoTrackSelected: Nullable<IVideoTrack>, forwardBufferHealth: Nullable<number>, abrTuning: ITuningConfig["autoTrackSelection"]): RuleLogData;
16
16
  }
17
17
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IVideoAbrContext, RuleLogData } from "../../types";
2
2
  import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { IRectangle, Nullable } from "@vkontakte/videoplayer-shared";
4
4
  import { LimitAboveRule } from "../limitAboveRule";
@@ -9,7 +9,7 @@ type FitsContainerLogsArgs = [containerSizeLimit: Nullable<IContainerSizeLimit>,
9
9
  export declare class FitsContainerRule extends LimitAboveRule<IVideoTrack, IVideoAbrContext, FitsContainerLogsArgs> implements IAbrRule<IVideoTrack, IVideoAbrContext> {
10
10
  constructor(phaseConfig: RulePhaseConfig);
11
11
  execute(context: IVideoAbrContext): IAbrRuleResolution<IVideoTrack>;
12
- protected createLogMessage(selectedTrack: IVideoTrack, containerSizeLimit: Nullable<IContainerSizeLimit>, containerSizeFactor: number, abrTuning: ITuningConfig["autoTrackSelection"]): string;
12
+ protected createLogData(selectedTrack: IVideoTrack, containerSizeLimit: Nullable<IContainerSizeLimit>, containerSizeFactor: number, abrTuning: ITuningConfig["autoTrackSelection"]): RuleLogData;
13
13
  private getContainerSizeLimit;
14
14
  }
15
15
  export {};
@@ -1,4 +1,4 @@
1
- import type { IAbrRule, IAbrRuleResolution, IRuleInitContext, IVideoAbrContext } from "../../types";
1
+ import type { IAbrRule, IAbrRuleResolution, IRuleInitContext, IVideoAbrContext, RuleLogData } from "../../types";
2
2
  import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { Milliseconds } from "@vkontakte/videoplayer-shared";
4
4
  import { LimitAboveRule } from "../limitAboveRule";
@@ -10,6 +10,6 @@ export declare class InsufficientBufferRule extends LimitAboveRule<IVideoTrack,
10
10
  override init(initContext: IRuleInitContext): void;
11
11
  execute(context: IVideoAbrContext): IAbrRuleResolution<IVideoTrack>;
12
12
  private selectThroughputAwareFallback;
13
- protected createLogMessage(selectedTrack: IVideoTrack, forwardBufferDuration: Milliseconds | undefined, thresholdMs: Milliseconds, triggered: boolean, suppressedByGrace: boolean): string;
13
+ protected createLogData(selectedTrack: IVideoTrack, forwardBufferDuration: Milliseconds | undefined, thresholdMs: Milliseconds, triggered: boolean, suppressedByGrace: boolean): RuleLogData;
14
14
  }
15
15
  export {};