UNPKG

@observertc/samples-encoder

Version:

ObserveRTC Library for Encoding Samples

51 lines (50 loc) 2.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MediaPlayoutStatsEncoder = void 0; const utils_1 = require("./utils"); const OutputSamples_1 = require("./OutputSamples"); class MediaPlayoutStatsEncoder { constructor(attachmentsEncoder) { this._visited = false; this._timestampEncoder = new utils_1.NumberToNumberEncoder(); this._idEncoder = new utils_1.StringToStringEncoder(); this._kindEncoder = new utils_1.StringToStringEncoder(); this._synthesizedSamplesDurationEncoder = new utils_1.NumberToNumberEncoder(); this._synthesizedSamplesEventsEncoder = new utils_1.NumberToNumberEncoder(); this._totalSamplesDurationEncoder = new utils_1.NumberToNumberEncoder(); this._totalPlayoutDelayEncoder = new utils_1.NumberToNumberEncoder(); this._totalSamplesCountEncoder = 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._synthesizedSamplesDurationEncoder.reset(); this._synthesizedSamplesEventsEncoder.reset(); this._totalSamplesDurationEncoder.reset(); this._totalPlayoutDelayEncoder.reset(); this._totalSamplesCountEncoder.reset(); this._attachmentsEncoder.reset(); } encode(sample) { this._visited = true; return new OutputSamples_1.ClientSample_PeerConnectionSample_MediaPlayoutStats({ timestamp: this._timestampEncoder.encode(sample.timestamp), id: sample.id, kind: this._kindEncoder.encode(sample.kind), synthesizedSamplesDuration: this._synthesizedSamplesDurationEncoder.encode(sample.synthesizedSamplesDuration), synthesizedSamplesEvents: this._synthesizedSamplesEventsEncoder.encode(sample.synthesizedSamplesEvents), totalSamplesDuration: this._totalSamplesDurationEncoder.encode(sample.totalSamplesDuration), totalPlayoutDelay: this._totalPlayoutDelayEncoder.encode(sample.totalPlayoutDelay), totalSamplesCount: this._totalSamplesCountEncoder.encode(sample.totalSamplesCount), attachments: this._attachmentsEncoder.encode(sample.attachments), }); } } exports.MediaPlayoutStatsEncoder = MediaPlayoutStatsEncoder;