@skyway-sdk/core
Version:
The official Next Generation JavaScript SDK for SkyWay
57 lines • 2.46 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalCustomVideoStream = void 0;
const common_1 = require("@skyway-sdk/common");
const media_1 = require("./media");
const log = new common_1.Logger('packages/core/src/media/stream/local/customVideo.ts');
class LocalCustomVideoStream extends media_1.LocalMediaStreamBase {
constructor(options = {}) {
super(media_1.emptyVideoTrack, 'video', options);
this.contentType = 'video';
this._promiseQueue = new common_1.PromiseQueue();
this._stream = null;
}
/**@internal */
setStream(processedStream) {
return __awaiter(this, void 0, void 0, function* () {
if (this._stream) {
throw new Error('ProcessedStream is already exists');
}
this._stream = processedStream;
this._updateTrack(processedStream.track);
});
}
/**@internal */
setEnabled(enabled) {
return __awaiter(this, void 0, void 0, function* () {
yield this._promiseQueue.push(() => __awaiter(this, void 0, void 0, function* () {
var _a;
yield ((_a = this._stream) === null || _a === void 0 ? void 0 : _a.setEnabled(enabled));
}));
});
}
/**@internal */
updateTrack(track) {
return __awaiter(this, void 0, void 0, function* () {
this._updateTrack(track);
this._onEnableChanged.emit(track);
});
}
release() {
var _a;
(_a = this._stream) === null || _a === void 0 ? void 0 : _a.dispose().catch(() => {
log.error('release failed');
});
}
}
exports.LocalCustomVideoStream = LocalCustomVideoStream;
//# sourceMappingURL=customVideo.js.map