UNPKG

@observertc/samples-encoder

Version:

ObserveRTC Library for Encoding Samples

39 lines (38 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PeerConnectionTransportEncoder = void 0; const utils_1 = require("./utils"); const OutputSamples_1 = require("./OutputSamples"); class PeerConnectionTransportEncoder { constructor(attachmentsEncoder) { this._visited = false; this._idEncoder = new utils_1.StringToStringEncoder(); this._timestampEncoder = new utils_1.NumberToNumberEncoder(); this._dataChannelsOpenedEncoder = new utils_1.NumberToNumberEncoder(); this._dataChannelsClosedEncoder = new utils_1.NumberToNumberEncoder(); this._attachmentsEncoder = attachmentsEncoder; } get visited() { const result = this._visited; this._visited = false; return result; } reset() { this._idEncoder.reset(); this._timestampEncoder.reset(); this._dataChannelsOpenedEncoder.reset(); this._dataChannelsClosedEncoder.reset(); this._attachmentsEncoder.reset(); } encode(sample) { this._visited = true; return new OutputSamples_1.ClientSample_PeerConnectionSample_PeerConnectionTransportStats({ id: sample.id, timestamp: this._timestampEncoder.encode(sample.timestamp), dataChannelsOpened: this._dataChannelsOpenedEncoder.encode(sample.dataChannelsOpened), dataChannelsClosed: this._dataChannelsClosedEncoder.encode(sample.dataChannelsClosed), attachments: this._attachmentsEncoder.encode(sample.attachments), }); } } exports.PeerConnectionTransportEncoder = PeerConnectionTransportEncoder;