@observertc/samples-encoder
Version:
ObserveRTC Library for Encoding Samples
42 lines (41 loc) • 1.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OutboundTrackSampleEncoder = void 0;
const utils_1 = require("./utils");
const OutputSamples_1 = require("./OutputSamples");
class OutboundTrackSampleEncoder {
constructor(attachmentsEncoder) {
this._visited = false;
this._timestampEncoder = new utils_1.NumberToNumberEncoder();
this._idEncoder = new utils_1.StringToStringEncoder();
this._kindEncoder = new utils_1.StringToStringEncoder();
this._scoreEncoder = new utils_1.NumberToNumberEncoder();
this._scoreReasonsEncoder = new utils_1.StringToStringEncoder();
this._attachmentsEncoder = attachmentsEncoder;
}
get visited() {
const result = this._visited;
this._visited = false;
return result;
}
reset() {
this._timestampEncoder.reset();
this._idEncoder.reset();
this._kindEncoder.reset();
this._scoreEncoder.reset();
this._scoreReasonsEncoder.reset();
this._attachmentsEncoder.reset();
}
encode(sample) {
this._visited = true;
return new OutputSamples_1.ClientSample_PeerConnectionSample_OutboundTrackSample({
timestamp: this._timestampEncoder.encode(sample.timestamp),
id: sample.id,
kind: this._kindEncoder.encode(sample.kind),
score: this._scoreEncoder.encode(sample.score),
scoreReasons: this._scoreReasonsEncoder.encode(sample.scoreReasons),
attachments: this._attachmentsEncoder.encode(sample.attachments),
});
}
}
exports.OutboundTrackSampleEncoder = OutboundTrackSampleEncoder;