@remedia/node 0.0.0-stage → 0.1.0-dev.1
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/LICENSE +21 -0
- package/README.md +144 -2
- package/THIRD_PARTY_LICENSES.txt +15655 -0
- package/THIRD_PARTY_NOTICES.md +126 -0
- package/dist/discord.d.ts +149 -0
- package/dist/discord.js +1168 -0
- package/dist/events.d.ts +21 -0
- package/dist/events.js +28 -0
- package/dist/filters.d.ts +22 -0
- package/dist/filters.js +52 -0
- package/dist/gateway.d.ts +88 -0
- package/dist/gateway.js +100 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -0
- package/dist/input.d.ts +46 -0
- package/dist/input.js +135 -0
- package/dist/lifecycle.d.ts +315 -0
- package/dist/lifecycle.js +109 -0
- package/dist/playback.d.ts +73 -0
- package/dist/playback.js +445 -0
- package/dist/remedia.d.ts +51 -0
- package/dist/remedia.js +150 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.js +75 -0
- package/native.d.ts +162 -0
- package/native.js +778 -0
- package/package.json +86 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Remedia is licensed under MIT; see `LICENSE`. Third-party dependencies retain their own terms.
|
|
4
|
+
This page highlights the major components. The accompanying `THIRD_PARTY_LICENSES.txt` reproduces
|
|
5
|
+
additional upstream copyright notices, conditions, and disclaimers required for redistribution,
|
|
6
|
+
including native Rust dependencies, Unicode data, and the Rust standard library. Keep both notice
|
|
7
|
+
files with redistributed packages and binaries.
|
|
8
|
+
|
|
9
|
+
## FFmpeg 7 — independently installed runtime libraries
|
|
10
|
+
|
|
11
|
+
Remedia dynamically links FFmpeg 7. Consumers install the shared libraries independently; they are
|
|
12
|
+
not bundled in Remedia's npm packages or standalone server binaries. FFmpeg's licensing depends on
|
|
13
|
+
the selected build, enabled components, and external libraries. GPL-enabled builds are not rejected.
|
|
14
|
+
Users must comply with applicable licensing requirements for their chosen build and deployment.
|
|
15
|
+
See [official licensing information](https://ffmpeg.org/legal.html) and
|
|
16
|
+
[FFmpeg source code](https://git.ffmpeg.org/ffmpeg.git).
|
|
17
|
+
|
|
18
|
+
The Rust `ffmpeg-next` and `ffmpeg-sys-next` bindings have separate WTFPL terms, reproduced in the
|
|
19
|
+
license appendix; those terms do not apply to FFmpeg itself.
|
|
20
|
+
|
|
21
|
+
## libopus — statically included
|
|
22
|
+
|
|
23
|
+
`opus2` 0.4.0 uses `libopus_sys` 0.3.3 with the bundled libopus backend. Its Opus source is compiled
|
|
24
|
+
and statically linked into the native addon and standalone server. A system libopus is not needed.
|
|
25
|
+
The bundled source's `opus/COPYING` is reproduced verbatim below. See
|
|
26
|
+
[Opus source](https://gitlab.xiph.org/xiph/opus) and [official licensing](https://opus-codec.org/license/).
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
|
|
30
|
+
Jean-Marc Valin, Timothy B. Terriberry,
|
|
31
|
+
CSIRO, Gregory Maxwell, Mark Borgerding,
|
|
32
|
+
Erik de Castro Lopo, Mozilla, Amazon
|
|
33
|
+
|
|
34
|
+
Redistribution and use in source and binary forms, with or without
|
|
35
|
+
modification, are permitted provided that the following conditions
|
|
36
|
+
are met:
|
|
37
|
+
|
|
38
|
+
- Redistributions of source code must retain the above copyright
|
|
39
|
+
notice, this list of conditions and the following disclaimer.
|
|
40
|
+
|
|
41
|
+
- Redistributions in binary form must reproduce the above copyright
|
|
42
|
+
notice, this list of conditions and the following disclaimer in the
|
|
43
|
+
documentation and/or other materials provided with the distribution.
|
|
44
|
+
|
|
45
|
+
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
|
46
|
+
names of specific contributors, may be used to endorse or promote
|
|
47
|
+
products derived from this software without specific prior written
|
|
48
|
+
permission.
|
|
49
|
+
|
|
50
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
51
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
52
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
53
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
54
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
55
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
56
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
57
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
58
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
59
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
60
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
61
|
+
|
|
62
|
+
Opus is subject to the royalty-free patent licenses which are
|
|
63
|
+
specified at:
|
|
64
|
+
|
|
65
|
+
Xiph.Org Foundation:
|
|
66
|
+
https://datatracker.ietf.org/ipr/1524/
|
|
67
|
+
|
|
68
|
+
Microsoft Corporation:
|
|
69
|
+
https://datatracker.ietf.org/ipr/1914/
|
|
70
|
+
|
|
71
|
+
Broadcom Corporation:
|
|
72
|
+
https://datatracker.ietf.org/ipr/1526/
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The bundled source also supplies this `opus/LICENSE_PLEASE_READ.txt`:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
Contributions to the collaboration shall not be considered confidential.
|
|
79
|
+
|
|
80
|
+
Each contributor represents and warrants that it has the right and
|
|
81
|
+
authority to license copyright in its contributions to the collaboration.
|
|
82
|
+
|
|
83
|
+
Each contributor agrees to license the copyright in the contributions
|
|
84
|
+
under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License.
|
|
85
|
+
|
|
86
|
+
Please see the IPR statements submitted to the IETF for the complete
|
|
87
|
+
patent licensing details:
|
|
88
|
+
|
|
89
|
+
Xiph.Org Foundation:
|
|
90
|
+
https://datatracker.ietf.org/ipr/1524/
|
|
91
|
+
|
|
92
|
+
Microsoft Corporation:
|
|
93
|
+
https://datatracker.ietf.org/ipr/1914/
|
|
94
|
+
|
|
95
|
+
Skype Limited:
|
|
96
|
+
https://datatracker.ietf.org/ipr/1602/
|
|
97
|
+
|
|
98
|
+
Broadcom Corporation:
|
|
99
|
+
https://datatracker.ietf.org/ipr/1526/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Discord voice and cryptography
|
|
103
|
+
|
|
104
|
+
[DAVE (`davey` 0.2.0)](https://crates.io/crates/davey/0.2.0) and
|
|
105
|
+
[OpenMLS 0.8.3](https://crates.io/crates/openmls/0.8.3) provide native voice encryption components
|
|
106
|
+
under their upstream MIT terms. Native TLS/crypto also incorporates
|
|
107
|
+
[ring 0.17.14](https://crates.io/crates/ring/0.17.14), whose Apache-2.0 and ISC notices include
|
|
108
|
+
BoringSSL-derived code. Their actual license and copyright notices are in `THIRD_PARTY_LICENSES.txt`.
|
|
109
|
+
|
|
110
|
+
HPKE components are MPL-2.0 covered and used unmodified. Corresponding source is available from
|
|
111
|
+
these exact published archives: [hpke-rs 0.6.1](https://crates.io/api/v1/crates/hpke-rs/0.6.1/download),
|
|
112
|
+
[hpke-rs-crypto 0.6.1](https://crates.io/api/v1/crates/hpke-rs-crypto/0.6.1/download),
|
|
113
|
+
[hpke-rs-libcrux 0.6.1](https://crates.io/api/v1/crates/hpke-rs-libcrux/0.6.1/download), and
|
|
114
|
+
[hpke-rs-rust-crypto 0.6.1](https://crates.io/api/v1/crates/hpke-rs-rust-crypto/0.6.1/download).
|
|
115
|
+
The MPL-2.0 text is in the license appendix. Redistributors must preserve source availability and
|
|
116
|
+
applicable notices, including for any modifications they make.
|
|
117
|
+
|
|
118
|
+
## JavaScript runtime dependency
|
|
119
|
+
|
|
120
|
+
The client uses [ws 8.22.1](https://registry.npmjs.org/ws/-/ws-8.22.1.tgz), installed separately by
|
|
121
|
+
npm under MIT terms. Its full copyright and license text is in `THIRD_PARTY_LICENSES.txt`.
|
|
122
|
+
The packages compile with `tsc`; development tools and documentation-site dependencies are not
|
|
123
|
+
bundled into the npm libraries or standalone server.
|
|
124
|
+
|
|
125
|
+
Review these files when dependencies, native build options, or distributed artifacts change.
|
|
126
|
+
Their presence does not guarantee legal compliance.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { RemediaEventEmitter } from './events.js';
|
|
2
|
+
import { PlaybackHooks, type PlayOptions, type SessionLifecycleEvents } from './lifecycle.js';
|
|
3
|
+
import { FilterControls } from './filters.js';
|
|
4
|
+
import type { MediaSource } from './input.js';
|
|
5
|
+
import type { AudioStreamInfo, PlaybackPosition, PlaybackState, VoiceConnectionState } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Identity, initial playback configuration, and Gateway voice flags for one guild session. The channel is a mutable destination, while userId identifies the bot.
|
|
8
|
+
*/
|
|
9
|
+
export interface DiscordSessionOptions {
|
|
10
|
+
/** Discord server snowflake as a decimal string. */
|
|
11
|
+
guildId: string;
|
|
12
|
+
/** Voice channel snowflake as a decimal string. */
|
|
13
|
+
channelId: string;
|
|
14
|
+
/** Bot user snowflake as a decimal string. */
|
|
15
|
+
userId: string;
|
|
16
|
+
/** Discord Gateway self-deaf state; defaults to true. */
|
|
17
|
+
selfDeaf?: boolean;
|
|
18
|
+
/** Discord Gateway self-mute state; defaults to false. */
|
|
19
|
+
selfMute?: boolean;
|
|
20
|
+
/** Session master linear gain, finite from 0 through 2; defaults to 1. */
|
|
21
|
+
volume?: number;
|
|
22
|
+
/** Trusted raw FFmpeg audio filtergraph; defaults to null. Native syntax validation occurs during backend configuration before playback. */
|
|
23
|
+
filterGraph?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/** Cancellation and timeout controls for obtaining credentials and establishing a voice transport. */
|
|
26
|
+
export interface DiscordConnectOptions {
|
|
27
|
+
/** Optional signal that cancels Gateway negotiation and pending transport setup. */
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
/** Maximum time to receive Gateway credentials and establish voice transport/DAVE. */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One Discord voice session. The caller supplies a Gateway send adapter to `Remedia.create()` and
|
|
34
|
+
* forwards raw dispatch packets to `Remedia.receive()`; this session collects the matching voice
|
|
35
|
+
* credentials and opens the native transport after both dispatches arrive.
|
|
36
|
+
* @typeParam Metadata - Application-owned metadata attached to playback generations.
|
|
37
|
+
*/
|
|
38
|
+
export declare class DiscordSession<Metadata = unknown> extends RemediaEventEmitter<SessionLifecycleEvents<Metadata>> {
|
|
39
|
+
#private;
|
|
40
|
+
/** Opaque Remedia session identity used to correlate events; distinct from the Discord bot user ID. */
|
|
41
|
+
readonly sessionId: `${string}-${string}-${string}-${string}-${string}`;
|
|
42
|
+
/** Discord guild snowflake as a decimal string; unique within the owning client. */
|
|
43
|
+
readonly guildId: string;
|
|
44
|
+
/** Discord bot user snowflake as a decimal string; separate from Remedia session identity. */
|
|
45
|
+
readonly userId: string;
|
|
46
|
+
/** Persistent raw FFmpeg filtergraph controls for this session. */
|
|
47
|
+
readonly filters: FilterControls;
|
|
48
|
+
/** Ordered, awaited local pre-play hooks; listeners are separate from hooks. */
|
|
49
|
+
readonly hooks: PlaybackHooks<Metadata>;
|
|
50
|
+
/** Current requested voice destination; independent of playback identity. */
|
|
51
|
+
get channelId(): string;
|
|
52
|
+
/** Discord Gateway self-deaf state; defaults to true and persists across moves and recovery. */
|
|
53
|
+
get selfDeaf(): boolean;
|
|
54
|
+
/** Discord Gateway self-mute state; defaults to false and persists across moves and recovery. */
|
|
55
|
+
get selfMute(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Replace only the voice transport. A newer move supersedes a pending move.
|
|
58
|
+
* @param channelId - Destination Discord voice channel snowflake as a positive decimal string.
|
|
59
|
+
* @returns Resolves when the requested destination connects; rejects on supersession, cancellation, or connection failure.
|
|
60
|
+
*/
|
|
61
|
+
move(channelId: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Update Discord self-deaf state without rebuilding playback. Unchanged values send nothing.
|
|
64
|
+
* @param enabled - The requested Discord self-state flag.
|
|
65
|
+
* @returns Resolves after storing the flag or sending its Gateway update; rejects if the update fails.
|
|
66
|
+
*/
|
|
67
|
+
setSelfDeaf(enabled: boolean): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Update Discord self-mute state without changing audio gain or playback pause. Unchanged values send nothing.
|
|
70
|
+
* @param enabled - The requested Discord self-state flag.
|
|
71
|
+
* @returns Resolves after storing the flag or sending its Gateway update; rejects if the update fails.
|
|
72
|
+
*/
|
|
73
|
+
setSelfMute(enabled: boolean): Promise<void>;
|
|
74
|
+
/** Current voice transport state. A connected voice WebSocket may temporarily be reconnecting. */
|
|
75
|
+
get connectionState(): VoiceConnectionState;
|
|
76
|
+
/** Most recent Gateway or native transport failure, if any. */
|
|
77
|
+
get connectionError(): string | null;
|
|
78
|
+
/** Current playback lifecycle state. */
|
|
79
|
+
get state(): PlaybackState;
|
|
80
|
+
/** Latest source and output timeline measurements in milliseconds. */
|
|
81
|
+
get position(): PlaybackPosition;
|
|
82
|
+
/** Source duration in milliseconds, or null when unknown. */
|
|
83
|
+
get durationMs(): number | null;
|
|
84
|
+
/** Most recent playback or voice failure message, or null when no error is available. */
|
|
85
|
+
get error(): string | null;
|
|
86
|
+
/** Current normalized linear master gain, from 0.0 (mute) through 2.0. */
|
|
87
|
+
get volume(): number;
|
|
88
|
+
/** Current native source generation, useful to adapters that preserve event correlation. */
|
|
89
|
+
get generation(): number;
|
|
90
|
+
/**
|
|
91
|
+
* Set master gain independently of this session's configured filtergraph.
|
|
92
|
+
* @param gain - Finite linear master gain from 0 through 2; 1 leaves amplitude unchanged.
|
|
93
|
+
* @returns Resolves after the gain is stored or applied; rejects for non-finite gain or values outside 0 through 2.
|
|
94
|
+
* @throws {RangeError} If gain is non-finite or outside the inclusive range 0 through 2.
|
|
95
|
+
*/
|
|
96
|
+
setVolume(gain: number): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Request a Gateway voice join and wait until both voice dispatches have arrived and the native
|
|
99
|
+
* voice transport has completed its DAVE setup. Repeated calls while connecting share a promise.
|
|
100
|
+
* @param options - Optional cancellation signal and positive timeout in milliseconds; defaults to 45000.
|
|
101
|
+
* @returns Resolves when connected; rejects on timeout, cancellation, session loss, or transport failure.
|
|
102
|
+
*/
|
|
103
|
+
connect(options?: DiscordConnectOptions): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Begin playback on this connected voice session. The decoder and Opus encoder remain in core;
|
|
106
|
+
* this object only associates their output with the native Discord transport.
|
|
107
|
+
* @param source - Encoded media input; Buffer and caller-owned binary Readable inputs require embedded mode.
|
|
108
|
+
* @param options - Optional metadata for this generation and a cancellation signal.
|
|
109
|
+
* @returns Selected stream metadata once startup succeeds; rejects if hooks, input opening, or playback startup fail.
|
|
110
|
+
*/
|
|
111
|
+
play(source: MediaSource, options?: PlayOptions<Metadata>): Promise<AudioStreamInfo>;
|
|
112
|
+
/**
|
|
113
|
+
* Pause the current playback without replacing its decoder or source generation.
|
|
114
|
+
* @returns Resolves when the backend accepts the pause request.
|
|
115
|
+
*/
|
|
116
|
+
pause(): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Resume paused playback on its existing source generation.
|
|
119
|
+
* @returns Resolves when the backend accepts the resume request.
|
|
120
|
+
*/
|
|
121
|
+
resume(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Seek on the original media timeline; non-seekable and one-shot sources may reject.
|
|
124
|
+
* @param positionMs - Non-negative finite position on the original media timeline, in milliseconds.
|
|
125
|
+
* @returns Resolves after the backend accepts the seek; rejects for invalid positions or unsupported inputs.
|
|
126
|
+
*/
|
|
127
|
+
seek(positionMs: number): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Stop the active playback generation and release its input without leaving the voice channel.
|
|
130
|
+
* @returns Resolves after the backend stops the active source.
|
|
131
|
+
*/
|
|
132
|
+
stop(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Wait for the current playback generation to reach a terminal state.
|
|
135
|
+
* @returns The terminal playback state for the generation captured by this wait.
|
|
136
|
+
*/
|
|
137
|
+
wait(): Promise<PlaybackState>;
|
|
138
|
+
/**
|
|
139
|
+
* Leave the Discord channel through Gateway OP 4 and close the native transport. This does not
|
|
140
|
+
* dispose the wrapper, so `connect()` can be called again with fresh Gateway dispatches.
|
|
141
|
+
* @returns Resolves after cleanup; concurrent disconnects share cleanup work.
|
|
142
|
+
*/
|
|
143
|
+
disconnect(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Disconnect and unregister this session.
|
|
146
|
+
* @returns Resolves after disposal; rejects if resource cleanup fails.
|
|
147
|
+
*/
|
|
148
|
+
dispose(): Promise<void>;
|
|
149
|
+
}
|