@vkontakte/videoplayer-core 2.0.166-dev.0bf203cc7.0 → 2.0.166-dev.1022d4dbd.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.166-dev.0bf203cc7.0",
3
+ "version": "2.0.166-dev.1022d4dbd.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.95-dev.0bf203cc7.0"
45
+ "@vkontakte/videoplayer-shared": "1.0.95-dev.1022d4dbd.0"
46
46
  }
47
47
  }
@@ -1,5 +1,5 @@
1
1
  import type { IOptionalTuningConfig } from "../utils/tuningConfig";
2
- import type { ILogEntry, ITracer, QualityLimits, Seconds, VideoQuality } from "@vkontakte/videoplayer-shared";
2
+ import type { ILogEntry, ITracer, QualityLimits, Seconds, VideoQuality, DebugData } from "@vkontakte/videoplayer-shared";
3
3
  import { type IAudioStream, type IConfig, type ICueSettings, type IExternalTextTrack, type IPlayer, type ITextTrack, type IVideoStream, type PlaybackRate, type PlayerEventsImpl, type PlayerExperimentalImpl, type PlayerInfoImpl, PredefinedQualityLimits } from "./types";
4
4
  import type { IPlayerOptions } from "../utils/playerOptions";
5
5
  export default class Player implements IPlayer {
@@ -74,49 +74,13 @@ export default class Player implements IPlayer {
74
74
  setLiveLowLatency(isLowLatency: boolean): IPlayer;
75
75
  setLooped(isLooped: boolean): IPlayer;
76
76
  toggleChromecast(): void;
77
- /**
78
- * Starts 3D-camera constant rotation
79
- * Base rotation speed is provided through the tuning config
80
- *
81
- * @param mx - camera X rotation speed multiplier
82
- * @param my - camera Y rotation speed multiplier
83
- *
84
- * 1 - positive direction
85
- * 0.5 - half speed in positive direction
86
- * 0 - no rotation
87
- * -1 negative direction
88
- * -2 double speed in negative direction
89
- *
90
- * Limitations:
91
- * When camera reaches angles 180 or -180 in vertical direction it stops.
92
- * z-axis is frozen for now
93
- *
94
- * Set all zeroes to stop the camera rotation
95
- * startCameraManualRotation(0, 0);
96
- */
97
- startCameraManualRotation(mx: number, my: number): this;
98
- /**
99
- * Rotates 3d-camera to given angles relative to current position
100
- */
101
- stopCameraManualRotation(immediate?: boolean): this;
102
- /**
103
- * Rotates 3d-camera to given angles relative to current position
104
- * using mouse deltas and scene fov
105
- */
106
- moveCameraFocusPX(dxpx: number, dypx: number): this;
107
- /**
108
- * "Holds" camera so that it can not perform movement without manual control
109
- */
110
- holdCamera(): this;
111
- /**
112
- * "Releases" the camera so that it can move using its internal logic
113
- */
114
- releaseCamera(): this;
115
77
  getExactTime(): Seconds;
116
78
  getExactLiveTime(): Seconds;
117
79
  getAllLogs(): ILogEntry[];
118
- private getScene3D;
80
+ getDebugData(): DebugData;
81
+ private buildDebugData;
119
82
  private setIntrinsicVideoSize;
83
+ private initDebugDataSubscriptions;
120
84
  private initDesiredStateSubscriptions;
121
85
  private initProviderContainerSubscription;
122
86
  private initChromecastSubscription;
@@ -1,5 +1,4 @@
1
- import type { IError, ILogEntry, IObservable, IRectangle, IValueObservable, IValueSubject, Kbps, Milliseconds, QualityLimits, Seconds, Subject, ValueSubject, VideoQuality } from "@vkontakte/videoplayer-shared";
2
- import type { Pixel } from "../utils/3d/types";
1
+ import type { DebugData, IError, ILogEntry, IObservable, IRectangle, IValueObservable, IValueSubject, Kbps, Milliseconds, QualityLimits, Seconds, Subject, ValueSubject, VideoQuality } from "@vkontakte/videoplayer-shared";
3
2
  import type { dump } from "../utils/playbackTelemetry";
4
3
  export interface StartEnd<Unit extends number> {
5
4
  start: Unit;
@@ -54,11 +53,6 @@ export interface IPlayer {
54
53
  * Установить предопределенные настройки лимитов.
55
54
  */
56
55
  setPredefinedQualityLimits(type: PredefinedQualityLimits): IPlayer;
57
- startCameraManualRotation(mx: number, my: number): IPlayer;
58
- stopCameraManualRotation(immediate: boolean): IPlayer;
59
- moveCameraFocusPX(mx: Pixel, my: Pixel, dt: number): IPlayer;
60
- holdCamera(): IPlayer;
61
- releaseCamera(): IPlayer;
62
56
  setPlaybackRate(playbackRate: PlaybackRate): IPlayer;
63
57
  setLooped(isLooped: boolean): IPlayer;
64
58
  setExternalTextTracks(tracks: Omit<IExternalTextTrack, "type">[]): IPlayer;
@@ -317,17 +311,29 @@ export interface PlayerInfoValues {
317
311
  */
318
312
  currentPlaybackRate$: PlaybackRate;
319
313
  /**
320
- * Текущий буффер плеера (тот; который содержит текущую позицию воспроизведения)
314
+ * Текущий видео буффер-плеера (тот; который содержит текущую позицию воспроизведения)
321
315
  *
322
316
  * default value: `undefined`
323
317
  */
324
- currentBuffer$: StartEnd<Seconds> | undefined;
318
+ currentVideoBuffer$: StartEnd<Seconds> | undefined;
325
319
  /**
326
- * Текущий браузерный буффер (тот; который содержит текущую позицию воспроизведения)
320
+ * Текущий аудио-буффер плеера (тот; который содержит текущую позицию воспроизведения)
327
321
  *
328
322
  * default value: `undefined`
329
323
  */
330
- 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;
331
337
  /** Суммарная длительность всех буферизованных диапазонов в миллисекундах */
332
338
  totalBufferDuration$: Milliseconds | undefined;
333
339
  /**
@@ -455,10 +461,6 @@ export interface PlayerInfoValues {
455
461
  */
456
462
  availableSources$: ISources | undefined;
457
463
  /**
458
- * Признак того; что сейчас проигрывается 3D-видео
459
- */
460
- is3DVideo$: boolean;
461
- /**
462
464
  * Длина видео сегмента
463
465
  */
464
466
  currentVideoSegmentLength$: number;
@@ -466,6 +468,10 @@ export interface PlayerInfoValues {
466
468
  * Длина аудио сегмента
467
469
  */
468
470
  currentAudioSegmentLength$: number;
471
+ /**
472
+ * Отладочная информация
473
+ */
474
+ debugData$: DebugData;
469
475
  }
470
476
  export type IPlayerInfo = { [K in keyof PlayerInfoValues]: IValueObservable<PlayerInfoValues[K]> };
471
477
  export type PlayerInfoImpl = { [K in keyof PlayerInfoValues]: ValueSubject<PlayerInfoValues[K]> };
@@ -1,14 +1,13 @@
1
1
  import type { IAudioTrack, IDashURLSource, IHLSSource, IInternalTextTrack, IVideoTrack, VideoCodec } from "../../player/types";
2
2
  import type { IProviderSubscriptionInfo } from "./lib/types";
3
3
  import { ProviderState } from "./lib/types";
4
- import type { CommonInit, Representation, Stream } from "../utils/parsers/types";
4
+ import type { Representation, Stream } from "../utils/parsers/types";
5
5
  import type { IProvider, IProviderAllocationResolution, 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
9
  import type { ExactVideoQuality, ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
10
10
  import { Player } from "./lib/player";
11
- import { Scene3D } from "../../utils/3d/Scene3D";
12
11
  import DroppedFramesManager from "../utils/HTMLVideoElement/DroppedFramesManager";
13
12
  import TextTrackManager from "../utils/HTMLVideoElement/TextTrackManager";
14
13
  import StallsManager from "../utils/StallsManager";
@@ -22,7 +21,6 @@ type IParams = IProviderParams<IDashURLSource> & {
22
21
  dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
23
22
  };
24
23
  export default abstract class BaseDashProvider implements IProvider {
25
- scene3D: Scene3D | undefined;
26
24
  protected subscription: ISubscription;
27
25
  protected volumeSubscription: ISubscription;
28
26
  protected videoState: IStateMachine<ProviderState>;
@@ -64,8 +62,6 @@ export default abstract class BaseDashProvider implements IProvider {
64
62
  protected selectVideoAudioRepresentations(): [Representation, Representation | undefined] | undefined;
65
63
  protected prepare(manifestOffset?: number): void;
66
64
  protected syncPlayback: () => void;
67
- protected init3DScene: (init: CommonInit) => void;
68
- protected destroy3DScene: () => void;
69
65
  protected playIfAllowed(): void;
70
66
  destroy(): void;
71
67
  }
@@ -1,13 +1,12 @@
1
1
  import type { IAudioTrack, IBaseTrack, IDashURLSource, IHLSSource, IInternalTextTrack, IVideoTrack, VideoCodec } from "../../player/types";
2
2
  import type { IProviderSubscriptionInfo } from "./lib/types";
3
3
  import { ProviderState } from "./lib/types";
4
- import type { CommonInit, Representation, Stream } from "../utils/parsers/types";
4
+ import type { Representation, Stream } from "../utils/parsers/types";
5
5
  import type { IProvider, IProviderAllocationResolution, 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
9
  import type { ExactVideoQuality, ISubscription, ITracer, Milliseconds, Nullable } from "@vkontakte/videoplayer-shared";
10
- import { Scene3D } from "../../utils/3d/Scene3D";
11
10
  import DroppedFramesManager from "../utils/HTMLVideoElement/DroppedFramesManager";
12
11
  import TextTrackManager from "../utils/HTMLVideoElement/TextTrackManager";
13
12
  import StallsManager from "../utils/StallsManager";
@@ -22,7 +21,6 @@ type IParams = IProviderParams<IDashURLSource> & {
22
21
  dashMaxTvVideoQuality?: Nullable<ExactVideoQuality>;
23
22
  };
24
23
  export default abstract class BaseDashProvider implements IProvider {
25
- scene3D: Scene3D | undefined;
26
24
  protected subscription: ISubscription;
27
25
  protected volumeSubscription: ISubscription;
28
26
  protected videoState: IStateMachine<ProviderState>;
@@ -64,8 +62,6 @@ export default abstract class BaseDashProvider implements IProvider {
64
62
  protected selectVideoAudioRepresentations(): [Representation, Representation | undefined] | undefined;
65
63
  protected prepare(manifestOffset?: number): void;
66
64
  protected syncPlayback: () => void;
67
- protected init3DScene: (init: CommonInit) => void;
68
- protected destroy3DScene: () => void;
69
65
  protected playIfAllowed(): void;
70
66
  destroy(): void;
71
67
  }
@@ -40,7 +40,8 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
40
40
  protected currentVirtualBufferSize: Byte;
41
41
  private baseUrls;
42
42
  private baseUrlsIndex;
43
- protected maintainMutex: boolean;
43
+ protected maintainPlaybackBufferMutex: boolean;
44
+ protected maintainNativeBufferMutex: boolean;
44
45
  protected bufferClearingMutex: boolean;
45
46
  protected abortNativeBufferMutex: boolean;
46
47
  protected switchMutex: boolean;
@@ -86,6 +87,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
86
87
  protected loadInits(): Promise<void>;
87
88
  protected loadInitIfNeeded(representation: Representation, requestedPriority?: Priority, critical?: boolean): Promise<void>;
88
89
  protected loadInit(representation: Representation, requestedPriority?: Priority, critical?: boolean): Promise<void>;
90
+ private isMaintainNativeBufferMutexActive;
89
91
  protected maintainNativeBuffer(): Promise<void>;
90
92
  protected maintainPlaybackBuffer(position: Milliseconds): Promise<void>;
91
93
  protected actualizeLastSegmentInfo(currentPosition: Milliseconds): void;
@@ -102,7 +104,7 @@ export declare abstract class BaseVirtualBufferManager<T extends Segment> implem
102
104
  protected onItemFullyDownloaded(downloadedItem: IBufferPlaybackQueueItem<T>): void;
103
105
  protected onItemFullyAppended(appendedItem: IBufferPlaybackQueueItem<T>): void;
104
106
  protected removeSegment(nextRemoveItem: IBufferPlaybackQueueItem<T>, signal: AbortSignal): Promise<void>;
105
- protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): void;
107
+ protected onDownloadItem(downloadedItem: IBufferPlaybackQueueItem<T>): Promise<void>;
106
108
  protected pruneVirtualBuffer(currentPosition: Milliseconds): void;
107
109
  protected updateRepresentationsBaseUrlIfNeeded(): void;
108
110
  }
@@ -62,9 +62,11 @@ export declare abstract class BasePlayer {
62
62
  liveSeekableDuration$: IValueSubject<Milliseconds>;
63
63
  liveAvailabilityStartTime$: IValueSubject<Milliseconds>;
64
64
  liveStreamStatus$: IValueSubject<LiveStreamStatus | undefined>;
65
- currentBuffer$: IValueSubject<IRange<Seconds>>;
65
+ currentVideoBuffer$: IValueSubject<IRange<Seconds>>;
66
+ currentAudioBuffer$: IValueSubject<IRange<Seconds>>;
66
67
  bufferLength$: IValueSubject<Milliseconds>;
67
68
  nativeBufferLength$: IValueSubject<Milliseconds>;
69
+ nativeAudioBufferLength$: IValueSubject<IRange<Seconds>>;
68
70
  liveLatency$: IValueSubject<Milliseconds | undefined>;
69
71
  liveLoadBufferLength$: IValueSubject<Milliseconds>;
70
72
  livePositionFromPlayer$: IValueSubject<number>;
@@ -13,7 +13,7 @@ export interface IMaydayProviderOutput {
13
13
  position$: IValueSubject<number>;
14
14
  currentVideoTrack$: IValueSubject<IVideoTrack | undefined>;
15
15
  totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
16
- currentNativeBuffer$: IValueSubject<IRange<Seconds> | undefined>;
16
+ currentNativeVideoBuffer$: IValueSubject<IRange<Seconds> | undefined>;
17
17
  bufferRangeCount$: IValueSubject<number | undefined>;
18
18
  availableVideoStreams$: IValueSubject<IVideoStream[]>;
19
19
  currentAudioStream$: IValueSubject<IAudioStream | undefined>;
@@ -5,10 +5,7 @@ import type { IExternalTextTrack, IInternalTextTrack, ITextTrack, IVideoTrack, I
5
5
  import type { AudioCodec, HttpConnectionMetrics, HttpConnectionType, HttpDownloadMetrics, IAudioStream, IAudioTrack, ICueSettings, ISources, IVideoStream, SeekState, VideoCodec } from "../player/types";
6
6
  import type { IStateMachine } from "../utils/StateMachine/types";
7
7
  import type ThroughputEstimator from "../utils/ThroughputEstimator";
8
- import type { Scene3D } from "../utils/3d/Scene3D";
9
- import type { Vector2D } from "../utils/3d/types";
10
8
  export interface IProvider {
11
- scene3D?: Scene3D;
12
9
  destroy(): void;
13
10
  }
14
11
  export interface IProviderDependencies {
@@ -33,7 +30,6 @@ export interface DesiredStateValues {
33
30
  audioStream: IAudioStream | undefined;
34
31
  autoVideoTrackLimits: QualityLimits;
35
32
  autoVideoTrackSwitching: boolean;
36
- cameraOrientation: Vector2D;
37
33
  currentTextTrack: ITextTrack["id"] | undefined;
38
34
  /**
39
35
  * Дополнительные дорожки субтитров подключаемые извне
@@ -85,8 +81,10 @@ export interface IProviderOutput {
85
81
  autoVideoTrackLimits$: IValueSubject<QualityLimits | undefined>;
86
82
  autoVideoTrackLimitingAvailable$: IValueSubject<boolean>;
87
83
  canChangePlaybackSpeed$: IValueSubject<boolean | undefined>;
88
- currentBuffer$: IValueSubject<IRange<Seconds> | undefined>;
89
- 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>;
90
88
  totalBufferDuration$: IValueSubject<Milliseconds | undefined>;
91
89
  bufferRangeCount$: IValueSubject<number | undefined>;
92
90
  videoLastDataObtainedTimestamp$: IValueSubject<Milliseconds | undefined>;
@@ -126,7 +124,6 @@ export interface IProviderOutput {
126
124
  soundProhibitedEvent$: ISubject<void>;
127
125
  canplay$: ISubject<void>;
128
126
  severeStallOccurred$: ISubject<boolean>;
129
- is3DVideo$: ISubject<boolean>;
130
127
  inPiP$: IValueSubject<boolean>;
131
128
  inFullscreen$: IValueSubject<boolean>;
132
129
  playbackState$: IValueSubject<PlaybackState | string>;
@@ -17,7 +17,7 @@ export interface IObservableVideo {
17
17
  loadedMetadata$: IObservable<undefined>;
18
18
  loadedData$: IObservable<undefined>;
19
19
  isBuffering$: IObservable<boolean>;
20
- currentBuffer$: IObservable<IRange<Seconds>>;
20
+ currentVideoBuffer$: IObservable<IRange<Seconds>>;
21
21
  totalBufferDuration$: IObservable<Milliseconds>;
22
22
  bufferRangeCount$: IObservable<number>;
23
23
  volumeState$: IObservable<IVolumeState>;
@@ -181,6 +181,7 @@ export type ITuningConfig = {
181
181
  minNativeBufferSize: Milliseconds;
182
182
  removeTimeShiftFromSegment: Milliseconds;
183
183
  tickMaintainInterval: Milliseconds;
184
+ tickMaintainThrottle: Milliseconds;
184
185
  minSafeBufferToPlay: Milliseconds;
185
186
  useBufferHoldingOnlyOnStall: boolean;
186
187
  useNewAbr: boolean;
@@ -365,24 +366,6 @@ export type ITuningConfig = {
365
366
  webrtc: {
366
367
  connectionRetryMaxNumber: number;
367
368
  };
368
- spherical: {
369
- enabled: boolean;
370
- fov: {
371
- x: number;
372
- y: number;
373
- };
374
- orientation?: {
375
- x: number;
376
- y: number;
377
- z: number;
378
- };
379
- rotationSpeed: number;
380
- maxYawAngle: number;
381
- rotationSpeedCorrection: number;
382
- degreeToPixelCorrection: number;
383
- speedFadeTime: Milliseconds;
384
- speedFadeThreshold: Milliseconds;
385
- };
386
369
  useVolumeMultiplier: boolean;
387
370
  ignoreAudioRendererError: boolean;
388
371
  useEnableSubtitlesParam: boolean;
@@ -1,14 +0,0 @@
1
- import type { Degree, Vector2D, Vector3D } from "./types";
2
- /**
3
- * Модель камеры трехмерной сцены
4
- */
5
- export declare class Camera3D {
6
- fov: Vector2D<Degree>;
7
- /**
8
- * x: Degree; // yaw (around vertical Y axis)
9
- * y: Degree; // pitch (around horizontal X axis)
10
- * z: Degree; // roll (around normal Z axis)
11
- */
12
- orientation: Vector3D<Degree>;
13
- constructor(fov: Vector2D<Degree>, orientation: Vector3D<Degree>);
14
- }
@@ -1,62 +0,0 @@
1
- import type { Camera3D } from "./Camera3D";
2
- import type { DegreePerSecond, CameraRotationManagerParams, Degree, Vector3D } from "./types";
3
- /**
4
- * Класс управляющий вращением камеры
5
- */
6
- export declare class CameraRotationManager {
7
- private options;
8
- private camera;
9
- private rotating;
10
- private fading;
11
- private lastTickTS;
12
- private lastCameraTurn;
13
- private lastCameraTurnTS;
14
- private fadeStartSpeed;
15
- private fadeCorrection;
16
- private fadeTime;
17
- rotationSpeed: Vector3D<DegreePerSecond>;
18
- constructor(camera: Camera3D, options: CameraRotationManagerParams);
19
- /**
20
- * Поворот камеры из текущего положения на заданное количество градусов
21
- */
22
- turnCamera(dx?: Degree, dy?: Degree, dz?: Degree): void;
23
- /**
24
- * Поворот камеры в заданное положение
25
- */
26
- pointCameraTo(x?: Degree, y?: Degree, z?: Degree): void;
27
- /**
28
- * Устанавливает угловые скорости по осям
29
- * Если скорость для оси не задана будет использована ее текущая скорость
30
- */
31
- setRotationSpeed(sx?: DegreePerSecond, sy?: DegreePerSecond, sz?: DegreePerSecond): void;
32
- /**
33
- * Start permanent rotation
34
- */
35
- startRotation(): void;
36
- /**
37
- * Выставляет нулевую скорость, что приводит к плавной остановке
38
- * при передаче поднятого флага останавливает движение мгновенно
39
- */
40
- stopRotation(immediate?: boolean): void;
41
- /**
42
- * "Толкает" камеру для плавного затухания при наличии остаточного "крутящего момента"
43
- */
44
- onCameraRelease(): void;
45
- /**
46
- * Запускает режим затухания
47
- */
48
- private startFading;
49
- /**
50
- * Останавливает режим затухания
51
- */
52
- private stopFading;
53
- /**
54
- * Ограничивает угол поворота по вертикальной оси
55
- */
56
- private limitCameraRotationY;
57
- /**
58
- * Рассчитывает положение камеры согласно текущей скорости с эмуляцией инерции
59
- * @param time - ms from page load
60
- */
61
- tick(time: number): void;
62
- }
@@ -1,132 +0,0 @@
1
- import type { Degree, Pixel, Scene3DParams, Vector2D, Vector3D } from "./types";
2
- /**
3
- * Класс описывающий 3D сцену - канву на которой будет рисоваться проекция
4
- */
5
- export declare class Scene3D {
6
- private container;
7
- private sourceVideoElement;
8
- private canvas;
9
- private gl;
10
- private params;
11
- private frameWidth;
12
- private frameHeight;
13
- private viewportWidth;
14
- private viewportHeight;
15
- private videoInitialized;
16
- private program;
17
- private videoTexture;
18
- private vertexBuffer;
19
- private textureMappingBuffer;
20
- private camera;
21
- private cameraRotationManager;
22
- private videoElementDataLoadedFn;
23
- private renderFn;
24
- private active;
25
- constructor(container: HTMLElement, sourceVideoElement: HTMLVideoElement, params: Scene3DParams);
26
- /**
27
- * Запускает отрисовку сцены
28
- */
29
- play(): void;
30
- /**
31
- * Останавливает отрисовку сцены
32
- */
33
- stop(): void;
34
- /**
35
- * Запускает режим постоянного вращение камеры согласно переданным коэффициентам угловых скоростей
36
- * Базовая величина скорости задается в конфиге
37
- * Итоговая скорость будет равна произведению базовой скорости и переданного коэффициента
38
- * Принимает как положительные так и отрицательные значения (для противоположного вращения)
39
- */
40
- startCameraManualRotation(mx: number, my: number): void;
41
- /**
42
- * Останавливает режим постоянного вращение камеры
43
- */
44
- stopCameraManualRotation(immediate?: boolean): void;
45
- /**
46
- * Перемещает точку фокуса камеры на заданный угол
47
- */
48
- turnCamera(dx: Degree, dy: Degree): void;
49
- /**
50
- * Перемещает точку фокуса камеры на заданный угол
51
- */
52
- pointCameraTo(dx: Degree, dy: Degree): void;
53
- /**
54
- * Преобразовывает экранные координаты в градусы в соответствии с текущим полем обзора
55
- */
56
- pixelToDegree(vector: Vector2D<Pixel>): Vector2D<Degree>;
57
- /**
58
- * Возвращает текущую ориентацию камеры
59
- */
60
- getCameraRotation(): Vector3D;
61
- /**
62
- * Захват камеры - переход в ручное управление
63
- */
64
- holdCamera(): void;
65
- /**
66
- * Возвращает управление внутренним алгоритмам
67
- */
68
- releaseCamera(): void;
69
- /**
70
- * Уничтожает сцену
71
- */
72
- destroy(): void;
73
- /**
74
- * Устанавливает размер "экрана"
75
- */
76
- setViewportSize(vpx: number, vpy: number): void;
77
- /**
78
- * Обработчик события загрузки данных на видеоэлементе
79
- */
80
- private onDataLoadedHandler;
81
- /**
82
- * Запускает режим отрисовки
83
- */
84
- private doPlay;
85
- /**
86
- * Основная функция отрисовки
87
- *
88
- * @param ts - ms from page load
89
- */
90
- private render;
91
- /**
92
- * Создает шейдер
93
- */
94
- private createShader;
95
- /**
96
- * Создает webGL програму
97
- */
98
- private createProgram;
99
- /**
100
- * Создает текстуру
101
- */
102
- private createTexture;
103
- /**
104
- * Обновляет текстуру
105
- * Считывает текущий кадр из видео
106
- */
107
- private updateTexture;
108
- /**
109
- * Создает буфер вершин плоскости с учетом поправки на отношение сторон
110
- */
111
- private createVertexBuffer;
112
- /**
113
- * Создает буффер маппинга текстуры
114
- */
115
- private createTextureMappingBuffer;
116
- /**
117
- * Рассчитывает положение текстуры на плоскости
118
- */
119
- private calculateTexturePosition;
120
- /**
121
- * Обновляет значения в буффере маппинга текстуры
122
- */
123
- private updateTextureMappingBuffer;
124
- /**
125
- * Обновляет кэш различных размеров
126
- */
127
- private updateFrameSize;
128
- /**
129
- * Создает канву для сцены
130
- */
131
- createCanvas(): HTMLCanvasElement;
132
- }
@@ -1,25 +0,0 @@
1
- import type { Milliseconds } from "@vkontakte/videoplayer-shared";
2
- export interface Vector3D<T = number> {
3
- x: T;
4
- y: T;
5
- z: T;
6
- }
7
- export interface Vector2D<T = number> {
8
- x: T;
9
- y: T;
10
- }
11
- export type Pixel = number;
12
- export type Degree = number;
13
- export type DegreePerSecond = number;
14
- export interface CameraRotationManagerParams {
15
- rotationSpeed: DegreePerSecond;
16
- maxYawAngle: Degree;
17
- speedFadeTime: Milliseconds;
18
- speedFadeThreshold: Milliseconds;
19
- degreeToPixelCorrection: number;
20
- rotationSpeedCorrection: number;
21
- }
22
- export interface Scene3DParams extends CameraRotationManagerParams {
23
- fov: Vector2D;
24
- orientation: Vector3D;
25
- }