UNPKG

@rtn263net/cloudhub-rts-electron-sdk

Version:

cloudhub-rts-electron-sdk

131 lines (130 loc) 4.61 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const log_1 = __importDefault(require("../helpers/log")); const Renderer_1 = require("../Renderer"); const initPullerFun_1 = __importDefault(require("./initPullerFun")); const devicesManager_1 = __importDefault(require("./devicesManager")); class RtsDownStream extends initPullerFun_1.default { constructor(clientId) { super(clientId); } getVersion() { log_1.default.info('getVersion'); return this.cRtsPuller.getVersion(); } getClientId() { log_1.default.info('getClientId'); return this.cRtsPuller.getClientId(); } startPull(urlPull) { log_1.default.info(`startPush urlPush:${urlPull}`); if (!urlPull) return; this.cRtsPuller.startPull(urlPull); } stopPull() { log_1.default.info('stopPull'); this.cRtsPuller.stopPull(); } isPulling() { log_1.default.info('isPulling'); return this.cRtsPuller.isPulling(); } pauseAudio() { log_1.default.info('pauseAudio'); return this.cRtsPuller.pauseAudio(); } resumeAudio() { log_1.default.info('resumeAudio'); return this.cRtsPuller.resumeAudio(); } pauseVideo() { log_1.default.info('pauseVideo'); return this.cRtsPuller.pauseVideo(); } resumeVideo() { log_1.default.info('resumeVideo'); return this.cRtsPuller.resumeVideo(); } enableVolumeIndication(interval) { log_1.default.info(`enableVolumeIndication interval: ${interval}`); return this.cRtsPuller.enableVolumeIndication(interval); } getUrl() { log_1.default.info('getUrl '); return this.cRtsPuller.getUrl(); } setupRemoteVideo(view) { log_1.default.info(`setupRemoteVideo view: ${view}`); this.cRtsPuller.setupRemoteVideo(); const sourceId = this.cRtsPuller.getSourceId(); const renderer = new Renderer_1.GlRenderer(); renderer.bind(view); this.streamRenders[sourceId] = renderer; } onRegisterDeliverFrame(infos) { const len = infos.length; for (let i = 0; i < len; i++) { const info = infos[i]; const { streamId, header, ydata, udata, vdata } = info; if (!header || !ydata || !udata || !vdata) { console.log('Invalid data param 没有数据: ' + header + ' ' + ydata + ' ' + udata + ' ' + vdata); continue; } const rendererLocal = this.streamRenders[streamId]; if (rendererLocal) { rendererLocal.drawFrame({ header, yUint8Array: ydata, uUint8Array: udata, vUint8Array: vdata, }); continue; } const renderer = this.streamRenders[streamId]; if (!renderer) { console.warn(`Can't find remote renderer for streamId 没有找到远端的streamId : ${streamId}`, infos); continue; } renderer.drawFrame({ header, yUint8Array: ydata, uUint8Array: udata, vUint8Array: vdata, }); } } removeRemoteVideo() { log_1.default.info('removeRemoteVideo'); const sourceId = this.cRtsPuller.getSourceId(); const renderremote = this.streamRenders[sourceId]; if (renderremote) { renderremote.unbind(); delete this.streamRenders[sourceId]; } this.cRtsPuller.removeRemoteVideo(); } getDeviceManager() { log_1.default.info('getDeviceManager'); return (0, devicesManager_1.default)(this.devicesManager); } getSourceId() { return this.cRtsPuller.getSourceId(); } setStreamConfigs(option) { if (!option) { option = { delay_time_ms: 500 }; } this.cRtsPuller.setStreamConfigs(option); } onEvent(eventNname, fn) { const newS = eventNname.slice(2); const first = newS[0].toLowerCase(); const new_eventNname = first + newS.slice(1); this.innerEvent.on(new_eventNname, fn); } } exports.default = RtsDownStream;