@routr/rtprelay 2.0.9 → 2.0.10
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/dist/index.d.ts +2 -0
- package/dist/index.js +26 -0
- package/dist/runner.js +4 -86
- package/dist/service.d.ts +11 -0
- package/dist/service.js +118 -0
- package/package.json +5 -6
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rtprelay = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Routr.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const service_1 = __importDefault(require("./service"));
|
|
26
|
+
exports.rtprelay = service_1.default;
|
package/dist/runner.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
-
});
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
5
|
};
|
|
35
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
7
|
/*
|
|
@@ -53,59 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
24
|
*/
|
|
54
25
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
55
26
|
require("./tracer").init("dispatcher");
|
|
56
|
-
const processor_1 = __importStar(require("@routr/processor"));
|
|
57
|
-
const client_1 = require("./client");
|
|
58
|
-
const common_1 = require("@routr/common");
|
|
59
|
-
const types_1 = require("./types");
|
|
60
|
-
const logger_1 = require("@fonoster/logger");
|
|
61
27
|
const envs_1 = require("./envs");
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const rtpeConfig = { host: envs_1.RTPENGINE_HOST, port: envs_1.RTPENGINE_PORT };
|
|
65
|
-
new processor_1.default({
|
|
66
|
-
bindAddr: envs_1.BIND_ADDR,
|
|
67
|
-
name: "rtprelay-middleware"
|
|
68
|
-
}).listen((req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
try {
|
|
70
|
-
if ((0, utils_1.shouldNotHandleRequest)(req)) {
|
|
71
|
-
return res.send(req);
|
|
72
|
-
}
|
|
73
|
-
const direction = processor_1.Helper.isTypeResponse(req)
|
|
74
|
-
? (0, utils_1.getDirectionFromResponse)(req)
|
|
75
|
-
: (0, utils_1.getDirectionFromRequest)(req);
|
|
76
|
-
const sendRequest = (f) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
-
var _a;
|
|
78
|
-
const r = yield f(rtpeConfig)(req);
|
|
79
|
-
if (r.result === "error") {
|
|
80
|
-
throw new common_1.CommonErrors.BadRequestError(r["error-reason"]);
|
|
81
|
-
}
|
|
82
|
-
if ((0, utils_1.callInvolvesWebRTC)(direction)) {
|
|
83
|
-
req.message.body = (_a = r.sdp) === null || _a === void 0 ? void 0 : _a.replaceAll("a=crypto:", "a=ignore:").replaceAll("a=sendrecv", "a=sendrecv\na=rtcp-mux");
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
req.message.body = r.sdp;
|
|
87
|
-
}
|
|
88
|
-
return res.send(req);
|
|
89
|
-
});
|
|
90
|
-
if (processor_1.Helper.isInviteOrAckWithSDP(req)) {
|
|
91
|
-
return yield sendRequest(client_1.offer);
|
|
92
|
-
}
|
|
93
|
-
else if (processor_1.Helper.isRinging(req) && direction === types_1.Direction.WEB_TO_PHONE) {
|
|
94
|
-
// Fixme: This was added to prevent the ringing message from being sent to the
|
|
95
|
-
// caller while the call is being established. This is a temporary fix
|
|
96
|
-
req.message.body = "";
|
|
97
|
-
return res.send(req);
|
|
98
|
-
}
|
|
99
|
-
else if (processor_1.Helper.isOkOrRingingWithSDP(req)) {
|
|
100
|
-
return yield sendRequest(client_1.answer);
|
|
101
|
-
}
|
|
102
|
-
else if (processor_1.Helper.isBye(req)) {
|
|
103
|
-
return yield sendRequest(client_1.del);
|
|
104
|
-
}
|
|
105
|
-
res.send(req);
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
logger.error(e);
|
|
109
|
-
res.sendInternalServerError();
|
|
110
|
-
}
|
|
111
|
-
}));
|
|
28
|
+
const service_1 = __importDefault(require("./service"));
|
|
29
|
+
(0, service_1.default)(envs_1.BIND_ADDR, { host: envs_1.RTPENGINE_HOST, port: envs_1.RTPENGINE_PORT });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new rtp service.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} bindAddr - The address to bind to.
|
|
6
|
+
* @param {object} rtpeConfig - The address of the rtpengine server.
|
|
7
|
+
*/
|
|
8
|
+
export default function rtprelay(bindAddr: string, rtpeConfig: {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
}): void;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
/*
|
|
37
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
38
|
+
* http://github.com/fonoster/routr
|
|
39
|
+
*
|
|
40
|
+
* This file is part of Routr
|
|
41
|
+
*
|
|
42
|
+
* Licensed under the MIT License (the "License");
|
|
43
|
+
* you may not use this file except in compliance with
|
|
44
|
+
* the License. You may obtain a copy of the License at
|
|
45
|
+
*
|
|
46
|
+
* https://opensource.org/licenses/MIT
|
|
47
|
+
*
|
|
48
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
49
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
50
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
51
|
+
* See the License for the specific language governing permissions and
|
|
52
|
+
* limitations under the License.
|
|
53
|
+
*/
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
55
|
+
require("./tracer").init("dispatcher");
|
|
56
|
+
const processor_1 = __importStar(require("@routr/processor"));
|
|
57
|
+
const client_1 = require("./client");
|
|
58
|
+
const common_1 = require("@routr/common");
|
|
59
|
+
const types_1 = require("./types");
|
|
60
|
+
const logger_1 = require("@fonoster/logger");
|
|
61
|
+
const utils_1 = require("./utils");
|
|
62
|
+
const logger = (0, logger_1.getLogger)({ service: "rtprelay", filePath: __filename });
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new rtp service.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} bindAddr - The address to bind to.
|
|
67
|
+
* @param {object} rtpeConfig - The address of the rtpengine server.
|
|
68
|
+
*/
|
|
69
|
+
function rtprelay(bindAddr, rtpeConfig) {
|
|
70
|
+
new processor_1.default({
|
|
71
|
+
bindAddr,
|
|
72
|
+
name: "rtprelay-middleware"
|
|
73
|
+
}).listen((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
if ((0, utils_1.shouldNotHandleRequest)(req)) {
|
|
76
|
+
return res.send(req);
|
|
77
|
+
}
|
|
78
|
+
const direction = processor_1.Helper.isTypeResponse(req)
|
|
79
|
+
? (0, utils_1.getDirectionFromResponse)(req)
|
|
80
|
+
: (0, utils_1.getDirectionFromRequest)(req);
|
|
81
|
+
const sendRequest = (f) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a;
|
|
83
|
+
const r = yield f(rtpeConfig)(req);
|
|
84
|
+
if (r.result === "error") {
|
|
85
|
+
throw new common_1.CommonErrors.BadRequestError(r["error-reason"]);
|
|
86
|
+
}
|
|
87
|
+
if ((0, utils_1.callInvolvesWebRTC)(direction)) {
|
|
88
|
+
req.message.body = (_a = r.sdp) === null || _a === void 0 ? void 0 : _a.replaceAll("a=crypto:", "a=ignore:").replaceAll("a=sendrecv", "a=sendrecv\na=rtcp-mux");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
req.message.body = r.sdp;
|
|
92
|
+
}
|
|
93
|
+
return res.send(req);
|
|
94
|
+
});
|
|
95
|
+
if (processor_1.Helper.isInviteOrAckWithSDP(req)) {
|
|
96
|
+
return yield sendRequest(client_1.offer);
|
|
97
|
+
}
|
|
98
|
+
else if (processor_1.Helper.isRinging(req) && direction === types_1.Direction.WEB_TO_PHONE) {
|
|
99
|
+
// Fixme: This was added to prevent the ringing message from being sent to the
|
|
100
|
+
// caller while the call is being established. This is a temporary fix
|
|
101
|
+
req.message.body = "";
|
|
102
|
+
return res.send(req);
|
|
103
|
+
}
|
|
104
|
+
else if (processor_1.Helper.isOkOrRingingWithSDP(req)) {
|
|
105
|
+
return yield sendRequest(client_1.answer);
|
|
106
|
+
}
|
|
107
|
+
else if (processor_1.Helper.isBye(req)) {
|
|
108
|
+
return yield sendRequest(client_1.del);
|
|
109
|
+
}
|
|
110
|
+
res.send(req);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
logger.error(e);
|
|
114
|
+
res.sendInternalServerError();
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
exports.default = rtprelay;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/rtprelay",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "Media Relay for Routr using RTPengine",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "dist/
|
|
9
|
-
"types": "dist/
|
|
8
|
+
"main": "dist/index",
|
|
9
|
+
"types": "dist/index",
|
|
10
10
|
"directories": {
|
|
11
11
|
"src": "src",
|
|
12
12
|
"test": "test"
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"build": "tsc -b tsconfig.json"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"run_rtprelay": "dist/runner.js"
|
|
20
|
-
"healthcheck_rtprelay": "dist/healthcheck.js"
|
|
19
|
+
"run_rtprelay": "dist/runner.js"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"@fonoster/logger": "0.3.20",
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"bugs": {
|
|
47
46
|
"url": "https://github.com/fonoster/routr/issues"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2886cad085d6beecea03b33b0b4241e9ea00f38e"
|
|
50
49
|
}
|