@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
67 lines (66 loc) • 3.37 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoteOutboundRtpEncoder = void 0;
const utils_1 = require("./utils");
const OutputSamples_1 = require("./OutputSamples");
class RemoteOutboundRtpEncoder {
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._packetsSentEncoder = new utils_1.NumberToNumberEncoder();
this._bytesSentEncoder = new utils_1.NumberToBigIntEncoder();
this._localIdEncoder = new utils_1.StringToStringEncoder();
this._remoteTimestampEncoder = new utils_1.NumberToNumberEncoder();
this._reportsSentEncoder = new utils_1.NumberToNumberEncoder();
this._roundTripTimeEncoder = new utils_1.NumberToNumberEncoder();
this._totalRoundTripTimeEncoder = 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._packetsSentEncoder.reset();
this._bytesSentEncoder.reset();
this._localIdEncoder.reset();
this._remoteTimestampEncoder.reset();
this._reportsSentEncoder.reset();
this._roundTripTimeEncoder.reset();
this._totalRoundTripTimeEncoder.reset();
this._roundTripTimeMeasurementsEncoder.reset();
}
encode(sample) {
this._visited = true;
return new OutputSamples_1.ClientSample_PeerConnectionSample_RemoteOutboundRtpStats({
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),
packetsSent: this._packetsSentEncoder.encode(sample.packetsSent),
bytesSent: this._bytesSentEncoder.encode(sample.bytesSent),
localId: this._localIdEncoder.encode(sample.localId),
remoteTimestamp: this._remoteTimestampEncoder.encode(sample.remoteTimestamp),
reportsSent: this._reportsSentEncoder.encode(sample.reportsSent),
roundTripTime: this._roundTripTimeEncoder.encode(sample.roundTripTime),
totalRoundTripTime: this._totalRoundTripTimeEncoder.encode(sample.totalRoundTripTime),
roundTripTimeMeasurements: this._roundTripTimeMeasurementsEncoder.encode(sample.roundTripTimeMeasurements),
attachments: this._attachmentsEncoder.encode(sample.attachments),
});
}
}
exports.RemoteOutboundRtpEncoder = RemoteOutboundRtpEncoder;