summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--api/src/index.ts3
-rw-r--r--bundle/package.json1
-rw-r--r--bundle/scripts/build.js2
-rw-r--r--bundle/src/Server.ts7
-rw-r--r--bundle/tsconfig.json3
-rw-r--r--util/src/schemas/Validator.ts2
-rw-r--r--webrtc/src/opcodes/Identify.ts2
-rw-r--r--webrtc/src/opcodes/sdp.json420
8 files changed, 430 insertions, 10 deletions
diff --git a/api/src/index.ts b/api/src/index.ts
index a731d326..09663452 100644
--- a/api/src/index.ts
+++ b/api/src/index.ts
@@ -1,4 +1,3 @@
 export * from "./Server";
 export * from "./middlewares/";
-export * from "./util/";
-export * from "./voice_schema_hack";
\ No newline at end of file
+export * from "./util/";
\ No newline at end of file
diff --git a/bundle/package.json b/bundle/package.json
index 484c0f05..3eb49719 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -66,6 +66,7 @@
 		"@fosscord/api": "file:../api",
 		"@fosscord/cdn": "file:../cdn",
 		"@fosscord/gateway": "file:../gateway",
+		"@fosscord/webrtc": "file:../webrtc",
 		"@sentry/node": "^6.16.1",
 		"@sentry/tracing": "^6.16.1",
 		"@yukikaze-bot/erlpack": "^1.0.1",
diff --git a/bundle/scripts/build.js b/bundle/scripts/build.js
index f73fb11a..06e01e2f 100644
--- a/bundle/scripts/build.js
+++ b/bundle/scripts/build.js
@@ -7,7 +7,7 @@ const { argv } = require("process");
 var steps = 2, i = 0;
 if (argv.includes("clean")) steps++;
 if (argv.includes("copyonly")) steps--;
-const dirs = ["api", "util", "cdn", "gateway", "bundle"];
+const dirs = ["api", "util", "cdn", "gateway", "bundle", "webrtc"];
 
 const verbose = argv.includes("verbose") || argv.includes("v");
 
diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts
index df29266d..2fbba318 100644
--- a/bundle/src/Server.ts
+++ b/bundle/src/Server.ts
@@ -4,6 +4,7 @@ process.on("uncaughtException", console.error);
 import http from "http";
 import * as Api from "@fosscord/api";
 import * as Gateway from "@fosscord/gateway";
+import * as WebRTC from "@fosscord/webrtc";
 import { CDNServer } from "@fosscord/cdn";
 import express from "express";
 import { green, bold, yellow } from "picocolors";
@@ -17,12 +18,10 @@ const port = Number(process.env.PORT) || 3001;
 const production = process.env.NODE_ENV == "development" ? false : true;
 server.on("request", app);
 
-// @ts-ignore
 const api = new Api.FosscordServer({ server, port, production, app });
-// @ts-ignore
 const cdn = new CDNServer({ server, port, production, app });
-// @ts-ignore
 const gateway = new Gateway.Server({ server, port, production });
+const webrtc = new WebRTC.Server({ server, port, production });
 
 //this is what has been added for the /stop API route
 process.on('SIGTERM', () => {
@@ -93,7 +92,7 @@ async function main() {
 		});
 	}
 
