@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
220 lines (219 loc) • 14.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InboundRtpEncoder = void 0;
const utils_1 = require("./utils");
const OutputSamples_1 = require("./OutputSamples");
class InboundRtpEncoder {
constructor(ssrc, _trackIdentifierEncoder, _attachmentsEncoder) {
this._trackIdentifierEncoder = _trackIdentifierEncoder;
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._audioLevelEncoder = new utils_1.NumberToNumberEncoder();
this._bytesReceivedEncoder = new utils_1.NumberToBigIntEncoder();
this._codecIdEncoder = new utils_1.OneTimePassEncoder();
this._concealedSamplesEncoder = new utils_1.NumberToNumberEncoder();
this._concealmentEventsEncoder = new utils_1.NumberToNumberEncoder();
this._corruptionMeasurementsEncoder = new utils_1.NumberToNumberEncoder();
this._decoderImplementationEncoder = new utils_1.StringToStringEncoder();
this._estimatedPlayoutTimestampEncoder = new utils_1.NumberToNumberEncoder();
this._fecBytesReceivedEncoder = new utils_1.NumberToBigIntEncoder();
this._fecPacketsDiscardedEncoder = new utils_1.NumberToNumberEncoder();
this._fecPacketsReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._fecSsrcEncoder = new utils_1.NumberToBigIntEncoder();
this._firCountEncoder = new utils_1.NumberToNumberEncoder();
this._frameHeightEncoder = new utils_1.NumberToNumberEncoder();
this._frameWidthEncoder = new utils_1.NumberToNumberEncoder();
this._framesAssembledFromMultiplePacketsEncoder = new utils_1.NumberToNumberEncoder();
this._framesDecodedEncoder = new utils_1.NumberToNumberEncoder();
this._framesDroppedEncoder = new utils_1.NumberToNumberEncoder();
this._framesPerSecondEncoder = new utils_1.NumberToNumberEncoder();
this._framesReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._framesRenderedEncoder = new utils_1.NumberToNumberEncoder();
this._freezeCountEncoder = new utils_1.NumberToNumberEncoder();
this._headerBytesReceivedEncoder = new utils_1.NumberToBigIntEncoder();
this._insertedSamplesForDecelerationEncoder = new utils_1.NumberToNumberEncoder();
this._jitterEncoder = new utils_1.NumberToNumberEncoder();
this._jitterBufferDelayEncoder = new utils_1.NumberToNumberEncoder();
this._jitterBufferEmittedCountEncoder = new utils_1.NumberToNumberEncoder();
this._jitterBufferMinimumDelayEncoder = new utils_1.NumberToNumberEncoder();
this._jitterBufferTargetDelayEncoder = new utils_1.NumberToNumberEncoder();
this._keyFramesDecodedEncoder = new utils_1.NumberToNumberEncoder();
this._lastPacketReceivedTimestampEncoder = new utils_1.NumberToNumberEncoder();
this._midEncoder = new utils_1.OneTimePassEncoder();
this._nackCountEncoder = new utils_1.NumberToNumberEncoder();
this._packetsDiscardedEncoder = new utils_1.NumberToNumberEncoder();
this._packetsLostEncoder = new utils_1.NumberToNumberEncoder();
this._packetsReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._pauseCountEncoder = new utils_1.NumberToNumberEncoder();
this._pliCountEncoder = new utils_1.NumberToNumberEncoder();
this._playoutIdEncoder = new utils_1.StringToStringEncoder();
this._powerEfficientDecoderEncoder = new utils_1.BooleanToBooleanEncoder();
this._qpSumEncoder = new utils_1.NumberToNumberEncoder();
this._remoteIdEncoder = new utils_1.StringToStringEncoder();
this._removedSamplesForAccelerationEncoder = new utils_1.NumberToNumberEncoder();
this._retransmittedBytesReceivedEncoder = new utils_1.NumberToBigIntEncoder();
this._retransmittedPacketsReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._rtxSsrcEncoder = new utils_1.NumberToBigIntEncoder();
this._silentConcealedSamplesEncoder = new utils_1.NumberToNumberEncoder();
this._totalAssemblyTimeEncoder = new utils_1.NumberToNumberEncoder();
this._totalAudioEnergyEncoder = new utils_1.NumberToNumberEncoder();
this._totalCorruptionProbabilityEncoder = new utils_1.NumberToNumberEncoder();
this._totalDecodeTimeEncoder = new utils_1.NumberToNumberEncoder();
this._totalFreezesDurationEncoder = new utils_1.NumberToNumberEncoder();
this._totalInterFrameDelayEncoder = new utils_1.NumberToNumberEncoder();
this._totalPausesDurationEncoder = new utils_1.NumberToNumberEncoder();
this._totalProcessingDelayEncoder = new utils_1.NumberToNumberEncoder();
this._totalSamplesDurationEncoder = new utils_1.NumberToNumberEncoder();
this._totalSamplesReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._totalSquaredCorruptionProbabilityEncoder = new utils_1.NumberToNumberEncoder();
this._totalSquaredInterFrameDelayEncoder = 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._audioLevelEncoder.reset();
this._bytesReceivedEncoder.reset();
this._codecIdEncoder.reset();
this._concealedSamplesEncoder.reset();
this._concealmentEventsEncoder.reset();
this._corruptionMeasurementsEncoder.reset();
this._decoderImplementationEncoder.reset();
this._estimatedPlayoutTimestampEncoder.reset();
this._fecBytesReceivedEncoder.reset();
this._fecPacketsDiscardedEncoder.reset();
this._fecPacketsReceivedEncoder.reset();
this._fecSsrcEncoder.reset();
this._firCountEncoder.reset();
this._frameHeightEncoder.reset();
this._frameWidthEncoder.reset();
this._framesAssembledFromMultiplePacketsEncoder.reset();
this._framesDecodedEncoder.reset();
this._framesDroppedEncoder.reset();
this._framesPerSecondEncoder.reset();
this._framesReceivedEncoder.reset();
this._framesRenderedEncoder.reset();
this._freezeCountEncoder.reset();
this._headerBytesReceivedEncoder.reset();
this._insertedSamplesForDecelerationEncoder.reset();
this._jitterEncoder.reset();
this._jitterBufferDelayEncoder.reset();
this._jitterBufferEmittedCountEncoder.reset();
this._jitterBufferMinimumDelayEncoder.reset();
this._jitterBufferTargetDelayEncoder.reset();
this._keyFramesDecodedEncoder.reset();
this._lastPacketReceivedTimestampEncoder.reset();
this._midEncoder.reset();
this._nackCountEncoder.reset();
this._packetsDiscardedEncoder.reset();
this._packetsLostEncoder.reset();
this._packetsReceivedEncoder.reset();
this._pauseCountEncoder.reset();
this._pliCountEncoder.reset();
this._playoutIdEncoder.reset();
this._powerEfficientDecoderEncoder.reset();
this._qpSumEncoder.reset();
this._remoteIdEncoder.reset();
this._removedSamplesForAccelerationEncoder.reset();
this._retransmittedBytesReceivedEncoder.reset();
this._retransmittedPacketsReceivedEncoder.reset();
this._rtxSsrcEncoder.reset();
this._silentConcealedSamplesEncoder.reset();
this._totalAssemblyTimeEncoder.reset();
this._totalAudioEnergyEncoder.reset();
this._totalCorruptionProbabilityEncoder.reset();
this._totalDecodeTimeEncoder.reset();
this._totalFreezesDurationEncoder.reset();
this._totalInterFrameDelayEncoder.reset();
this._totalPausesDurationEncoder.reset();
this._totalProcessingDelayEncoder.reset();
this._totalSamplesDurationEncoder.reset();
this._totalSamplesReceivedEncoder.reset();
this._totalSquaredCorruptionProbabilityEncoder.reset();
this._totalSquaredInterFrameDelayEncoder.reset();
this._transportIdEncoder.reset();
}
encode(sample) {
this._visited = true;
const result = new OutputSamples_1.ClientSample_PeerConnectionSample_InboundRtpStats({
ssrc: this._ssrc,
trackIdentifier: this._trackIdentifierEncoder.encode(sample.trackIdentifier),
attachments: this._attachmentsEncoder.encode(sample.attachments),
id: this._idEncoder.encode(sample.id),
kind: this._kindEncoder.encode(sample.kind),
timestamp: this._timestampEncoder.encode(sample.timestamp),
audioLevel: this._audioLevelEncoder.encode(sample.audioLevel),
bytesReceived: this._bytesReceivedEncoder.encode(sample.bytesReceived),
codecId: this._codecIdEncoder.encode(sample.codecId),
concealedSamples: this._concealedSamplesEncoder.encode(sample.concealedSamples),
concealmentEvents: this._concealmentEventsEncoder.encode(sample.concealmentEvents),
corruptionMeasurements: this._corruptionMeasurementsEncoder.encode(sample.corruptionMeasurements),
decoderImplementation: this._decoderImplementationEncoder.encode(sample.decoderImplementation),
estimatedPlayoutTimestamp: this._estimatedPlayoutTimestampEncoder.encode(sample.estimatedPlayoutTimestamp),
fecBytesReceived: this._fecBytesReceivedEncoder.encode(sample.fecBytesReceived),
fecPacketsDiscarded: this._fecPacketsDiscardedEncoder.encode(sample.fecPacketsDiscarded),
fecPacketsReceived: this._fecPacketsReceivedEncoder.encode(sample.fecPacketsReceived),
fecSsrc: this._fecSsrcEncoder.encode(sample.fecSsrc),
firCount: this._firCountEncoder.encode(sample.firCount),
frameHeight: this._frameHeightEncoder.encode(sample.frameHeight),
frameWidth: this._frameWidthEncoder.encode(sample.frameWidth),
framesAssembledFromMultiplePackets: this._framesAssembledFromMultiplePacketsEncoder.encode(sample.framesAssembledFromMultiplePackets),
framesDecoded: this._framesDecodedEncoder.encode(sample.framesDecoded),
framesDropped: this._framesDroppedEncoder.encode(sample.framesDropped),
framesPerSecond: this._framesPerSecondEncoder.encode(sample.framesPerSecond),
framesReceived: this._framesReceivedEncoder.encode(sample.framesReceived),
framesRendered: this._framesRenderedEncoder.encode(sample.framesRendered),
freezeCount: this._freezeCountEncoder.encode(sample.freezeCount),
headerBytesReceived: this._headerBytesReceivedEncoder.encode(sample.headerBytesReceived),
insertedSamplesForDeceleration: this._insertedSamplesForDecelerationEncoder.encode(sample.insertedSamplesForDeceleration),
jitter: this._jitterEncoder.encode(sample.jitter),
jitterBufferDelay: this._jitterBufferDelayEncoder.encode(sample.jitterBufferDelay),
jitterBufferEmittedCount: this._jitterBufferEmittedCountEncoder.encode(sample.jitterBufferEmittedCount),
jitterBufferMinimumDelay: this._jitterBufferMinimumDelayEncoder.encode(sample.jitterBufferMinimumDelay),
jitterBufferTargetDelay: this._jitterBufferTargetDelayEncoder.encode(sample.jitterBufferTargetDelay),
keyFramesDecoded: this._keyFramesDecodedEncoder.encode(sample.keyFramesDecoded),
lastPacketReceivedTimestamp: this._lastPacketReceivedTimestampEncoder.encode(sample.lastPacketReceivedTimestamp),
mid: this._midEncoder.encode(sample.mid),
nackCount: this._nackCountEncoder.encode(sample.nackCount),
packetsDiscarded: this._packetsDiscardedEncoder.encode(sample.packetsDiscarded),
packetsLost: this._packetsLostEncoder.encode(sample.packetsLost),
packetsReceived: this._packetsReceivedEncoder.encode(sample.packetsReceived),
pauseCount: this._pauseCountEncoder.encode(sample.pauseCount),
pliCount: this._pliCountEncoder.encode(sample.pliCount),
playoutId: this._playoutIdEncoder.encode(sample.playoutId),
powerEfficientDecoder: this._powerEfficientDecoderEncoder.encode(sample.powerEfficientDecoder),
qpSum: this._qpSumEncoder.encode(sample.qpSum),
remoteId: this._remoteIdEncoder.encode(sample.remoteId),
removedSamplesForAcceleration: this._removedSamplesForAccelerationEncoder.encode(sample.removedSamplesForAcceleration),
retransmittedBytesReceived: this._retransmittedBytesReceivedEncoder.encode(sample.retransmittedBytesReceived),
retransmittedPacketsReceived: this._retransmittedPacketsReceivedEncoder.encode(sample.retransmittedPacketsReceived),
rtxSsrc: this._rtxSsrcEncoder.encode(sample.rtxSsrc),
silentConcealedSamples: this._silentConcealedSamplesEncoder.encode(sample.silentConcealedSamples),
totalAssemblyTime: this._totalAssemblyTimeEncoder.encode(sample.totalAssemblyTime),
totalAudioEnergy: this._totalAudioEnergyEncoder.encode(sample.totalAudioEnergy),
totalCorruptionProbability: this._totalCorruptionProbabilityEncoder.encode(sample.totalCorruptionProbability),
totalDecodeTime: this._totalDecodeTimeEncoder.encode(sample.totalDecodeTime),
totalFreezesDuration: this._totalFreezesDurationEncoder.encode(sample.totalFreezesDuration),
totalInterFrameDelay: this._totalInterFrameDelayEncoder.encode(sample.totalInterFrameDelay),
totalPausesDuration: this._totalPausesDurationEncoder.encode(sample.totalPausesDuration),
totalProcessingDelay: this._totalProcessingDelayEncoder.encode(sample.totalProcessingDelay),
totalSamplesDuration: this._totalSamplesDurationEncoder.encode(sample.totalSamplesDuration),
totalSamplesReceived: this._totalSamplesReceivedEncoder.encode(sample.totalSamplesReceived),
totalSquaredCorruptionProbability: this._totalSquaredCorruptionProbabilityEncoder.encode(sample.totalSquaredCorruptionProbability),
totalSquaredInterFrameDelay: this._totalSquaredInterFrameDelayEncoder.encode(sample.totalSquaredInterFrameDelay),
transportId: this._transportIdEncoder.encode(sample.transportId),
});
return result;
}
}
exports.InboundRtpEncoder = InboundRtpEncoder;