@vkontakte/videoplayer-core 2.0.161-dev.0b04a4c87.0 → 2.0.161-dev.34e0711e0.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.161-dev.0b04a4c87.0",
3
+ "version": "2.0.161-dev.34e0711e0.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.90-dev.0b04a4c87.0"
45
+ "@vkontakte/videoplayer-shared": "1.0.90-dev.34e0711e0.0"
46
46
  }
47
47
  }
@@ -6,7 +6,7 @@ import type { IProvider, IProviderParams } from "../types";
6
6
  import type { IObservableVideo } from "../utils/HTMLVideoElement/observable";
7
7
  import { TrackHistory } from "../../utils/autoSelectTrack";
8
8
  import type { IStateMachine } from "../../utils/StateMachine/types";
9
- import type { ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
9
+ import type { ExactVideoQuality, ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
10
10
  import { Player } from "./lib/player";
11
11
  import { Scene3D } from "../../utils/3d/Scene3D";
12
12
  import DroppedFramesManager from "../utils/HTMLVideoElement/DroppedFramesManager";
@@ -19,6 +19,7 @@ type IParams = IProviderParams<IDashURLSource> & {
19
19
  forceVideoCodec?: VideoCodec;
20
20
  failedVideoTrack?: Nullable<IVideoTrack>;
21
21
  isOnDemand?: boolean;
22
+ dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
22
23
  };
23
24
  export default abstract class BaseDashProvider implements IProvider {
24
25
  scene3D: Scene3D | undefined;
@@ -5,7 +5,7 @@ import { StreamKind } from "../../utils/parsers/types";
5
5
  import StateMachine from "../../../utils/StateMachine/StateMachine";
6
6
  import type ThroughputEstimator from "../../../utils/ThroughputEstimator";
7
7
  import type { ITuningConfig } from "../../../utils/tuningConfig";
8
- import type { IError, ISubject, ITracer, IValueSubject, Milliseconds } from "@vkontakte/videoplayer-shared";
8
+ import type { ExactVideoQuality, IError, ISubject, ITracer, IValueSubject, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
9
9
  import { abortable, Subject } from "@vkontakte/videoplayer-shared";
10
10
  export declare enum State {
11
11
  NONE = "none",
@@ -20,6 +20,7 @@ export interface Params {
20
20
  forceVideoCodec?: VideoCodec;
21
21
  tracer: ITracer;
22
22
  isOnDemand: boolean;
23
+ dashMaxTvVideoQuality: Nullable<ExactVideoQuality>;
23
24
  }
24
25
  export declare class Player {
25
26
  private element;
@@ -83,6 +84,7 @@ export declare class Player {
83
84
  private livePauseWatchdogSubscription;
84
85
  private liveWasInterrupted;
85
86
  private isOnDemand;
87
+ private dashMaxTvVideoQuality;
86
88
  private destroyController;
87
89
  constructor(params: Params);
88
90
  initManifest: ReturnType<typeof abortable<[HTMLVideoElement, string, number]>>;
@@ -6,7 +6,7 @@ import type { IProvider, IProviderParams } from "../types";
6
6
  import type { IObservableVideo } from "../utils/HTMLVideoElement/observable";
7
7
  import { TrackHistory } from "../../utils/autoSelectTrack";
8
8
  import type { IStateMachine } from "../../utils/StateMachine/types";
9
- import type { ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
9
+ import type { ExactVideoQuality, ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
10
10
  import { Scene3D } from "../../utils/3d/Scene3D";
11
11
  import DroppedFramesManager from "../utils/HTMLVideoElement/DroppedFramesManager";
12
12
  import TextTrackManager from "../utils/HTMLVideoElement/TextTrackManager";
@@ -19,6 +19,7 @@ type IParams = IProviderParams<IDashURLSource> & {
19
19
  forceVideoCodec?: VideoCodec;
20
20
  failedVideoTrack?: Nullable<IVideoTrack>;
21
21
  isOnDemand?: boolean;
22
+ dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
22
23
  };
23
24
  export default abstract class BaseDashProvider implements IProvider {
24
25
  scene3D: Scene3D | undefined;
@@ -71,6 +71,7 @@ export declare abstract class BasePlayer {
71
71
  fetcherRecoverableError$: Subject<IError>;
72
72
  fetcherError$: Subject<IError>;
73
73
  private isOnDemand;
74
+ private dashMaxTvVideoQuality;
74
75
  protected constructor(params: Params);
75
76
  protected abstract prepareManifestUrlString(manifestBaseUrlString: string, offset: number): string;
76
77
  protected abstract setSourceDuration(): void;
@@ -1,7 +1,7 @@
1
1
  import type ThroughputEstimator from "../../../../utils/ThroughputEstimator";
2
2
  import type { ITuningConfig } from "../../../../utils/tuningConfig";
3
3
  import type { VideoCodec } from "../../../../player/types";
4
- import type { ITracer } from "@vkontakte/videoplayer-shared";
4
+ import type { ExactVideoQuality, ITracer, Nullable } from "@vkontakte/videoplayer-shared";
5
5
  export declare enum State {
6
6
  NONE = "none",
7
7
  MANIFEST_READY = "manifest_ready",
@@ -15,4 +15,5 @@ export interface Params {
15
15
  forceVideoCodec?: VideoCodec;
16
16
  tracer: ITracer;
17
17
  isOnDemand?: boolean;
18
+ dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
18
19
  }
@@ -1,6 +1,6 @@
1
1
  import type { Representation, Segment, SegmentReference, Stream, TemplateSegment, TemplateSegmentReference, TextRepresentation } from "../../utils/parsers/types";
2
2
  import type { IAudioStream, IAudioTrack, IInternalTextTrack, IVideoStream, IVideoTrack } from "../../../player/types";
3
- export declare const representationToVideoTrack: ({ id, width, height, bitrate, fps, quality: qualityString, streamId }: Representation) => IVideoTrack | undefined;
3
+ export declare const representationToVideoTrack: ({ id, width, height, bitrate, fps, quality: qualityString, streamId, tvDisabled }: Representation) => IVideoTrack | undefined;
4
4
  export declare const representationToAudioTrack: ({ id, bitrate }: Representation) => IAudioTrack;
5
5
  export declare const representationToTextTrack: ({ language, label }: Stream, { id, url, isAuto }: Representation & {
6
6
  url: string;
@@ -18,7 +18,7 @@ export default class HlsProvider implements IProvider {
18
18
  private subscribe;
19
19
  destroy(): void;
20
20
  private prepare;
21
- private playIfAllowed;
21
+ protected playIfAllowed(): void;
22
22
  private seek;
23
23
  private syncPlayback;
24
24
  }
@@ -13,7 +13,7 @@ export default class MpegProvider implements IProvider {
13
13
  private subscribe;
14
14
  destroy(): void;
15
15
  private prepare;
16
- private playIfAllowed;
16
+ protected playIfAllowed(): void;
17
17
  private seek;
18
18
  private syncPlayback;
19
19
  private handleQualityLimitTransition;
@@ -36,6 +36,7 @@ export default class ProviderContainer implements IProviderContainer {
36
36
  private failoverIndex;
37
37
  private currentFailedVideoTrack;
38
38
  private volumeMultiplierManager;
39
+ private dashMaxTvVideoQuality;
39
40
  constructor(params: IParams);
40
41
  init(): void;
41
42
  destroy(): void;
@@ -3,10 +3,67 @@ import type { IVideoTrack } from "../../../../../player/types";
3
3
  import type { Nullable, QualityLimits, VideoQuality } from "@vkontakte/videoplayer-shared";
4
4
  import { type ExactVideoQuality } from "@vkontakte/videoplayer-shared";
5
5
  import { LimitAboveRule } from "../limitAboveRule";
6
- type UpperLimitsLogsArgs = [limitsAreInvalid: boolean, lowestAvailableQuality: Nullable<ExactVideoQuality>, highestAvailableQuality: Nullable<ExactVideoQuality>, visible: boolean, limits: QualityLimits, backgroundVideoQualityLimit: VideoQuality];
6
+ type UpperLimitsLogsArgs = [limitsAreInvalid: boolean, lowestAvailableQuality: Nullable<ExactVideoQuality>, highestAvailableQuality: Nullable<ExactVideoQuality>, visible: boolean, limits: QualityLimits, backgroundVideoQualityLimit: VideoQuality, effectiveType: string | undefined, connectionDataQualityLimit: ExactVideoQuality | undefined];
7
+ /**
8
+ * Правило верхнего ограничения качества в авто-ABR. Из списка `videoTracksDesc`
9
+ * (отсортирован от высшего к низшему) выбирает самый высокий трек, который
10
+ * одновременно удовлетворяет ВСЕМ активным лимитам сверху. Если подходящего
11
+ * нет — возвращает минимально доступный трек (graceful fallback).
12
+ *
13
+ * Источники лимитов сверху (действуют совместно, победитель — самый строгий):
14
+ *
15
+ * 1. `context.limits.max` — явный пользовательский/интеграционный лимит.
16
+ * Приходит из публичного API `Player.setAutoQualityLimits({ max, min })`
17
+ * (см. `packages/core/src/player/Player.ts`). Слой UI/интеграция пробрасывает
18
+ * его в `desiredState.autoVideoTrackLimits` → `AbrManager.updateContext({ limits })`
19
+ * → `IVideoAbrContext.limits`. `undefined` в `limits` или `limits.max` снимает
20
+ * лимит. Значение типа `ExactVideoQuality` (например, '720p'), трактуется
21
+ * включительно (`<=`). Если лимиты невалидны (min > max, либо min выше
22
+ * highestAvailable, либо max ниже lowestAvailable) — см. `areLimitsInvalid` —
23
+ * лимит игнорируется целиком, чтобы не заблокировать воспроизведение.
24
+ *
25
+ * Реальные кейсы:
26
+ * - Пользователь в настройках плеера выбрал пресет «Экономия трафика»
27
+ * (`PredefinedQualityLimits.TRAFFIC_SAVING`) — хост передаёт
28
+ * `{ max: tuning.autoTrackSelection.trafficSavingLimit }` (Q_480P).
29
+ * - Хост-приложение (мини-апп ВК, лента) ограничивает качество для
30
+ * превью/фонового воспроизведения.
31
+ * - A/B-эксперимент или бизнес-правило режет качество для конкретной
32
+ * категории видео / региона / тарифа.
33
+ *
34
+ * 2. `tuning.autoTrackSelection.backgroundVideoQualityLimit` — применяется
35
+ * только когда `context.visible === false` (плеер вне viewport, по данным
36
+ * `elementVisible$` из `observeElementVisibility`, порог — `activeVideoAreaThreshold`).
37
+ *
38
+ * Реальные кейсы: автовоспроизведение в ленте при прокрутке мимо плеера,
39
+ * PiP/мини-плеер в фоне, неактивная вкладка.
40
+ *
41
+ * 3. `effectiveType` из Network Information API (`navigator.connection`).
42
+ * Активируется `tuning.dash.useConnectionDataUpperLimit`.
43
+ * Приоритет разрешения в `connectionDataQualityLimit`:
44
+ * a. `effectiveType ∈ {'2g', 'slow-2g'}` → `tuning.dash.saveData2gQualityLimit`
45
+ * (Q_360P) — жёсткий лимит на очень слабой сети.
46
+ * b. `effectiveType === '3g'` → `tuning.dash.saveData3gQualityLimit` (Q_480P).
47
+ * c. Иначе — без ограничения.
48
+ *
49
+ * Network Information API доступен только в Chromium (Android, десктоп Chrome/Edge/
50
+ * Opera/Samsung Internet, Android WebView). В Firefox, Safari и Chrome iOS
51
+ * (WebKit) `navigator.connection === undefined` — этот источник лимита
52
+ * неактивен, правило работает только по п.1 и п.2.
53
+ *
54
+ * Реальные кейсы: пользователь в метро / зоне слабого сигнала, пользователь
55
+ * на edge/3G-тарифе.
56
+ *
57
+ * Все три источника комбинируются операцией AND: трек проходит, если
58
+ * `fitsLimits && fitsBackgroundVideoQualityLimit && fitsSaveDataLimit`. Поэтому
59
+ * итоговый потолок = минимум из активных. Нижнюю границу закрывает
60
+ * `LowerLimitRule` (поле `limits.min` здесь не используется).
61
+ */
7
62
  export declare class UpperLimitsRule extends LimitAboveRule<IVideoTrack, IVideoAbrContext, UpperLimitsLogsArgs> implements IAbrRule<IVideoTrack, IVideoAbrContext> {
8
63
  constructor(confidence: RuleConfidence);
9
64
  execute(context: IVideoAbrContext): IAbrRuleResolution<IVideoTrack>;
10
- protected createLogMessage(selectedTrack: IVideoTrack, limitsAreInvalid: boolean, lowestAvailableQuality: Nullable<ExactVideoQuality>, highestAvailableQuality: Nullable<ExactVideoQuality>, visible: boolean, limits: QualityLimits, backgroundVideoQualityLimit: VideoQuality): string;
65
+ protected createLogMessage(selectedTrack: IVideoTrack, limitsAreInvalid: boolean, lowestAvailableQuality: Nullable<ExactVideoQuality>, highestAvailableQuality: Nullable<ExactVideoQuality>, visible: boolean, limits: QualityLimits, backgroundVideoQualityLimit: VideoQuality, effectiveType: string | undefined, connectionDataQualityLimit: ExactVideoQuality | undefined): string;
66
+ private getConnection;
67
+ private resolveConnectionDataQualityLimit;
11
68
  }
12
69
  export {};
@@ -0,0 +1,7 @@
1
+ import { VideoFormat } from "../player/types";
2
+ import type { Manifest } from "../providers/utils/parsers/types";
3
+ import type { ExactVideoQuality, IError } from "@vkontakte/videoplayer-shared";
4
+ import { VideoQuality } from "@vkontakte/videoplayer-shared";
5
+ export declare const getDashMaxTvVideoQuality: (e: IError, videoFormat?: VideoFormat, currentQuality?: VideoQuality) => ExactVideoQuality | null;
6
+ /** @mutates streams.video */
7
+ export declare const markDashMaxTvVideoQuality: (streams: Manifest["streams"], dashMaxTvVideoQuality: ExactVideoQuality) => void;
@@ -160,8 +160,12 @@ export type ITuningConfig = {
160
160
  useNewFailoverLogic: boolean;
161
161
  useFailoverHostsOnAllProviderCrash: boolean;
162
162
  videoTrackBanAfterProviderFail: Milliseconds;
163
+ saveData3gQualityLimit: ExactVideoQuality;
164
+ saveData2gQualityLimit: ExactVideoQuality;
165
+ useConnectionDataUpperLimit: boolean;
163
166
  videoStreamRepresentaionsFilter: [VideoQuality, number, VideoCodec][];
164
167
  filterOnDemandQualityList: boolean;
168
+ dashMaxTvVideoQuality: boolean;
165
169
  };
166
170
  dashCmafLive: {
167
171
  externalStopControl: boolean;
@@ -340,6 +344,10 @@ export type ITuningConfig = {
340
344
  * Очищаем кэш урлов при падение провайдера.
341
345
  */
342
346
  dropUrlCacheWhenProviderCrashed?: boolean;
347
+ /**
348
+ * При смене/реините провайдера игнорируем результат того, смогло видео заиграть или нет.
349
+ */
350
+ ignoreForcePlayResultWhenProviderChanged?: boolean;
343
351
  hls: {
344
352
  filterOnDemandQualityList: boolean;
345
353
  };