@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
50 lines (49 loc) • 2.21 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CodecStatsEncoder = void 0;
const OutputSamples_1 = require("./OutputSamples");
const utils_1 = require("./utils");
class CodecStatsEncoder {
constructor(attachmentsEncoder) {
this._visited = false;
this._timestampEncoder = new utils_1.NumberToNumberEncoder();
this._typeEncoder = new utils_1.StringToStringEncoder();
this._payloadTypeEncoder = new utils_1.NumberToNumberEncoder();
this._transportIdEncoder = new utils_1.StringToStringEncoder();
this._mimeTypeEncoder = new utils_1.StringToStringEncoder();
this._clockRateEncoder = new utils_1.NumberToNumberEncoder();
this._channelsEncoder = new utils_1.NumberToNumberEncoder();
this._sdpFmtpLineEncoder = new utils_1.StringToStringEncoder();
this._attachmentsEncoder = attachmentsEncoder;
}
get visited() {
const result = this._visited;
this._visited = false;
return result;
}
reset() {
this._attachmentsEncoder.reset();
this._channelsEncoder.reset();
this._clockRateEncoder.reset();
this._mimeTypeEncoder.reset();
this._payloadTypeEncoder.reset();
this._sdpFmtpLineEncoder.reset();
this._timestampEncoder.reset();
this._transportIdEncoder.reset();
this._typeEncoder.reset();
}
encode(sample) {
return new OutputSamples_1.ClientSample_PeerConnectionSample_CodecStats({
timestamp: this._timestampEncoder.encode(sample.timestamp),
id: sample.id,
payloadType: this._payloadTypeEncoder.encode(sample.payloadType),
transportId: this._transportIdEncoder.encode(sample.transportId),
mimeType: this._mimeTypeEncoder.encode(sample.mimeType),
clockRate: this._clockRateEncoder.encode(sample.clockRate),
channels: this._channelsEncoder.encode(sample.channels),
sdpFmtpLine: this._sdpFmtpLineEncoder.encode(sample.sdpFmtpLine),
attachments: this._attachmentsEncoder.encode(sample.attachments),
});
}
}
exports.CodecStatsEncoder = CodecStatsEncoder;