piixishstream 0.0.0-stage → 1.0.2
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/README.md +124 -2
- package/dist/client/GatewayEvents.d.ts +30 -0
- package/dist/client/GatewayEvents.js +2 -0
- package/dist/client/GatewayEvents.js.map +1 -0
- package/dist/client/GatewayOpCodes.d.ts +40 -0
- package/dist/client/GatewayOpCodes.js +42 -0
- package/dist/client/GatewayOpCodes.js.map +1 -0
- package/dist/client/Streamer.d.ts +30 -0
- package/dist/client/Streamer.js +188 -0
- package/dist/client/Streamer.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/processing/AnnexBBitstreamReaderWriter.d.ts +23 -0
- package/dist/client/processing/AnnexBBitstreamReaderWriter.js +149 -0
- package/dist/client/processing/AnnexBBitstreamReaderWriter.js.map +1 -0
- package/dist/client/processing/AnnexBHelper.d.ts +93 -0
- package/dist/client/processing/AnnexBHelper.js +127 -0
- package/dist/client/processing/AnnexBHelper.js.map +1 -0
- package/dist/client/processing/SPSVUIRewriter.d.ts +1 -0
- package/dist/client/processing/SPSVUIRewriter.js +297 -0
- package/dist/client/processing/SPSVUIRewriter.js.map +1 -0
- package/dist/client/voice/BaseMediaConnection.d.ts +80 -0
- package/dist/client/voice/BaseMediaConnection.js +552 -0
- package/dist/client/voice/BaseMediaConnection.js.map +1 -0
- package/dist/client/voice/CodecPayloadType.d.ts +59 -0
- package/dist/client/voice/CodecPayloadType.js +60 -0
- package/dist/client/voice/CodecPayloadType.js.map +1 -0
- package/dist/client/voice/StreamConnection.d.ts +11 -0
- package/dist/client/voice/StreamConnection.js +34 -0
- package/dist/client/voice/StreamConnection.js.map +1 -0
- package/dist/client/voice/VoiceConnection.d.ts +8 -0
- package/dist/client/voice/VoiceConnection.js +15 -0
- package/dist/client/voice/VoiceConnection.js.map +1 -0
- package/dist/client/voice/VoiceMessageTypes.d.ts +178 -0
- package/dist/client/voice/VoiceMessageTypes.js +2 -0
- package/dist/client/voice/VoiceMessageTypes.js.map +1 -0
- package/dist/client/voice/VoiceOpCodes.d.ts +35 -0
- package/dist/client/voice/VoiceOpCodes.js +38 -0
- package/dist/client/voice/VoiceOpCodes.js.map +1 -0
- package/dist/client/voice/WebRtcWrapper.d.ts +23 -0
- package/dist/client/voice/WebRtcWrapper.js +159 -0
- package/dist/client/voice/WebRtcWrapper.js.map +1 -0
- package/dist/client/voice/index.d.ts +4 -0
- package/dist/client/voice/index.js +6 -0
- package/dist/client/voice/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/media/AudioStream.d.ts +7 -0
- package/dist/media/AudioStream.js +12 -0
- package/dist/media/AudioStream.js.map +1 -0
- package/dist/media/BaseMediaStream.d.ts +31 -0
- package/dist/media/BaseMediaStream.js +164 -0
- package/dist/media/BaseMediaStream.js.map +1 -0
- package/dist/media/LibavCodecId.d.ts +541 -0
- package/dist/media/LibavCodecId.js +553 -0
- package/dist/media/LibavCodecId.js.map +1 -0
- package/dist/media/LibavDecoder.d.ts +5 -0
- package/dist/media/LibavDecoder.js +43 -0
- package/dist/media/LibavDecoder.js.map +1 -0
- package/dist/media/LibavDemuxer.d.ts +44 -0
- package/dist/media/LibavDemuxer.js +231 -0
- package/dist/media/LibavDemuxer.js.map +1 -0
- package/dist/media/VideoStream.d.ts +7 -0
- package/dist/media/VideoStream.js +12 -0
- package/dist/media/VideoStream.js.map +1 -0
- package/dist/media/encoders/index.d.ts +26 -0
- package/dist/media/encoders/index.js +12 -0
- package/dist/media/encoders/index.js.map +1 -0
- package/dist/media/encoders/merge.d.ts +3 -0
- package/dist/media/encoders/merge.js +10 -0
- package/dist/media/encoders/merge.js.map +1 -0
- package/dist/media/encoders/nvenc.d.ts +10 -0
- package/dist/media/encoders/nvenc.js +23 -0
- package/dist/media/encoders/nvenc.js.map +1 -0
- package/dist/media/encoders/software.d.ts +17 -0
- package/dist/media/encoders/software.js +31 -0
- package/dist/media/encoders/software.js.map +1 -0
- package/dist/media/encoders/vaapi.d.ts +6 -0
- package/dist/media/encoders/vaapi.js +22 -0
- package/dist/media/encoders/vaapi.js.map +1 -0
- package/dist/media/index.d.ts +4 -0
- package/dist/media/index.js +5 -0
- package/dist/media/index.js.map +1 -0
- package/dist/media/newApi.d.ts +130 -0
- package/dist/media/newApi.js +409 -0
- package/dist/media/newApi.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.js +65 -0
- package/dist/utils.js.map +1 -0
- package/package.json +82 -5
- package/src/client/GatewayEvents.ts +48 -0
- package/src/client/GatewayOpCodes.ts +40 -0
- package/src/client/Streamer.ts +259 -0
- package/src/client/index.ts +3 -0
- package/src/client/processing/AnnexBBitstreamReaderWriter.ts +148 -0
- package/src/client/processing/AnnexBHelper.ts +134 -0
- package/src/client/processing/SPSVUIRewriter.ts +332 -0
- package/src/client/voice/BaseMediaConnection.ts +639 -0
- package/src/client/voice/CodecPayloadType.ts +59 -0
- package/src/client/voice/MediaUdp.ts.bak +171 -0
- package/src/client/voice/StreamConnection.ts +38 -0
- package/src/client/voice/VoiceConnection.ts +19 -0
- package/src/client/voice/VoiceMessageTypes.ts +263 -0
- package/src/client/voice/VoiceOpCodes.ts +36 -0
- package/src/client/voice/WebRtcWrapper.ts +218 -0
- package/src/client/voice/index.ts +5 -0
- package/src/index.ts +3 -0
- package/src/media/AudioStream.ts +18 -0
- package/src/media/BaseMediaStream.ts +198 -0
- package/src/media/LibavCodecId.ts +564 -0
- package/src/media/LibavDecoder.ts +47 -0
- package/src/media/LibavDemuxer.ts +293 -0
- package/src/media/VideoStream.ts +17 -0
- package/src/media/encoders/index.ts +27 -0
- package/src/media/encoders/merge.ts +14 -0
- package/src/media/encoders/nvenc.ts +38 -0
- package/src/media/encoders/software.ts +76 -0
- package/src/media/encoders/vaapi.ts +29 -0
- package/src/media/index.ts +4 -0
- package/src/media/newApi.ts +642 -0
- package/src/utils.ts +101 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import udpCon from 'node:dgram';
|
|
2
|
+
import { isIP } from 'node:net';
|
|
3
|
+
import { AudioPacketizer } from '../packet/AudioPacketizer.js';
|
|
4
|
+
import {
|
|
5
|
+
VideoPacketizerH264,
|
|
6
|
+
VideoPacketizerH265
|
|
7
|
+
} from '../packet/VideoPacketizerAnnexB.js';
|
|
8
|
+
import { VideoPacketizerVP8 } from '../packet/VideoPacketizerVP8.js';
|
|
9
|
+
import { normalizeVideoCodec } from '../../utils.js';
|
|
10
|
+
import type { BaseMediaPacketizer } from '../packet/BaseMediaPacketizer.js';
|
|
11
|
+
import type { BaseMediaConnection } from './BaseMediaConnection.js';
|
|
12
|
+
|
|
13
|
+
// credit to discord.js
|
|
14
|
+
function parseLocalPacket(message: Buffer) {
|
|
15
|
+
const packet = Buffer.from(message);
|
|
16
|
+
|
|
17
|
+
const ip = packet.subarray(8, packet.indexOf(0, 8)).toString('utf8');
|
|
18
|
+
|
|
19
|
+
if (!isIP(ip)) {
|
|
20
|
+
throw new Error('Malformed IP address');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const port = packet.readUInt16BE(packet.length - 2);
|
|
24
|
+
|
|
25
|
+
return { ip, port };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class MediaUdp {
|
|
29
|
+
private _mediaConnection: BaseMediaConnection;
|
|
30
|
+
private _socket: udpCon.Socket | null = null;
|
|
31
|
+
private _ready = false;
|
|
32
|
+
private _audioPacketizer?: BaseMediaPacketizer;
|
|
33
|
+
private _videoPacketizer?: BaseMediaPacketizer;
|
|
34
|
+
private _ip?: string;
|
|
35
|
+
private _port?: number;
|
|
36
|
+
|
|
37
|
+
constructor(voiceConnection: BaseMediaConnection) {
|
|
38
|
+
this._mediaConnection = voiceConnection;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public get audioPacketizer(): BaseMediaPacketizer | undefined {
|
|
42
|
+
return this._audioPacketizer;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public get videoPacketizer(): BaseMediaPacketizer | undefined {
|
|
46
|
+
// This will never be undefined anyway, so it's safe
|
|
47
|
+
return this._videoPacketizer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get mediaConnection(): BaseMediaConnection {
|
|
51
|
+
return this._mediaConnection;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public get ip()
|
|
55
|
+
{
|
|
56
|
+
return this._ip;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get port()
|
|
60
|
+
{
|
|
61
|
+
return this._port;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public async sendAudioFrame(frame: Buffer, frametime: number): Promise<void> {
|
|
65
|
+
if(!this.ready) return;
|
|
66
|
+
await this.audioPacketizer?.sendFrame(frame, frametime);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async sendVideoFrame(frame: Buffer, frametime: number): Promise<void> {
|
|
70
|
+
if(!this.ready) return;
|
|
71
|
+
await this.videoPacketizer?.sendFrame(frame, frametime);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public setPacketizer(videoCodec: string): void {
|
|
75
|
+
if (!this.mediaConnection.webRtcParams)
|
|
76
|
+
throw new Error("WebRTC connection not ready");
|
|
77
|
+
const { audioSsrc, videoSsrc } = this.mediaConnection.webRtcParams;
|
|
78
|
+
this._audioPacketizer = new AudioPacketizer(this, audioSsrc);
|
|
79
|
+
switch (normalizeVideoCodec(videoCodec))
|
|
80
|
+
{
|
|
81
|
+
case "H264":
|
|
82
|
+
this._videoPacketizer = new VideoPacketizerH264(this, videoSsrc);
|
|
83
|
+
break;
|
|
84
|
+
case "H265":
|
|
85
|
+
this._videoPacketizer = new VideoPacketizerH265(this, videoSsrc);
|
|
86
|
+
break;
|
|
87
|
+
case "VP8":
|
|
88
|
+
this._videoPacketizer = new VideoPacketizerVP8(this, videoSsrc);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
throw new Error(`Packetizer not implemented for ${videoCodec}`)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public sendPacket(packet: Buffer): Promise<void> {
|
|
96
|
+
if (!this.mediaConnection.webRtcParams)
|
|
97
|
+
throw new Error("WebRTC connection not ready");
|
|
98
|
+
const { address, port } = this.mediaConnection.webRtcParams;
|
|
99
|
+
return new Promise<void>((resolve, reject) => {
|
|
100
|
+
try {
|
|
101
|
+
this._socket?.send(packet, 0, packet.length, port, address, (error, bytes) => {
|
|
102
|
+
if (error) {
|
|
103
|
+
console.log("ERROR", error);
|
|
104
|
+
reject(error);
|
|
105
|
+
}
|
|
106
|
+
resolve();
|
|
107
|
+
});
|
|
108
|
+
} catch(e) {reject(e)}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
handleIncoming(buf: unknown): void {
|
|
113
|
+
//console.log("RECEIVED PACKET", buf);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public get ready(): boolean {
|
|
117
|
+
return this._ready;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public set ready(val: boolean) {
|
|
121
|
+
this._ready = val;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public stop(): void {
|
|
125
|
+
try {
|
|
126
|
+
this.ready = false;
|
|
127
|
+
this._socket?.disconnect();
|
|
128
|
+
}catch(e) {}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public createUdp(): Promise<void> {
|
|
132
|
+
if (!this.mediaConnection.webRtcParams)
|
|
133
|
+
throw new Error("WebRTC connection not ready");
|
|
134
|
+
const { audioSsrc, address, port } = this.mediaConnection.webRtcParams;
|
|
135
|
+
return new Promise<void>((resolve, reject) => {
|
|
136
|
+
this._socket = udpCon.createSocket('udp4');
|
|
137
|
+
|
|
138
|
+
this._socket.on('error', (error: Error) => {
|
|
139
|
+
console.error("Error connecting to media udp server", error);
|
|
140
|
+
reject(error);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
this._socket.once('message', (message) => {
|
|
144
|
+
if (message.readUInt16BE(0) !== 2) {
|
|
145
|
+
reject('wrong handshake packet for udp')
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const packet = parseLocalPacket(message);
|
|
149
|
+
this._ip = packet.ip;
|
|
150
|
+
this._port = packet.port;
|
|
151
|
+
this._ready = true;
|
|
152
|
+
} catch(e) { reject(e) }
|
|
153
|
+
|
|
154
|
+
resolve();
|
|
155
|
+
this._socket?.on('message', this.handleIncoming);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const blank = Buffer.alloc(74);
|
|
159
|
+
|
|
160
|
+
blank.writeUInt16BE(1, 0);
|
|
161
|
+
blank.writeUInt16BE(70, 2);
|
|
162
|
+
blank.writeUInt32BE(audioSsrc, 4);
|
|
163
|
+
|
|
164
|
+
this._socket.send(blank, 0, blank.length, port, address, (error, bytes) => {
|
|
165
|
+
if (error) {
|
|
166
|
+
reject(error)
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VoiceOpCodes } from "../voice/VoiceOpCodes.js";
|
|
2
|
+
import { BaseMediaConnection } from "./BaseMediaConnection.js";
|
|
3
|
+
|
|
4
|
+
export class StreamConnection extends BaseMediaConnection {
|
|
5
|
+
private _streamKey: string | null = null;
|
|
6
|
+
private _serverId: string | null = null;
|
|
7
|
+
|
|
8
|
+
public override setSpeaking(speaking: boolean): void {
|
|
9
|
+
if (!this.webRtcParams) throw new Error("WebRTC connection not ready");
|
|
10
|
+
this.sendOpcode(VoiceOpCodes.SPEAKING, {
|
|
11
|
+
delay: 0,
|
|
12
|
+
speaking: speaking ? 2 : 0,
|
|
13
|
+
ssrc: this.webRtcParams.audioSsrc,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public override get daveChannelId() {
|
|
18
|
+
if (this._serverId === null)
|
|
19
|
+
throw new Error("Server ID not set (this shouldn't happen)");
|
|
20
|
+
const channelId = BigInt(this._serverId) - 1n;
|
|
21
|
+
return channelId.toString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public override get serverId(): string | null {
|
|
25
|
+
return this._serverId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public set serverId(id: string) {
|
|
29
|
+
this._serverId = id;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public get streamKey(): string | null {
|
|
33
|
+
return this._streamKey;
|
|
34
|
+
}
|
|
35
|
+
public set streamKey(value: string) {
|
|
36
|
+
this._streamKey = value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseMediaConnection } from "./BaseMediaConnection.js";
|
|
2
|
+
import type { StreamConnection } from "./StreamConnection.js";
|
|
3
|
+
|
|
4
|
+
export class VoiceConnection extends BaseMediaConnection {
|
|
5
|
+
public streamConnection?: StreamConnection;
|
|
6
|
+
|
|
7
|
+
public override get daveChannelId() {
|
|
8
|
+
return this.channelId;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public override get serverId(): string {
|
|
12
|
+
return this.guildId ?? this.channelId; // for guild vc it is the guild id, for dm voice it is the channel id
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public override stop(): void {
|
|
16
|
+
super.stop();
|
|
17
|
+
this.streamConnection?.stop();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { VoiceOpCodes } from "./VoiceOpCodes.js";
|
|
2
|
+
import type { SupportedEncryptionModes } from "../../utils.js";
|
|
3
|
+
|
|
4
|
+
type StreamInfo = {
|
|
5
|
+
active: boolean;
|
|
6
|
+
quality: number;
|
|
7
|
+
rid: string;
|
|
8
|
+
ssrc: number;
|
|
9
|
+
rtx_ssrc: number;
|
|
10
|
+
/**
|
|
11
|
+
* always "video" from what I observed
|
|
12
|
+
*/
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type SimulcastInfo = {
|
|
17
|
+
type: string;
|
|
18
|
+
rid: string;
|
|
19
|
+
quality: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type CodecPayloadType =
|
|
23
|
+
| {
|
|
24
|
+
name: string;
|
|
25
|
+
type: "audio";
|
|
26
|
+
priority: number;
|
|
27
|
+
payload_type: number;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
name: string;
|
|
31
|
+
type: "video";
|
|
32
|
+
priority: number;
|
|
33
|
+
payload_type: number;
|
|
34
|
+
rtx_payload_type: number;
|
|
35
|
+
encode: boolean;
|
|
36
|
+
decode: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export namespace Message {
|
|
40
|
+
// Request messages
|
|
41
|
+
export type Identify = {
|
|
42
|
+
server_id: string;
|
|
43
|
+
user_id: string;
|
|
44
|
+
session_id: string;
|
|
45
|
+
token: string;
|
|
46
|
+
video: boolean;
|
|
47
|
+
streams: SimulcastInfo[];
|
|
48
|
+
max_dave_protocol_version?: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type Resume = {
|
|
52
|
+
server_id: string;
|
|
53
|
+
session_id: string;
|
|
54
|
+
token: string;
|
|
55
|
+
seq_ack: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type Heartbeat = {
|
|
59
|
+
t: number;
|
|
60
|
+
seq_ack?: number;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type SelectProtocol =
|
|
64
|
+
| {
|
|
65
|
+
protocol: "udp";
|
|
66
|
+
codecs: CodecPayloadType[];
|
|
67
|
+
data: {
|
|
68
|
+
address: string;
|
|
69
|
+
port: number;
|
|
70
|
+
mode: SupportedEncryptionModes;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
protocol: "webrtc";
|
|
75
|
+
codecs: CodecPayloadType[];
|
|
76
|
+
data: string;
|
|
77
|
+
sdp: string;
|
|
78
|
+
rtc_connection_id: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type Video = {
|
|
82
|
+
audio_ssrc: number;
|
|
83
|
+
video_ssrc: number;
|
|
84
|
+
rtx_ssrc: number;
|
|
85
|
+
streams: {
|
|
86
|
+
type: "video";
|
|
87
|
+
rid: string;
|
|
88
|
+
ssrc: number;
|
|
89
|
+
active: boolean;
|
|
90
|
+
quality: number;
|
|
91
|
+
rtx_ssrc: number;
|
|
92
|
+
max_bitrate: number;
|
|
93
|
+
max_framerate: number;
|
|
94
|
+
max_resolution: {
|
|
95
|
+
type: "fixed";
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
};
|
|
99
|
+
}[];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Response messages
|
|
103
|
+
export type Hello = {
|
|
104
|
+
heartbeat_interval: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type Ready = {
|
|
108
|
+
ssrc: number;
|
|
109
|
+
ip: string;
|
|
110
|
+
port: number;
|
|
111
|
+
modes: SupportedEncryptionModes[];
|
|
112
|
+
experiments: string[];
|
|
113
|
+
streams: StreamInfo[];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type Speaking = {
|
|
117
|
+
speaking: 0 | 1 | 2;
|
|
118
|
+
delay: number;
|
|
119
|
+
ssrc: number;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type SelectProtocolAck = {
|
|
123
|
+
audio_codec: string;
|
|
124
|
+
video_codec: string;
|
|
125
|
+
dave_protocol_version: number;
|
|
126
|
+
} & (
|
|
127
|
+
| {
|
|
128
|
+
secret_key: number[];
|
|
129
|
+
mode: string;
|
|
130
|
+
}
|
|
131
|
+
| {
|
|
132
|
+
media_session_id: number;
|
|
133
|
+
sdp: string;
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export type HeartbeatAck = {
|
|
138
|
+
t: number;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type ClientsConnect = {
|
|
142
|
+
user_ids: string[];
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type ClientDisconnect = {
|
|
146
|
+
user_id: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type DavePrepareTransition = {
|
|
150
|
+
transition_id: number;
|
|
151
|
+
protocol_version: number;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type DaveExecuteTransition = {
|
|
155
|
+
transition_id: number;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type DaveTransitionReady = {
|
|
159
|
+
transition_id: number;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type DavePrepareEpoch = {
|
|
163
|
+
epoch: number;
|
|
164
|
+
protocol_version: number;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export type MlsInvalidCommitWelcome = {
|
|
168
|
+
transition_id: number;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export namespace GatewayResponse {
|
|
173
|
+
type Generic<
|
|
174
|
+
Op extends VoiceOpCodes,
|
|
175
|
+
T extends Record<string, unknown> | null,
|
|
176
|
+
> = {
|
|
177
|
+
op: Op;
|
|
178
|
+
d: T;
|
|
179
|
+
seq?: number;
|
|
180
|
+
};
|
|
181
|
+
export type Hello = Generic<VoiceOpCodes.HELLO, Message.Hello>;
|
|
182
|
+
export type Ready = Generic<VoiceOpCodes.READY, Message.Ready>;
|
|
183
|
+
export type Resumed = Generic<VoiceOpCodes.RESUMED, null>;
|
|
184
|
+
export type Speaking = Generic<VoiceOpCodes.SPEAKING, Message.Speaking>;
|
|
185
|
+
export type SelectProtocolAck = Generic<
|
|
186
|
+
VoiceOpCodes.SELECT_PROTOCOL_ACK,
|
|
187
|
+
Message.SelectProtocolAck
|
|
188
|
+
>;
|
|
189
|
+
export type HeartbeatAck = Generic<
|
|
190
|
+
VoiceOpCodes.HEARTBEAT_ACK,
|
|
191
|
+
Message.HeartbeatAck
|
|
192
|
+
>;
|
|
193
|
+
export type ClientsConnect = Generic<
|
|
194
|
+
VoiceOpCodes.CLIENTS_CONNECT,
|
|
195
|
+
Message.ClientsConnect
|
|
196
|
+
>;
|
|
197
|
+
export type ClientDisconnect = Generic<
|
|
198
|
+
VoiceOpCodes.CLIENT_DISCONNECT,
|
|
199
|
+
Message.ClientDisconnect
|
|
200
|
+
>;
|
|
201
|
+
export type DavePrepareTransition = Generic<
|
|
202
|
+
VoiceOpCodes.DAVE_PREPARE_TRANSITION,
|
|
203
|
+
Message.DavePrepareTransition
|
|
204
|
+
>;
|
|
205
|
+
export type DaveExecuteTransition = Generic<
|
|
206
|
+
VoiceOpCodes.DAVE_EXECUTE_TRANSITION,
|
|
207
|
+
Message.DaveExecuteTransition
|
|
208
|
+
>;
|
|
209
|
+
export type DavePrepareEpoch = Generic<
|
|
210
|
+
VoiceOpCodes.DAVE_PREPARE_EPOCH,
|
|
211
|
+
Message.DavePrepareEpoch
|
|
212
|
+
>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export type GatewayResponse =
|
|
216
|
+
| GatewayResponse.Hello
|
|
217
|
+
| GatewayResponse.Ready
|
|
218
|
+
| GatewayResponse.Resumed
|
|
219
|
+
| GatewayResponse.Speaking
|
|
220
|
+
| GatewayResponse.SelectProtocolAck
|
|
221
|
+
| GatewayResponse.HeartbeatAck
|
|
222
|
+
| GatewayResponse.ClientsConnect
|
|
223
|
+
| GatewayResponse.ClientDisconnect
|
|
224
|
+
| GatewayResponse.DavePrepareTransition
|
|
225
|
+
| GatewayResponse.DaveExecuteTransition
|
|
226
|
+
| GatewayResponse.DavePrepareEpoch;
|
|
227
|
+
|
|
228
|
+
export namespace GatewayRequest {
|
|
229
|
+
type Generic<
|
|
230
|
+
Op extends VoiceOpCodes,
|
|
231
|
+
T extends Record<string, unknown> | null,
|
|
232
|
+
> = {
|
|
233
|
+
op: Op;
|
|
234
|
+
d: T;
|
|
235
|
+
};
|
|
236
|
+
export type Identify = Generic<VoiceOpCodes.IDENTIFY, Message.Identify>;
|
|
237
|
+
export type Resume = Generic<VoiceOpCodes.RESUME, Message.Resume>;
|
|
238
|
+
export type Heartbeat = Generic<VoiceOpCodes.HEARTBEAT, Message.Heartbeat>;
|
|
239
|
+
export type SelectProtocol = Generic<
|
|
240
|
+
VoiceOpCodes.SELECT_PROTOCOL,
|
|
241
|
+
Message.SelectProtocol
|
|
242
|
+
>;
|
|
243
|
+
export type Video = Generic<VoiceOpCodes.VIDEO, Message.Video>;
|
|
244
|
+
export type Speaking = Generic<VoiceOpCodes.SPEAKING, Message.Speaking>;
|
|
245
|
+
export type DaveTransitionReady = Generic<
|
|
246
|
+
VoiceOpCodes.DAVE_TRANSITION_READY,
|
|
247
|
+
Message.DaveTransitionReady
|
|
248
|
+
>;
|
|
249
|
+
export type MlsInvalidCommitWelcome = Generic<
|
|
250
|
+
VoiceOpCodes.MLS_INVALID_COMMIT_WELCOME,
|
|
251
|
+
Message.MlsInvalidCommitWelcome
|
|
252
|
+
>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export type GatewayRequest =
|
|
256
|
+
| GatewayRequest.Identify
|
|
257
|
+
| GatewayRequest.Resume
|
|
258
|
+
| GatewayRequest.Heartbeat
|
|
259
|
+
| GatewayRequest.SelectProtocol
|
|
260
|
+
| GatewayRequest.Video
|
|
261
|
+
| GatewayRequest.Speaking
|
|
262
|
+
| GatewayRequest.DaveTransitionReady
|
|
263
|
+
| GatewayRequest.MlsInvalidCommitWelcome;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export enum VoiceOpCodes {
|
|
2
|
+
IDENTIFY = 0,
|
|
3
|
+
SELECT_PROTOCOL = 1,
|
|
4
|
+
READY = 2,
|
|
5
|
+
HEARTBEAT = 3,
|
|
6
|
+
SELECT_PROTOCOL_ACK = 4,
|
|
7
|
+
SPEAKING = 5,
|
|
8
|
+
HEARTBEAT_ACK = 6,
|
|
9
|
+
RESUME = 7,
|
|
10
|
+
HELLO = 8,
|
|
11
|
+
RESUMED = 9,
|
|
12
|
+
CLIENTS_CONNECT = 11,
|
|
13
|
+
VIDEO = 12,
|
|
14
|
+
CLIENT_DISCONNECT = 13,
|
|
15
|
+
SESSION_UPDATE = 14,
|
|
16
|
+
MEDIA_SINK_WANTS = 15,
|
|
17
|
+
VOICE_BACKEND_VERSION = 16,
|
|
18
|
+
CHANNEL_OPTIONS_UPDATE = 17,
|
|
19
|
+
FLAGS = 18,
|
|
20
|
+
SPEED_TEST = 19,
|
|
21
|
+
PLATFORM = 20,
|
|
22
|
+
DAVE_PREPARE_TRANSITION = 21,
|
|
23
|
+
DAVE_EXECUTE_TRANSITION = 22,
|
|
24
|
+
DAVE_TRANSITION_READY = 23,
|
|
25
|
+
DAVE_PREPARE_EPOCH = 24,
|
|
26
|
+
MLS_INVALID_COMMIT_WELCOME = 31,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum VoiceOpCodesBinary {
|
|
30
|
+
MLS_EXTERNAL_SENDER = 25,
|
|
31
|
+
MLS_KEY_PACKAGE = 26,
|
|
32
|
+
MLS_PROPOSALS = 27,
|
|
33
|
+
MLS_COMMIT_WELCOME = 28,
|
|
34
|
+
MLS_ANNOUNCE_COMMIT_TRANSITION = 29,
|
|
35
|
+
MLS_WELCOME = 30,
|
|
36
|
+
}
|