UNPKG

@rtn263net/cloudhub-rts-electron-sdk

Version:

cloudhub-rts-electron-sdk

105 lines (104 loc) 4.82 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 rts_addon = require('./../../addon/Release/rts_addon.node'); const globalInfo_1 = require("../globalInfo"); class RtsUpStreamEventHandler { constructor(clientId) { this.cRtsPusher = new rts_addon.NodeRtsPusher(clientId); this.devicesManager = this.cRtsPusher.getDeviceManager(); this.streamRenders = globalInfo_1.streamRenders; this.innerEvent = new event_1.PlayerEvent(); log_1.default.info('rts_addon', this.cRtsPusher); const that = this; this.cRtsPusher.onEvent('firstlocalvideoframe', (sourceId, width, height) => { log_1.default.debug(`firstlocalvideoframe sourceId:${sourceId} width:${width} height:${height}`); that.innerEvent.trigger('firstlocalvideoframe', { sourceId, width, height, }); }); this.cRtsPusher.onEvent('error', (err, msg) => { log_1.default.info(`onError err:${err} msg:${msg}`); that.innerEvent.trigger('error', { err, msg }); }); this.cRtsPusher.onEvent('apierror', (functionName) => { log_1.default.info(`onApierror functionName:${functionName}`); that.innerEvent.trigger('apierror', { functionName }); }); this.cRtsPusher.onEvent('volumeindication', (sourceId, totalVolume) => { log_1.default.debug(`volumeindication sourceId:${sourceId} totalVolume:${totalVolume}`); that.innerEvent.trigger('volumeindication', { sourceId, totalVolume, }); }); this.cRtsPusher.onEvent('rtsstats', (sourceId, stats) => { log_1.default.debug(`rtsstats sourceId:${sourceId} stats:${stats}`); that.innerEvent.trigger('rtsstats', { sourceId, stats, }); }); this.cRtsPusher.onEvent('audiodevicestatechanged', (sourceId, deviceId, deviceType, state) => { log_1.default.debug(`audiodevicestatechanged sourceId:${sourceId} deviceId:${deviceId} deviceType:${deviceType} state:${state}`); that.innerEvent.trigger('audiodevicestatechanged', { sourceId, deviceId, deviceType, state, }); }); this.cRtsPusher.onEvent('videodevicestatechanged', (sourceId, state) => { log_1.default.debug(`videodevicestatechanged sourceId:${sourceId} state:${state}`); that.innerEvent.trigger('videodevicestatechanged', { sourceId, state, }); }); this.cRtsPusher.onEvent('videosizechanged', (sourceId, width, height) => { log_1.default.debug(`videosizechanged sourceId:${sourceId} width:${width} height:${height}`); that.innerEvent.trigger('videosizechanged', { sourceId, width, height, }); }); this.cRtsPusher.onEvent('pushstateupdated', (sourceId, state) => { log_1.default.debug(`pushstateupdated sourceId:${sourceId} state:${state}`); that.innerEvent.trigger('pushstateupdated', { sourceId, state, }); }); this.cRtsPusher.onEvent('firstlocalaudioframe', (sourceId) => { log_1.default.debug(`firstlocalaudioframe sourceId:${sourceId}`); that.innerEvent.trigger('firstlocalaudioframe', { sourceId, }); }); this.cRtsPusher.onEvent('localVideoStateChanged', (sourceId, state, error) => { log_1.default.debug(`localVideoStateChanged sourceId:${sourceId} state:${state} error:${error}`); that.innerEvent.trigger('localVideoStateChanged', { sourceId, state, error, }); }); this.cRtsPusher.onEvent('localAudioStateChanged', (sourceId, state, error) => { log_1.default.debug(`localAudioStateChanged sourceId:${sourceId} state:${state} error:${error}`); that.innerEvent.trigger('localAudioStateChanged', { sourceId, state, error, }); }); this.cRtsPusher.registerDeliverFrame(globalInfo_1.registerDeliverFrame); } } exports.default = RtsUpStreamEventHandler;