@vkontakte/videoplayer-core 2.0.171-dev.a5a2d3fc3.0 → 2.0.171-dev.cb6e2e206.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 (71) hide show
  1. package/es2015.cjs +160 -48
  2. package/es2015.esm.js +162 -50
  3. package/esnext.cjs +158 -46
  4. package/esnext.esm.js +158 -46
  5. package/evergreen.esm.js +158 -46
  6. package/package.json +2 -2
  7. package/types/player/Player.d.ts +0 -1
  8. package/types/player/types.d.ts +4 -16
  9. package/types/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +9 -3
  10. package/types/providers/DashProvider/baseDashProvider.d.ts +4 -1
  11. package/types/providers/DashProvider/lib/buffer.d.ts +0 -4
  12. package/types/providers/DashProvider/lib/fetcher.d.ts +4 -6
  13. package/types/providers/DashProvider/lib/player.d.ts +0 -1
  14. package/types/providers/DashProvider/lib/sourceBufferTaskQueue.d.ts +2 -1
  15. package/types/providers/DashProvider/lib/urlsCache.d.ts +23 -0
  16. package/types/providers/DashProviderVirtual/baseDashProvider.d.ts +3 -1
  17. package/types/providers/DashProviderVirtual/lib/buffer/nativeBufferManager.d.ts +1 -1
  18. package/types/providers/DashProviderVirtual/lib/buffer/sourceBufferTaskQueue.d.ts +2 -1
  19. package/types/providers/DashProviderVirtual/lib/buffer/types.d.ts +0 -2
  20. package/types/providers/DashProviderVirtual/lib/buffer/virtualBuffer/baseVirtualBufferManager.versionA.d.ts +1 -5
  21. package/types/providers/DashProviderVirtual/lib/buffer/virtualBuffer/byteRangeVirtualBufferManager.versionA.d.ts +0 -1
  22. package/types/providers/DashProviderVirtual/lib/fetcher.d.ts +4 -6
  23. package/types/providers/DashProviderVirtual/lib/player/basePlayer.d.ts +1 -5
  24. package/types/providers/DashProviderVirtual/lib/urlsCache.d.ts +22 -0
  25. package/types/providers/ProviderContainer/Mayday/heuristics/HangupHeuristic.d.ts +23 -0
  26. package/types/providers/ProviderContainer/Mayday/index.d.ts +1 -2
  27. package/types/providers/ProviderContainer/Mayday/types.d.ts +1 -2
  28. package/types/providers/ProviderContainer/index.d.ts +1 -3
  29. package/types/providers/ProviderContainer/utils/formatsSupport.d.ts +1 -0
  30. package/types/providers/ProviderContainer/utils/playbackHangup.d.ts +2 -6
  31. package/types/providers/types.d.ts +2 -4
  32. package/types/providers/utils/Abr/abrController.d.ts +1 -4
  33. package/types/providers/utils/Abr/abrManager.d.ts +0 -1
  34. package/types/providers/utils/Abr/controllers/stallsController.d.ts +1 -8
  35. package/types/providers/utils/Abr/rules/audio/audioThroughputRule.d.ts +2 -2
  36. package/types/providers/utils/Abr/rules/audio/minAudioForVideoRule.d.ts +2 -2
  37. package/types/providers/utils/Abr/rules/baseRule.d.ts +2 -2
  38. package/types/providers/utils/Abr/rules/video/abandonRequestRule.d.ts +2 -2
  39. package/types/providers/utils/Abr/rules/video/bolaRule.d.ts +2 -2
  40. package/types/providers/utils/Abr/rules/video/bufferRule.d.ts +2 -2
  41. package/types/providers/utils/Abr/rules/video/downloadTimeRule.d.ts +15 -0
  42. package/types/providers/utils/Abr/rules/video/failedVideoTrackRule.d.ts +14 -0
  43. package/types/providers/utils/Abr/rules/video/fitsContainerRule.d.ts +2 -2
  44. package/types/providers/utils/Abr/rules/video/insufficientBufferRule.d.ts +2 -2
  45. package/types/providers/utils/Abr/rules/video/lowerLimitRule.d.ts +2 -2
  46. package/types/providers/utils/Abr/rules/video/stallsRule.d.ts +2 -6
  47. package/types/providers/utils/Abr/rules/video/throughputRule.d.ts +2 -2
  48. package/types/providers/utils/Abr/rules/video/tvDisabledVideoTrackRule.d.ts +2 -2
  49. package/types/providers/utils/Abr/rules/video/upperLimitRule.d.ts +2 -2
  50. package/types/providers/utils/Abr/types.d.ts +8 -6
  51. package/types/providers/utils/Abr/utils.d.ts +3 -1
  52. package/types/providers/utils/HTMLVideoElement/destroy.d.ts +1 -1
  53. package/types/providers/utils/HTMLVideoElement/observable.d.ts +1 -1
  54. package/types/providers/utils/HTMLVideoElement/pool.d.ts +3 -2
  55. package/types/utils/autoSelectTrack.d.ts +4 -3
  56. package/types/utils/buffer/dynamicBufferTarget.d.ts +10 -0
  57. package/types/utils/tuningConfig.d.ts +42 -28
  58. package/types/providers/ProviderContainer/Mayday/GraceTimeout.d.ts +0 -17
  59. package/types/providers/ProviderContainer/Mayday/heuristics/SegmentAppendHeuristic.d.ts +0 -10
  60. package/types/providers/ProviderContainer/Mayday/heuristics/StartupHangupHeuristic.d.ts +0 -46
  61. package/types/providers/ProviderContainer/Mayday/heuristics/TvFetcherErrorHeuristic.d.ts +0 -10
  62. package/types/providers/utils/segmentCache/IndexedDbSegmentCacheStorage.d.ts +0 -52
  63. package/types/providers/utils/segmentCache/SegmentCache.d.ts +0 -40
  64. package/types/providers/utils/segmentCache/constants.d.ts +0 -20
  65. package/types/providers/utils/segmentCache/index.d.ts +0 -8
  66. package/types/providers/utils/segmentCache/segmentCacheDb.d.ts +0 -25
  67. package/types/providers/utils/segmentCache/segmentCacheUtils.d.ts +0 -25
  68. package/types/providers/utils/segmentCache/types.d.ts +0 -74
  69. package/types/utils/buffer/isBrokenSegmentAppend.d.ts +0 -3
  70. package/types/utils/buffer/timeRangesToIntervals.d.ts +0 -3
  71. package/types/utils/timers.d.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.171-dev.a5a2d3fc3.0",
