Initial commit
This commit is contained in:
275
Backend/dist/Integrations/buildin/wirecast/WirecastConnection.js
vendored
Normal file
275
Backend/dist/Integrations/buildin/wirecast/WirecastConnection.js
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
exports.__esModule = true;
|
||||
exports.WirecastConnection = void 0;
|
||||
var axios_1 = require("axios");
|
||||
var WirecastConnection = /** @class */ (function () {
|
||||
function WirecastConnection() {
|
||||
var _this = this;
|
||||
this.shots = {
|
||||
'1': { shots: {} },
|
||||
'2': { shots: {} },
|
||||
'3': { shots: {} },
|
||||
'4': { shots: {} },
|
||||
'5': { shots: {} }
|
||||
};
|
||||
this.layers = {
|
||||
'1': { id: null, name: null },
|
||||
'2': { id: null, name: null },
|
||||
'3': { id: null, name: null },
|
||||
'4': { id: null, name: null },
|
||||
'5': { id: null, name: null }
|
||||
};
|
||||
this.clockInterval = setInterval(function () {
|
||||
_this.clock();
|
||||
}, 30000);
|
||||
}
|
||||
WirecastConnection.prototype.destroy = function () {
|
||||
clearInterval(this.clockInterval);
|
||||
};
|
||||
WirecastConnection.prototype.clock = function () {
|
||||
this.update();
|
||||
};
|
||||
WirecastConnection.prototype.update = function () {
|
||||
if (this.ip != undefined && this.port != undefined) {
|
||||
// axios
|
||||
// .get(`http://${this.ip}:${this.port}/api/v2/shots/get`)
|
||||
// .then((response) => {
|
||||
// if (response.data != undefined && response.data.succeed == true) {
|
||||
// this.shots = response.data.shots;
|
||||
// }
|
||||
// })
|
||||
// .catch(() => {});
|
||||
// axios
|
||||
// .get(`http://${this.ip}:${this.port}/api/v2/layers/get`)
|
||||
// .then((response) => {
|
||||
// if (response.data != undefined && response.data.succeed == true) {
|
||||
// this.layers = response.data.layers;
|
||||
// }
|
||||
// })
|
||||
// .catch(() => {});
|
||||
}
|
||||
};
|
||||
WirecastConnection.prototype.setHost = function (ip, port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.update();
|
||||
};
|
||||
WirecastConnection.prototype.ping = function (callback) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/ping")
|
||||
.then(function () {
|
||||
if (callback)
|
||||
callback(true);
|
||||
if (callback == undefined)
|
||||
resolve();
|
||||
})["catch"](function (error) {
|
||||
if (callback)
|
||||
callback(false);
|
||||
if (callback == undefined)
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.setShotLiveByID = function (shotID) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/shots/liveByID/" + shotID)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.clearShotIfLive = function (shotID) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/shots/clearIfLive/" + shotID)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.clearLayer = function (layerID) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/layers/clear/" + layerID)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.go = function () {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log("http://" + _this.ip + ":" + _this.port + "/api/v2/document/go");
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/document/go")
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.multiShot = function (layer1Shot, layer2Shot, layer3Shot, layer4Shot, layer5Shot) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this
|
||||
.port + "/api/v2/shots/multi/" + layer1Shot + "/" + layer2Shot + "/" + layer3Shot + "/" + layer4Shot + "/" + layer5Shot)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve(response.data);
|
||||
else
|
||||
reject(response.data);
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject({ succeed: false, error: 'Unable to reach Wirecast-Bridge' });
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.setBroadcasting = function (state) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/document/broadcasting/" + state)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject('Unable to reach Wirecast-Bridge');
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.setRecording = function (state) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/document/recording/" + state)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject('Unable to reach Wirecast-Bridge');
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.setAutoLive = function (state) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/document/autolive/" + state)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject('Unable to reach Wirecast-Bridge');
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.setTransitionSpeed = function (speed) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
axios_1["default"]
|
||||
.get("http://" + _this.ip + ":" + _this.port + "/api/v2/document/transitionspeed/" + speed)
|
||||
.then(function (response) {
|
||||
if (response.data.succeed == true)
|
||||
resolve();
|
||||
else
|
||||
reject();
|
||||
})["catch"](function (error) {
|
||||
console.log(error);
|
||||
reject('Unable to reach Wirecast-Bridge');
|
||||
});
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.getShots = function (callback) {
|
||||
var _this = this;
|
||||
if (this.ip != undefined && this.port != undefined) {
|
||||
axios_1["default"]
|
||||
.get("http://" + this.ip + ":" + this.port + "/api/v2/shots/get")
|
||||
.then(function (response) {
|
||||
if (response.data != undefined && response.data.succeed == true) {
|
||||
_this.shots = response.data.shots;
|
||||
callback(_this.shots);
|
||||
}
|
||||
})["catch"](function () { });
|
||||
}
|
||||
};
|
||||
WirecastConnection.prototype.getShotsList = function (layerIndex, callback) {
|
||||
var _this = this;
|
||||
this.getShots(function () {
|
||||
var list = [];
|
||||
if (layerIndex == undefined)
|
||||
for (var layer in _this.shots) {
|
||||
for (var shot in _this.shots[layer].shots) {
|
||||
list.push(_this.shots[layer].shots[shot]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var shot in _this.shots[layerIndex].shots) {
|
||||
list.push(_this.shots[layerIndex].shots[shot]);
|
||||
}
|
||||
}
|
||||
callback(list);
|
||||
});
|
||||
};
|
||||
WirecastConnection.prototype.getLayers = function (callback) {
|
||||
var _this = this;
|
||||
axios_1["default"]
|
||||
.get("http://" + this.ip + ":" + this.port + "/api/v2/layers/get")
|
||||
.then(function (response) {
|
||||
if (response.data != undefined && response.data.succeed == true) {
|
||||
_this.layers = response.data.layers;
|
||||
callback(_this.layers);
|
||||
}
|
||||
})["catch"](function () { });
|
||||
};
|
||||
WirecastConnection.prototype.getLayersList = function (callback) {
|
||||
var _this = this;
|
||||
this.getLayers(function () {
|
||||
var list = [];
|
||||
for (var layer in _this.layers) {
|
||||
list.push(_this.layers[layer]);
|
||||
}
|
||||
callback(list);
|
||||
});
|
||||
};
|
||||
return WirecastConnection;
|
||||
}());
|
||||
exports.WirecastConnection = WirecastConnection;
|
||||
//# sourceMappingURL=WirecastConnection.js.map
|
||||
Reference in New Issue
Block a user