"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsumerDumpT = exports.ConsumerDump = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
const flatbuffers = require("flatbuffers");
const base_consumer_dump_1 = require("../../fbs/consumer/base-consumer-dump");
const dump_1 = require("../../fbs/rtp-stream/dump");
class ConsumerDump {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsConsumerDump(bb, obj) {
        return (obj || new ConsumerDump()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsConsumerDump(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new ConsumerDump()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    base(obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new base_consumer_dump_1.BaseConsumerDump()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    rtpStreams(index, obj) {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? (obj || new dump_1.Dump()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
    }
    rtpStreamsLength() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    preferredSpatialLayer() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    targetSpatialLayer() {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    currentSpatialLayer() {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    preferredTemporalLayer() {
        const offset = this.bb.__offset(this.bb_pos, 14);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    targetTemporalLayer() {
        const offset = this.bb.__offset(this.bb_pos, 16);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    currentTemporalLayer() {
        const offset = this.bb.__offset(this.bb_pos, 18);
        return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
    }
    static startConsumerDump(builder) {
        builder.startObject(8);
    }
    static addBase(builder, baseOffset) {
        builder.addFieldOffset(0, baseOffset, 0);
    }
    static addRtpStreams(builder, rtpStreamsOffset) {
        builder.addFieldOffset(1, rtpStreamsOffset, 0);
    }
    static createRtpStreamsVector(builder, data) {
        builder.startVector(4, data.length, 4);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addOffset(data[i]);
        }
        return builder.endVector();
    }
    static startRtpStreamsVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static addPreferredSpatialLayer(builder, preferredSpatialLayer) {
        builder.addFieldInt16(2, preferredSpatialLayer, null);
    }
    static addTargetSpatialLayer(builder, targetSpatialLayer) {
        builder.addFieldInt16(3, targetSpatialLayer, null);
    }
    static addCurrentSpatialLayer(builder, currentSpatialLayer) {
        builder.addFieldInt16(4, currentSpatialLayer, null);
    }
    static addPreferredTemporalLayer(builder, preferredTemporalLayer) {
        builder.addFieldInt16(5, preferredTemporalLayer, null);
    }
    static addTargetTemporalLayer(builder, targetTemporalLayer) {
        builder.addFieldInt16(6, targetTemporalLayer, null);
    }
    static addCurrentTemporalLayer(builder, currentTemporalLayer) {
        builder.addFieldInt16(7, currentTemporalLayer, null);
    }
    static endConsumerDump(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // base
        builder.requiredField(offset, 6); // rtp_streams
        return offset;
    }
    static createConsumerDump(builder, baseOffset, rtpStreamsOffset, preferredSpatialLayer, targetSpatialLayer, currentSpatialLayer, preferredTemporalLayer, targetTemporalLayer, currentTemporalLayer) {
        ConsumerDump.startConsumerDump(builder);
        ConsumerDump.addBase(builder, baseOffset);
        ConsumerDump.addRtpStreams(builder, rtpStreamsOffset);
        if (preferredSpatialLayer !== null)
            ConsumerDump.addPreferredSpatialLayer(builder, preferredSpatialLayer);
        if (targetSpatialLayer !== null)
            ConsumerDump.addTargetSpatialLayer(builder, targetSpatialLayer);
        if (currentSpatialLayer !== null)
            ConsumerDump.addCurrentSpatialLayer(builder, currentSpatialLayer);
        if (preferredTemporalLayer !== null)
            ConsumerDump.addPreferredTemporalLayer(builder, preferredTemporalLayer);
        if (targetTemporalLayer !== null)
            ConsumerDump.addTargetTemporalLayer(builder, targetTemporalLayer);
        if (currentTemporalLayer !== null)
            ConsumerDump.addCurrentTemporalLayer(builder, currentTemporalLayer);
        return ConsumerDump.endConsumerDump(builder);
    }
    unpack() {
        return new ConsumerDumpT((this.base() !== null ? this.base().unpack() : null), this.bb.createObjList(this.rtpStreams.bind(this), this.rtpStreamsLength()), this.preferredSpatialLayer(), this.targetSpatialLayer(), this.currentSpatialLayer(), this.preferredTemporalLayer(), this.targetTemporalLayer(), this.currentTemporalLayer());
    }
    unpackTo(_o) {
        _o.base = (this.base() !== null ? this.base().unpack() : null);
        _o.rtpStreams = this.bb.createObjList(this.rtpStreams.bind(this), this.rtpStreamsLength());
        _o.preferredSpatialLayer = this.preferredSpatialLayer();
        _o.targetSpatialLayer = this.targetSpatialLayer();
        _o.currentSpatialLayer = this.currentSpatialLayer();
        _o.preferredTemporalLayer = this.preferredTemporalLayer();
        _o.targetTemporalLayer = this.targetTemporalLayer();
        _o.currentTemporalLayer = this.currentTemporalLayer();
    }
}
exports.ConsumerDump = ConsumerDump;
class ConsumerDumpT {
    base;
    rtpStreams;
    preferredSpatialLayer;
    targetSpatialLayer;
    currentSpatialLayer;
    preferredTemporalLayer;
    targetTemporalLayer;
    currentTemporalLayer;
    constructor(base = null, rtpStreams = [], preferredSpatialLayer = null, targetSpatialLayer = null, currentSpatialLayer = null, preferredTemporalLayer = null, targetTemporalLayer = null, currentTemporalLayer = null) {
        this.base = base;
        this.rtpStreams = rtpStreams;
        this.preferredSpatialLayer = preferredSpatialLayer;
        this.targetSpatialLayer = targetSpatialLayer;
        this.currentSpatialLayer = currentSpatialLayer;
        this.preferredTemporalLayer = preferredTemporalLayer;
        this.targetTemporalLayer = targetTemporalLayer;
        this.currentTemporalLayer = currentTemporalLayer;
    }
    pack(builder) {
        const base = (this.base !== null ? this.base.pack(builder) : 0);
        const rtpStreams = ConsumerDump.createRtpStreamsVector(builder, builder.createObjectOffsetList(this.rtpStreams));
        return ConsumerDump.createConsumerDump(builder, base, rtpStreams, this.preferredSpatialLayer, this.targetSpatialLayer, this.currentSpatialLayer, this.preferredTemporalLayer, this.targetTemporalLayer, this.currentTemporalLayer);
    }
}
exports.ConsumerDumpT = ConsumerDumpT;
