You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
// media-worker.js
|
|
// Copyright (C) 2022 DTP Technologies, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
const STATUS_LIST = [
|
|
'starting', // the router process is starting and configuring itself
|
|
'active', // the router is active and available for service
|
|
'capacity', // the router is at or over capacity
|
|
'closing', // the router is closing/shutting down
|
|
'closed', // the router no longer exists
|
|
];
|
|
|
|
const WebRtcListenSchema = new Schema({
|
|
protocol: { type: String, enum: ['tcp','udp'], required: true },
|
|
ip: { type: String, required: true },
|
|
port: { type: Number, required: true },
|
|
});
|
|
|
|
/*
|
|
* A media worker is a host process with one or more MediaRouter instances
|
|
* processing multi-user conference calls.
|
|
*/
|
|
const MediaWorkerSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, expires: '30d' },
|
|
lastActivity: { type: Date, default: Date.now, required: true },
|
|
status: { type: String, enum: STATUS_LIST, default: 'starting', required: true, index: true },
|
|
webRtcServer: {
|
|
listenInfos: { type: [WebRtcListenSchema] },
|
|
},
|
|
stats: {
|
|
routerCount: { type: Number, default: 0, required: true },
|
|
consumerCount: { type: Number, default: 0, required: true },
|
|
producerCount: { type: Number, default: 0, required: true },
|
|
}
|
|
});
|
|
|
|
module.exports = (conn) => {
|
|
return conn.model('MediaWorker', MediaWorkerSchema);
|
|
};
|