@remedia/node 0.0.0-stage → 0.1.0-dev.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/native.d.ts ADDED
@@ -0,0 +1,162 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
12
+ export declare class NativeRemedia {
13
+ /** Forward this context's bounded diagnostic queue to one JavaScript callback. */
14
+ setDebugCallback(callback: (arg: NativeDiagnosticEvent) => void): void
15
+ /** Number of events discarded by the observability queue or full N-API callback queue. */
16
+ get droppedDebugEvents(): number
17
+ /** Open a Discord voice transport using session data collected by the caller's Gateway client. */
18
+ connectVoice(options: NativeVoiceOptions): Promise<NativeVoiceSessionIds>
19
+ /**
20
+ * Replace only the Discord transport while retaining the existing
21
+ * playback decoder, filters, volume, pause state, and output timeline.
22
+ */
23
+ replaceVoice(voiceId: string, generation: number, options: NativeVoiceOptions): Promise<void>
24
+ /**
25
+ * Invalidate an in-flight transport replacement before newer Gateway
26
+ * credentials are used. This does not touch the active playback session.
27
+ */
28
+ invalidateVoiceRecovery(voiceId: string, generation: number): void
29
+ /** Close the old Discord transport while leaving the playback session parked for recovery. */
30
+ suspendVoice(voiceId: string, generation: number): Promise<void>
31
+ /** Terminate a playback parked during voice recovery after retries fail. */
32
+ failVoiceRecovery(voiceId: string, message: string): void
33
+ /** Current transport state for one voice session. */
34
+ voiceState(voiceId: string): string
35
+ /** Return the latest transport failure for one voice session. */
36
+ voiceError(voiceId: string): string | null
37
+ /** Stop playback and release the associated voice transport. */
38
+ disconnectVoice(voiceId: string): Promise<void>
39
+ /** Forget a voice session after its transport has been disconnected. */
40
+ releaseVoiceSession(voiceId: string): void
41
+ /** Create a bounded native byte input for one Node.js Readable producer. */
42
+ createByteStream(): string
43
+ /**
44
+ * Copy one Node buffer into the native-owned bounded input, applying
45
+ * backpressure when the decoder has not consumed enough pending bytes.
46
+ */
47
+ writeByteStream(streamId: string, chunk: Buffer): Promise<void>
48
+ /**
49
+ * Signal a clean producer EOF. The stream handle remains valid until it is
50
+ * cancelled so playback can resolve its source if EOF arrives quickly.
51
+ */
52
+ finishByteStream(streamId: string): Promise<void>
53
+ /** Propagate a JavaScript Readable error through FFmpeg to playback state. */
54
+ failByteStream(streamId: string, message: string): Promise<void>
55
+ /**
56
+ * Cancel an input and wake any native readers or writers blocked by its
57
+ * bounded queue. Repeated calls are harmless.
58
+ */
59
+ cancelByteStream(streamId: string): void
60
+ /** Create an isolated, diagnostics-only Remedia context from environment configuration. */
61
+ static create(): Promise<NativeRemedia>
62
+ /**
63
+ * Stop all playback, disconnect all voice transports, flush telemetry, and close the context.
64
+ * This method is safe to call repeatedly.
65
+ */
66
+ close(): Promise<void>
67
+ /** Create a decoder-only session that consumes frames into a no-op output. */
68
+ createPlaybackSession(): string
69
+ /** Start decoding into the null output or the associated Discord Opus sender. */
70
+ play(playbackId: string, source: NativeMediaSource): Promise<NativeStreamInfo>
71
+ /** Request playback pause at the current output frame boundary. */
72
+ pause(playbackId: string): Promise<void>
73
+ /** Resume a paused playback session. */
74
+ resume(playbackId: string): Promise<void>
75
+ /** Seek to a media position in milliseconds. */
76
+ seek(playbackId: string, positionMs: number): Promise<void>
77
+ /** Validate and replace the trusted native FFmpeg audio filtergraph. */
78
+ playbackSetFilterGraph(playbackId: string, graph: string): Promise<void>
79
+ /** Clear the current native audio filtergraph. */
80
+ playbackClearFilterGraph(playbackId: string): Promise<void>
81
+ /** Current configured raw FFmpeg filtergraph, if any. */
82
+ playbackFilterGraph(playbackId: string): string | null
83
+ /** Set normalized linear master gain in the inclusive range 0.0 through 2.0. */
84
+ playbackSetVolume(playbackId: string, gain: number): Promise<void>
85
+ /** Current normalized linear master gain. */
86
+ playbackVolume(playbackId: string): number
87
+ /** Validate a filtergraph before a Discord voice session has a native playback object. */
88
+ validateFilterGraph(graph: string): Promise<void>
89
+ /** Stop playback without disconnecting its Discord voice transport. */
90
+ stop(playbackId: string): Promise<void>
91
+ /** Capture the source generation before an asynchronous wait is scheduled. */
92
+ playbackGeneration(playbackId: string): string
93
+ /** Wait for a generation captured synchronously by the JavaScript wrapper. */
94
+ wait(playbackId: string, generation: string): Promise<string>
95
+ /** Current playback lifecycle state. */
96
+ playbackState(playbackId: string): string
97
+ /** Source media, filtered output submission, and output-reported played positions. */
98
+ playbackPosition(playbackId: string): NativePlaybackPosition
99
+ /** Known media duration in milliseconds. */
100
+ playbackDurationMs(playbackId: string): number | null
101
+ /** Latest decoder, resampler, output, or worker failure. */
102
+ playbackError(playbackId: string): string | null
103
+ /** Stop and forget a standalone playback session. Voice sessions remain connected. */
104
+ disposePlaybackSession(playbackId: string): Promise<void>
105
+ }
106
+
107
+ export interface NativeDiagnosticEvent {
108
+ timestamp: number
109
+ severity: string
110
+ target: string
111
+ event: string
112
+ message?: string
113
+ playbackId?: string
114
+ voiceConnectionId?: string
115
+ fields: Record<string, NativeDiagnosticField>
116
+ }
117
+
118
+ export interface NativeDiagnosticField {
119
+ kind: string
120
+ stringValue?: string
121
+ boolValue?: boolean
122
+ numberValue?: number
123
+ }
124
+
125
+ export interface NativeMediaSource {
126
+ /** Explicitly `file`, `url`, `buffer`, or `stream`. */
127
+ kind: string
128
+ value?: string
129
+ bytes?: Buffer
130
+ }
131
+
132
+ export interface NativePlaybackPosition {
133
+ mediaMs?: number
134
+ mediaPositionAccuracy?: string
135
+ submittedMs: number
136
+ playedMs?: number
137
+ }
138
+
139
+ export interface NativeStreamInfo {
140
+ streamIndex: number
141
+ codec: string
142
+ sampleRate?: number
143
+ channels?: number
144
+ channelLayout?: string
145
+ durationMs?: number
146
+ bitRate?: number
147
+ metadata: Record<string, string>
148
+ }
149
+
150
+ export interface NativeVoiceOptions {
151
+ guildId: string
152
+ channelId: string
153
+ userId: string
154
+ sessionId: string
155
+ token: string
156
+ endpoint: string
157
+ }
158
+
159
+ export interface NativeVoiceSessionIds {
160
+ voiceId: string
161
+ playbackId: string
162
+ }