pubo-node 1.0.8-alpha.0 → 1.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/pubo-node.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-node"]=e():t["pubo-node"]=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){t.exports=require("pubo-utils")},function(t,e){t.exports=require("child_process")},function(t,e){t.exports=require("crypto")},function(t,e,n){"use strict";n.r(e),n.d(e,"initRtspVideos",(function(){return y})),n.d(e,"md5",(function(){return p})),n.d(e,"FtpClient",(function(){return f}));var r=n(0),o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},i=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}s((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},c=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},s=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},a=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},f=function(){function t(t){var e=t.driver,n=c(t,["driver"]);this.queue=new r.SyncQueue,this.get=this._bind("get"),this.put=this._bind("put"),this.delete=this._bind("delete"),this.list=this._bind("list"),this.rename=this._bind("rename"),this.driver=e,this.options=n}return t.prototype._push=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.queue.push((function(){return t.call.apply(t,a([e],n))}))}},t.prototype._bind=function(t){var e=this;return this._push((function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return[4,this.connect()];case 1:return e=r.sent(),[2,this._run(t,e,n)]}}))}))}))},t.prototype._run=function(t,e,n){return new Promise((function(r,o){e[t].apply(e,a(n,[function(n,i){n?(o(n),e.end()):(r(i||"operation successful."),"get"===t?i.once("close",(function(){return e.end()})):e.end())}]))}))},t.prototype.connect=function(){var t=this;return new Promise((function(e,n){var r=new t.driver;r.once("ready",(function(){e(r)})),r.once("error",(function(t){n(t),r.end()})),r.connect(o({},t.options))}))},t}(),l=n(2),p=function(t){return Object(l.createHash)("md5").update(t).digest("hex")},d=n(1),h=function(){function t(t){var e=this;this.eventEmitter=new r.Emitter,this.dog=new r.WatchDog({limit:10,onTimeout:function(){return e.connect()}}),this.url=t,this.connect(),this.dog.init()}return t.prototype.onMessage=function(t){this.dog.feed(),this.eventEmitter.emit("message",t.toString())},t.prototype.closeOld=function(){this.s&&(console.log("LOG Video-Server: "+this.url+" try to reconnect;"),this.s.kill(),this.s=null)},t.prototype.connect=function(){var t=this;this.closeOld();var e=["-rtsp_transport","tcp","-i",this.url,"-f","mpegts","-codec:v","mpeg1video","-"];this.s=Object(d.spawn)("ffmpeg",e,{detached:!1}),this.s.stderr.on("data",(function(e){return t.onMessage(e)})),this.s.stdout.on("data",(function(e){return t.eventEmitter.emit("data",e)}))},t.prototype.on=function(t,e){return this.eventEmitter.on(t,e)},t.prototype.cancel=function(t){this.eventEmitter.cancel(t)},t}(),y=function(t){var e=t.app,n=t.server,r=t.videos,o=t.path,i=t.expressWs,u=r.map((function(t){return new h(t)}));return i(e,n),e.ws(o,(function(t,e){var n=e.query.channel,r=void 0===n?0:n,o=null;u[r]&&(o=u[r].on("data",(function(e){t.send(e)}))),t.on("close",(function(){o&&u[r].cancel(o)}))})),u}}])}));
1
+ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["pubo-node"]=n():t["pubo-node"]=n()}(this,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=3)}([function(t,n){t.exports=require("pubo-utils")},function(t,n){t.exports=require("child_process")},function(t,n){t.exports=require("crypto")},function(t,n,e){"use strict";e.r(n),e.d(n,"initRtspVideos",(function(){return g})),e.d(n,"md5",(function(){return p})),e.d(n,"FtpClient",(function(){return l}));var r=e(0),o=function(){return(o=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},i=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}s((r=r.apply(t,n||[])).next())}))},u=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},c=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e},s=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},a=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(s(arguments[n]));return t},l=function(){function t(t){var n=t.driver,e=c(t,["driver"]);this.queue=new r.SyncQueue,this.get=this._bind("get"),this.put=this._bind("put"),this.delete=this._bind("delete"),this.list=this._bind("list"),this.rename=this._bind("rename"),this.driver=n,this.options=e}return t.prototype._push=function(t){var n=this;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n.queue.push((function(){return t.call.apply(t,a([n],e))}))}},t.prototype._bind=function(t){var n=this;return this._push((function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return i(n,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return[4,this.connect()];case 1:return n=r.sent(),[2,this._run(t,n,e)]}}))}))}))},t.prototype._run=function(t,n,e){return new Promise((function(r,o){n[t].apply(n,a(e,[function(e,i){e?(o(e),n.end()):(r(i||"operation successful."),"get"===t?i.once("close",(function(){return n.end()})):n.end())}]))}))},t.prototype.connect=function(){var t=this;return new Promise((function(n,e){var r=new t.driver;r.once("ready",(function(){n(r)})),r.once("error",(function(t){e(t),r.end()})),r.connect(o({},t.options))}))},t}(),f=e(2),p=function(t){return Object(f.createHash)("md5").update(t).digest("hex")},h=e(1),d=function(){return(d=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},y=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},v=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(y(arguments[n]));return t},b=function(){function t(t,n){var e=this;this.eventEmitter=new r.Emitter,this.dog=new r.WatchDog({limit:10,onTimeout:function(){return e.connect()}}),this.url=t,this.options=d({},n),this.options.input||(this.options.input=["-rtsp_transport","tcp","-i"]),this.options.output||(this.options.output=["-f","mpegts","-codec:v","mpeg1video"]),this.connect(),this.dog.init()}return t.prototype.onMessage=function(t){this.dog.feed(),this.eventEmitter.emit("message",t.toString())},t.prototype.closeOld=function(){this.s&&(console.log("LOG Video-Server: "+this.url+" try to reconnect;"),this.s.kill(),this.s=null)},t.prototype.connect=function(){var t=this;this.closeOld();var n=v(this.options.input,[this.url],this.options.output,["-"]);this.s=Object(h.spawn)("ffmpeg",n,{detached:!1}),this.s.stderr.on("data",(function(n){return t.onMessage(n)})),this.s.stdout.on("data",(function(n){return t.eventEmitter.emit("data",n)}))},t.prototype.on=function(t,n){return this.eventEmitter.on(t,n)},t.prototype.cancel=function(t){this.eventEmitter.cancel(t)},t}(),m=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e},g=function(t){var n=t.app,e=t.server,r=t.videos,o=t.path,i=t.expressWs,u=r.map((function(t){var n=t.url,e=m(t,["url"]);return new b(n,e)}));return i(n,e),n.ws(o,(function(t,n){var e=n.query.channel,r=void 0===e?0:e,o=null;u[r]&&(o=u[r].on("data",(function(n){t.send(n)}))),t.on("close",(function(){o&&u[r].cancel(o)}))})),u}}])}));
@@ -1,7 +1,15 @@
1
- export declare const initRtspVideos: ({ app, server, videos, path, expressWs }: {
1
+ import { RTSP2Mpeg } from './rtsp2mpeg';
2
+ interface VideoConfig {
3
+ url: string;
4
+ input?: string[];
5
+ output?: string[];
6
+ }
7
+ interface Props {
2
8
  app: any;
3
- server: any;
4
- videos: any;
5
- path: any;
9
+ server?: any;
10
+ videos: VideoConfig[];
11
+ path: string;
6
12
  expressWs: any;
7
- }) => any;
13
+ }
14
+ export declare const initRtspVideos: ({ app, server, videos, path, expressWs }: Props) => RTSP2Mpeg[];
15
+ export {};
@@ -1,3 +1,16 @@
1
+ var __rest = this && this.__rest || function (s, e) {
2
+ var t = {};
3
+
4
+ for (var p in s) {
5
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ }
7
+
8
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+
1
14
  import { RTSP2Mpeg } from './rtsp2mpeg';
2
15
  export var initRtspVideos = function initRtspVideos(_a) {
3
16
  var app = _a.app,
@@ -5,8 +18,11 @@ export var initRtspVideos = function initRtspVideos(_a) {
5
18
  videos = _a.videos,
6
19
  path = _a.path,
7
20
  expressWs = _a.expressWs;
8
- var mpegList = videos.map(function (url) {
9
- return new RTSP2Mpeg(url);
21
+ var mpegList = videos.map(function (_a) {
22
+ var url = _a.url,
23
+ options = __rest(_a, ["url"]);
24
+
25
+ return new RTSP2Mpeg(url, options);
10
26
  });
11
27
  expressWs(app, server);
12
28
  app.ws(path, function (ws, req) {
@@ -3,7 +3,8 @@ export declare class RTSP2Mpeg {
3
3
  private readonly dog;
4
4
  private readonly url;
5
5
  private s;
6
- constructor(url: string);
6
+ private readonly options;
7
+ constructor(url: string, options: any);
7
8
  private onMessage;
8
9
  private closeOld;
9
10
  private connect;
@@ -1,10 +1,61 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __read = this && this.__read || function (o, n) {
18
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19
+ if (!m) return o;
20
+ var i = m.call(o),
21
+ r,
22
+ ar = [],
23
+ e;
24
+
25
+ try {
26
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
27
+ ar.push(r.value);
28
+ }
29
+ } catch (error) {
30
+ e = {
31
+ error: error
32
+ };
33
+ } finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ } finally {
37
+ if (e) throw e.error;
38
+ }
39
+ }
40
+
41
+ return ar;
42
+ };
43
+
44
+ var __spread = this && this.__spread || function () {
45
+ for (var ar = [], i = 0; i < arguments.length; i++) {
46
+ ar = ar.concat(__read(arguments[i]));
47
+ }
48
+
49
+ return ar;
50
+ };
51
+
1
52
  import { spawn } from 'child_process';
2
53
  import { Emitter, WatchDog } from 'pubo-utils';
3
54
 
4
55
  var RTSP2Mpeg =
5
56
  /** @class */
6
57
  function () {
7
- function RTSP2Mpeg(url) {
58
+ function RTSP2Mpeg(url, options) {
8
59
  var _this = this;
9
60
 
10
61
  this.eventEmitter = new Emitter();
@@ -15,6 +66,16 @@ function () {
15
66
  }
16
67
  });
17
68
  this.url = url;
69
+ this.options = __assign({}, options);
70
+
71
+ if (!this.options.input) {
72
+ this.options.input = ['-rtsp_transport', 'tcp', '-i'];
73
+ }
74
+
75
+ if (!this.options.output) {
76
+ this.options.output = ['-f', 'mpegts', '-codec:v', 'mpeg1video'];
77
+ }
78
+
18
79
  this.connect();
19
80
  this.dog.init();
20
81
  }
@@ -36,7 +97,9 @@ function () {
36
97
  var _this = this;
37
98
 
38
99
  this.closeOld();
39
- var options = ['-rtsp_transport', 'tcp', '-i', this.url, '-f', 'mpegts', '-codec:v', 'mpeg1video', '-'];
100
+
101
+ var options = __spread(this.options.input, [this.url], this.options.output, ['-']);
102
+
40
103
  this.s = spawn('ffmpeg', options, {
41
104
  detached: false
42
105
  });
@@ -1,7 +1,15 @@
1
- export declare const initRtspVideos: ({ app, server, videos, path, expressWs }: {
1
+ import { RTSP2Mpeg } from './rtsp2mpeg';
2
+ interface VideoConfig {
3
+ url: string;
4
+ input?: string[];
5
+ output?: string[];
6
+ }
7
+ interface Props {
2
8
  app: any;
3
- server: any;
4
- videos: any;
5
- path: any;
9
+ server?: any;
10
+ videos: VideoConfig[];
11
+ path: string;
6
12
  expressWs: any;
7
- }) => any;
13
+ }
14
+ export declare const initRtspVideos: ({ app, server, videos, path, expressWs }: Props) => RTSP2Mpeg[];
15
+ export {};
@@ -1,5 +1,18 @@
1
1
  "use strict";
2
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
+
3
16
  Object.defineProperty(exports, "__esModule", {
4
17
  value: true
5
18
  });
@@ -13,8 +26,11 @@ exports.initRtspVideos = function (_a) {
13
26
  videos = _a.videos,
14
27
  path = _a.path,
15
28
  expressWs = _a.expressWs;
16
- var mpegList = videos.map(function (url) {
17
- return new rtsp2mpeg_1.RTSP2Mpeg(url);
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);
18
34
  });
19
35
  expressWs(app, server);
20
36
  app.ws(path, function (ws, req) {
@@ -3,7 +3,8 @@ export declare class RTSP2Mpeg {
3
3
  private readonly dog;
4
4
  private readonly url;
5
5
  private s;
6
- constructor(url: string);
6
+ private readonly options;
7
+ constructor(url: string, options: any);
7
8
  private onMessage;
8
9
  private closeOld;
9
10
  private connect;
@@ -1,5 +1,56 @@
1
1
  "use strict";
2
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
+
3
54
  Object.defineProperty(exports, "__esModule", {
4
55
  value: true
5
56
  });
@@ -12,7 +63,7 @@ var pubo_utils_1 = require("pubo-utils");
12
63
  var RTSP2Mpeg =
13
64
  /** @class */
14
65
  function () {
15
- function RTSP2Mpeg(url) {
66
+ function RTSP2Mpeg(url, options) {
16
67
  var _this = this;
17
68
 
18
69
  this.eventEmitter = new pubo_utils_1.Emitter();
@@ -23,6 +74,16 @@ function () {
23
74
  }
24
75
  });
25
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
+
26
87
  this.connect();
27
88
  this.dog.init();
28
89
  }
@@ -44,7 +105,9 @@ function () {
44
105
  var _this = this;
45
106
 
46
107
  this.closeOld();
47
- var options = ['-rtsp_transport', 'tcp', '-i', this.url, '-f', 'mpegts', '-codec:v', 'mpeg1video', '-'];
108
+
109
+ var options = __spread(this.options.input, [this.url], this.options.output, ['-']);
110
+
48
111
  this.s = child_process_1.spawn('ffmpeg', options, {
49
112
  detached: false
50
113
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-node",
3
- "version": "1.0.8-alpha.0",
3
+ "version": "1.0.10",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@types/node": "^17.0.25",
23
- "pubo-utils": "^1.0.8-alpha.0"
23
+ "pubo-utils": "^1.0.10"
24
24
  },
25
- "gitHead": "c53f05a089b215345e172ec93350d1b72188227a"
25
+ "gitHead": "64ad9dbebbf1770915c08294f09ec0e37d824adf"
26
26
  }