-	await Promise.all([api.start(), cdn.start(), gateway.start()]);
+	await Promise.all([api.start(), cdn.start(), gateway.start(), webrtc.start()]);
 	console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`);
 }
 
diff --git a/bundle/tsconfig.json b/bundle/tsconfig.json
index 57fe10ad..1a1aa0bf 100644
--- a/bundle/tsconfig.json
+++ b/bundle/tsconfig.json
@@ -77,7 +77,8 @@
 			"@fosscord/api": ["api/src/index"],

 			"@fosscord/gateway": ["gateway/src/index"],

 			"@fosscord/cdn": ["cdn/src/index"],

-			"@fosscord/util": ["util/src/index"]

+			"@fosscord/util": ["util/src/index"],

+			"@fosscord/webrtc": ["webrtc/src/index"]

 		},

 		"plugins": [{ "transform": "@zerollup/ts-transform-paths" }],

 		"noEmitHelpers": true,

diff --git a/util/src/schemas/Validator.ts b/util/src/schemas/Validator.ts
index b71bf6a1..e5f12ac5 100644
--- a/util/src/schemas/Validator.ts
+++ b/util/src/schemas/Validator.ts
@@ -3,7 +3,7 @@ import addFormats from "ajv-formats";
 import fs from "fs";
 import path from "path";
 
-const SchemaPath = path.join(__dirname, "..", "..", "..", "assets", "schemas.json");
+const SchemaPath = path.join(__dirname, "..", "..", "..", "api", "assets", "schemas.json");
 const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
 
 export const ajv = new Ajv({
diff --git a/webrtc/src/opcodes/Identify.ts b/webrtc/src/opcodes/Identify.ts
index 4ecec949..7e579027 100644
--- a/webrtc/src/opcodes/Identify.ts
+++ b/webrtc/src/opcodes/Identify.ts
@@ -2,7 +2,7 @@ import { CLOSECODES, Payload, Send, WebSocket } from "@fosscord/gateway";
 import { validateSchema, VoiceIdentifySchema, VoiceState } from "@fosscord/util";
 import { endpoint, getClients, VoiceOPCodes } from "@fosscord/webrtc";
 import SemanticSDP from "semantic-sdp";
-const defaultSDP = require("../../../assets/sdp.json");
+const defaultSDP = require("./sdp.json");
 
 export async function onIdentify(this: WebSocket, data: Payload) {
 	clearTimeout(this.readyTimeout);
diff --git a/webrtc/src/opcodes/sdp.json b/webrtc/src/opcodes/sdp.json
new file mode 100644
index 00000000..4867b9c7
--- /dev/null
+++ b/webrtc/src/opcodes/sdp.json
@@ -0,0 +1,420 @@
+{
+	"version": 0,
+	"streams": [],
+	"medias": [
+		{
+			"id": "0",
+			"type": "audio",
+			"direction": "sendrecv",
+			"codecs": [
+				{
+					"codec": "opus",
+					"type": 111,
+					"channels": 2,
+					"params": {
+						"minptime": "10",
+						"useinbandfec": "1"
+					},
+					"rtcpfbs": [
+						{
+							"id": "transport-cc"
+						}
+					]
+				}
+			],
+			"extensions": {
+				"1": "urn:ietf:params:rtp-hdrext:ssrc-audio-level",
+				"2": "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",
+				"3": "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",
+				"4": "urn:ietf:params:rtp-hdrext:sdes:mid"
+			}
+		},
+		{
+			"id": "1",
+			"type": "video",
+			"direction": "sendrecv",
+			"codecs": [
+				{
+					"codec": "VP8",
+					"type": 96,
+					"rtx": 97,
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "VP9",
+					"type": 98,
+					"rtx": 99,
+					"params": {
+						"profile-id": "0"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "VP9",
+					"type": 100,
+					"rtx": 101,
+					"params": {
+						"profile-id": "2"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "VP9",
+					"type": 102,
+					"rtx": 122,
+					"params": {
+						"profile-id": "1"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 127,
+					"rtx": 121,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "1",
+						"profile-level-id": "42001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 125,
+					"rtx": 107,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "0",
+						"profile-level-id": "42001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 108,
+					"rtx": 109,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "1",
+						"profile-level-id": "42e01f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 124,
+					"rtx": 120,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "0",
+						"profile-level-id": "42e01f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 123,
+					"rtx": 119,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "1",
+						"profile-level-id": "4d001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 35,
+					"rtx": 36,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "0",
+						"profile-level-id": "4d001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 37,
+					"rtx": 38,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "1",
+						"profile-level-id": "f4001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 39,
+					"rtx": 40,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "0",
+						"profile-level-id": "f4001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				},
+				{
+					"codec": "H264",
+					"type": 114,
+					"rtx": 115,
+					"params": {
+						"level-asymmetry-allowed": "1",
+						"packetization-mode": "1",
+						"profile-level-id": "64001f"
+					},
+					"rtcpfbs": [
+						{
+							"id": "goog-remb"
+						},
+						{
+							"id": "transport-cc"
+						},
+						{
+							"id": "ccm",
+							"params": ["fir"]
+						},
+						{
+							"id": "nack"
+						},
+						{
+							"id": "nack",
+							"params": ["pli"]
+						}
+					]
+				}
+			],
+			"extensions": {
+				"2": "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",
+				"3": "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",
+				"4": "urn:ietf:params:rtp-hdrext:sdes:mid",
+				"5": "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",
+				"6": "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",
+				"7": "http://www.webrtc.org/experiments/rtp-hdrext/video-timing",
+				"8": "http://www.webrtc.org/experiments/rtp-hdrext/color-space",
+				"10": "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",
+				"11": "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",
+				"13": "urn:3gpp:video-orientation",
+				"14": "urn:ietf:params:rtp-hdrext:toffset"
+			}
+		}
+	],
+	"candidates": []
+}
\ No newline at end of file