@vestra-player/sdk 1.7.17 → 1.7.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.19
4
+
5
+ **Who must change: nobody.** A new capability and member for the player's motion smoothing (player 0.8.1), which each GPU vendor's store plugin offers (user ruling 2026-11-12: AMD Motion Smoothing now, NVIDIA's later); `apiVersion` stays `vestra/1`; the API surface snapshot gains the new names.
6
+
7
+ - **`plugin.video.motion(engine)`** (`VideoMotion`, capability **`video.motion`**, not risky, residency `live`): motion smoothing, the video's frame rate doubled by one GPU vendor's frame-rate converter, chosen by `MotionEngine`: `"amd"` (AMD AMF's `frc_amf` on Windows: real in-between frames, not blends) or `"nvidia"` (reserved: every mode reports `engine` until a player has NVIDIA's converter). Every request and the event name the engine; the state has `engine`. `state()` reports this plugin's `mode`, what the player does now (`active`), why each mode cannot work (`double`, `display`: a `MotionReason` or `null`), the converter's `searchMode`, `sourceFps`, the measured `outputFps`, `displayFps`, the converting `gpu` and `inChain`. `set(mode)` with `"off"`, `"double"` (twice the frames, shown as they come) or `"display"` (the doubled frames interpolated to the display, GPU rendering only); a mode a reason holds for the whole run (`platform`, `no-gpu`, `runtime`, `filter`, `rendering`) is refused with `unsupported`, the others (`upscaling`, `doubling`: another filter raises the frame rate, `failed`, `overload`, `rate`: 10–30 fps and within the display's rate, `format`: 10-bit or HDR, not measured, `size`: too large for this mode on this renderer, as measured) keep the request until they pass; an unknown mode is `invalid` before anything is sent. `onChange` follows `video.motion.changed` (the state without `mode`). It is a dedicated capability like `video.upscaling`, not a `processing.video` node: the converter needs copy-back decoding, a hardware check, a fallback the player runs while the video plays, and it excludes AI upscaling, all of which the player owns. Types: `MotionEngine`, `MotionMode`, `MotionState`, `MotionReason`, `MotionReasonCode`, `WireMotionState`; `HostEvent` and `EventPayloads` gain `video.motion.changed`.
8
+ - **`TestHost.motion`** and **`TestHost.motionChanged()`** model the player: per-mode reasons, `active` while that mode's reason is `null` and the rate is known, `unsupported` for the run-long reasons (`rendering` passes while `renderingStarting`), `off` always accepted. Test: `test/motion.test.ts`.
9
+ - Docs: [Platforms](docs/reference/platforms.md) (Windows: an AMD GPU and the AMD driver; elsewhere `platform`); the generated tables of capabilities, events, messages, commands and testing follow.
10
+
11
+ ## 1.7.18
12
+
13
+ **Who must change: nobody.** A docs-only patch following the player (Ask Vestra UX, step 5: main-window confirmations drawn in the player): no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged. `dialogs.confirm` keeps its parameters and its answer `{ confirmed, checked }`.
14
+
15
+ - **`Dialogs.confirm`** (player b38b2316, 31a3170f): a confirmation for the main window (no tool window has the focus) is drawn in the player in the style of its approval sheet: the message, the detail (a long one scrolls and the buttons stay in view), the checkbox at the footer's left, confirm (Enter) and cancel (Esc) at its right; presses in its first 0.5 s are ignored and a click outside it is Cancel. One raised while a tool window has the focus stays the system's dialog on that window (Windows: the quiet task dialog; macOS: an `NSAlert` sheet). On other systems with a window it is drawn in the player instead of rejecting with `unsupported` (which only older players there still give); headless is still `unavailable`. A new `busy` case: another confirmation or the approval sheet is waiting for the user's answer (`Commands.run`'s confirmation too). `destructive` now draws nothing in the player (no red text, no warning icon); the Windows task dialog still shows its warning icon and macOS's alert its red button. The TSDoc of `Dialogs`, `ConfirmOptions` and `Commands.run`, [Platforms](docs/reference/platforms.md) and [Troubleshooting](docs/guides/troubleshooting.md) follow.
16
+
3
17
  ## 1.7.17
4
18
 
5
19
  **Who must change: nobody.** A product-data refresh (Ask Vestra UX, step 4): no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged.
@@ -167,6 +167,9 @@ export const API_REQUESTS = Object.freeze({
167
167
  "VideoUpscaling.state": [{ method: "video.upscaling.state" }],
168
168
  "VideoUpscaling.set": [{ method: "video.upscaling.set" }],
169
169
  "VideoUpscaling.onChange": [listen("video.upscaling.changed")],
170
+ "VideoMotion.state": [{ method: "video.motion.state" }],
171
+ "VideoMotion.set": [{ method: "video.motion.set" }],
172
+ "VideoMotion.onChange": [listen("video.motion.changed")],
170
173
  "WireCommands.register": [{ method: "commands.register" }],
171
174
  });
172
175
  /**
@@ -188,6 +191,7 @@ export const SUBSCRIBED_EVENTS = Object.freeze([
188
191
  "appearance.changed",
189
192
  "resolvers.fileTypes",
190
193
  "video.upscaling.changed",
194
+ "video.motion.changed",
191
195
  ]);
192
196
  /**
193
197
  * Members whose requests depend on an argument, which `API_REQUESTS` cannot
Binary file
@@ -92,6 +92,7 @@ export const HOST_CAPABILITIES = {
92
92
  "commands.keys": "commands",
93
93
  "packages.changed": null,
94
94
  "video.upscaling.changed": "video.upscaling",
95
+ "video.motion.changed": "video.motion",
95
96
  },
96
97
  otherwise: "events",
97
98
  param: "event",
@@ -105,6 +106,7 @@ export const HOST_CAPABILITIES = {
105
106
  "commands.keys": "commands",
106
107
  "packages.changed": null,
107
108
  "video.upscaling.changed": "video.upscaling",
109
+ "video.motion.changed": "video.motion",
108
110
  },
109
111
  otherwise: "events",
110
112
  param: "event",
@@ -420,6 +422,18 @@ export const HOST_CAPABILITIES = {
420
422
  residency: "live",
421
423
  risky: false,
422
424
  },
425
+ {
426
+ builtinOnly: false,
427
+ label: "Smooth motion with the GPU's frame-rate converter",
428
+ methods: [
429
+ { name: "video.motion.state", needs: "video.motion" },
430
+ { name: "video.motion.set", needs: "video.motion" },
431
+ ],
432
+ name: "video.motion",
433
+ requires: [],
434
+ residency: "live",
435
+ risky: false,
436
+ },
423
437
  {
424
438
  builtinOnly: true,
425
439
  label: "Run any player or plugin command",
@@ -21,6 +21,7 @@ export const EVENT_NEEDS = {
21
21
  "appearance.changed": "events",
22
22
  "resolvers.fileTypes": "events",
23
23
  "video.upscaling.changed": "video.upscaling",
24
+ "video.motion.changed": "video.motion",
24
25
  };
25
26
  /** `Player.on`'s arguments: a {@link HostEvent} name and a function. */
26
27
  export function checkOn(event, listener) {
@@ -1,3 +1,5 @@
1
+ /** Scopes own handles. Disposal runs newest first and never throws. */
2
+ import type { MotionEngine } from "./types.ts";
1
3
  import type { Change } from "./passes.ts";
2
4
  import type { Runtime } from "./runtime.ts";
3
5
  import type { Disposable, DisposeInfo, Plugin, PluginError, Scope, StopReason } from "./types.ts";
@@ -26,6 +28,7 @@ export declare class ScopeImpl implements Plugin {
26
28
  render: () => import("./types.ts").RenderOptions;
27
29
  shaders: (id?: string) => import("./types.ts").VideoShaders;
28
30
  upscaling: import("./types.ts").VideoUpscaling;
31
+ motion: (engine: MotionEngine) => import("./types.ts").VideoMotion;
29
32
  filter(id: string): import("./types.ts").VideoFilter;
30
33
  };
31
34
  readonly audio: {
@@ -1,4 +1,3 @@
1
- /** Scopes own handles. Disposal runs newest first and never throws. */
2
1
  import { failure, toError } from "./errors.js";
3
2
  import { commands, keysOf, palette } from "./commands.js";
4
3
  import { WHEN } from "./when.js";
@@ -24,7 +23,7 @@ import { mainWindow } from "./window.js";
24
23
  import { bindingsApi } from "./bindings.js";
25
24
  import { trackedState } from "./state.js";
26
25
  import { wire } from "./wire-facade.js";
27
- import { clipboard, host, power, rendering, secrets, storage, system, tools, videoUpscaling, } from "./services.js";
26
+ import { clipboard, host, power, rendering, secrets, storage, system, tools, videoMotion, videoUpscaling, } from "./services.js";
28
27
  /**
29
28
  * The SDK's state copies that a player event keeps current, by event: a
30
29
  * `player.on` listener of the event starts its copy first, so the copy
@@ -81,6 +80,7 @@ export class ScopeImpl {
81
80
  render: () => videoRender(this),
82
81
  shaders: (id) => videoShaders(this, id),
83
82
  upscaling: videoUpscaling(this),
83
+ motion: (engine) => videoMotion(this, engine),
84
84
  };
85
85
  audio = audioFilters(this);
86
86
  subtitles = subtitles(this);
@@ -1,5 +1,5 @@
1
1
  import type { ScopeImpl } from "./scope.ts";
2
- import type { Clipboard, Host, Power, Rendering, Secrets, Storage, System, Tools, VideoUpscaling } from "./types.ts";
2
+ import type { Clipboard, Host, Power, Rendering, Secrets, Storage, System, Tools, MotionEngine, VideoMotion, VideoUpscaling } from "./types.ts";
3
3
  export declare const clipboard: (scope: ScopeImpl) => Clipboard;
4
4
  export declare const host: (scope: ScopeImpl) => Host;
5
5
  export declare const power: (scope: ScopeImpl) => Power;
@@ -118,3 +118,10 @@ export declare const rendering: (scope: ScopeImpl) => Rendering;
118
118
  * answers once its GPU check ran (the first call starts it).
119
119
  */
120
120
  export declare const videoUpscaling: (scope: ScopeImpl) => VideoUpscaling;
121
+ /**
122
+ * `plugin.video.motion(engine)`: both requests need `video.motion` and
123
+ * name the engine; the event names it too and leaves out each plugin's own
124
+ * `mode`, which the SDK keeps from the answers per engine (only this
125
+ * plugin's `set` changes it).
126
+ */
127
+ export declare const videoMotion: (scope: ScopeImpl, engine: MotionEngine) => VideoMotion;
@@ -541,3 +541,64 @@ export const videoUpscaling = (scope) => {
541
541
  };
542
542
  /** Each plugin's own upscaling request, as its last answer said. */
543
543
  const enabledOf = new WeakMap();
544
+ /** The modes `VideoMotion.set` accepts. */
545
+ const MOTION_MODES = ["off", "double", "display"];
546
+ /** The engines `plugin.video.motion(engine)` accepts. */
547
+ const MOTION_ENGINES = ["amd", "nvidia"];
548
+ /**
549
+ * `plugin.video.motion(engine)`: both requests need `video.motion` and
550
+ * name the engine; the event names it too and leaves out each plugin's own
551
+ * `mode`, which the SDK keeps from the answers per engine (only this
552
+ * plugin's `set` changes it).
553
+ */
554
+ export const videoMotion = (scope, engine) => {
555
+ if (typeof engine !== "string" || !MOTION_ENGINES.includes(engine))
556
+ throw failure("invalid", 'engine must be "amd" or "nvidia"');
557
+ const declared = () => {
558
+ if (!scope.runtime.can("video.motion"))
559
+ throw failure("capability", "video.motion must be declared in manifest");
560
+ };
561
+ const modes = () => {
562
+ let map = modeOf.get(scope.runtime);
563
+ if (!map)
564
+ modeOf.set(scope.runtime, (map = new Map()));
565
+ return map;
566
+ };
567
+ const noted = (state) => {
568
+ modes().set(engine, state.mode);
569
+ return state;
570
+ };
571
+ return {
572
+ async state() {
573
+ declared();
574
+ return noted(await scope.runtime.host.video.motionState(engine));
575
+ },
576
+ async set(mode) {
577
+ declared();
578
+ if (typeof mode !== "string" || !MOTION_MODES.includes(mode))
579
+ throw failure("invalid", 'mode must be "off", "double" or "display"');
580
+ return noted(await scope.runtime.host.video.motionSet(engine, mode));
581
+ },
582
+ onChange(listener) {
583
+ declared();
584
+ const watch = scope.runtime.on("video.motion.changed", (data) => {
585
+ const state = data;
586
+ // Another engine's change is not this handle's.
587
+ if (state.engine !== engine)
588
+ return;
589
+ scope.run(listener, {
590
+ ...state,
591
+ mode: modes().get(engine) ?? "off",
592
+ });
593
+ }, "video.motion");
594
+ return scope.add({
595
+ dispose: async () => {
596
+ scope.forget(watch);
597
+ await watch.dispose();
598
+ },
599
+ });
600
+ },
601
+ };
602
+ };
603
+ /** Each plugin's own motion smoothing mode per engine, as its last answer said. */
604
+ const modeOf = new WeakMap();
@@ -17,7 +17,7 @@ import type { CommandDeclaration } from "../../commands.ts";
17
17
  import type { SourceState } from "../../source.ts";
18
18
  import type { SubtitleState } from "../../subtitles.ts";
19
19
  import { VIDEO_PROCESSING_LIMITS } from "../../processing.ts";
20
- import type { RenderingMode, RenderingPreference, RenderingReason, RenderSettings, UpscalingDecodingCause, UpscalingPlugin, UpscalingReason, UpscalingVideoSize, ViewSettings } from "../types.ts";
20
+ import type { MotionMode, MotionReason, RenderingMode, RenderingPreference, RenderingReason, RenderSettings, UpscalingDecodingCause, UpscalingPlugin, UpscalingReason, UpscalingVideoSize, ViewSettings } from "../types.ts";
21
21
  import type { MediaJob } from "../../media.ts";
22
22
  import type { LanguagePreference, Locale, Plugin, StopReason, TemplateArgs, TextValue, ThemeId } from "../types.ts";
23
23
  import { LOCALES, LIST_SEPARATORS, TEXT_LIMITS } from "../../i18n.ts";
@@ -534,7 +534,7 @@ export type FakePanel = Omit<FakeWindow, "callbacks" | "userClose"> & {
534
534
  * {@link TestHost.chapters}, {@link TestHost.audioDevices},
535
535
  * {@link TestHost.secrets}, {@link TestHost.clipboard},
536
536
  * {@link TestHost.tools}, {@link TestHost.rendering},
537
- * {@link TestHost.upscaling}.
537
+ * {@link TestHost.upscaling}, {@link TestHost.motion}.
538
538
  * - **Assert** on records: {@link TestHost.osd}, {@link TestHost.calls},
539
539
  * {@link TestHost.sent}, {@link TestHost.conflicts},
540
540
  * {@link TestHost.layout}, {@link TestHost.menus}, and many more.
@@ -2225,6 +2225,83 @@ export declare class TestHost implements Transport {
2225
2225
  * @since 1.5.43
2226
2226
  */
2227
2227
  upscalingChanged(): void;
2228
+ /**
2229
+ * Motion smoothing behind `plugin.video.motion`, answered as the player
2230
+ * would:
2231
+ *
2232
+ * - `state()` and `set()` report this plugin's `mode`, the reasons
2233
+ * `double` and `display` (`null`: that mode works) and `active`: the
2234
+ * mode while its reason is `null` and `sourceFps` is known, else
2235
+ * `off`; while active, `searchMode` (`performance` with
2236
+ * `performance`) and `outputFps` (`outputFps`, or twice `sourceFps`).
2237
+ * - `set(mode)` refuses with `unsupported` and the reason's message while
2238
+ * that mode's reason is `platform`, `no-gpu`, `runtime`, `filter` or
2239
+ * `rendering` (unless `renderingStarting`): those hold for the run. The
2240
+ * others can pass, so the player keeps the request. `off` always
2241
+ * succeeds; an unknown mode is `invalid`.
2242
+ *
2243
+ * Inject other answers with `host.handle("video.motion.set", …)`. The
2244
+ * defaults are a player where both modes work on a 24 fps video and a
2245
+ * 60 Hz display.
2246
+ *
2247
+ * @example Test the Picture panel on software rendering
2248
+ * Match Display needs GPU rendering: the plugin greys it with the
2249
+ * player's reason, and Double waits for a rate that fits.
2250
+ * ```ts
2251
+ * import assert from "node:assert/strict";
2252
+ * declare const host: TestHost;
2253
+ * // ---cut---
2254
+ * host.motion.display = { code: "rendering", message: "Match Display needs GPU rendering" };
2255
+ * host.motion.double = { code: "rate", message: "24 fps doubled is 48 fps on a 60 Hz display" };
2256
+ * host.motionChanged();
2257
+ * await host.settle();
2258
+ * assert.equal(host.motion.mode, "off");
2259
+ * ```
2260
+ *
2261
+ * @since 1.7.19
2262
+ */
2263
+ readonly motion: {
2264
+ /** This plugin's mode (`set`); a test may preset it. */
2265
+ mode: MotionMode;
2266
+ /** Why Double Frame Rate does not work; `null` while it does. */
2267
+ double: MotionReason | null;
2268
+ /** Why Match Display does not work; `null` while it does. */
2269
+ display: MotionReason | null;
2270
+ /** GPU rendering is still starting: a `rendering` reason then lets `set` keep the request. */
2271
+ renderingStarting: boolean;
2272
+ /** The video's rate; `null`: not known yet (nothing is active). */
2273
+ sourceFps: number | null;
2274
+ /** The measured output rate while active; `null`: twice `sourceFps`. */
2275
+ outputFps: number | null;
2276
+ /** The faster motion search (the player's first fallback step). */
2277
+ performance: boolean;
2278
+ /** The display's refresh rate. */
2279
+ displayFps: number;
2280
+ /** The converting GPU's name; `null`: none. */
2281
+ gpu: string | null;
2282
+ };
2283
+ /**
2284
+ * Send `video.motion.changed` with the state {@link TestHost.motion}
2285
+ * describes now (without `mode`), as the player does when it changes; a
2286
+ * plugin listening with `plugin.video.motion("amd").onChange` receives it.
2287
+ * Nothing reaches a plugin that does not listen.
2288
+ *
2289
+ * @capability None.
2290
+ *
2291
+ * @example The GPU fell behind
2292
+ * The player turned the converter off for this video; the plugin's
2293
+ * panel shows the reason.
2294
+ * ```ts
2295
+ * declare const host: TestHost;
2296
+ * // ---cut---
2297
+ * host.motion.double = { code: "overload", message: "the GPU could not keep up with this video" };
2298
+ * host.motionChanged();
2299
+ * await host.settle();
2300
+ * ```
2301
+ *
2302
+ * @since 1.7.19
2303
+ */
2304
+ motionChanged(): void;
2228
2305
  /** What `player.chapters()` lists while media is ready. */
2229
2306
  chapters: {
2230
2307
  /** The chapter title, `null` without one. */
@@ -92,7 +92,7 @@ import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer,
92
92
  import { osdHandlers } from "./osd.js";
93
93
  import { packageDirectories } from "./slint-types.js";
94
94
  import { failStream, jobsHandlers } from "./jobs.js";
95
- import { upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
95
+ import { motionState, upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
96
96
  import { sourceIntent, startResolution, setSource, mediaHandlers, initialSource, } from "./media.js";
97
97
  import { drop, setMainWindow, servicesHandlers, sortedJson, } from "./services.js";
98
98
  /** Throw one of these from `host.handle(...)` to simulate a definite refusal. */
@@ -193,7 +193,7 @@ export { LOCALES };
193
193
  * {@link TestHost.chapters}, {@link TestHost.audioDevices},
194
194
  * {@link TestHost.secrets}, {@link TestHost.clipboard},
195
195
  * {@link TestHost.tools}, {@link TestHost.rendering},
196
- * {@link TestHost.upscaling}.
196
+ * {@link TestHost.upscaling}, {@link TestHost.motion}.
197
197
  * - **Assert** on records: {@link TestHost.osd}, {@link TestHost.calls},
198
198
  * {@link TestHost.sent}, {@link TestHost.conflicts},
199
199
  * {@link TestHost.layout}, {@link TestHost.menus}, and many more.
@@ -1710,6 +1710,79 @@ export class TestHost {
1710
1710
  const { enabled: _, ...state } = upscalingState(this, this.#inner, false);
1711
1711
  this.emit("video.upscaling.changed", state);
1712
1712
  }
1713
+ /**
1714
+ * Motion smoothing behind `plugin.video.motion`, answered as the player
1715
+ * would:
1716
+ *
1717
+ * - `state()` and `set()` report this plugin's `mode`, the reasons
1718
+ * `double` and `display` (`null`: that mode works) and `active`: the
1719
+ * mode while its reason is `null` and `sourceFps` is known, else
1720
+ * `off`; while active, `searchMode` (`performance` with
1721
+ * `performance`) and `outputFps` (`outputFps`, or twice `sourceFps`).
1722
+ * - `set(mode)` refuses with `unsupported` and the reason's message while
1723
+ * that mode's reason is `platform`, `no-gpu`, `runtime`, `filter` or
1724
+ * `rendering` (unless `renderingStarting`): those hold for the run. The
1725
+ * others can pass, so the player keeps the request. `off` always
1726
+ * succeeds; an unknown mode is `invalid`.
1727
+ *
1728
+ * Inject other answers with `host.handle("video.motion.set", …)`. The
1729
+ * defaults are a player where both modes work on a 24 fps video and a
1730
+ * 60 Hz display.
1731
+ *
1732
+ * @example Test the Picture panel on software rendering
1733
+ * Match Display needs GPU rendering: the plugin greys it with the
1734
+ * player's reason, and Double waits for a rate that fits.
1735
+ * ```ts
1736
+ * import assert from "node:assert/strict";
1737
+ * declare const host: TestHost;
1738
+ * // ---cut---
1739
+ * host.motion.display = { code: "rendering", message: "Match Display needs GPU rendering" };
1740
+ * host.motion.double = { code: "rate", message: "24 fps doubled is 48 fps on a 60 Hz display" };
1741
+ * host.motionChanged();
1742
+ * await host.settle();
1743
+ * assert.equal(host.motion.mode, "off");
1744
+ * ```
1745
+ *
1746
+ * @since 1.7.19
1747
+ */
1748
+ motion = {
1749
+ mode: "off",
1750
+ double: null,
1751
+ display: null,
1752
+ renderingStarting: false,
1753
+ sourceFps: 24,
1754
+ outputFps: null,
1755
+ performance: false,
1756
+ displayFps: 60,
1757
+ gpu: "AMD Radeon 780M Graphics",
1758
+ };
1759
+ /**
1760
+ * Send `video.motion.changed` with the state {@link TestHost.motion}
1761
+ * describes now (without `mode`), as the player does when it changes; a
1762
+ * plugin listening with `plugin.video.motion("amd").onChange` receives it.
1763
+ * Nothing reaches a plugin that does not listen.
1764
+ *
1765
+ * @capability None.
1766
+ *
1767
+ * @example The GPU fell behind
1768
+ * The player turned the converter off for this video; the plugin's
1769
+ * panel shows the reason.
1770
+ * ```ts
1771
+ * declare const host: TestHost;
1772
+ * // ---cut---
1773
+ * host.motion.double = { code: "overload", message: "the GPU could not keep up with this video" };
1774
+ * host.motionChanged();
1775
+ * await host.settle();
1776
+ * ```
1777
+ *
1778
+ * @since 1.7.19
1779
+ */
1780
+ motionChanged() {
1781
+ if (!this.subscriptions.has("video.motion.changed"))
1782
+ return;
1783
+ const { mode: _, ...state } = motionState(this);
1784
+ this.emit("video.motion.changed", state);
1785
+ }
1713
1786
  /** What `player.chapters()` lists while media is ready. */
1714
1787
  chapters = [];
1715
1788
  /**
@@ -1,4 +1,4 @@
1
- import type { Json, WireRenderingState, WireUpscalingState } from "../../wire.ts";
1
+ import type { Json, WireMotionState, WireRenderingState, WireUpscalingState } from "../../wire.ts";
2
2
  import type { UpscalingDecodingCause, UpscalingPlugin, UpscalingReason } from "../types.ts";
3
3
  import type { TestHost } from "./index.ts";
4
4
  import type { Handler, Internals } from "./internals.ts";
@@ -52,5 +52,6 @@ export declare function failVideoRender(host: TestHost, _inner: Internals, code:
52
52
  export declare function failVideoShaders(host: TestHost, _inner: Internals, id: string, message: string, code?: "failed" | "previous-crash"): void;
53
53
  /** Implements `TestHost.upscalingDecoding`. */
54
54
  export declare function upscalingDecoding(host: TestHost, _inner: Internals, cause: UpscalingDecodingCause, plugins?: readonly UpscalingPlugin[]): UpscalingReason;
55
+ export declare function motionState(host: TestHost): WireMotionState;
55
56
  /** The default handlers of this area's wire methods, by method name. */
56
57
  export declare function processingHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
@@ -247,6 +247,69 @@ export function upscalingDecoding(host, _inner, cause, plugins = []) {
247
247
  host.upscaling.hwdecCurrent = current;
248
248
  return reason;
249
249
  }
250
+ /** `video.motion.state` from {@link TestHost.motion}. */
251
+ /** The player's message for the reserved engine (as playback/motion.rs). */
252
+ const NO_NVIDIA = {
253
+ code: "engine",
254
+ message: "this player has no NVIDIA frame-rate converter; motion smoothing works with AMD's (engine amd)",
255
+ };
256
+ /** `video.motion.state` of the reserved `nvidia` engine: every mode `engine`. */
257
+ function nvidiaState(host) {
258
+ return {
259
+ engine: "nvidia",
260
+ mode: "off",
261
+ active: "off",
262
+ double: { ...NO_NVIDIA },
263
+ display: { ...NO_NVIDIA },
264
+ searchMode: null,
265
+ sourceFps: host.motion.sourceFps,
266
+ outputFps: null,
267
+ displayFps: host.motion.displayFps,
268
+ gpu: null,
269
+ inChain: false,
270
+ };
271
+ }
272
+ /** The engine a request names, checked as the player does. */
273
+ function engineOf(p) {
274
+ if (p.engine !== "amd" && p.engine !== "nvidia")
275
+ throw new HostError("invalid", 'engine must be "amd" or "nvidia"');
276
+ return p.engine;
277
+ }
278
+ export function motionState(host) {
279
+ const { mode, double, display, sourceFps, displayFps, gpu } = host.motion;
280
+ const reasonOf = (wanted) => wanted === "double" ? double : wanted === "display" ? display : null;
281
+ const works = mode !== "off" && reasonOf(mode) === null && sourceFps !== null;
282
+ const active = works ? mode : "off";
283
+ const copy = (reason) => reason ? structuredClone(reason) : null;
284
+ return {
285
+ engine: "amd",
286
+ mode,
287
+ active,
288
+ double: copy(double),
289
+ display: copy(display),
290
+ searchMode: works
291
+ ? host.motion.performance
292
+ ? "performance"
293
+ : "native"
294
+ : null,
295
+ sourceFps,
296
+ outputFps: works
297
+ ? (host.motion.outputFps ?? Math.round(sourceFps * 20) / 10)
298
+ : null,
299
+ displayFps,
300
+ gpu,
301
+ inChain: works,
302
+ };
303
+ }
304
+ /** The reason codes that hold for the whole run (`set` rejects them). */
305
+ const MOTION_FIXED = [
306
+ "engine",
307
+ "platform",
308
+ "no-gpu",
309
+ "runtime",
310
+ "filter",
311
+ "rendering",
312
+ ];
250
313
  /** The default handlers of this area's wire methods, by method name. */
251
314
  export function processingHandlers(host, inner) {
252
315
  return {
@@ -292,6 +355,27 @@ export function processingHandlers(host, inner) {
292
355
  host.upscaling.enabled = true;
293
356
  return upscalingState(host, inner);
294
357
  },
358
+ // As the player 0.8.1 (see TestHost.motion for the model).
359
+ "video.motion.state": (p) => engineOf(p) === "amd" ? motionState(host) : nvidiaState(host),
360
+ "video.motion.set": (p) => {
361
+ const engine = engineOf(p);
362
+ const mode = p.mode;
363
+ if (mode !== "off" && mode !== "double" && mode !== "display")
364
+ throw new HostError("invalid", 'mode must be "off", "double" or "display"');
365
+ if (engine === "nvidia") {
366
+ if (mode !== "off")
367
+ throw new HostError("unsupported", `motion smoothing cannot work here: ${NO_NVIDIA.message}`);
368
+ return nvidiaState(host);
369
+ }
370
+ if (mode !== "off") {
371
+ const reason = host.motion[mode];
372
+ const passes = reason?.code === "rendering" && host.motion.renderingStarting;
373
+ if (reason && MOTION_FIXED.includes(reason.code) && !passes)
374
+ throw new HostError("unsupported", `motion smoothing cannot work here: ${reason.message}`);
375
+ }
376
+ host.motion.mode = mode;
377
+ return motionState(host);
378
+ },
295
379
  "video.view.set": (p) => {
296
380
  const owner = host.videoView.owner;
297
381
  if (owner !== null && owner !== host.manifestId)
@@ -13,7 +13,7 @@ import type { Panel, Window } from "./ui-layout.ts";
13
13
  import type { Bindings, Commands, Host, Palette, When } from "./commands.ts";
14
14
  import type { Packages } from "./packages.ts";
15
15
  import type { Player, Timeline } from "./playback.ts";
16
- import type { AudioFilter, RenderOptions, VideoFilter, VideoShaders, VideoUpscaling, VideoView } from "./processing.ts";
16
+ import type { AudioFilter, RenderOptions, VideoFilter, MotionEngine, VideoMotion, VideoShaders, VideoUpscaling, VideoView } from "./processing.ts";
17
17
  import type { Clipboard, Power, Rendering, RenderingReason, Secrets, Storage, System, Tools } from "./services.ts";
18
18
  import type { MediaCapture } from "./snapshots.ts";
19
19
  import type { Resolvers } from "./sources.ts";
@@ -232,11 +232,12 @@ export interface Scope extends Disposable {
232
232
  readonly player: Player;
233
233
  /**
234
234
  * Video processing: this plugin's filter chain, the display layer, the
235
- * GPU render options, this plugin's shaders and the GPU's video
236
- * upscaler. The first four need `processing.video` and `playback.read`;
237
- * the filter chain also needs `events` (without it the SDK never sees
238
- * the media become ready and the chain stays `waiting`). The upscaler
239
- * needs `video.upscaling` only.
235
+ * GPU render options, this plugin's shaders, the GPU's video upscaler and
236
+ * motion smoothing. The first four need `processing.video` and
237
+ * `playback.read`; the filter chain also needs `events` (without it the
238
+ * SDK never sees the media become ready and the chain stays `waiting`).
239
+ * The upscaler needs `video.upscaling` only, motion smoothing
240
+ * `video.motion` only.
240
241
  */
241
242
  readonly video: {
242
243
  /**
@@ -292,6 +293,19 @@ export interface Scope extends Disposable {
292
293
  * it on or off for this plugin.
293
294
  */
294
295
  readonly upscaling: VideoUpscaling;
296
+ /**
297
+ * Motion smoothing with one GPU vendor's frame-rate converter (needs
298
+ * `video.motion`): whether it works here and why not, and this
299
+ * plugin's mode. `amd` is AMD AMF's on Windows; `nvidia` is reserved
300
+ * (every mode reports `engine` until a player has it).
301
+ *
302
+ * @param engine - The converter: `"amd"` or `"nvidia"`.
303
+ * @returns A {@link VideoMotion} for that converter.
304
+ * @throws `invalid` (throws) `engine` is not one of the two.
305
+ * @player 0.8.1
306
+ * @since 1.7.19
307
+ */
308
+ motion(engine: MotionEngine): VideoMotion;
295
309
  };
296
310
  /**
297
311
  * Audio processing: this plugin's filter chain and delay
@@ -955,8 +955,8 @@ export interface Commands {
955
955
  * the ids of `then`.
956
956
  * @throws `disabled` (rejects) The command is disabled now; `message` has
957
957
  * its reason.
958
- * @throws `busy` (rejects) The command is busy, or its confirmation
959
- * cannot be shown while another alert is open.
958
+ * @throws `busy` (rejects) The command is busy, or another confirmation
959
+ * or approval sheet is waiting for the user's answer.
960
960
  * @throws `limit` (rejects) Over the rate limits above.
961
961
  * @throws `invalid` (rejects) Only one of `step` and `of`, or not
962
962
  * whole numbers with 1 ≤ `step` ≤ `of` ≤ 99; `then` is not an array
@@ -9,7 +9,7 @@ import type { Bindable } from "./commands.ts";
9
9
  import type { Text } from "./ui-locale.ts";
10
10
  import type { CommandKeys } from "../../commands.ts";
11
11
  import type { SourceState } from "../../source.ts";
12
- import type { PackageInfo, WindowFacts, WireTimeline, WireUpscalingState } from "../../wire.ts";
12
+ import type { PackageInfo, WindowFacts, WireMotionState, WireTimeline, WireUpscalingState } from "../../wire.ts";
13
13
  /**
14
14
  * What a timeline mark stands for; readers choose colours by it.
15
15
  *
@@ -833,7 +833,7 @@ export interface PlaybackStats {
833
833
  width: number | null;
834
834
  /** Coded height. */
835
835
  height: number | null;
836
- /** Frames per second (after a `frameBlend` node: the output rate). */
836
+ /** Frames per second (after a `frameBlend` node: the output rate; motion smoothing's doubling is not counted). */
837
837
  fps: number | null;
838
838
  /** Short decoder name, e.g. "h264". */
839
839
  decoder: string | null;
@@ -996,7 +996,8 @@ export interface Player {
996
996
  *
997
997
  * Each event needs a capability: `events` for most, `bindings.manage` for
998
998
  * `bindings.changed`, `commands` for `commands.keys`, `video.upscaling` for
999
- * `video.upscaling.changed`, none for `packages.changed`. Without it the
999
+ * `video.upscaling.changed`, `video.motion` for `video.motion.changed`,
1000
+ * none for `packages.changed`. Without it the
1000
1001
  * listener never runs (for `events`, a warning in the log says so). Added
1001
1002
  * during `activate`, that fails the activation.
1002
1003
  *
@@ -1008,7 +1009,7 @@ export interface Player {
1008
1009
  * `listener` is not a function.
1009
1010
  *
1010
1011
  * @capability That of the event: `events`, or `bindings.manage`,
1011
- * `commands`, `video.upscaling` for the events named above.
1012
+ * `commands`, `video.upscaling`, `video.motion` for the events named above.
1012
1013
  *
1013
1014
  * @example Push the speed to a panel as it changes
1014
1015
  * A bottom panel shows the playback speed. The listener gets each
@@ -1721,7 +1722,7 @@ export interface Player {
1721
1722
  * @since 1.7.0
1722
1723
  * @category Playback
1723
1724
  */
1724
- export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed";
1725
+ export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed" | "video.motion.changed";
1725
1726
  /**
1726
1727
  * The data each {@link HostEvent} carries, as the player sends it: the
1727
1728
  * listener of {@link Player.on} gets a copy.
@@ -1770,6 +1771,8 @@ export interface EventPayloads {
1770
1771
  };
1771
1772
  /** The AI upscaling state, without this plugin's own `enabled`. */
1772
1773
  "video.upscaling.changed": Omit<WireUpscalingState, "enabled">;
1774
+ /** Motion smoothing's state, without this plugin's own `mode`. */
1775
+ "video.motion.changed": Omit<WireMotionState, "mode">;
1773
1776
  }
1774
1777
  /**
1775
1778
  * The data of event `E`, as the listener of {@link Player.on} gets it.
@@ -146,7 +146,7 @@ export interface Wire {
146
146
  * `listener` is not a function.
147
147
  *
148
148
  * @capability That of the event: `events`, or `bindings.manage`,
149
- * `commands`, `video.upscaling` as for {@link Player.on}; none for an
149
+ * `commands`, `video.upscaling`, `video.motion` as for {@link Player.on}; none for an
150
150
  * event listened to without a subscription.
151
151
  *
152
152
  * @example Log each command the player runs for this plugin
@@ -958,4 +958,309 @@ export interface VideoUpscaling {
958
958
  */
959
959
  onChange(listener: (state: UpscalingState) => void): Disposable;
960
960
  }
961
+ /**
962
+ * A GPU vendor's frame-rate converter for motion smoothing: `amd` (AMD
963
+ * AMF's, on Windows with an AMD Radeon GPU); `nvidia` is reserved for
964
+ * NVIDIA's converter, which no player has yet (every mode reports
965
+ * `engine`). Each vendor's motion smoothing is its own plugin.
966
+ *
967
+ * @player 0.8.1
968
+ * @since 1.7.19
969
+ * @category Processing
970
+ */
971
+ export type MotionEngine = "amd" | "nvidia";
972
+ /**
973
+ * What motion smoothing does: `off`; `double`, twice the video's frame rate
974
+ * with real in-between frames from the GPU's frame-rate converter, shown as
975
+ * they come; `display`, the doubled frames also interpolated to the
976
+ * display's refresh rate (GPU rendering only), so 24 fps doubled to 48 meets
977
+ * a 60 Hz display without judder.
978
+ *
979
+ * @player 0.8.1
980
+ * @since 1.7.19
981
+ * @category Processing
982
+ */
983
+ export type MotionMode = "off" | "double" | "display";
984
+ /**
985
+ * Why a motion smoothing mode does not work, as a stable kebab-case code. A
986
+ * newer player may add codes: compare with the ones you handle and show
987
+ * {@link MotionReason.message} for the rest. The codes, in the order the
988
+ * player checks them (the first that holds is reported):
989
+ *
990
+ * | Code | Meaning |
991
+ * | --- | --- |
992
+ * | `engine` | The player has no converter of this engine (`nvidia`, until a player has it). |
993
+ * | `platform` | The player has no frame-rate converter on this system (macOS, Linux). |
994
+ * | `no-gpu` | No GPU with a frame-rate converter (Windows: no AMD Radeon GPU). |
995
+ * | `runtime` | The GPU's runtime is missing (Windows: AMD's AMF runtime, installed with the AMD driver), or the converter failed to start the same way on two videos in this run (an older GPU AMF does not serve). |
996
+ * | `filter` | The player's video library has no frame-rate converter (a player built without it). |
997
+ * | `rendering` | Match Display only: the player renders in software, or GPU rendering is still starting ({@link Rendering}). |
998
+ * | `upscaling` | AI upscaling is on ({@link VideoUpscaling}); the two cannot run together. |
999
+ * | `doubling` | A plugin's video filter already raises the frame rate (a `frameBlend` node, such as Frame Doubling); the two cannot run together. |
1000
+ * | `failed` | The converter stopped on this video; the message has its error. The next video tries again. |
1001
+ * | `overload` | The GPU could not keep up with this video, even with the faster motion search. The next video tries again. |
1002
+ * | `rate` | The video's frame rate does not fit: outside 10–30 fps (the rates measured), doubled above the display's refresh rate, or (software rendering, Double) twice it is not the display's rate. |
1003
+ * | `format` | The video's format was not measured: 10-bit or deeper, or HDR. |
1004
+ * | `size` | The video is too large for this mode on this renderer: its width × height × the doubled rate is more than the player measured it keeps up with (on the reference laptop: software rendering up to 1080p at 30 fps, GPU rendering's Double up to 4K at 24 fps, Match Display up to 1080p on a 60 Hz display, counted at the display's refresh rate). The next video may fit. |
1005
+ *
1006
+ * `engine`, `platform`, `no-gpu`, `runtime`, `filter` and `rendering` (once GPU
1007
+ * rendering is not just starting) hold until the player restarts, and
1008
+ * {@link VideoMotion.set} rejects a mode they stand in the way of; the
1009
+ * others can pass during the run, so `set` keeps the request and the player
1010
+ * applies it as soon as they do.
1011
+ *
1012
+ * @example Advise the user by reason
1013
+ * The plugin shows its own advice for the reasons the user can act on and
1014
+ * the player's message for the rest.
1015
+ * ```ts
1016
+ * const { double } = await plugin.video.motion("amd").state();
1017
+ * // Advice for the codes this plugin knows; any other code shows the message.
1018
+ * const advice: Partial<Record<MotionReasonCode, string>> = {
1019
+ * upscaling: "Turn off AI Upscaling to smooth motion.",
1020
+ * runtime: "Install or update the AMD graphics driver.",
1021
+ * };
1022
+ * if (double) console.log(advice[double.code] ?? double.message);
1023
+ * ```
1024
+ *
1025
+ * @player 0.8.1
1026
+ * @since 1.7.19
1027
+ * @category Processing
1028
+ */
1029
+ export type MotionReasonCode = "engine" | "platform" | "no-gpu" | "runtime" | "filter" | "rendering" | "upscaling" | "doubling" | "failed" | "overload" | "rate" | "format" | "size" | (string & {});
1030
+ /**
1031
+ * Why a motion smoothing mode does not work: a stable
1032
+ * {@link MotionReasonCode} to branch on and a sentence to show, the same
1033
+ * shape as {@link RenderingReason}.
1034
+ *
1035
+ * @example Grey out a mode with the player's reason
1036
+ * The plugin shows why Match Display is not offered.
1037
+ * ```ts
1038
+ * const state = await plugin.video.motion("amd").state();
1039
+ * if (state.display) console.log(`Match Display: ${state.display.message}`);
1040
+ * ```
1041
+ *
1042
+ * @player 0.8.1
1043
+ * @since 1.7.19
1044
+ * @category Processing
1045
+ */
1046
+ export interface MotionReason {
1047
+ /** The reason as a stable kebab-case code; branch on this. */
1048
+ readonly code: MotionReasonCode;
1049
+ /**
1050
+ * The reason as English text for people, for example with the rates and
1051
+ * what to change; never branch on it.
1052
+ */
1053
+ readonly message: string;
1054
+ }
1055
+ /**
1056
+ * What {@link VideoMotion.state} and {@link VideoMotion.set} report: this
1057
+ * plugin's mode, what the player does now, and why each mode cannot work.
1058
+ *
1059
+ * @example Say what motion smoothing does now
1060
+ * The plugin's status line shows the rates while the converter runs, else
1061
+ * why the chosen mode waits.
1062
+ * ```ts
1063
+ * const state = await plugin.video.motion("amd").state();
1064
+ * // The reason of the mode this plugin chose.
1065
+ * const waiting = state.mode === "display" ? state.display : state.double;
1066
+ * const line =
1067
+ * state.active === "off"
1068
+ * ? (waiting?.message ?? "Off")
1069
+ * : `${state.sourceFps} → ${state.outputFps ?? "…"} fps`;
1070
+ * console.log(line);
1071
+ * ```
1072
+ *
1073
+ * @player 0.8.1
1074
+ * @since 1.7.19
1075
+ * @category Processing
1076
+ */
1077
+ export interface MotionState {
1078
+ /** The converter this state is of ({@link MotionEngine}). */
1079
+ readonly engine: MotionEngine;
1080
+ /** This plugin's request ({@link VideoMotion.set}); `off` until it asks. */
1081
+ readonly mode: MotionMode;
1082
+ /**
1083
+ * What the player does now, for this plugin or another one (the strongest
1084
+ * mode asked for that can work): `off` while nothing is asked, while a
1085
+ * reason stands in the way, and while the video's rate is not known yet.
1086
+ */
1087
+ readonly active: MotionMode;
1088
+ /** Why Double Frame Rate cannot work now; `null` while it can. */
1089
+ readonly double: MotionReason | null;
1090
+ /** Why Match Display cannot work now; `null` while it can. */
1091
+ readonly display: MotionReason | null;
1092
+ /**
1093
+ * The converter's motion search while it runs: `native` on the full
1094
+ * frames, `performance` on downscaled ones (the first step when the GPU
1095
+ * falls behind); `null` while off.
1096
+ */
1097
+ readonly searchMode: "native" | "performance" | null;
1098
+ /** The video's frame rate, in frames a second; `null` while unknown. */
1099
+ readonly sourceFps: number | null;
1100
+ /** The converter's output rate as measured, in tenths; `null` while off. */
1101
+ readonly outputFps: number | null;
1102
+ /** The display's refresh rate the player paces to, in Hz. */
1103
+ readonly displayFps: number;
1104
+ /** The name of the GPU that converts; `null` where there is none. */
1105
+ readonly gpu: string | null;
1106
+ /** The converter is in the player's video filter chain now, read from the chain itself. */
1107
+ readonly inChain: boolean;
1108
+ }
1109
+ /**
1110
+ * `plugin.video.motion(engine)`: motion smoothing, the video's frame rate doubled by
1111
+ * the GPU's frame-rate converter (AMD AMF's on Windows; `video.motion`).
1112
+ * Read whether it works here and why not; choose a mode for this plugin.
1113
+ *
1114
+ * @remarks
1115
+ * The converter makes real in-between frames (motion estimation, not
1116
+ * blending). While some plugin asks for a mode that can work, the player
1117
+ * puts the converter last in the video filter chain, decodes with copy-back
1118
+ * (the converter needs the frames in memory) and, for `display`, has the
1119
+ * GPU renderer interpolate the doubled frames to the display. The strongest
1120
+ * mode any plugin asked for applies; a stopped plugin's request is revoked.
1121
+ *
1122
+ * The player watches the converter while the video plays: when its output
1123
+ * falls behind the doubled rate or many frames are dropped, it first
1124
+ * switches to a faster motion search on downscaled frames, then turns the
1125
+ * converter off for this video with an `overload` reason. The next video
1126
+ * starts afresh.
1127
+ *
1128
+ * Motion smoothing and {@link VideoUpscaling | AI upscaling} exclude each
1129
+ * other (the upscaler needs the frames on the GPU, the converter in
1130
+ * memory): while upscaling is on, every mode waits with `upscaling`.
1131
+ * Doubling makes film look like video (the "soap-opera effect"): offer it
1132
+ * off by default.
1133
+ *
1134
+ * **Windows:** an AMD Radeon GPU with the AMD driver (AMF). On a laptop
1135
+ * with two GPUs the converter runs on the AMD one, whichever GPU renders.
1136
+ * **macOS, Linux:** every mode reports `platform`.
1137
+ *
1138
+ * @example Offer the three modes as radio commands
1139
+ * Each command chooses one mode; one the player cannot run here is
1140
+ * refused with `unsupported`, and the state is read again for its reason.
1141
+ * ```ts
1142
+ * let state: MotionState | null = null; // unknown until first picked
1143
+ * for (const mode of ["off", "double", "display"] as const)
1144
+ * plugin.commands.add({
1145
+ * id: `motion.${mode}`,
1146
+ * title: mode,
1147
+ * radio: true,
1148
+ * checked: () => (state?.mode ?? "off") === mode,
1149
+ * run: async () => {
1150
+ * try {
1151
+ * state = await plugin.video.motion("amd").set(mode);
1152
+ * } catch (error) {
1153
+ * // Cannot work in this run (no AMD GPU, Match Display in software…).
1154
+ * if ((error as PluginError).code !== "unsupported") throw error;
1155
+ * state = await plugin.video.motion("amd").state();
1156
+ * }
1157
+ * },
1158
+ * });
1159
+ * ```
1160
+ *
1161
+ * @capability video.motion
1162
+ * @player 0.8.1
1163
+ * @since 1.7.19
1164
+ * @category Processing
1165
+ */
1166
+ export interface VideoMotion {
1167
+ /**
1168
+ * Read this plugin's mode, what the player does now and why each mode
1169
+ * cannot work.
1170
+ *
1171
+ * @capability video.motion
1172
+ * @returns The state. The first call of any plugin looks for the GPU
1173
+ * (no device is created, so no GPU is woken).
1174
+ * @throws `capability` (rejects) The manifest does not declare
1175
+ * `video.motion`.
1176
+ *
1177
+ * @example Find out whether Match Display can work here
1178
+ * The plugin reads the state when its panel shows; a reason greys the
1179
+ * mode out with the player's message.
1180
+ * ```ts
1181
+ * const { display } = await plugin.video.motion("amd").state();
1182
+ * if (display) console.log(display.message);
1183
+ * ```
1184
+ *
1185
+ * @since 1.7.19
1186
+ */
1187
+ state(): Promise<MotionState>;
1188
+ /**
1189
+ * Choose this plugin's motion smoothing mode.
1190
+ *
1191
+ * @remarks
1192
+ * The mode stays this plugin's request until it changes it or stops; the
1193
+ * player applies it whenever it can work (a `rate`, `size`, `format`, `doubling`, `upscaling`,
1194
+ * `failed` or `overload` reason can pass with the next video). `off`
1195
+ * takes the converter out at once unless another plugin asks for it. The
1196
+ * mode is a request of the whole plugin, not of a {@link Scope}.
1197
+ *
1198
+ * @capability video.motion
1199
+ * @param mode - `off`, `double` or `display`.
1200
+ * @returns The new state.
1201
+ * @throws `capability` (rejects) The manifest does not declare
1202
+ * `video.motion`.
1203
+ * @throws `invalid` (rejects) `mode` is not one of the three.
1204
+ * @throws `unsupported` (rejects) A mode that cannot work in this run:
1205
+ * `platform`, `no-gpu`, `runtime`, `filter`, and `rendering` for
1206
+ * `display` once GPU rendering is not just starting; `message` is the
1207
+ * reason. Nothing changes. `off` is always accepted.
1208
+ *
1209
+ * @example Turn on Match Display, or say why not
1210
+ * The plugin asks for Match Display and tells the user when it waits
1211
+ * (the video's rate, AI upscaling) or cannot work in this run.
1212
+ * ```ts
1213
+ * try {
1214
+ * const state = await plugin.video.motion("amd").set("display");
1215
+ * // Kept, but waiting for a reason that can pass.
1216
+ * if (state.active === "off" && state.display)
1217
+ * await plugin.osd.show("Motion smoothing waits: {}", [state.display.message]);
1218
+ * } catch (error) {
1219
+ * // Cannot work in this run: nothing changed.
1220
+ * if ((error as PluginError).code !== "unsupported") throw error;
1221
+ * await plugin.osd.show("Motion smoothing: {}", [(error as PluginError).message]);
1222
+ * }
1223
+ * ```
1224
+ *
1225
+ * @since 1.7.19
1226
+ */
1227
+ set(mode: MotionMode): Promise<MotionState>;
1228
+ /**
1229
+ * Call `listener` with the new state whenever it changes while some
1230
+ * plugin asks for motion smoothing: what is active, the reasons, the
1231
+ * search mode, the rates.
1232
+ *
1233
+ * @remarks
1234
+ * The player looks twice a second while a mode is asked for and sends a
1235
+ * change only when something differs (the measured output rate in
1236
+ * tenths); after the last plugin turns it off one more change says so.
1237
+ * Nothing is sent before the first `state()` or `set()` of any plugin.
1238
+ * `mode` is this plugin's own request, as in `state()`.
1239
+ *
1240
+ * **A listener keeps the plugin running**, as
1241
+ * {@link VideoUpscaling.onChange}'s does: listen only while a window or
1242
+ * panel shows the state.
1243
+ *
1244
+ * @capability video.motion
1245
+ * @param listener - Receives the new state.
1246
+ * @returns Stops listening; also when the scope that added it is
1247
+ * disposed.
1248
+ * @throws `capability` (synchronously) The manifest does not declare
1249
+ * `video.motion`.
1250
+ *
1251
+ * @example Show the rates while a panel is open
1252
+ * The plugin listens only while its panel shows, since the listener
1253
+ * keeps the plugin running.
1254
+ * ```ts
1255
+ * const watch = plugin.video.motion("amd").onChange((state) => {
1256
+ * console.log(`${state.sourceFps ?? "?"} → ${state.outputFps ?? "off"} fps on ${state.gpu ?? "no GPU"}`);
1257
+ * });
1258
+ * // When the panel hides:
1259
+ * await watch.dispose();
1260
+ * ```
1261
+ *
1262
+ * @since 1.7.19
1263
+ */
1264
+ onChange(listener: (state: MotionState) => void): Disposable;
1265
+ }
961
1266
  export {};
@@ -523,7 +523,11 @@ export interface Panels {
523
523
  export interface ConfirmOptions {
524
524
  /** The question, shown in bold; 1–200 characters. */
525
525
  message: TextValue;
526
- /** More text under the message; at most 2000 characters. */
526
+ /**
527
+ * More text under the message; at most 2000 characters. In the
528
+ * confirmation drawn in the player a long detail scrolls and the buttons
529
+ * stay in view.
530
+ */
527
531
  detail?: TextValue;
528
532
  /** The confirm button's text (the default button: Enter picks it); 1–40 characters. */
529
533
  confirm: TextValue;
@@ -534,13 +538,18 @@ export interface ConfirmOptions {
534
538
  */
535
539
  cancel?: TextValue;
536
540
  /**
537
- * Mark the confirm button as destructive: red text on macOS, a warning
538
- * icon on Windows.
541
+ * Mark the confirm button as destructive. Only a tool window's system
542
+ * dialog shows it (a warning icon on Windows, red button text on
543
+ * macOS); the confirmation drawn in the player marks nothing, as its
544
+ * approval sheet marks no destructive step. Enter confirms either way.
539
545
  *
540
546
  * @defaultValue `false`
541
547
  */
542
548
  destructive?: boolean;
543
- /** A checkbox under the text, such as "Don't ask again"; 1–40 characters. */
549
+ /**
550
+ * A checkbox, such as "Don't ask again" (in the player, at the left of
551
+ * the buttons); 1–40 characters.
552
+ */
544
553
  checkbox?: TextValue;
545
554
  /**
546
555
  * Values for the placeholders of `message` and `detail`. Any of the texts may
@@ -555,20 +564,22 @@ export interface ConfirmOptions {
555
564
  args?: TemplateArgs;
556
565
  }
557
566
  /**
558
- * The system's own dialogs: a confirmation alert and the open and save file
559
- * dialogs. `plugin.dialogs`.
567
+ * Confirmations and the system's open and save file dialogs.
568
+ * `plugin.dialogs`.
560
569
  *
561
570
  * @remarks
562
- * The plugin passes text and gets the answer; the system draws the dialog,
563
- * so it looks and behaves like every other dialog on the system. Each call
564
- * resolves when the user answers; there is no time limit and no way to close
565
- * a dialog from code. Only one dialog (of any kind, from any plugin) is open
566
- * at a time: another call meanwhile rejects with `busy`. Playback continues
567
- * while a dialog is open; command key bindings pause.
571
+ * The plugin passes text and gets the answer. A confirmation for the main
572
+ * window is drawn in the player; one asked while a tool window has the
573
+ * focus, and every file dialog, is the system's own (see
574
+ * {@link Dialogs.confirm}). Each call resolves when the user answers; there
575
+ * is no time limit and no way to close a dialog from code. Only one system
576
+ * dialog (of any kind, from any plugin) is open at a time: another call
577
+ * meanwhile rejects with `busy`. A confirmation is also `busy` while
578
+ * another confirmation or the player's approval sheet waits for the
579
+ * user's answer; the file dialogs are not. Playback continues while a dialog is open; command key bindings pause.
568
580
  *
569
- * **Platforms:** {@link Dialogs.confirm} needs macOS or Windows (other
570
- * systems reject it with `unsupported`); the file dialogs work on every
571
- * system.
581
+ * **Platforms:** every system with a window; a player without one
582
+ * (headless) rejects every call with `unavailable`.
572
583
  *
573
584
  * For anything more than a question or a path, use a {@link Windows | tool
574
585
  * window}.
@@ -576,9 +587,8 @@ export interface ConfirmOptions {
576
587
  * @capability ui.dialog
577
588
  *
578
589
  * @example Ask before deleting, remembering "Don't ask again"
579
- * Deleting asks for confirmation in a system alert with a "Don't ask
580
- * again" box; once the user ticks it, later deletes go ahead without
581
- * asking. `confirm` resolves with the button and the checkbox when the
590
+ * Deleting asks for confirmation with a "Don't ask again" box; once the
591
+ * user ticks it, later deletes go ahead without asking. `confirm` resolves with the button and the checkbox when the
582
592
  * user answers; the texts are templates the player translates, so the
583
593
  * count goes in `args`. Remembering the box is up to the plugin.
584
594
  * ```ts
@@ -606,17 +616,29 @@ export interface ConfirmOptions {
606
616
  */
607
617
  export interface Dialogs {
608
618
  /**
609
- * Ask the user to confirm something, in a system alert.
619
+ * Ask the user to confirm something.
610
620
  *
611
621
  * @remarks
612
- * **macOS:** an `NSAlert` sheet on the active player window (usually the
613
- * tool window the user just clicked in), else on the main window.
614
- *
615
- * **Windows:** a task dialog owned by the active player window, titled
616
- * "Vestra Player" and centred on it: `message` is the main instruction
617
- * and `detail` the text below it. A `checkbox` is the dialog's own
618
- * verification box (no second dialog); `checked` is its state on cancel
619
- * too. No system sound plays; `destructive` shows a warning icon.
622
+ * **For the main window** (no tool window has the focus, also while the
623
+ * player is not in the foreground, which then takes no focus): drawn in
624
+ * the player in the style of its approval sheet, the same on every
625
+ * system: `message`, then `detail` (a long one scrolls; the sheet stays
626
+ * inside the window and its buttons in view), the `checkbox` at the
627
+ * footer's left and the confirm (Enter) and cancel (Esc) buttons at its
628
+ * right. Presses in its first 0.5 s are ignored, and a click outside it
629
+ * is Cancel. A click toggles the checkbox (Space does not).
630
+ * `destructive` draws nothing different.
631
+ *
632
+ * **For a tool window** (a plugin's window, Options or the floating
633
+ * sidebar has the focus): the system's dialog on that window. macOS: an
634
+ * `NSAlert` sheet with the custom buttons and the checkbox. Windows: a
635
+ * task dialog titled "Vestra Player" and centred on the window: `message`
636
+ * is the main instruction and `detail` the text below it; a `checkbox`
637
+ * is the dialog's own verification box (no second dialog); no system
638
+ * sound plays; `destructive` shows a warning icon. Other systems have no
639
+ * system alerts, so it is drawn in the player there too.
640
+ *
641
+ * Either way `checked` is the checkbox's state on cancel too.
620
642
  *
621
643
  * Remembering "Don't ask again" is up to the plugin (see
622
644
  * {@link Scope.storage}).
@@ -630,16 +652,18 @@ export interface Dialogs {
630
652
  *
631
653
  * @throws `invalid` (rejects) A text is empty or too long, or `destructive`
632
654
  * is not a boolean.
633
- * @throws `busy` (rejects) Another dialog is open.
655
+ * @throws `busy` (rejects) Another dialog is open, or another
656
+ * confirmation or the approval sheet is waiting for the user's answer.
634
657
  * @throws `unavailable` (rejects) The player runs without a user interface.
635
- * @throws `unsupported` (rejects) A system other than macOS and Windows.
658
+ * @throws `unsupported` (rejects) Only players before the confirmation
659
+ * drawn in the player, on a system other than macOS and Windows.
636
660
  * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
637
661
  *
638
662
  * @example Confirm before replacing the playlist
639
663
  * The user sees "Replace the current playlist?" with a Replace button and
640
- * the playlist is replaced only after a yes. The system draws the alert
641
- * and the promise resolves when the user answers; only one dialog is
642
- * open at a time, so a second one meanwhile rejects with `busy`.
664
+ * the playlist is replaced only after a yes. The promise resolves when
665
+ * the user answers; only one dialog waits for the user at a time, so a
666
+ * second one meanwhile rejects with `busy`.
643
667
  * ```ts
644
668
  * try {
645
669
  * const { confirmed } = await plugin.dialogs.confirm({
@@ -649,7 +673,7 @@ export interface Dialogs {
649
673
  * if (confirmed) await plugin.osd.show("Playlist replaced");
650
674
  * } catch (error) {
651
675
  * if ((error as PluginError).code !== "busy") throw error;
652
- * // Another dialog is already open: let the user finish that one.
676
+ * // Another dialog is waiting: let the user finish that one.
653
677
  * }
654
678
  * ```
655
679
  *
@@ -13,12 +13,12 @@
13
13
  * and are re-exported here with `export type *`: this module exports the
14
14
  * same names as before the split.
15
15
  */
16
- import type { Json, PackageInfo, PropertyWrite, RowOp, WindowFacts, WireMark, WireRange, WireRenderingReason, WireSource, WireTimeline, WireUpscalingReason, WireUpscalingState } from "../wire.ts";
16
+ import type { Json, PackageInfo, PropertyWrite, RowOp, WindowFacts, WireMark, WireRange, WireRenderingReason, WireSource, WireMotionState, WireTimeline, WireUpscalingReason, WireUpscalingState } from "../wire.ts";
17
17
  import type { CommandKeys } from "../commands.ts";
18
18
  import type { AudioNode, ConvolutionPlane, VideoNode } from "../processing.ts";
19
19
  import type { SubtitleStyle } from "../subtitles.ts";
20
20
  import type { ResolvedMedia } from "../source-resolvers.ts";
21
- export type { Json, PropertyWrite, RowOp, AudioNode, ConvolutionPlane, VideoNode, SubtitleStyle, ResolvedMedia, CommandKeys, PackageInfo, WindowFacts, WireMark, WireRange, WireRenderingReason, WireSource, WireTimeline, WireUpscalingReason, WireUpscalingState, };
21
+ export type { Json, PropertyWrite, RowOp, AudioNode, ConvolutionPlane, VideoNode, SubtitleStyle, ResolvedMedia, CommandKeys, PackageInfo, WindowFacts, WireMark, WireRange, WireRenderingReason, WireSource, WireMotionState, WireTimeline, WireUpscalingReason, WireUpscalingState, };
22
22
  export type * from "./types/base.ts";
23
23
  export type * from "./types/commands.ts";
24
24
  export type * from "./types/ui-content.ts";
package/dist/wire.d.ts CHANGED
@@ -645,6 +645,43 @@ export interface WireUpscalingState {
645
645
  /** The upscaler is in the player's video filter chain now, read from the chain itself. */
646
646
  inChain?: boolean;
647
647
  }
648
+ /**
649
+ * Motion smoothing's state as `video.motion.state` and `video.motion.set`
650
+ * answer it (also sent without `mode` as the event `video.motion.changed`):
651
+ * what `MotionState` is made from. A reason is `{ code, message }`, as a
652
+ * rendering reason.
653
+ *
654
+ * @remarks
655
+ * The player's wire shape (`video.motion.state`, `video.motion.changed`), part of the protocol, which is not
656
+ * semver: it can gain fields with a player version.
657
+ *
658
+ * @since 1.7.19
659
+ * @category Playback
660
+ */
661
+ export interface WireMotionState {
662
+ /** The converter this state is of (`amd`; `nvidia` is reserved). */
663
+ engine: string;
664
+ /** This plugin's own mode (`off`, `double` or `display`). */
665
+ mode: "off" | "double" | "display";
666
+ /** What the player does now, for this plugin or another one. */
667
+ active: "off" | "double" | "display";
668
+ /** Why Double Frame Rate cannot work now; `null` while it can. */
669
+ double: WireRenderingReason | null;
670
+ /** Why Match Display cannot work now; `null` while it can. */
671
+ display: WireRenderingReason | null;
672
+ /** The converter's motion search while it runs; `null` while off. */
673
+ searchMode: "native" | "performance" | null;
674
+ /** The video's frame rate; `null` while unknown. */
675
+ sourceFps: number | null;
676
+ /** The converter's output rate, measured; `null` while off. */
677
+ outputFps: number | null;
678
+ /** The display's refresh rate the player paces to. */
679
+ displayFps: number;
680
+ /** The GPU that converts; `null` where there is none. */
681
+ gpu: string | null;
682
+ /** The converter is in the player's video filter chain now. */
683
+ inChain: boolean;
684
+ }
648
685
  /**
649
686
  * Template arguments on the wire (`osd.show`, `osd.panel`, `dialogs.confirm`, a
650
687
  * text's `args`): data, or text values.
@@ -675,7 +712,7 @@ export interface Transport {
675
712
  * The events a plugin subscribes to (`events.subscribe`). The plugin API names
676
713
  * the same list `HostEvent` (`plugin.player.on`); a test keeps the two equal.
677
714
  */
678
- export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed";
715
+ export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed" | "video.motion.changed";
679
716
  export declare function createWire(transport: Transport): {
680
717
  processing: {
681
718
  state: () => Promise<import("./processing.ts").ProcessingState>;
@@ -815,6 +852,9 @@ export declare function createWire(transport: Transport): {
815
852
  /** The GPU's video upscaler (`plugin.video.upscaling`). */
816
853
  upscalingState: () => Promise<WireUpscalingState>;
817
854
  upscalingSet: (enabled: boolean) => Promise<WireUpscalingState>;
855
+ /** Motion smoothing (`plugin.video.motion`). */
856
+ motionState: (engine: string) => Promise<WireMotionState>;
857
+ motionSet: (engine: string, mode: string) => Promise<WireMotionState>;
818
858
  };
819
859
  /** Mark layers on the seek bar (`plugin.timeline`). */
820
860
  timeline: {
package/dist/wire.js CHANGED
@@ -154,6 +154,12 @@ export function createWire(transport) {
154
154
  upscalingSet: (enabled) => transport.request("video.upscaling.set", {
155
155
  enabled,
156
156
  }),
157
+ /** Motion smoothing (`plugin.video.motion`). */
158
+ motionState: (engine) => transport.request("video.motion.state", { engine }),
159
+ motionSet: (engine, mode) => transport.request("video.motion.set", {
160
+ engine,
161
+ mode,
162
+ }),
157
163
  },
158
164
  /** Mark layers on the seek bar (`plugin.timeline`). */
159
165
  timeline: {
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.7.17: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
3
+ > @vestra-player/sdk 1.7.19: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
4
4
 
5
5
  ## Read the documentation
6
6
 
@@ -28,9 +28,9 @@
28
28
  - `/API/Commands`: 23 entries: CommandState, Bindable, Condition, When, MenuId, BarButtonIcon, CommandButton, CommandOptions, Command, Commands, CommandRunOptions, CommandRunResult, CommandList, CommandInfo, Palette,…
29
29
  - `/API/Media`: 12 entries: CaptureOptions, Snapshot, ExportOptions, ExportEncoding, JobState, ExportJob, MediaCapture, SourceReference, MediaSources, ExportPart, PartsExportOptions, ExportCheck
30
30
  - `/API/Packages`: 10 entries: PackageManifest, PackageSource, InstallOptions, PackageCandidate, PackageChangeStatus, PackageChange, PluginInfo, PluginDisplay, PluginWarning, Packages
31
- - `/API/Playback`: 33 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
31
+ - `/API/Playback`: 34 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
32
32
  - `/API/Plugin`: 21 entries: Disposable, PluginError, Scope, Plugin, StopReason, DisposeInfo, WindowState, MainWindow, AppInfo, App, SystemInfo, DisplayInfo, Wire, WireView, WireCommands, WireCommandOptions,…
33
- - `/API/Processing`: 18 entries: FilterStatus, VideoFilter, AudioFilter, ViewSettings, VideoView, RenderSettings, RenderOptions, VideoShaders, UpscalingReasonCode, UpscalingReason, UpscalingDecodingCause,…
33
+ - `/API/Processing`: 24 entries: FilterStatus, VideoFilter, AudioFilter, ViewSettings, VideoView, RenderSettings, RenderOptions, VideoShaders, UpscalingReasonCode, UpscalingReason, UpscalingDecodingCause,…
34
34
  - `/API/Services`: 15 entries: Clipboard, Power, ToolResult, Tools, JsonStore, Storage, SessionStorage, System, Secrets, RenderingMode, RenderingPreference, RenderingReasonCode, RenderingReason, RenderingState,…
35
35
  - `/API/Sources`: 7 entries: ResolverOptions, WebResolverOptions, FileResolverOptions, ResolvedStream, Resolver, Resolvers, ResolvedMedia
36
36
  - `/API/Subtitles`: 5 entries: SubtitleTrack, SubtitlesState, SubtitleConditional, Subtitles, SubtitleStyle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.7.17",
3
+ "version": "1.7.19",
4
4
  "description": "Plugin API types, test host and plugin CLI for Vestra Player (apiVersion vestra/1)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {