@4players/odin
Version:
A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects
45 lines (44 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerAudioOutput = registerAudioOutput;
exports.unregisterAudioOutput = unregisterAudioOutput;
const helpers_1 = require("./utils/helpers");
const audioOutputs = new Map();
async function main() {
emitActivity().catch(console.error);
emitPowerLevel().catch(console.error);
emitJitterStats().catch(console.error);
}
function registerAudioOutput(output, handler, room) {
audioOutputs.set(output, { handler, room });
}
function unregisterAudioOutput(output) {
audioOutputs.delete(output);
}
async function emitActivity(interval = 100) {
while (true) {
await (0, helpers_1.sleep)(interval);
for (const [media, data] of audioOutputs) {
data.handler('Activity');
}
}
}
async function emitPowerLevel(interval = 500) {
while (true) {
await (0, helpers_1.sleep)(interval);
for (const [media, data] of audioOutputs) {
data.handler('PowerLevel');
}
}
}
async function emitJitterStats(interval = 1000) {
while (true) {
await (0, helpers_1.sleep)(interval);
for (const [media, data] of audioOutputs) {
data.handler('JitterStats');
}
}
}
main().catch(console.error);
// I create a Capture that's not related to a room
// The capture gets linked to a room, the function that links (room.addAudioInput) needs to tell this module, that capture xyz was linked