@routr/rtprelay 2.8.0 → 2.9.1
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/client.d.ts +3 -2
- package/dist/client.js +15 -5
- package/dist/service.js +17 -5
- package/dist/types.d.ts +1 -1
- package/package.json +5 -4
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MessageRequest } from "@routr/common";
|
|
2
2
|
import { RTPEConfig, RTPEFunctionResult } from "./types";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
3
|
+
export declare function query(config: RTPEConfig): (request: MessageRequest) => Promise<RTPEFunctionResult>;
|
|
4
|
+
export declare function offer(config: RTPEConfig, invertTags?: boolean): (request: MessageRequest) => Promise<RTPEFunctionResult>;
|
|
5
|
+
export declare function answer(config: RTPEConfig, invertTags?: boolean): (request: MessageRequest) => Promise<RTPEFunctionResult>;
|
|
5
6
|
export declare function del(config: RTPEConfig): (request: MessageRequest) => Promise<RTPEFunctionResult>;
|
package/dist/client.js
CHANGED
|
@@ -9,25 +9,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.del = exports.answer = exports.offer = void 0;
|
|
12
|
+
exports.del = exports.answer = exports.offer = exports.query = void 0;
|
|
13
13
|
const envs_1 = require("./envs");
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
16
|
const Client = require("rtpengine-client").Client;
|
|
17
17
|
const rtpe = new Client({ timeout: envs_1.RTPENGINE_TIMEOUT });
|
|
18
|
-
function
|
|
18
|
+
function query(config) {
|
|
19
|
+
return (request) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return yield rtpe.query(config, {
|
|
21
|
+
"call-id": request.message.callId.callId
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.query = query;
|
|
26
|
+
function offer(config, invertTags = false) {
|
|
19
27
|
return (request) => __awaiter(this, void 0, void 0, function* () {
|
|
20
28
|
const direction = (0, utils_1.getDirectionFromRequest)(request);
|
|
21
29
|
const sdpModifiers = (0, utils_1.getRTPEParamsByDirection)(direction);
|
|
22
|
-
return yield rtpe.offer(config, Object.assign(Object.assign({}, sdpModifiers), { sdp: request.message.body, "call-id": request.message.callId.callId, "from-tag": request.message.from.tag }));
|
|
30
|
+
return yield rtpe.offer(config, Object.assign(Object.assign({}, sdpModifiers), { sdp: request.message.body, "call-id": request.message.callId.callId, "from-tag": invertTags ? request.message.to.tag : request.message.from.tag }));
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
33
|
exports.offer = offer;
|
|
26
|
-
function answer(config) {
|
|
34
|
+
function answer(config, invertTags = false) {
|
|
27
35
|
return (request) => __awaiter(this, void 0, void 0, function* () {
|
|
28
36
|
const direction = (0, utils_1.getDirectionFromResponse)(request);
|
|
29
37
|
const sdpModifiers = (0, utils_1.getRTPEParamsByDirection)(direction);
|
|
30
|
-
return yield rtpe.answer(config, Object.assign(Object.assign({}, sdpModifiers), { sdp: request.message.body, "call-id": request.message.callId.callId, "from-tag":
|
|
38
|
+
return yield rtpe.answer(config, Object.assign(Object.assign({}, sdpModifiers), { sdp: request.message.body, "call-id": request.message.callId.callId, "from-tag": invertTags
|
|
39
|
+
? request.message.to.tag
|
|
40
|
+
: request.message.from.tag, "to-tag": invertTags ? request.message.from.tag : request.message.to.tag }));
|
|
31
41
|
});
|
|
32
42
|
}
|
|
33
43
|
exports.answer = answer;
|
package/dist/service.js
CHANGED
|
@@ -78,24 +78,36 @@ function rtprelay(bindAddr, rtpeConfig) {
|
|
|
78
78
|
const direction = processor_1.Helper.isTypeResponse(req)
|
|
79
79
|
? (0, utils_1.getDirectionFromResponse)(req)
|
|
80
80
|
: (0, utils_1.getDirectionFromRequest)(req);
|
|
81
|
-
const sendRequest = (f) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const r = yield f(rtpeConfig)(req);
|
|
81
|
+
const sendRequest = (f, invertTags = false) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const r = yield f(rtpeConfig, invertTags)(req);
|
|
83
83
|
if (r.result === "error") {
|
|
84
84
|
throw new common_1.CommonErrors.BadRequestError(r["error-reason"]);
|
|
85
85
|
}
|
|
86
86
|
req.message.body = r.sdp;
|
|
87
87
|
return res.send(req);
|
|
88
88
|
});
|
|
89
|
-
|
|
89
|
+
const queryResponse = yield (0, client_1.query)(rtpeConfig)(req);
|
|
90
|
+
const isNewCall = queryResponse.result === "error";
|
|
91
|
+
logger.verbose("request", {
|
|
92
|
+
direction,
|
|
93
|
+
isNewCall,
|
|
94
|
+
type: processor_1.Helper.isTypeRequest(req) ? req.method : req.message.responseType
|
|
95
|
+
});
|
|
96
|
+
if (processor_1.Helper.isInviteWithSDP(req)) {
|
|
90
97
|
return yield sendRequest(client_1.offer);
|
|
91
98
|
}
|
|
99
|
+
else if (processor_1.Helper.isAckWithSDP(req)) {
|
|
100
|
+
return yield sendRequest(client_1.answer, true);
|
|
101
|
+
}
|
|
92
102
|
else if (processor_1.Helper.isRinging(req) && direction === types_1.Direction.WEB_TO_PHONE) {
|
|
93
103
|
// FIXME: This was added to prevent the ringing message from being sent to the
|
|
94
104
|
// caller while the call is being established. This is a temporary fix
|
|
95
105
|
req.message.body = "";
|
|
96
|
-
return res.send(req);
|
|
97
106
|
}
|
|
98
|
-
else if (processor_1.Helper.
|
|
107
|
+
else if (processor_1.Helper.isResponseWithSDP(req) && isNewCall) {
|
|
108
|
+
return yield sendRequest(client_1.offer, true);
|
|
109
|
+
}
|
|
110
|
+
else if (processor_1.Helper.isResponseWithSDP(req)) {
|
|
99
111
|
return yield sendRequest(client_1.answer);
|
|
100
112
|
}
|
|
101
113
|
else if (processor_1.Helper.isBye(req)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -30,4 +30,4 @@ export type RTPEFunctionResult = {
|
|
|
30
30
|
result: "error";
|
|
31
31
|
"error-reason": string;
|
|
32
32
|
};
|
|
33
|
-
export type RTPEFunction = (config: RTPEConfig) => (req: MessageRequest) => Promise<RTPEFunctionResult>;
|
|
33
|
+
export type RTPEFunction = (config: RTPEConfig, invertTags?: boolean) => (req: MessageRequest) => Promise<RTPEFunctionResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/rtprelay",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
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",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fonoster/logger": "0.3.20",
|
|
23
|
+
"@grpc/grpc-js": "~1.10.1",
|
|
23
24
|
"@opentelemetry/api": "^1.0.4",
|
|
24
25
|
"@opentelemetry/exporter-jaeger": "^1.0.4",
|
|
25
26
|
"@opentelemetry/instrumentation": "^0.27.0",
|
|
@@ -28,8 +29,8 @@
|
|
|
28
29
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
29
30
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
30
31
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
31
|
-
"@routr/common": "^2.
|
|
32
|
-
"@routr/processor": "^2.
|
|
32
|
+
"@routr/common": "^2.9.1",
|
|
33
|
+
"@routr/processor": "^2.9.1",
|
|
33
34
|
"rtpengine-client": "^0.4.11"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"bugs": {
|
|
46
47
|
"url": "https://github.com/fonoster/routr/issues"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e9fa0c9f251b4fb694c2d7ac7c37c0958e0a9b56"
|
|
49
50
|
}
|