UNPKG

@observertc/samples-encoder

Version:

ObserveRTC Library for Encoding Samples

39 lines (38 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InboundTrackSampleEncoder = void 0; const utils_1 = require("./utils"); const OutputSamples_1 = require("./OutputSamples"); class InboundTrackSampleEncoder { 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._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._attachmentsEncoder.reset(); } encode(sample) { this._visited = true; return new OutputSamples_1.ClientSample_PeerConnectionSample_InboundTrackSample({ timestamp: this._timestampEncoder.encode(sample.timestamp), id: sample.id, kind: this._kindEncoder.encode(sample.kind), score: this._scoreEncoder.encode(sample.score), attachments: this._attachmentsEncoder.encode(sample.attachments), }); } } exports.InboundTrackSampleEncoder = InboundTrackSampleEncoder;