awrtc_browser
Version:
Compatible browser implementation to the Unity asset WebRTC Video Chat. Try examples in build folder
58 lines • 2.06 kB
JavaScript
import { DeviceApi } from "./DeviceApi";
import { VideoInput } from "./VideoInput";
var Media = /** @class */ (function () {
function Media() {
this.videoInput = null;
}
Object.defineProperty(Media, "SharedInstance", {
/**
* Singleton used for now as the browser version is missing a proper factory yet.
* Might be removed later.
*/
get: function () {
return this.sSharedInstance;
},
enumerable: true,
configurable: true
});
Media.ResetSharedInstance = function () {
this.sSharedInstance = new Media();
};
Object.defineProperty(Media.prototype, "VideoInput", {
get: function () {
if (this.videoInput === null)
this.videoInput = new VideoInput();
return this.videoInput;
},
enumerable: true,
configurable: true
});
Media.prototype.GetVideoDevices = function () {
var real_devices = DeviceApi.GetVideoDevices();
var virtual_devices = this.VideoInput.GetDeviceNames();
return real_devices.concat(virtual_devices);
};
Media.prototype.getUserMedia = function (config) {
var _this = this;
if (config.VideoDeviceName !== null
&& config.VideoDeviceName !== ""
&& this.videoInput != null
&& this.videoInput.HasDevice(config.VideoDeviceName)) {
return new Promise(function (resolve, reject) {
try {
var res = _this.videoInput.GetStream(config.VideoDeviceName);
resolve(res);
}
catch (err) {
reject(err);
}
});
}
return DeviceApi.getAssetUserMedia(config);
};
//experimental. Will be used instead of the device api to create streams
Media.sSharedInstance = new Media();
return Media;
}());
export { Media };
//# sourceMappingURL=Media.js.map