UNPKG

@rtn263net/cloudhub-rts-electron-sdk

Version:

cloudhub-rts-electron-sdk

79 lines (78 loc) 3.55 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 event_1 = require("../helpers/event"); const globalInfo_1 = require("../globalInfo"); const rts_addon = require('./../../addon/Release/rts_addon.node'); class RtsDownStreamEventHandler { constructor(clientId) { this.cRtsPuller = new rts_addon.NodeRtsPuller(clientId); this.devicesManager = this.cRtsPuller.getDeviceManager(); this.innerEvent = new event_1.PlayerEvent(); this.streamRenders = globalInfo_1.streamRenders; log_1.default.info('rts_addon', this.cRtsPuller); const that = this; this.cRtsPuller.onEvent('volumeindication', (sourceId, totalVolume) => { log_1.default.debug(`volumeindication sourceId:${sourceId} totalVolume:${totalVolume}`); that.innerEvent.trigger('volumeindication', { sourceId, totalVolume, }); }); this.cRtsPuller.onEvent('rtsstats', (sourceId, stats) => { log_1.default.debug(`rtsstats sourceId:${sourceId} stats:${stats}`); that.innerEvent.trigger('rtsstats', { sourceId, stats, }); }); this.cRtsPuller.onEvent('pullstateupdated', (sourceId, state) => { log_1.default.debug(`pullstateupdated sourceId:${sourceId} state:${state}`); that.innerEvent.trigger('pullstateupdated', { sourceId, state, }); }); this.cRtsPuller.onEvent('videosizechanged', (sourceId, width, height) => { log_1.default.debug(`videosizechanged sourceId:${sourceId} width:${width} height:${height}`); that.innerEvent.trigger('videosizechanged', { sourceId, width, height, }); }); this.cRtsPuller.onEvent('remoteVideoStateChanged', (sourceId, state) => { log_1.default.debug(`remoteVideoStateChanged sourceId:${sourceId} state:${state} `); that.innerEvent.trigger('remoteVideoStateChanged', { sourceId, state, }); }); this.cRtsPuller.onEvent('firstremotevideoframe', (sourceId, width, height) => { log_1.default.debug(`firstremotevideoframe sourceId:${sourceId} width:${width} height:${height}`); that.innerEvent.trigger('firstremotevideoframe', { sourceId, width, height, }); }); this.cRtsPuller.onEvent('firstremoteaudioframe', (sourceId) => { log_1.default.debug(`firstremoteaudioframe sourceId:${sourceId}`); that.innerEvent.trigger('firstremoteaudioframe', { sourceId, }); }); this.cRtsPuller.onEvent('remoteAudioStateChanged', (sourceId, state) => { log_1.default.debug(`remoteAudioStateChanged sourceId:${sourceId} state:${state}`); that.innerEvent.trigger('remoteAudioStateChanged', { sourceId, state, }); }); this.cRtsPuller.registerDeliverFrame(globalInfo_1.registerDeliverFrame); } } exports.default = RtsDownStreamEventHandler;