@norskvideo/norsk-sdk 0.0.322

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.
@@ -0,0 +1,515 @@
1
+ import { MediaClient } from "@norskvideo/norsk-api/lib/media_grpc_pb";
2
+ import { StreamStatsSampling, Subscription } from "@norskvideo/norsk-api/lib/media_pb";
3
+ import { FrameRate } from "../types";
4
+ import { AutoSinkMediaNode, MediaNodeState, SourceMediaNode, SourceNodeSettings, StreamStatsMixin } from "./common";
5
+ import { AacProfile, AudioLevels, ChannelLayout, ComposeMissingStreamBehaviour, Db, NetintH264, NetintHevc, NvidiaH264, NvidiaHevc, PixelFormat, SampleAspectRatio, Resolution, SampleRate, SentenceBuildMode, SimpleEasing, StabilizationMode, StreamKey, X264Codec, X265Codec, MultiStreamStats } from "./types";
6
+ import { PlainMessage } from "@bufbuild/protobuf";
7
+ interface ProcessorMediaNode<Pins extends string> extends SourceMediaNode, AutoSinkMediaNode<Pins> {
8
+ }
9
+ declare class ProcessorMediaNode<Pins extends string> {
10
+ constructor(client: MediaClient, subscribeFn: (subscription: Subscription) => void);
11
+ }
12
+ interface AutoProcessorMediaNode<Pins extends string> extends SourceMediaNode, AutoSinkMediaNode<Pins> {
13
+ }
14
+ declare class AutoProcessorMediaNode<Pins extends string> {
15
+ constructor(client: MediaClient, subscribeFn: (subscription: Subscription) => void);
16
+ }
17
+ /** @public */
18
+ export interface ProcessorNodeSettings<T extends MediaNodeState> extends SourceNodeSettings<T> {
19
+ }
20
+ /** @public */
21
+ export interface HardSwitcherSettings<Pins extends string> extends ProcessorNodeSettings<HardSwitcherNode<Pins>> {
22
+ activeSource: Pins;
23
+ outputSource: string;
24
+ }
25
+ /**
26
+ * @public
27
+ * {@link NorskControl.hardSwitcher}
28
+ */
29
+ export declare class HardSwitcherNode<Pins extends string> extends ProcessorMediaNode<Pins> {
30
+ switchSource(newSource: Pins): void;
31
+ close(): void;
32
+ }
33
+ /** @public */
34
+ export interface SmoothSwitcherSettings<Pins extends string> extends ProcessorNodeSettings<SmoothSwitcherNode<Pins>> {
35
+ activeSource?: Pins;
36
+ outputSource: string;
37
+ transitionDurationMs?: number;
38
+ outputResolution: Resolution;
39
+ sampleRate: SampleRate;
40
+ }
41
+ /**
42
+ * @public
43
+ * {@link NorskControl.smoothSwitcher}
44
+ */
45
+ export declare class SmoothSwitcherNode<Pins extends string> extends ProcessorMediaNode<Pins> {
46
+ switchSource(newSource: Pins): void;
47
+ close(): void;
48
+ }
49
+ /**
50
+ * @public
51
+ * Settings for an {@link StreamStatsNode}
52
+ */
53
+ export interface StreamStatsSettings extends ProcessorNodeSettings<StreamStatsNode>, StreamStatsMixin {
54
+ /**
55
+ * Called periodically with the stream stats
56
+ * @param stats - The statistics for the stream
57
+ * @eventProperty
58
+ */
59
+ onStreamStats: (stats: MultiStreamStats) => void;
60
+ /**
61
+ * Sampling rates for stream stats, in seconds
62
+ */
63
+ statsSampling?: PlainMessage<StreamStatsSampling>;
64
+ }
65
+ /**
66
+ * @public
67
+ * Monitor statistics about a media stream. Create a new instance of this node with {@link NorskControl.streamStats}.
68
+ */
69
+ export declare class StreamStatsNode extends AutoProcessorMediaNode<"audio" | "video"> {
70
+ close(): void;
71
+ }
72
+ /**
73
+ * @public
74
+ * Settings for an {@link AudioLevelsNode}
75
+ */
76
+ export interface AudioLevelsSettings extends ProcessorNodeSettings<AudioLevelsNode> {
77
+ /**
78
+ * Called with the audio level data
79
+ * @param levels - The level data for the audio stream
80
+ * @eventProperty
81
+ */
82
+ onData: (levels: AudioLevels) => void;
83
+ intervalFrames?: number;
84
+ }
85
+ /**
86
+ * @public
87
+ * Monitor audio levels. Create a new instance of this node with {@link NorskControl.audioLevels}.
88
+ */
89
+ export declare class AudioLevelsNode extends AutoProcessorMediaNode<"audio"> {
90
+ close(): void;
91
+ }
92
+ /** @public */
93
+ export interface TimestampNudgerSettings extends ProcessorNodeSettings<TimestampNudgerNode> {
94
+ nudge?: number;
95
+ }
96
+ /**
97
+ * @public
98
+ * {@link NorskTransform.timestampNudge}
99
+ */
100
+ export declare class TimestampNudgerNode extends AutoProcessorMediaNode<"audio" | "video"> {
101
+ nudge(nudge: number): void;
102
+ close(): void;
103
+ }
104
+ /** @public */
105
+ export interface StreamKeyOverrideSettings extends ProcessorNodeSettings<StreamKeyOverrideNode> {
106
+ streamKey: StreamKey;
107
+ }
108
+ /**
109
+ * @public
110
+ * {@link NorskTransform.streamKeyOverride}
111
+ */
112
+ export declare class StreamKeyOverrideNode extends AutoProcessorMediaNode<"audio" | "video" | "subtitle"> {
113
+ close(): void;
114
+ }
115
+ /** @public */
116
+ export interface MetadataOverrideSettings extends ProcessorNodeSettings<MetadataOverrideNode>, MetadataOverrideSettingsUpdate {
117
+ }
118
+ /** @public */
119
+ export interface MetadataOverrideSettingsUpdate {
120
+ video?: {
121
+ /** Override the bitrate metadata of a compressed video stream, or `0` to clear */
122
+ bitrate?: number;
123
+ };
124
+ audio?: {
125
+ /** Override the bitrate metadata of a compressed audio stream, or `0` to clear */
126
+ bitrate?: number;
127
+ /** Override the language metadata of an audio stream, or `""` to clear */
128
+ language?: string;
129
+ };
130
+ subtitles?: {
131
+ /** Override the language metadata of a subtitles stream, or `""` to clear */
132
+ language?: string;
133
+ };
134
+ }
135
+ /**
136
+ * @public
137
+ * {@link NorskTransform.metadataOverride}
138
+ */
139
+ export declare class MetadataOverrideNode extends AutoProcessorMediaNode<"audio" | "video" | "subtitle"> {
140
+ updateConfig(settings: MetadataOverrideSettingsUpdate): void;
141
+ close(): void;
142
+ }
143
+ /** @public */
144
+ export interface SyncSettings extends ProcessorNodeSettings<SyncNode> {
145
+ }
146
+ /**
147
+ * @public
148
+ * {@link NorskTransform.sync}
149
+ */
150
+ export declare class SyncNode extends AutoProcessorMediaNode<"audio" | "video"> {
151
+ close(): void;
152
+ }
153
+ /** @public */
154
+ export interface OpusSettings {
155
+ kind: "opus";
156
+ }
157
+ /** @public */
158
+ export interface AacSettings {
159
+ kind: "aac";
160
+ sampleRate: SampleRate;
161
+ profile: AacProfile;
162
+ }
163
+ /** @public */
164
+ export interface AudioEncoderSettings extends ProcessorNodeSettings<AudioEncoderNode> {
165
+ channelLayout: ChannelLayout;
166
+ bitrate: number;
167
+ outputRenditionName: string;
168
+ codec: OpusSettings | AacSettings;
169
+ }
170
+ /**
171
+ * @public
172
+ * {@link NorskTransform.audioEncoder}
173
+ */
174
+ export declare class AudioEncoderNode extends AutoProcessorMediaNode<"audio"> {
175
+ close(): void;
176
+ }
177
+ /** @public */
178
+ export interface OffsetRect {
179
+ x: number;
180
+ y: number;
181
+ width: number;
182
+ height: number;
183
+ }
184
+ /** @public */
185
+ export interface ComposePart<Pins> {
186
+ pin: Pins;
187
+ sourceRect: OffsetRect;
188
+ destRect: OffsetRect;
189
+ zIndex: number;
190
+ opacity: number;
191
+ id?: string;
192
+ transition?: PartTransition;
193
+ referenceResolution?: Resolution;
194
+ }
195
+ /** @public */
196
+ export interface PartTransition {
197
+ durationMs: number;
198
+ easing?: SimpleEasing;
199
+ }
200
+ /** @public */
201
+ export interface ComposeVideoSettings<Pins extends string> extends ProcessorNodeSettings<ComposeVideoNode<Pins>> {
202
+ referenceStream: Pins;
203
+ parts: readonly ComposePart<Pins>[];
204
+ referenceResolution?: Resolution;
205
+ outputResolution: Resolution;
206
+ outputPixelFormat?: PixelFormat;
207
+ missingStreamBehaviour?: ComposeMissingStreamBehaviour;
208
+ onTransitionComplete?: () => void;
209
+ }
210
+ /** @public */
211
+ export interface ComposeVideoSettingsUpdate<Pins extends string> {
212
+ parts: readonly ComposePart<Pins>[];
213
+ }
214
+ /**
215
+ * @public
216
+ * {@link NorskTransform.composeOverlay}
217
+ */
218
+ export declare class ComposeVideoNode<Pins extends string> extends ProcessorMediaNode<Pins> {
219
+ updateConfig(settings: ComposeVideoSettingsUpdate<Pins>): void;
220
+ close(): void;
221
+ }
222
+ /** @public */
223
+ export interface AudioMixerSource<Pins> {
224
+ /** The name of the InputPin for this source */
225
+ pin: Pins;
226
+ /** A vector of gains for this source, one for each channel */
227
+ channelGains?: readonly Gain[];
228
+ }
229
+ /** @public */
230
+ export interface AudioMixerSettings<Pins extends string> extends ProcessorNodeSettings<AudioMixerNode<Pins>> {
231
+ /** The sources to mix */
232
+ sources: readonly AudioMixerSource<Pins>[];
233
+ /** The name of the output source */
234
+ outputSource: string;
235
+ /** The sample rate of the output */
236
+ sampleRate?: SampleRate;
237
+ }
238
+ /** @public */
239
+ export interface AudioMixerSettingsUpdate<Pins extends string> {
240
+ sources: readonly AudioMixerSource<Pins>[];
241
+ }
242
+ /**
243
+ * @public
244
+ * {@link NorskTransform.audioMixer}
245
+ */
246
+ export declare class AudioMixerNode<Pins extends string> extends ProcessorMediaNode<Pins> {
247
+ updateConfig(settings: AudioMixerSettingsUpdate<Pins>): void;
248
+ close(): void;
249
+ }
250
+ /**
251
+ * @public
252
+ * A relative change in decibels, expressing a power ratio.
253
+ *
254
+ * A value of 0dB means no change, positive values mean an increase in power, and negative values mean a decrease in power.
255
+ */
256
+ export declare type Gain = Db;
257
+ /** @public Config for the {@link AudioMatrixMixerNode} */
258
+ export interface AudioMatrixMixerSettings extends ProcessorNodeSettings<AudioMatrixMixerNode> {
259
+ /** The NxM matrix of gains from N input channels to M output channels */
260
+ channelGains: readonly Gain[][];
261
+ /** The desired output channel layout, such as "5.1" */
262
+ outputChannelLayout: ChannelLayout;
263
+ }
264
+ /** @public Config update for the {@link AudioMatrixMixerNode}.
265
+ * Call {@link AudioMatrixMixerNode.updateConfig} for updating the config.
266
+ */
267
+ export interface AudioMatrixMixerSettingsUpdate {
268
+ /** The NxM updated matrix of gains from N input channels to M output channels */
269
+ channelGains: readonly Gain[][];
270
+ }
271
+ /**
272
+ * @public Mix N audio channels to M audio channels with a matrix of gains.
273
+ * Use {@link NorskTransform.audioMatrixMixer} to create one.
274
+ */
275
+ export declare class AudioMatrixMixerNode extends AutoProcessorMediaNode<"audio"> {
276
+ /** @public */
277
+ updateConfig(settings: AudioMatrixMixerSettingsUpdate): void;
278
+ close(): void;
279
+ }
280
+ /** @public */
281
+ export interface AudioGainSettings extends ProcessorNodeSettings<AudioGainNode> {
282
+ /** A vector of gains for this source, one for each channel */
283
+ channelGains: readonly Gain[];
284
+ }
285
+ /** @public */
286
+ export interface AudioGainSettingsUpdate {
287
+ /** A vector of gains for this source, one for each channel */
288
+ channelGains?: readonly Gain[];
289
+ }
290
+ /**
291
+ * @public
292
+ * {@link NorskTransform.audioGain}
293
+ */
294
+ export declare class AudioGainNode extends AutoProcessorMediaNode<"audio"> {
295
+ updateConfig(settings: AudioGainSettingsUpdate): void;
296
+ close(): void;
297
+ }
298
+ /** @public */
299
+ export interface AudioSplitMultichannelSettings extends ProcessorNodeSettings<AudioSplitMultichannelNode> {
300
+ outputStreamKey: StreamKey;
301
+ }
302
+ /**
303
+ * @public
304
+ * {@link NorskTransform.audioSplitMultichannel}
305
+ */
306
+ export declare class AudioSplitMultichannelNode extends AutoProcessorMediaNode<"audio"> {
307
+ close(): void;
308
+ }
309
+ /** @public */
310
+ export interface AudioBuildMultichannelSettings extends ProcessorNodeSettings<AudioBuildMultichannelNode> {
311
+ channelLayout: ChannelLayout;
312
+ channelList: readonly StreamKey[];
313
+ outputStreamKey: StreamKey;
314
+ }
315
+ /**
316
+ * @public
317
+ * {@link NorskTransform.audioBuildMultichannel}
318
+ */
319
+ export declare class AudioBuildMultichannelNode extends AutoProcessorMediaNode<"audio"> {
320
+ close(): void;
321
+ }
322
+ /** @public */
323
+ export interface AwsTranscribeSettings extends ProcessorNodeSettings<AwsTranscribeNode> {
324
+ awsRegion: string;
325
+ outputStreamId: number;
326
+ language: string;
327
+ sentenceBuildMode: SentenceBuildMode;
328
+ sentenceStabilizationMode: StabilizationMode;
329
+ }
330
+ /**
331
+ * @public
332
+ * {@link NorskTransform.awsTranscribe}
333
+ */
334
+ export declare class AwsTranscribeNode extends AutoProcessorMediaNode<"audio"> {
335
+ close(): void;
336
+ }
337
+ /**
338
+ * @public
339
+ * Methods that allow you to both ingest and egest media from your application
340
+ * at the same time
341
+ */
342
+ export interface NorskDuplex {
343
+ /**
344
+ * Playback audio/video via webrtc to a browser, and accept audio/video input from a browser.
345
+ * The browser client must conform to a custom protocol as implemented in the hosted test page.
346
+ * For general WebRTC ingest prefer the WHIP input node, and for egest to a downstream media server
347
+ * use the WHIP output node.
348
+ * @param settings - Options for the webrtc node
349
+ */
350
+ localWebRTC(settings: LocalWebRTCSettings): Promise<LocalWebRTCNode>;
351
+ }
352
+ /** @public */
353
+ export interface VideoEncodeLadderRung {
354
+ name: string;
355
+ width: number;
356
+ height: number;
357
+ frameRate?: FrameRate;
358
+ /**
359
+ * Specifies the input video's Sample Aspect Ratio (SAR) to be used by the
360
+ * encoder in width:height
361
+ */
362
+ sar?: SampleAspectRatio;
363
+ codec: X264Codec | X265Codec | NvidiaH264 | NvidiaHevc | NetintH264 | NetintHevc;
364
+ }
365
+ /** @public */
366
+ export interface VideoEncodeLadderSettings extends ProcessorNodeSettings<VideoEncodeLadderNode> {
367
+ rungs: readonly VideoEncodeLadderRung[];
368
+ }
369
+ /**
370
+ * @public
371
+ * {@link NorskTransform.videoEncodeLadder}
372
+ */
373
+ export declare class VideoEncodeLadderNode extends AutoProcessorMediaNode<"video"> {
374
+ close(): void;
375
+ }
376
+ /** @public */
377
+ export interface VideoTransformSettings extends ProcessorNodeSettings<VideoTransformNode> {
378
+ resolution?: Resolution;
379
+ frameRate?: FrameRate;
380
+ sar?: SampleAspectRatio;
381
+ }
382
+ /**
383
+ * @public
384
+ * {@link NorskTransform.videoTransform}
385
+ */
386
+ export declare class VideoTransformNode extends AutoProcessorMediaNode<"video"> {
387
+ close(): void;
388
+ }
389
+ /** @public */
390
+ export interface DropRandom {
391
+ kind: "random";
392
+ percentage: number;
393
+ }
394
+ /** @public */
395
+ export interface DropEvery {
396
+ kind: "every";
397
+ every: number;
398
+ }
399
+ /** @public */
400
+ export interface ChaosMonkeySettings extends ProcessorNodeSettings<ChaosMonkeyNode> {
401
+ frameDrop?: DropRandom | DropEvery;
402
+ }
403
+ /**
404
+ * @public
405
+ * {@link NorskTransform.chaosMonkey}
406
+ */
407
+ export declare class ChaosMonkeyNode extends AutoProcessorMediaNode<"audio" | "video" | "subtitle"> {
408
+ close(): void;
409
+ }
410
+ /** @public */
411
+ export interface LocalWebRTCSettings extends ProcessorNodeSettings<LocalWebRTCNode>, StreamStatsMixin {
412
+ }
413
+ /**
414
+ * @public
415
+ * {@link NorskDuplex.localWebRTC}
416
+ */
417
+ export declare class LocalWebRTCNode extends AutoProcessorMediaNode<"audio" | "video"> {
418
+ /** @public The URL of the local player */
419
+ playerUrl: string;
420
+ close(): void;
421
+ }
422
+ /**
423
+ * @public
424
+ * Methods that allow you to manipulate your media streams
425
+ */
426
+ export interface NorskTransform {
427
+ /**
428
+ * Encode a video stream to one or more renditions
429
+ * @param settings - Encode ladder settings
430
+ */
431
+ videoEncodeLadder(settings: VideoEncodeLadderSettings): Promise<VideoEncodeLadderNode>;
432
+ /**
433
+ * Transform a video stream (rescale, etc)
434
+ * @param settings - Transform settings
435
+ */
436
+ videoTransform(settings: VideoTransformSettings): Promise<VideoTransformNode>;
437
+ /**
438
+ * Interferes with a stream by dropping frames
439
+ * @param settings - Chaos monkey settings
440
+ */
441
+ chaosMonkey(settings: ChaosMonkeySettings): Promise<ChaosMonkeyNode>;
442
+ /**
443
+ * Compose multiple video streams together into a single output
444
+ * @param settings - Composition setting
445
+ */
446
+ composeOverlay<Pins extends string>(settings: ComposeVideoSettings<Pins>): Promise<ComposeVideoNode<Pins>>;
447
+ awsTranscribe(settings: AwsTranscribeSettings): Promise<AwsTranscribeNode>;
448
+ /**
449
+ * Mix multiple audio streams together into a single output,
450
+ * with optional gain control on each input.
451
+ * @param settings - Settings for the mixer, including the gain vectors
452
+ */
453
+ audioMixer<Pins extends string>(settings: AudioMixerSettings<Pins>): Promise<AudioMixerNode<Pins>>;
454
+ /**
455
+ * Given an audio stream of N channels, mix it down to M channels through a matrix of NxM gains.
456
+ * @param settings - Settings for the mixer, including the gain matrix
457
+ */
458
+ audioMatrixMixer(settings: AudioMatrixMixerSettings): Promise<AudioMatrixMixerNode>;
459
+ /**
460
+ * Apply gain to an audio stream
461
+ * @param settings - Settings for the gain node
462
+ */
463
+ audioGain(settings: AudioGainSettings): Promise<AudioGainNode>;
464
+ audioBuildMultichannel(settings: AudioBuildMultichannelSettings): Promise<AudioBuildMultichannelNode>;
465
+ audioSplitMultichannel(settings: AudioSplitMultichannelSettings): Promise<AudioSplitMultichannelNode>;
466
+ audioEncoder(settings: AudioEncoderSettings): Promise<AudioEncoderNode>;
467
+ timestampNudge(settings: TimestampNudgerSettings): Promise<TimestampNudgerNode>;
468
+ streamKeyOverride(settings: StreamKeyOverrideSettings): Promise<StreamKeyOverrideNode>;
469
+ metadataOverride(settings: MetadataOverrideSettings): Promise<MetadataOverrideNode>;
470
+ sync(settings: SyncSettings): Promise<SyncNode>;
471
+ }
472
+ /**
473
+ * @public
474
+ * Methods that allow you to control and monitor media streams
475
+ */
476
+ export interface NorskControl {
477
+ /**
478
+ * Switch between multiple input sources via a hard cut. May be used to switch between
479
+ * sources of possibly different configurations or without decoding.
480
+ * @param settings - Options for the switcher
481
+ */
482
+ hardSwitcher<Pins extends string>(settings: HardSwitcherSettings<Pins>): Promise<HardSwitcherNode<Pins>>;
483
+ /**
484
+ * Switch between multiple input sources without interruption, via a transition.
485
+ * @param settings - Options for the switcher
486
+ */
487
+ smoothSwitcher<Pins extends string>(settings: SmoothSwitcherSettings<Pins>): Promise<SmoothSwitcherNode<Pins>>;
488
+ /**
489
+ * Record statistical information about media streams, including bitrate,
490
+ * frame rate, and number of keyframes, measured over some configurable
491
+ * sampling windows.
492
+ * @param settings - Callback and sampling intervals
493
+ */
494
+ streamStats(settings: StreamStatsSettings): Promise<StreamStatsNode>;
495
+ /**
496
+ * Monitor the volume of an audio stream
497
+ * @param settings - Callback and options for the level data
498
+ */
499
+ audioLevels(settings: AudioLevelsSettings): Promise<AudioLevelsNode>;
500
+ }
501
+ /** @public */
502
+ export declare class NorskProcessor {
503
+ /**
504
+ * Implements the {@link NorskControl} interface
505
+ */
506
+ control: NorskControl;
507
+ /**
508
+ * Implements the {@link NorskTransform} interface
509
+ */
510
+ transform: NorskTransform;
511
+ close(): Promise<void>;
512
+ constructor(client: MediaClient);
513
+ }
514
+ export {};
515
+ //# sourceMappingURL=processor.d.ts.map