@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
166 lines (165 loc) • 9.28 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OutboundRtpEncoder = exports.QualityLimitationDurationsEncoder = void 0;
const utils_1 = require("./utils");
const OutputSamples_1 = require("./OutputSamples");
class QualityLimitationDurationsEncoder {
get actualValue() {
return this._value;
}
reset() {
this._value = undefined;
}
encode(newValue) {
if (newValue === undefined)
return;
if (newValue.bandwidth === this._value?.bandwidth &&
newValue.cpu === this._value?.cpu &&
newValue.none === this._value?.none &&
newValue.other === this._value?.other) {
return;
}
this._value = newValue;
return new OutputSamples_1.ClientSample_PeerConnectionSample_OutboundRtpStats_QualityLimitationDurations({
bandwidth: newValue.bandwidth,
cpu: newValue.cpu,
none: newValue.none,
other: newValue.other,
});
}
}
exports.QualityLimitationDurationsEncoder = QualityLimitationDurationsEncoder;
class OutboundRtpEncoder {
constructor(ssrc, _attachmentsEncoder) {
this._attachmentsEncoder = _attachmentsEncoder;
this._visited = false;
this._ssrc = BigInt(ssrc);
this._idEncoder = new utils_1.StringToStringEncoder();
this._kindEncoder = new utils_1.StringToStringEncoder();
this._timestampEncoder = new utils_1.NumberToNumberEncoder();
this._activeEncoder = new utils_1.BooleanToBooleanEncoder();
this._bytesSentEncoder = new utils_1.NumberToBigIntEncoder();
this._codecIdEncoder = new utils_1.OneTimePassEncoder();
this._encoderImplementationEncoder = new utils_1.OneTimePassEncoder();
this._firCountEncoder = new utils_1.NumberToNumberEncoder();
this._frameHeightEncoder = new utils_1.NumberToNumberEncoder();
this._frameWidthEncoder = new utils_1.NumberToNumberEncoder();
this._framesEncodedEncoder = new utils_1.NumberToNumberEncoder();
this._framesPerSecondEncoder = new utils_1.NumberToNumberEncoder();
this._framesSentEncoder = new utils_1.NumberToNumberEncoder();
this._headerBytesSentEncoder = new utils_1.NumberToBigIntEncoder();
this._hugeFramesSentEncoder = new utils_1.NumberToNumberEncoder();
this._keyFramesEncodedEncoder = new utils_1.NumberToNumberEncoder();
this._mediaSourceIdEncoder = new utils_1.OneTimePassEncoder();
this._midEncoder = new utils_1.OneTimePassEncoder();
this._nackCountEncoder = new utils_1.NumberToNumberEncoder();
this._packetsSentEncoder = new utils_1.NumberToNumberEncoder();
this._pliCountEncoder = new utils_1.NumberToNumberEncoder();
this._powerEfficientEncoderEncoder = new utils_1.BooleanToBooleanEncoder();
this._qpSumEncoder = new utils_1.NumberToNumberEncoder();
this._qualityLimitationDurationsEncoder = new QualityLimitationDurationsEncoder();
this._qualityLimitationReasonEncoder = new utils_1.StringToStringEncoder();
this._qualityLimitationResolutionChangesEncoder = new utils_1.NumberToNumberEncoder();
this._remoteIdEncoder = new utils_1.StringToStringEncoder();
this._retransmittedBytesSentEncoder = new utils_1.NumberToBigIntEncoder();
this._retransmittedPacketsSentEncoder = new utils_1.NumberToNumberEncoder();
this._ridEncoder = new utils_1.StringToStringEncoder();
this._rtxSsrcEncoder = new utils_1.NumberToBigIntEncoder();
this._scalabilityModeEncoder = new utils_1.StringToStringEncoder();
this._targetBitrateEncoder = new utils_1.NumberToNumberEncoder();
this._totalEncodeTimeEncoder = new utils_1.NumberToNumberEncoder();
this._totalEncodedBytesTargetEncoder = new utils_1.NumberToBigIntEncoder();
this._totalPacketSendDelayEncoder = new utils_1.NumberToNumberEncoder();
this._transportIdEncoder = new utils_1.OneTimePassEncoder();
}
get visited() {
const result = this._visited;
this._visited = false;
return result;
}
reset() {
this._idEncoder.reset();
this._kindEncoder.reset();
this._timestampEncoder.reset();
this._activeEncoder.reset();
this._bytesSentEncoder.reset();
this._codecIdEncoder.reset();
this._encoderImplementationEncoder.reset();
this._firCountEncoder.reset();
this._frameHeightEncoder.reset();
this._frameWidthEncoder.reset();
this._framesEncodedEncoder.reset();
this._framesPerSecondEncoder.reset();
this._framesSentEncoder.reset();
this._headerBytesSentEncoder.reset();
this._hugeFramesSentEncoder.reset();
this._keyFramesEncodedEncoder.reset();
this._mediaSourceIdEncoder.reset();
this._midEncoder.reset();
this._nackCountEncoder.reset();
this._packetsSentEncoder.reset();
this._pliCountEncoder.reset();
this._powerEfficientEncoderEncoder.reset();
this._qpSumEncoder.reset();
this._qualityLimitationDurationsEncoder.reset();
this._qualityLimitationReasonEncoder.reset();
this._qualityLimitationResolutionChangesEncoder.reset();
this._remoteIdEncoder.reset();
this._retransmittedBytesSentEncoder.reset();
this._retransmittedPacketsSentEncoder.reset();
this._ridEncoder.reset();
this._rtxSsrcEncoder.reset();
this._scalabilityModeEncoder.reset();
this._targetBitrateEncoder.reset();
this._totalEncodeTimeEncoder.reset();
this._totalEncodedBytesTargetEncoder.reset();
this._totalPacketSendDelayEncoder.reset();
this._transportIdEncoder.reset();
}
encode(sample) {
this._visited = true;
const result = new OutputSamples_1.ClientSample_PeerConnectionSample_OutboundRtpStats({
ssrc: this._ssrc,
id: this._idEncoder.encode(sample.id),
kind: this._kindEncoder.encode(sample.kind),
timestamp: this._timestampEncoder.encode(sample.timestamp),
active: this._activeEncoder.encode(sample.active),
attachments: this._attachmentsEncoder.encode(sample.attachments),
bytesSent: this._bytesSentEncoder.encode(sample.bytesSent),
codecId: this._codecIdEncoder.encode(sample.codecId),
encoderImplementation: this._encoderImplementationEncoder.encode(sample.encoderImplementation),
firCount: this._firCountEncoder.encode(sample.firCount),
frameHeight: this._frameHeightEncoder.encode(sample.frameHeight),
frameWidth: this._frameWidthEncoder.encode(sample.frameWidth),
framesEncoded: this._framesEncodedEncoder.encode(sample.framesEncoded),
framesPerSecond: this._framesPerSecondEncoder.encode(sample.framesPerSecond),
framesSent: this._framesSentEncoder.encode(sample.framesSent),
headerBytesSent: this._headerBytesSentEncoder.encode(sample.headerBytesSent),
hugeFramesSent: this._hugeFramesSentEncoder.encode(sample.hugeFramesSent),
keyFramesEncoded: this._keyFramesEncodedEncoder.encode(sample.keyFramesEncoded),
mediaSourceId: this._mediaSourceIdEncoder.encode(sample.mediaSourceId),
mid: this._midEncoder.encode(sample.mid),
nackCount: this._nackCountEncoder.encode(sample.nackCount),
packetsSent: this._packetsSentEncoder.encode(sample.packetsSent),
pliCount: this._pliCountEncoder.encode(sample.pliCount),
powerEfficientEncoder: this._powerEfficientEncoderEncoder.encode(sample.powerEfficientEncoder),
qpSum: this._qpSumEncoder.encode(sample.qpSum),
qualityLimitationDurations: this._qualityLimitationDurationsEncoder.encode(sample.qualityLimitationDurations),
qualityLimitationReason: this._qualityLimitationReasonEncoder.encode(sample.qualityLimitationReason),
qualityLimitationResolutionChanges: this._qualityLimitationResolutionChangesEncoder.encode(sample.qualityLimitationResolutionChanges),
remoteId: this._remoteIdEncoder.encode(sample.remoteId),
retransmittedBytesSent: this._retransmittedBytesSentEncoder.encode(sample.retransmittedBytesSent),
retransmittedPacketsSent: this._retransmittedPacketsSentEncoder.encode(sample.retransmittedPacketsSent),
rid: this._ridEncoder.encode(sample.rid),
rtxSsrc: this._rtxSsrcEncoder.encode(sample.rtxSsrc),
scalabilityMode: this._scalabilityModeEncoder.encode(sample.scalabilityMode),
targetBitrate: this._targetBitrateEncoder.encode(sample.targetBitrate),
totalEncodeTime: this._totalEncodeTimeEncoder.encode(sample.totalEncodeTime),
totalEncodedBytesTarget: this._totalEncodedBytesTargetEncoder.encode(sample.totalEncodedBytesTarget),
totalPacketSendDelay: this._totalPacketSendDelayEncoder.encode(sample.totalPacketSendDelay),
transportId: this._transportIdEncoder.encode(sample.transportId),
});
return result;
}
}
exports.OutboundRtpEncoder = OutboundRtpEncoder;