@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
67 lines (66 loc) • 3.35 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoteInboundRtpEncoder = void 0;
const utils_1 = require("./utils");
const OutputSamples_1 = require("./OutputSamples");
class RemoteInboundRtpEncoder {
constructor(ssrc, _attachmentsEncoder) {
this._attachmentsEncoder = _attachmentsEncoder;
this._visited = false;
this.ssrc = BigInt(ssrc);
this._timestampEncoder = new utils_1.NumberToNumberEncoder();
this._idEncoder = new utils_1.StringToStringEncoder();
this._kindEncoder = new utils_1.StringToStringEncoder();
this._transportIdEncoder = new utils_1.OneTimePassEncoder();
this._codecIdEncoder = new utils_1.OneTimePassEncoder();
this._packetsReceivedEncoder = new utils_1.NumberToNumberEncoder();
this._packetsLostEncoder = new utils_1.NumberToNumberEncoder();
this._jitterEncoder = new utils_1.NumberToNumberEncoder();
this._localIdEncoder = new utils_1.StringToStringEncoder();
this._roundTripTimeEncoder = new utils_1.NumberToNumberEncoder();
this._totalRoundTripTimeEncoder = new utils_1.NumberToNumberEncoder();
this._fractionLostEncoder = new utils_1.NumberToNumberEncoder();
this._roundTripTimeMeasurementsEncoder = new utils_1.NumberToNumberEncoder();
}
get visited() {
const result = this._visited;
this._visited = false;
return result;
}
reset() {
this._timestampEncoder.reset();
this._idEncoder.reset();
this._kindEncoder.reset();
this._transportIdEncoder.reset();
this._codecIdEncoder.reset();
this._packetsReceivedEncoder.reset();
this._packetsLostEncoder.reset();
this._jitterEncoder.reset();
this._localIdEncoder.reset();
this._roundTripTimeEncoder.reset();
this._totalRoundTripTimeEncoder.reset();
this._fractionLostEncoder.reset();
this._roundTripTimeMeasurementsEncoder.reset();
}
encode(sample) {
this._visited = true;
return new OutputSamples_1.ClientSample_PeerConnectionSample_RemoteInboundRtpStats({
ssrc: this.ssrc,
timestamp: this._timestampEncoder.encode(sample.timestamp),
id: this._idEncoder.encode(sample.id),
kind: this._kindEncoder.encode(sample.kind),
transportId: this._transportIdEncoder.encode(sample.transportId),
codecId: this._codecIdEncoder.encode(sample.codecId),
packetsReceived: this._packetsReceivedEncoder.encode(sample.packetsReceived),
packetsLost: this._packetsLostEncoder.encode(sample.packetsLost),
jitter: this._jitterEncoder.encode(sample.jitter),
localId: this._localIdEncoder.encode(sample.localId),
roundTripTime: this._roundTripTimeEncoder.encode(sample.roundTripTime),
totalRoundTripTime: this._totalRoundTripTimeEncoder.encode(sample.totalRoundTripTime),
fractionLost: this._fractionLostEncoder.encode(sample.fractionLost),
roundTripTimeMeasurements: this._roundTripTimeMeasurementsEncoder.encode(sample.roundTripTimeMeasurements),
attachments: this._attachmentsEncoder.encode(sample.attachments),
});
}
}
exports.RemoteInboundRtpEncoder = RemoteInboundRtpEncoder;