UNPKG

@rtn263net/cloudhub-rts-electron-sdk

Version:

cloudhub-rts-electron-sdk

221 lines (220 loc) 8.91 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 utils_1 = __importDefault(require("../helpers/utils")); const Renderer_1 = require("../Renderer"); const initPusherFun_1 = __importDefault(require("./initPusherFun")); const devicesManager_1 = __importDefault(require("./devicesManager")); class RtsUpStream extends initPusherFun_1.default { constructor(clientId) { super(clientId); } getVersion() { log_1.default.info('getVersion'); return this.cRtsPusher.getVersion(); } getClientId() { log_1.default.info('getClientId'); return this.cRtsPusher.getClientId(); } getStreamId() { log_1.default.info('getStreamId'); return this.cRtsPusher.getStreamId(); } startPush(urlPush) { log_1.default.info(`startPush urlPush:${urlPush}`); if (!urlPush) return; this.cRtsPusher.startPush(urlPush); } stopPush() { log_1.default.info('stopPush'); this.cRtsPusher.stopPush(); } isPushing() { log_1.default.info('isPushing'); return this.cRtsPusher.isPushing(); } setVideoQuality(width, height, fr, deviceId = "") { log_1.default.info(`setVideoQuality width:${width} height:${height} fr:${fr} deviceId:${deviceId}`); const objJson = `{"width":${width},"height":${height},"frameRate":${fr}}`; return this.cRtsPusher.setVideoQuality(JSON.parse(objJson), deviceId); } startCamera(deviceId = '') { log_1.default.info('startCamera'); this.cRtsPusher.startCamera(deviceId); } stopCamera(deviceId = '') { log_1.default.info('stopCamera'); this.cRtsPusher.stopCamera(deviceId); } startMicrophone() { log_1.default.info('startMicrophone'); this.cRtsPusher.startMicrophone(); } stopMicrophone() { log_1.default.info('stopMicrophone'); this.cRtsPusher.stopMicrophone(); } setAudioQuality(quality = 1) { log_1.default.info(`setAudioQuality quality: ${quality}`); this.cRtsPusher.setAudioQuality(quality); } enableVolumeIndication(interval) { log_1.default.info(`enableVolumeIndication interval: ${interval}`); return this.cRtsPusher.enableVolumeIndication(interval); } setupLocalVideo(view) { log_1.default.info(`setupLocalVideo view: ${view}`); this.cRtsPusher.setupLocalVideo(); const sourceId = this.cRtsPusher.getSourceId(); const renderer = new Renderer_1.GlRenderer(); renderer.bind(view); this.streamRenders[sourceId] = renderer; } removeLocalVideo() { log_1.default.info('removeLocalVideo'); const sourceId = this.cRtsPusher.getSourceId(); const rendererLocal = this.streamRenders[sourceId]; if (rendererLocal) { rendererLocal.unbind(); delete this.streamRenders[sourceId]; } this.cRtsPusher.removeLocalVideo(); } getSourceId() { return this.cRtsPusher.getSourceId(); } getUrl() { log_1.default.info('getUrl '); return this.cRtsPusher.getUrl(); } getDeviceManager() { log_1.default.info('getDeviceManager'); return (0, devicesManager_1.default)(this.devicesManager); } setBeautyEffectOptions(enable = false, options, deviceId = '') { log_1.default.info(`setBeautyEffectOptions enable:${enable} options:${options} deviceId:${deviceId}`); return this.cRtsPusher.setBeautyEffectOptions(enable, options, deviceId); } setVideoEffectOptions(enable = false, options, deviceId = '') { log_1.default.info(`setVideoEffectOptions enable:${enable} options:${options} deviceId:${deviceId}`); return this.cRtsPusher.setVideoEffectOptions(enable, options, deviceId); } startPlayMovie(mediaFile) { log_1.default.info(`startPlayMovie, mediaFile:${mediaFile}`); if (!mediaFile) return; this.cRtsPusher.startPlayMovie(mediaFile); } setupLocalMovie(view, movieUrl) { log_1.default.info('setupLocalMovie movieUrl:', movieUrl); this.cRtsPusher.setupLocalMovie(movieUrl); const sourceId = this.cRtsPusher.getSourceId(); const renderer = new Renderer_1.GlRenderer(); renderer.bind(view); this.streamRenders[sourceId] = renderer; } removeLocalMovie() { log_1.default.info('removeLocalVideo'); const sourceId = this.cRtsPusher.getSourceId(); const rendererLocal = this.streamRenders[sourceId]; if (rendererLocal) { rendererLocal.unbind(); delete this.streamRenders[sourceId]; } this.cRtsPusher.removeLocalMovie(); } stopPlayMovie(url) { log_1.default.info('stopPlayMovie'); this.cRtsPusher.stopPlayMovie(url); } pausePlayMovie(mediaFile) { log_1.default.info('pausePlayMovie mediaFile: ', mediaFile); if (!mediaFile) return; this.cRtsPusher.pausePlayMovie(mediaFile); } pauseMediaFile(mediaFile) { log_1.default.info('pauseMediaFile mediaFile: ', mediaFile); if (!mediaFile) return; this.cRtsPusher.pauseMediaFile(mediaFile); } getMovieInfo(mediaFile) { log_1.default.info('getMovieInfo', mediaFile); if (!mediaFile) return false; return this.cRtsPusher.getMovieInfo(mediaFile); } resumePlayMovie(mediaFile) { log_1.default.info('resumePlayMovie', mediaFile); if (!mediaFile) return; this.cRtsPusher.resumePlayMovie(mediaFile); } resumeMediaFile(mediaFile) { log_1.default.info('resumeMediaFile', mediaFile); if (!mediaFile) return; this.cRtsPusher.resumeMediaFile(mediaFile); } getMovieDuration(mediaFile) { log_1.default.info(`getMovieDuration mediaFile:${mediaFile}`); return this.cRtsPusher.getMovieDuration(mediaFile); } getMovieCurrentPosition(mediaFile) { log_1.default.info(`getMovieCurrentPosition mediaFile:${mediaFile}`); if (!mediaFile) return false; return this.cRtsPusher.getMovieCurrentPosition(mediaFile); } setMoviePosition(mediaFile, pos) { log_1.default.info('setMoviePosition', mediaFile, pos); if (!mediaFile) return; this.cRtsPusher.setMoviePosition(mediaFile, utils_1.default.strToNum(pos)); } getScreenWindowsInfo() { log_1.default.info('getScreenWindowsInfo'); return this.cRtsPusher.getScreenWindowsInfo(); } getScreenDisplaysInfo() { log_1.default.info('getScreenDisplaysInfo'); return this.cRtsPusher.getScreenDisplaysInfo(); } startScreenCaptureByDisplayId(displayId, excludeWindow, framerate = 5, isCaptureCursor = false) { log_1.default.info(`startScreenCaptureByDisplayId displayId: ${displayId} excludeWindow: ${excludeWindow} framerate: ${framerate} isCaptureCursor: ${isCaptureCursor}`); this.cRtsPusher.startScreenCaptureByDisplayId(displayId, excludeWindow, framerate, 1200, isCaptureCursor); } startScreenCaptureByWindowId(windowId, excludeWindow = 0, framerate = 5, isCaptureCursor = false) { log_1.default.info('startScreenCaptureByWindowId', windowId, excludeWindow, framerate, isCaptureCursor); return this.cRtsPusher.startScreenCaptureByWindowId(windowId, excludeWindow, framerate, 1200, isCaptureCursor); } stopScreenCapture() { log_1.default.info('stopScreenCapture'); this.cRtsPusher.stopScreenCapture(); } startSpeakerCaptureWhileSharing() { log_1.default.info('startSpeakerCaptureWhileSharing'); this.cRtsPusher.startSpeakerCaptureWhileSharing(); } stopSpeakerCaptureWhileSharing() { log_1.default.info('stopSpeakerCaptureWhileSharing'); this.cRtsPusher.stopSpeakerCaptureWhileSharing(); } enableDeepLearningDenoise(enabled = true) { log_1.default.info(`enableDeepLearningDenoise enabled:${enabled}`); return this.cRtsPusher.enableDeepLearningDenoise(enabled); } 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 = RtsUpStream;