decord/alpha/source/modules/go_live/GoLiveQualityManager.tsx

130 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 5222
// Function ID: 5223
// Name: GoLiveQualityManager
2026-10-09 10:00:15 +00:00
// Dependencies: [5139, 3, 2059, 2]
2026-07-20 16:05:17 +00:00
2026-10-09 10:00:15 +00:00
// Module 5222 (GoLiveQualityManager)
import LoggerDefault from "Logger" /* 3 */;
2026-10-09 10:00:15 +00:00
import Timers from "Timers" /* 2059 */;
import TypedEventEmitter from "TypedEventEmitter" /* 5139 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
const GoLiveQualityManagerEvent = { RequestedSSRCsUpdate: "requested-ssrcs-update", RequestedStreamsUpdate: "requested-streams-update" };
2026-10-03 08:58:59 +00:00
class GoLiveQualityManager extends TypedEventEmitter {
2026-07-29 08:29:29 +00:00
constructor() {
2026-10-03 08:58:59 +00:00
const tmp6 = new GoLiveQualityManager(tmp5, tmp4, tmp3, new.target, this, tmp2, undefined, tmp);
let closure_0 = tmp6;
2026-07-29 08:29:29 +00:00
tmp6.streamId = null;
tmp6.resolutionWidth = 0;
tmp6.resolutionHeight = 0;
tmp6.zoom = 1;
tmp6.audioSSRC = 0;
tmp6.incomingVideoEnabled = true;
tmp6.delayedUpdate = function delayedUpdate() {
2026-10-03 08:58:59 +00:00
delayedCall = delayedCall.delayedCall;
2026-07-29 08:29:29 +00:00
delayedCall.delay();
};
2026-10-03 08:58:59 +00:00
tmp6.logger = new LoggerDefault("GoLiveQualityManager");
const logger = tmp6.logger;
new LoggerDefault("GoLiveQualityManager");
logger.enableNativeLogger(true);
let delayedCall = new Timers.DelayedCall(500, () => {
closure_0.update();
2026-07-29 08:29:29 +00:00
});
tmp6.delayedCall = delayedCall;
return tmp6;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
setUserID(userId) {
this.userId = userId;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
getUserID() {
return this.userId;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
updateAudioAndVideoStreamInfo(audioSSRC, items) {
this.audioSSRC = audioSSRC;
this.videoStream = items.find((active) => active.active);
this.update();
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
onIncomingVideoEnabled(incomingVideoEnabled) {
const self = this;
if (this.incomingVideoEnabled !== incomingVideoEnabled) {
const logger = self.logger;
logger.info("onIncomingVideoEnabled", incomingVideoEnabled);
self.incomingVideoEnabled = incomingVideoEnabled;
self.update();
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
update() {
const self = this;
const tmp = null != this.userId && null != self.videoStream;
if (tmp) {
if (self.incomingVideoEnabled) {
const stream = self.requestStream();
} else {
self.stopStream();
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
requestStream() {
const self = this;
if (null != this.videoStream) {
const obj = {};
obj[self.videoStream.ssrc] = 100;
const items = [self.videoStream.ssrc];
self.request(obj, items);
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
stopStream() {
const self = this;
if (null != this.videoStream) {
const obj = {};
obj[self.videoStream.ssrc] = 0;
self.request(obj, []);
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
request(arg0, arr) {
const self = this;
if (undefined !== this.userId) {
let closure_0 = arg0;
const item = arr.forEach((item) => {
if (null == pixelCounts.pixelCounts) {
pixelCounts.pixelCounts = {};
}
if (pixelCounts[item] > 0) {
const _Math = Math;
pixelCounts.pixelCounts[item] = Math.floor(self.resolutionWidth * self.resolutionHeight * self.zoom * self.zoom);
}
});
self.emit(obj.RequestedSSRCsUpdate, self.userId, self.audioSSRC, arr);
self.emit(obj.RequestedStreamsUpdate, arg0);
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
setVideoSize(arg0, arg1, zoom) {
const self = this;
if (this.streamId === arg0) {
if (null != arg1) {
({ width: self.resolutionWidth, height: self.resolutionHeight } = arg1);
}
if (null != zoom) {
self.zoom = zoom;
}
self.delayedUpdate();
}
}
setStreamId(streamId) {
const self = this;
if (this.streamId !== streamId) {
self.streamId = streamId;
self.resolutionWidth = 0;
self.resolutionHeight = 0;
self.zoom = 1;
self.delayedUpdate();
}
}
}
const prototype = GoLiveQualityManager.prototype;
const result = size.fileFinishedImporting("modules/go_live/GoLiveQualityManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default GoLiveQualityManager;
export { GoLiveQualityManagerEvent };