3
+ "version": "2.0.171-dev.cb6e2e206.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.a5a2d3fc3.0"
45
+ "@vkontakte/videoplayer-shared": "1.0.100-dev.cb6e2e206.0"
46
46
  }
47
47
  }
@@ -30,7 +30,6 @@ export default class Player implements IPlayer {
30
30
  experimental: PlayerExperimentalImpl;
31
31
  private devNullLog;
32
32
  private collectDecodingInfoDestroyCb;
33
- private hasReleasedTimers;
34
33
  constructor(tuning?: IOptionalTuningConfig, tracer?: ITracer, playerOptions?: IPlayerOptions);
35
34
  private readonly doInit;
36
35
  /**
@@ -311,29 +311,17 @@ export interface PlayerInfoValues {
311
311
  */
312
312
  currentPlaybackRate$: PlaybackRate;
313
313
  /**
314
- * Текущий видео буффер-плеера (тот; который содержит текущую позицию воспроизведения)
314
+ * Текущий буффер плеера (тот; который содержит текущую позицию воспроизведения)
315
315
  *
316
316
  * default value: `undefined`
317
317
  */
318
- currentVideoBuffer$: StartEnd<Seconds> | undefined;
318
+ currentBuffer$: StartEnd<Seconds> | undefined;
319
319
  /**
320
- * Текущий аудио-буффер плеера (тот; который содержит текущую позицию воспроизведения)
320
+ * Текущий браузерный буффер (тот; который содержит текущую позицию воспроизведения)
321
321
  *
322
322
  * default value: `undefined`
323
323
  */
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;
324
+ currentNativeBuffer$: StartEnd<Seconds> | undefined;
337
325
  /** Суммарная длительность всех буферизованных диапазонов в миллисекундах */
338
326
  totalBufferDuration$: Milliseconds | undefined;
339
327
  /**
@@ -49,9 +49,6 @@ export default class LiveDashPlayer {
49
49
  private bufferStates;
50
50
  private downloadRate?;
51
51
  private sourceJitter;
52
- private srcToken;
53
- private videoListeners;
54
- private objectUrl;
55
52
  private chunkRateEstimator;
56
53
  private manifestUrl;
57
54
  private urlResolver;
@@ -60,6 +57,7 @@ export default class LiveDashPlayer {
60
57
  */
61
58
  private waitingForFirstBufferAfterSrcChange;
62
59
  private params;
60
+ private playbackStateSubscription;
63
61
  soundProhibitedEvent$: Subject<void>;
64
62
  constructor(params: IParams);
65
63
  attachSource(manifestUrl: string): void;
@@ -101,6 +99,14 @@ export default class LiveDashPlayer {
101
99
  * send buffering notification to player
102
100
  */
103
101
  private _notifyBuffering;
102
+ private _notifyLoadStart;
103
+ /**
104
+ * Лоадер для случая, когда play запрошен до завершения подготовки видео:
105
+ * syncPlayback при этом умирает на раннем выходе по активному videoState-переходу и не вызывает play().
106
+ * Смотрим только переходы подготовки (MANIFEST_READY/READY): переход PAUSED→PLAYING создаётся
107
+ * syncPlayback позже (debounce(0)), поэтому обычный resume сюда не попадает.
108
+ */
109
+ private _syncBufferingWithDesiredPlayback;
104
110
  /**
105
111
  * initialize video tag, add necessary event listeners
106
112
  * @private
@@ -16,6 +16,7 @@ import { ElementSizeManager } from "../utils/HTMLVideoElement/ElementSizeManager
16
16
  type IParams = IProviderParams<IDashURLSource> & {
17
17
  sourceHls?: IHLSSource;
18
18
  forceVideoCodec?: VideoCodec;
19
+ failedVideoTrack?: Nullable<IVideoTrack>;
19
20
  isOnDemand?: boolean;
20
21
  dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
21
22
  };
@@ -33,6 +34,7 @@ export default abstract class BaseDashProvider implements IProvider {
33
34
  protected stallsManager: StallsManager;
34
35
  protected elementSizeManager: ElementSizeManager;
35
36
  protected abrManager: AbrManager;
37
+ protected failedVideoTrack: Nullable<IVideoTrack>;
36
38
  protected videoTracksMap: Map<IVideoTrack, {
37
39
  stream: Stream;
38
40
  representation: Representation;
@@ -54,8 +56,9 @@ export default abstract class BaseDashProvider implements IProvider {
54
56
  protected getProviderSubscriptionInfo(): IProviderSubscriptionInfo;
55
57
  protected subscribe(): void;
56
58
  private syncBufferTarget;
57
- private resolveBufferTargetMs;
58
59
  private resolveAudioBufferTargetMs;
60
+ private resolveBufferTargetMs;
61
+ private getCurrentVideoBitrateKbps;
59
62
  protected selectVideoAudioRepresentations(): [Representation, Representation | undefined] | undefined;
60
63
  protected prepare(manifestOffset?: number): void;
61
64
  protected syncPlayback: () => void;
@@ -41,7 +41,6 @@ export declare class BufferManager {
41
41
  private parsedInitData;
42
42
  private representations;
43
43
  private segments;
44
- private segmentIndexMap;
45
44
  private allInitsLoaded;
46
45
  private activeSegments;
47
46
  private forwardBufferRepresentations;
@@ -76,7 +75,6 @@ export declare class BufferManager {
76
75
  private lastDataObtainedTimestampMs;
77
76
  private loadByteRangeSegmentsTimeoutId;
78
77
  private preDownloadedFirstSegment;
79
- private brokenSegmentAppendDetected;
80
78
  constructor(kind: StreamKind, mediaSource: MediaSource, representations: Representation[], { fetcher, tuning, getCurrentPosition, isActiveLowLatency, compatibilityMode, manifest }: Dependencies);
81
79
  startWith: ReturnType<typeof abortable<[Representation["id"]]>>;
82
80
  switchToWithPreviousAbort(newRepresentationId: Representation["id"], dropBuffer?: boolean): Promise<void | undefined>;
@@ -108,7 +106,6 @@ export declare class BufferManager {
108
106
  private feedPreDownloadedFirstSegment;
109
107
  private loadByteRangeSegments;
110
108
  private prepareByteRangeFetchSegmentParams;
111
- private buildCacheMetadata;
112
109
  private prepareTemplateFetchSegmentParams;
113
110
  private abortActiveSegments;
114
111
  private onSomeTemplateDataLoaded;
@@ -122,7 +119,6 @@ export declare class BufferManager {
122
119
  */
123
120
  private onSomeByteRangesDataLoaded;
124
121
  private onSegmentFullyAppended;
125
- private detectBrokenSegmentAppend;
126
122
  private abortSegment;
127
123
  private loadNextInit;
128
124
  private loadInit;
@@ -4,7 +4,6 @@ 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";
8
7
  declare global {
9
8
  interface Navigator {
10
9
  connection: {
@@ -25,11 +24,11 @@ export interface IParams {
25
24
  tracer: ITracer;
26
25
  useEnableSubtitlesParam?: boolean;
27
26
  handleExtendedNetworkErrorsSet?: boolean;
27
+ useUrlCacheMechanism?: boolean;
28
28
  measureNonSegmentRequests?: boolean;
29
29
  measureFastSamples?: boolean;
30
30
  preloadFirstSegment?: boolean;
31
31
  maxQualityForFirstSegmentPreload?: ExactVideoQuality;
32
- segmentCacheService?: ISegmentCacheStorage;
33
32
  }
34
33
  export type Priority = "high" | "low" | "auto";
35
34
  export interface FetchParamsWithUrl extends FetchParams {
@@ -46,8 +45,8 @@ export interface FetchParams {
46
45
  isLowLatency?: boolean;
47
46
  bufferOptimisation?: boolean;
48
47
  ignoreNetworkErrors?: boolean;
48
+ urlCacheMechanismEnabled?: boolean;
49
49
  representationHeight?: number;
50
- cacheMetadata?: CacheMetadata;
51
50
  }
52
51
  export type RepresentationFetchResult = {
53
52
  init: CommonInit | null;
@@ -74,17 +73,16 @@ export declare class Fetcher {
74
73
  private readonly subscription;
75
74
  private compatibilityMode;
76
75
  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;
83
81
  private startupPhase;
84
82
  private performanceObserver;
85
83
  private pendingConnectionMetrics;
86
84
  private handleExtendedNetworkErrorsSet;
87
- constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload, segmentCacheService }: IParams);
85
+ constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, useUrlCacheMechanism, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload }: IParams);
88
86
  private onHeadersReceived;
89
87
  private setupPerformanceObserver;
90
88
  private processPerformanceResourceTiming;
@@ -40,7 +40,6 @@ export declare class Player {
40
40
  private subscriptionRemovable;
41
41
  private representationSubscription;
42
42
  private fetcher;
43
- private segmentCacheService;
44
43
  state$: StateMachine<State>;
45
44
  currentVideoRepresentation$: IValueSubject<Representation["id"] | undefined>;
46
45
  currentVideoRepresentationInit$: IValueSubject<CommonInit | undefined>;
@@ -7,7 +7,8 @@ declare class SourceBufferTaskQueue {
7
7
  private currentTask;
8
8
  private destroyed;
9
9
  private abortRequested;
10
- constructor(buffer: SourceBuffer);
10
+ private isAbortFixEnabled;
11
+ constructor(buffer: SourceBuffer, isAbortFixEnabled?: boolean);
11
12
  append(data: BufferSource, signal?: AbortSignal): Promise<boolean>;
12
13
  remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
13
14
  abort(init?: BufferSource): Promise<boolean>;
@@ -0,0 +1,23 @@
1
+ export type CacheManager = {
2
+ get: () => Promise<Response | null>;
3
+ set: (response: Response) => void;
4
+ };
5
+ /**
6
+ * Пытаемся добиться кэширования вызовов.
7
+ * Сейчас есть проблема, что expires и sig меняются, хотя контент не меняется, поэтому ходим мимо кэша.
8
+ * Из за этого обрабатываем кэш вручную.
9
+ */
10
+ export declare const createCacheManager: (url: string) => Promise<CacheManager>;
11
+ export declare function canUseCacheApi(): boolean;
12
+ export declare function normalizeUrl(url: string): string;
13
+ /**
14
+ * Проверяет, не просрочен ли кэшированный ответ
15
+ */
16
+ export declare function isResponseExpired(response: Response): boolean;
17
+ export declare function cloneResponse(response: Response, url: string): Response;
18
+ /**
19
+ * Извлекает expires из оригинального URL (параметр expires1)
20
+ * Предполагается, что expires1 — timestamp в секундах
21
+ */
22
+ export declare function getExpiresFromUrl(url: string): number;
23
+ export declare const dropUrlsCache: () => Promise<void>;
@@ -16,6 +16,7 @@ import { AbrManager } from "../utils/Abr/abrManager";
16
16
  type IParams = IProviderParams<IDashURLSource> & {
17
17
  sourceHls?: IHLSSource;
18
18
  forceVideoCodec?: VideoCodec;
19
+ failedVideoTrack?: Nullable<IVideoTrack>;
19
20
  isOnDemand?: boolean;
20
21
  dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
21
22
  };
@@ -55,8 +56,9 @@ export default abstract class BaseDashProvider implements IProvider {
55
56
  protected getProviderSubscriptionInfo(): IProviderSubscriptionInfo;
56
57
  protected subscribe(): void;
57
58
  private syncBufferTarget;
58
- private resolveBufferTargetMs;
59
59
  private resolveAudioBufferTargetMs;
60
+ private resolveBufferTargetMs;
61
+ private getCurrentVideoBitrateKbps;
60
62
  protected selectVideoAudioRepresentations(): [Representation, Representation | undefined] | undefined;
61
63
  protected prepare(manifestOffset?: number): void;
62
64
  protected syncPlayback: () => void;
@@ -7,7 +7,7 @@ export declare class NativeBufferManager {
7
7
  private sourceBufferTaskQueue;
8
8
  private subscription;
9
9
  constructor(mediaSource: MediaSource);
10
- init(mime: string, codecs: string): void;
10
+ init(mime: string, codecs: string, useAbortMSEFix?: boolean): void;
11
11
  addInitSegment(initView: BufferSource, signal?: AbortSignal): Promise<boolean>;
12
12
  append(segmentView: BufferSource, signal?: AbortSignal): Promise<boolean>;
13
13
  remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
@@ -7,7 +7,8 @@ declare class SourceBufferTaskQueue {
7
7
  private currentTask;
8
8
  private destroyed;
9
9
  private abortRequested;
10
- constructor(buffer: SourceBuffer);
10
+ private isAbortFixEnabled;
11
+ constructor(buffer: SourceBuffer, isAbortFixEnabled?: boolean);
11
12
  append(data: BufferSource, signal?: AbortSignal): Promise<boolean>;
12
13
  remove(from: Milliseconds, to: Milliseconds, signal?: AbortSignal): Promise<boolean>;
13
14
  abort(init?: BufferSource): Promise<boolean>;
@@ -3,7 +3,6 @@ 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";
7
6
  export type TRepresentationSwitchMode = "lazy" | "force";
8
7
  export declare enum SwithRepresentationMode {
9
8
  Lazy = "lazy",
@@ -16,7 +15,6 @@ export interface Dependencies {
16
15
  tuning: ITuningConfig;
17
16
  compatibilityMode?: boolean;
18
17
  manifest: Manifest | null;
19
- segmentCacheService?: ISegmentCacheStorage;
20
18
  getCurrentPosition(): Milliseconds | undefined;
21
19
  getCurrentStallDuration(): Milliseconds;
22
20
  isActiveLowLatency(): boolean;
@@ -2,7 +2,6 @@ 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";
6
5
  import type { Byte, IError, IRange, ISubject, ITracer, IValueSubject, Milliseconds, Seconds } from "@vkontakte/videoplayer-shared";
7
6
  import { abortable, Subscription } from "@vkontakte/videoplayer-shared";
8
7
  import type { NativeBufferManager } from "../nativeBufferManager";
@@ -20,7 +19,6 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
20
19
  protected readonly fetcher: Fetcher;
21
20
  protected readonly tracer: ITracer;
22
21
  protected readonly tuning: ITuningConfig;
23
- protected readonly segmentCacheService: ISegmentCacheStorage | undefined;
24
22
  protected representations: Map<Representation["id"], Representation>;
25
23
  protected playingRepresentationId: Representation["id"] | undefined;
26
24
  protected downloadingRepresentationId: Representation["id"] | undefined;
@@ -54,8 +52,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
54
52
  protected subscription: Subscription;
55
53
  protected readonly getCurrentPosition: () => Milliseconds | undefined;
56
54
  protected readonly getCurrentStallDuration: () => Milliseconds | undefined;
57
- protected brokenSegmentAppendDetected: boolean;
58
- protected constructor(kind: StreamKind, nativeBufferManager: NativeBufferManager, representations: Representation[], { fetcher, tracer, tuning, getCurrentPosition, getCurrentStallDuration, manifest, segmentCacheService }: Dependencies);
55
+ protected constructor(kind: StreamKind, nativeBufferManager: NativeBufferManager, representations: Representation[], { fetcher, tracer, tuning, getCurrentPosition, getCurrentStallDuration, manifest }: Dependencies);
59
56
  protected abstract loadItems(itemsToLoad: IBufferPlaybackQueueItem<T>[], representation: Representation, priority?: Priority): Promise<void>;
60
57
  protected abstract selectItemsToLoad(): IBufferPlaybackQueueItem<T>[];
61
58
  protected abstract prepareFetchParams(items: IBufferPlaybackQueueItem<T>[], representation: Representation): FetchParamsWithUrl;
@@ -123,7 +120,6 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
123
120
  protected parseFeedableSegmentChunk(chunk: DataView): DataView | null;
124
121
  protected onItemFullyDownloaded(downloadedItem: IBufferPlaybackQueueItem<T>): void;
125
122
  protected onItemFullyAppended(appendedItem: IBufferPlaybackQueueItem<T>): void;
126
- private detectBrokenSegmentAppend;
127
123
  protected removeSegment(nextRemoveItem: IBufferPlaybackQueueItem<T>, signal: AbortSignal): Promise<void>;
128
124
  protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): void;
129
125
  protected pruneVirtualBuffer(currentPosition: Milliseconds): void;
@@ -8,7 +8,6 @@ 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;
12
11
  /**
13
12
  * Закидываем в буфер сегменты атомарнее чем сегмент целиком. Например, по боксам в мпеге и по блокам в вебме.
14
13
  * Таким образом не ждём его полной загрузки и готовы играть его намного быстрее
@@ -4,7 +4,6 @@ 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";
8
7
  declare global {
9
8
  interface Navigator {
10
9
  connection: {
@@ -25,11 +24,11 @@ export interface IParams {
25
24
  tracer: ITracer;
26
25
  useEnableSubtitlesParam?: boolean;
27
26
  handleExtendedNetworkErrorsSet?: boolean;
27
+ useUrlCacheMechanism?: boolean;
28
28
  measureNonSegmentRequests?: boolean;
29
29
  measureFastSamples?: boolean;
30
30
  preloadFirstSegment?: boolean;
31
31
  maxQualityForFirstSegmentPreload?: ExactVideoQuality;
32
- segmentCacheService?: ISegmentCacheStorage;
33
32
  }
34
33
  export type Priority = "high" | "low" | "auto";
35
34
  export interface FetchParamsWithUrl extends FetchParams {
@@ -45,8 +44,8 @@ export interface FetchParams {
45
44
  measureThroughput?: boolean;
46
45
  isLowLatency?: boolean;
47
46
  bufferOptimisation?: boolean;
47
+ urlCacheMechanismEnabled?: boolean;
48
48
  kind: StreamKind;
49
- cacheMetadata?: CacheMetadata;
50
49
  }
51
50
  export type RepresentationFetchResult<T extends Segment> = {
52
51
  initMetadata: CommonInit | null;
@@ -73,17 +72,16 @@ export declare class Fetcher {
73
72
  private subscription;
74
73
  private compatibilityMode;
75
74
  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;
82
80
  private startupPhase;
83
81
  private performanceObserver;
84
82
  private pendingConnectionMetrics;
85
83
  private handleExtendedNetworkErrorsSet;
86
- constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload, segmentCacheService }: IParams);
84
+ constructor({ throughputEstimator, requestQuic, tracer, compatibilityMode, useEnableSubtitlesParam, handleExtendedNetworkErrorsSet, useUrlCacheMechanism, measureNonSegmentRequests, measureFastSamples, preloadFirstSegment, maxQualityForFirstSegmentPreload }: IParams);
87
85
  private onHeadersReceived;
88
86
  private setupPerformanceObserver;
89
87
  private processResourceTiming;
@@ -9,7 +9,6 @@ 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";
13
12
  import type { Dependencies, IVirtualBufferManager, SwithRepresentationMode } from "../buffer/types";
14
13
  import type { Params } from "./types";
15
14
  import { State } from "./types";
@@ -36,7 +35,6 @@ export declare abstract class BasePlayer {
36
35
  protected subscriptionRemovable: SubscriptionRemovable;
37
36
  protected representationSubscription: Subscription;
38
37
  protected fetcher: Fetcher;
39
- protected segmentCacheService: ISegmentCacheStorage | undefined;
40
38
  protected forceEnded$: ISubject<void>;
41
39
  protected stallWatchdogSubscription: ISubscription | undefined;
42
40
  protected destroyController: AbortController;
@@ -65,11 +63,9 @@ export declare abstract class BasePlayer {
65
63
  liveSeekableDuration$: IValueSubject<Milliseconds>;
66
64
  liveAvailabilityStartTime$: IValueSubject<Milliseconds>;
67
65
  liveStreamStatus$: IValueSubject<LiveStreamStatus | undefined>;
68
- currentVideoBuffer$: IValueSubject<IRange<Seconds>>;
69
- currentAudioBuffer$: IValueSubject<IRange<Seconds>>;
66
+ currentBuffer$: IValueSubject<IRange<Seconds>>;
70
67
  bufferLength$: IValueSubject<Milliseconds>;
71
68
  nativeBufferLength$: IValueSubject<Milliseconds>;
72
- nativeAudioBufferLength$: IValueSubject<IRange<Seconds>>;
73
69
  liveLatency$: IValueSubject<Milliseconds | undefined>;
74
70
  liveLoadBufferLength$: IValueSubject<Milliseconds>;
75
71
  livePositionFromPlayer$: IValueSubject<number>;
@@ -0,0 +1,22 @@
1
+ export type CacheManager = {
2
+ get: () => Promise<Response | null>;
3
+ set: (response: Response) => Promise<void>;
4
+ };
5
+ /**
6
+ * Пытаемся добиться кэширования вызовов.
7
+ * Сейчас есть проблема, что expires и sig меняются, хотя контент не меняется, поэтому ходим мимо кэша.
8
+ * Из за этого обрабатываем кэш вручную.
9
+ */
10
+ export declare const createCacheManager: (url: string) => Promise<CacheManager>;
11
+ export declare function canUseCacheApi(): boolean;
12
+ export declare function normalizeUrl(url: string): string;
13
+ /**
14
+ * Проверяет, не просрочен ли кэшированный ответ
15
+ */
16
+ export declare function isResponseExpired(response: Response): boolean;
17
+ export declare function cloneResponse(response: Response, url: string): Response;
18
+ /**
19
+ * Извлекает expires из оригинального URL (параметр expires1)
20
+ * Предполагается, что expires1 — timestamp в секундах
21
+ */
22
+ export declare function getExpiresFromUrl(url: string): number;
@@ -0,0 +1,23 @@
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
+ export declare class HangupHeuristic implements IAsyncHeuristic {
6
+ private deps;
7
+ static readonly heuristicName = "HangupHeuristic";
8
+ readonly type = "async";
9
+ readonly recommendation$: Subject<IMaydayEvent>;
10
+ private timerId;
11
+ private sub;
12
+ private error;
13
+ private manifestRequested;
14
+ private manifestRequestedAt;
15
+ private manifestReceivedMs;
16
+ constructor(deps: IHeuristicDeps);
17
+ analyze(error: IError): HeuristicResult;
18
+ private restartTimer;
19
+ private expire;
20
+ private cancel;
21
+ reset(): void;
22
+ destroy(): void;
23
+ }
@@ -3,6 +3,5 @@ export type { IMaydayDeps, IFallbackContext, IRecommendation, RecoveryAction, IM
3
3
  export type { ISyncHeuristic, IAsyncHeuristic, HeuristicResult } from "./heuristics/IHeuristic";
4
4
  export { MediaErrorHeuristic } from "./heuristics/MediaErrorHeuristic";
5
5
  export { FetcherErrorHeuristic } from "./heuristics/FetcherErrorHeuristic";
6
- export { TvFetcherErrorHeuristic } from "./heuristics/TvFetcherErrorHeuristic";
7
- export { StartupHangupHeuristic } from "./heuristics/StartupHangupHeuristic";
6
+ export { HangupHeuristic } from "./heuristics/HangupHeuristic";
8
7
  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
- currentNativeVideoBuffer$: IValueSubject<IRange<Seconds> | undefined>;
17
+ currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
18
18
  bufferRangeCount$: IValueSubject<number | undefined>;
19
19
  availableVideoStreams$: IValueSubject<IVideoStream[]>;
20
20
  currentAudioStream$: IValueSubject<IAudioStream | undefined>;
@@ -54,7 +54,6 @@ export interface IHeuristicDeps {
54
54
  getVisibilityState: () => DocumentVisibilityState | undefined;
55
55
  getReadyState: () => number | undefined;
56
56
  getVideoPaused: () => boolean | undefined;
57
- getIsMuted: () => boolean;
58
57
  currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
59
58
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
60
59
  desiredPlaybackState$: IStateMachine<PlaybackState>;
@@ -35,9 +35,9 @@ export default class ProviderContainer implements IProviderContainer {
35
35
  private tracer;
36
36
  private params;
37
37
  private currentProviderStarted;
38
+ private currentFailedVideoTrack;
38
39
  private volumeMultiplierManager;
39
40
  private dashMaxTvVideoQuality;
40
- private segmentCacheCleared;
41
41
  private mayday;
42
42
  private maydayStatistics;
43
43
  constructor(params: IParams);
@@ -51,8 +51,6 @@ export default class ProviderContainer implements IProviderContainer {
51
51
  private destroyProvider;
52
52
  private handleMaydayRecommendation;
53
53
  private applyErrorSideEffects;
54
- /** Битые данные в кэше могут вызывать повторные ошибки после реинита — очищаем кэш целиком. */
55
- private clearSegmentCacheOnError;
56
54
  private createProvider;
57
55
  private createScreenProvider;
58
56
  private createChromecastProvider;
@@ -15,6 +15,7 @@ type LiveFormat = VideoFormat.WEB_RTC_LIVE | VideoFormat.HLS_LIVE | VideoFormat.
15
15
  type AllLiveFormats = [LiveFormat, LiveFormat, LiveFormat, LiveFormat, LiveFormat];
16
16
  export declare const getLiveFormatsPriority: ({ androidPreferredFormat, preferCMAF, preferWebRTC }: Constraints) => AllLiveFormats;
17
17
  export declare const getChromeCastFormatsPriority: (live: boolean) => VideoFormat[];
18
+ export declare const selectCodec: (codecs: Set<string>) => string | undefined;
18
19
  type CodecStream = {
19
20
  codecs: string;
20
21
  hdr?: boolean;
@@ -1,5 +1,6 @@
1
1
  import type { IProviderEntry } from "../types";
2
2
  import type { IObservable, Milliseconds } from "@vkontakte/videoplayer-shared";
3
+ import { Observable } from "@vkontakte/videoplayer-shared";
3
4
  import type { IStateMachine } from "../../../utils/StateMachine/types";
4
5
  import { PlaybackState } from "../../../player/types";
5
6
  interface IParams {
@@ -11,10 +12,5 @@ interface IParams {
11
12
  playbackHangupNoDataThreshold: Milliseconds;
12
13
  useDelayedPlaybackHangupWithData: boolean;
13
14
  }
14
- export interface IPlaybackHangupInfo {
15
- from: PlaybackState;
16
- to: PlaybackState;
17
- label: string;
18
- }
19
- declare const _default: (params: IParams) => IObservable<IPlaybackHangupInfo>;
15
+ declare const _default: (params: IParams) => Observable<string>;
20
16
  export default _default;
@@ -81,10 +81,8 @@ export interface IProviderOutput {
81
81
  autoVideoTrackLimits$: IValueSubject<QualityLimits | undefined>;
82
82
  autoVideoTrackLimitingAvailable$: IValueSubject<boolean>;
83
83
  canChangePlaybackSpeed$: IValueSubject<boolean | 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>;
84
+ currentBuffer$: IValueSubject<IRange<Seconds> | undefined>;
85
+ currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
88
86
  totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
89
87
  bufferRangeCount$: IValueSubject<number | undefined>;
90
88
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
@@ -1,6 +1,5 @@
1
- import type { IAbrController, IAbrRule, IBaseAbrControllerContext, IRuleInitContext, RuleLogData } from "./types";
1
+ import type { IAbrController, IAbrRule, IBaseAbrControllerContext, IRuleInitContext } from "./types";
2
2
  import type { IBaseTrack } from "../../../player/types";
3
- export declare const formatRuleLog: ({ name, ...logData }: RuleLogData) => string;
4
3
  export default class AbrController<
5
4
  T extends IBaseTrack,
6
5
  C extends IBaseAbrControllerContext
@@ -13,8 +12,6 @@ export default class AbrController<
13
12
  destroy(): void;
14
13
  updateContext(context: C): void;
15
14
  autoSelectTrack(rules?: IAbrRule<T, C>[]): T;
16
- private traceQualitySwitch;
17
- private isLowQuality;
18
15
  private selectTrackBasedOnHistory;
19
16
  /** при переключении аудио стрима очищаем историю для предотвращения залипания в `onCooldown` */
20
17
  historyReset(): void;
@@ -10,7 +10,6 @@ export declare class AbrManager {
10
10
  private context;
11
11
  private phaseController;
12
12
  private allVideoRules;
13
- private tracer;
14
13
  init(context: IInitAbrManagerContext): void;
15
14
  updateContext(updateContext: IUpdatableAbrManagerContext): void;
16
15
  autoSelectTrack<T extends IVideoTrack | IAudioTrack>(kind: Exclude<StreamKind, StreamKind.TEXT>): T;
@@ -1,4 +1,4 @@
1
- import type { IObservable, ITracer, IValueSubject, Milliseconds } from "@vkontakte/videoplayer-shared";
1
+ import type { IObservable, 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,7 +10,6 @@ interface IConnectData {
10
10
  observableVideo: IObservableVideo;
11
11
  currentStallDuration$: IValueSubject<Milliseconds>;
12
12
  tuning: ITuningConfig["stallsManager"];
13
- tracer: ITracer;
14
13
  }
15
14
  export declare class StallsController {
16
15
  private currentStallDuration$;
@@ -21,9 +20,6 @@ export declare class StallsController {
21
20
  private lastUniqueVideoTrackSelectedTimestamp;
22
21
  private lastUniqueVideoTrackSelected;
23
22
  private providerStartWatchingTimestamp;
24
- private tracer;
25
- private severeStallTracer;
26
- private severeStallStartedAt;
27
23
  private subscription;
28
24
  severeStallOccurred$: IValueSubject<boolean>;
29
25
  totalStallsCount$: IValueSubject<number>;
@@ -32,9 +28,6 @@ export declare class StallsController {
32
28
  lastStallDuration$: IValueSubject<Milliseconds>;
33
29
  init(data: IConnectData): void;
34
30
  destroy(): void;
35
- private startSevereStallTracer;
36
- private endSevereStallTracer;
37
- private traceUpdateStallData;
38
31
  private updateStallData;
39
32
  }
40
33
  export {};