pubo-node 1.0.33 → 1.0.34
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/pubo-node.js +1 -1
- package/es/grpc/Grpc.d.ts +15 -0
- package/es/grpc/Grpc.js +52 -0
- package/es/grpc/GrpcPool.d.ts +14 -0
- package/es/grpc/GrpcPool.js +43 -0
- package/es/grpc/GrpcService.d.ts +13 -0
- package/es/grpc/GrpcService.js +295 -0
- package/es/grpc/index.d.ts +8 -0
- package/es/grpc/index.js +23 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -2
- package/lib/grpc/Grpc.d.ts +15 -0
- package/lib/grpc/Grpc.js +93 -0
- package/lib/grpc/GrpcPool.d.ts +14 -0
- package/lib/grpc/GrpcPool.js +50 -0
- package/lib/grpc/GrpcService.d.ts +13 -0
- package/lib/grpc/GrpcService.js +302 -0
- package/lib/grpc/index.d.ts +8 -0
- package/lib/grpc/index.js +32 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +18 -9
- package/package.json +4 -3
- package/es/rtsp-video/index.d.ts +0 -15
- package/es/rtsp-video/index.js +0 -50
- package/es/rtsp-video/rtsp2mpeg.d.ts +0 -13
- package/es/rtsp-video/rtsp2mpeg.js +0 -125
- package/lib/rtsp-video/index.d.ts +0 -15
- package/lib/rtsp-video/index.js +0 -58
- package/lib/rtsp-video/rtsp2mpeg.d.ts +0 -13
- package/lib/rtsp-video/rtsp2mpeg.js +0 -133
package/lib/rtsp-video/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
4
|
-
var t = {};
|
|
5
|
-
|
|
6
|
-
for (var p in s) {
|
|
7
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
exports.initRtspVideos = void 0;
|
|
20
|
-
|
|
21
|
-
var rtsp2mpeg_1 = require("./rtsp2mpeg");
|
|
22
|
-
|
|
23
|
-
exports.initRtspVideos = function (_a) {
|
|
24
|
-
var app = _a.app,
|
|
25
|
-
server = _a.server,
|
|
26
|
-
videos = _a.videos,
|
|
27
|
-
path = _a.path,
|
|
28
|
-
expressWs = _a.expressWs;
|
|
29
|
-
var mpegList = videos.map(function (_a) {
|
|
30
|
-
var url = _a.url,
|
|
31
|
-
options = __rest(_a, ["url"]);
|
|
32
|
-
|
|
33
|
-
return new rtsp2mpeg_1.RTSP2Mpeg(url, options);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (!app.ws) {
|
|
37
|
-
expressWs(app, server);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
app.ws(path, function (ws, req) {
|
|
41
|
-
var _a = req.query.channel,
|
|
42
|
-
channel = _a === void 0 ? 0 : _a;
|
|
43
|
-
var listener = null;
|
|
44
|
-
|
|
45
|
-
if (mpegList[channel]) {
|
|
46
|
-
listener = mpegList[channel].on('data', function (chunk) {
|
|
47
|
-
ws.send(chunk);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
ws.on('close', function () {
|
|
52
|
-
if (listener) {
|
|
53
|
-
mpegList[channel].cancel(listener);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
return mpegList;
|
|
58
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class RTSP2Mpeg {
|
|
2
|
-
private readonly eventEmitter;
|
|
3
|
-
private readonly dog;
|
|
4
|
-
private readonly url;
|
|
5
|
-
private s;
|
|
6
|
-
private readonly options;
|
|
7
|
-
constructor(url: string, options: any);
|
|
8
|
-
private onMessage;
|
|
9
|
-
private closeOld;
|
|
10
|
-
private connect;
|
|
11
|
-
on(event: string, cb: (data: any) => void): string;
|
|
12
|
-
cancel(id: any): void;
|
|
13
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __assign = this && this.__assign || function () {
|
|
4
|
-
__assign = Object.assign || function (t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
|
|
8
|
-
for (var p in s) {
|
|
9
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
var __read = this && this.__read || function (o, n) {
|
|
20
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
21
|
-
if (!m) return o;
|
|
22
|
-
var i = m.call(o),
|
|
23
|
-
r,
|
|
24
|
-
ar = [],
|
|
25
|
-
e;
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
29
|
-
ar.push(r.value);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
e = {
|
|
33
|
-
error: error
|
|
34
|
-
};
|
|
35
|
-
} finally {
|
|
36
|
-
try {
|
|
37
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
-
} finally {
|
|
39
|
-
if (e) throw e.error;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return ar;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var __spread = this && this.__spread || function () {
|
|
47
|
-
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
48
|
-
ar = ar.concat(__read(arguments[i]));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return ar;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
Object.defineProperty(exports, "__esModule", {
|
|
55
|
-
value: true
|
|
56
|
-
});
|
|
57
|
-
exports.RTSP2Mpeg = void 0;
|
|
58
|
-
|
|
59
|
-
var child_process_1 = require("child_process");
|
|
60
|
-
|
|
61
|
-
var pubo_utils_1 = require("pubo-utils");
|
|
62
|
-
|
|
63
|
-
var RTSP2Mpeg =
|
|
64
|
-
/** @class */
|
|
65
|
-
function () {
|
|
66
|
-
function RTSP2Mpeg(url, options) {
|
|
67
|
-
var _this = this;
|
|
68
|
-
|
|
69
|
-
this.eventEmitter = new pubo_utils_1.Emitter();
|
|
70
|
-
this.dog = new pubo_utils_1.WatchDog({
|
|
71
|
-
limit: 10,
|
|
72
|
-
onTimeout: function onTimeout() {
|
|
73
|
-
return _this.connect();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
this.url = url;
|
|
77
|
-
this.options = __assign({}, options);
|
|
78
|
-
|
|
79
|
-
if (!this.options.input) {
|
|
80
|
-
this.options.input = ['-rtsp_transport', 'tcp', '-i'];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!this.options.output) {
|
|
84
|
-
this.options.output = ['-f', 'mpegts', '-codec:v', 'mpeg1video'];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.connect();
|
|
88
|
-
this.dog.init();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
RTSP2Mpeg.prototype.onMessage = function (msg) {
|
|
92
|
-
this.dog.feed();
|
|
93
|
-
this.eventEmitter.emit('message', msg.toString());
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
RTSP2Mpeg.prototype.closeOld = function () {
|
|
97
|
-
if (this.s) {
|
|
98
|
-
console.log("LOG Video-Server: " + this.url + " try to reconnect;");
|
|
99
|
-
this.s.kill();
|
|
100
|
-
this.s = null;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
RTSP2Mpeg.prototype.connect = function () {
|
|
105
|
-
var _this = this;
|
|
106
|
-
|
|
107
|
-
this.closeOld();
|
|
108
|
-
|
|
109
|
-
var options = __spread(this.options.input, [this.url], this.options.output, ['-']);
|
|
110
|
-
|
|
111
|
-
this.s = child_process_1.spawn('ffmpeg', options, {
|
|
112
|
-
detached: false
|
|
113
|
-
});
|
|
114
|
-
this.s.stderr.on('data', function (buffer) {
|
|
115
|
-
return _this.onMessage(buffer);
|
|
116
|
-
});
|
|
117
|
-
this.s.stdout.on('data', function (buffer) {
|
|
118
|
-
return _this.eventEmitter.emit('data', buffer);
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
RTSP2Mpeg.prototype.on = function (event, cb) {
|
|
123
|
-
return this.eventEmitter.on(event, cb);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
RTSP2Mpeg.prototype.cancel = function (id) {
|
|
127
|
-
this.eventEmitter.cancel(id);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
return RTSP2Mpeg;
|
|
131
|
-
}();
|
|
132
|
-
|
|
133
|
-
exports.RTSP2Mpeg = RTSP2Mpeg;
|