sp-broadcaster
Version:
I'm the container that runs Streamplace broadcasts!
76 lines (56 loc) • 3.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _spClient = require("sp-client");
var _spClient2 = _interopRequireDefault(_spClient);
var _winston = require("winston");
var _winston2 = _interopRequireDefault(_winston);
var _fileStreamManager = require("./file-stream-manager");
var _fileStreamManager2 = _interopRequireDefault(_fileStreamManager);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var FileStreamer = function () {
function FileStreamer(_ref) {
var _this = this;
var broadcastId = _ref.broadcastId,
podIp = _ref.podIp;
_classCallCheck(this, FileStreamer);
_winston2.default.info("FileStreamer booting up for " + JSON.stringify({ broadcastId: broadcastId, podIp: podIp }));
this.broadcastId = broadcastId;
this.podIp = podIp;
this.managers = {};
_spClient2.default.broadcasts.watch({ id: broadcastId }).on("data", function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 1),
broadcast = _ref3[0];
if (!broadcast) {
_winston2.default.warn("Looks like broadcast " + broadcastId + " was deleted, holding...");
return;
}
broadcast.sources.filter(function (s) {
return s.kind === "File";
}).forEach(function (source) {
if (_this.managers[source.id]) {
// We're already streamin' this one. Great.
return;
}
_this.managers[source.id] = new _fileStreamManager2.default({
fileId: source.id
});
});
}).on("deletedDoc", function () {
_this.managers.forEach(function (m) {
return m.shutdown();
});
});
}
_createClass(FileStreamer, [{
key: "playVideo",
value: function playVideo() {}
}]);
return FileStreamer;
}();
exports.default = FileStreamer;
//# sourceMappingURL=file-streamer.js.map