UNPKG

@observertc/samples-encoder

Version:

ObserveRTC Library for Encoding Samples

73 lines (72 loc) 3.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IceCandidateEncoder = void 0; const utils_1 = require("./utils"); const utils_2 = require("./utils"); const OutputSamples_1 = require("./OutputSamples"); class IceCandidateEncoder { constructor(attachmentsEncoder) { this._visited = false; this._timestampEncoder = new utils_2.NumberToNumberEncoder(); this._idEncoder = new utils_2.StringToStringEncoder(); this._transportIdEncoder = new utils_2.StringToStringEncoder(); this._addressEncoder = new utils_2.StringToStringEncoder(); this._portEncoder = new utils_2.NumberToNumberEncoder(); this._protocolEncoder = new utils_2.StringToStringEncoder(); this._candidateTypeEncoder = new utils_2.StringToStringEncoder(); this._priorityEncoder = new utils_1.NumberToBigIntEncoder(); this._urlEncoder = new utils_2.StringToStringEncoder(); this._relayProtocolEncoder = new utils_2.StringToStringEncoder(); this._foundationEncoder = new utils_2.StringToStringEncoder(); this._relatedAddressEncoder = new utils_2.StringToStringEncoder(); this._relatedPortEncoder = new utils_2.NumberToNumberEncoder(); this._usernameFragmentEncoder = new utils_2.StringToStringEncoder(); this._tcpTypeEncoder = new utils_2.StringToStringEncoder(); this._attachmentsEncoder = attachmentsEncoder; } get visited() { const result = this._visited; this._visited = false; return result; } reset() { this._timestampEncoder.reset(); this._idEncoder.reset(); this._transportIdEncoder.reset(); this._addressEncoder.reset(); this._portEncoder.reset(); this._protocolEncoder.reset(); this._candidateTypeEncoder.reset(); this._priorityEncoder.reset(); this._urlEncoder.reset(); this._relayProtocolEncoder.reset(); this._foundationEncoder.reset(); this._relatedAddressEncoder.reset(); this._relatedPortEncoder.reset(); this._usernameFragmentEncoder.reset(); this._tcpTypeEncoder.reset(); this._attachmentsEncoder.reset(); } encode(sample) { this._visited = true; return new OutputSamples_1.ClientSample_PeerConnectionSample_IceCandidateStats({ timestamp: this._timestampEncoder.encode(sample.timestamp), id: sample.id, transportId: this._transportIdEncoder.encode(sample.transportId), address: this._addressEncoder.encode(sample.address), port: this._portEncoder.encode(sample.port), protocol: this._protocolEncoder.encode(sample.protocol), candidateType: this._candidateTypeEncoder.encode(sample.candidateType), priority: this._priorityEncoder.encode(sample.priority), url: this._urlEncoder.encode(sample.url), relayProtocol: this._relayProtocolEncoder.encode(sample.relayProtocol), foundation: this._foundationEncoder.encode(sample.foundation), relatedAddress: this._relatedAddressEncoder.encode(sample.relatedAddress), relatedPort: this._relatedPortEncoder.encode(sample.relatedPort), usernameFragment: this._usernameFragmentEncoder.encode(sample.usernameFragment), tcpType: this._tcpTypeEncoder.encode(sample.tcpType), attachments: this._attachmentsEncoder.encode(sample.attachments), }); } } exports.IceCandidateEncoder = IceCandidateEncoder;