"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.PipeConsumerDumpT = exports.PipeConsumerDump = void 0;
const flatbuffers = require("flatbuffers");
const base_consumer_dump_1 = require("../../fbs/consumer/base-consumer-dump");
const dump_1 = require("../../fbs/rtp-stream/dump");
class PipeConsumerDump {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsPipeConsumerDump(bb, obj) {
        return (obj || new PipeConsumerDump()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsPipeConsumerDump(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new PipeConsumerDump()).__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;
    }
    static startPipeConsumerDump(builder) {
        builder.startObject(2);
    }
    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 endPipeConsumerDump(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // base
        builder.requiredField(offset, 6); // rtp_streams
        return offset;
    }
    static createPipeConsumerDump(builder, baseOffset, rtpStreamsOffset) {
        PipeConsumerDump.startPipeConsumerDump(builder);
        PipeConsumerDump.addBase(builder, baseOffset);
        PipeConsumerDump.addRtpStreams(builder, rtpStreamsOffset);
        return PipeConsumerDump.endPipeConsumerDump(builder);
    }
    unpack() {
        return new PipeConsumerDumpT((this.base() !== null ? this.base().unpack() : null), this.bb.createObjList(this.rtpStreams.bind(this), this.rtpStreamsLength()));
    }
    unpackTo(_o) {
        _o.base = (this.base() !== null ? this.base().unpack() : null);
        _o.rtpStreams = this.bb.createObjList(this.rtpStreams.bind(this), this.rtpStreamsLength());
    }
}
exports.PipeConsumerDump = PipeConsumerDump;
class PipeConsumerDumpT {
    base;
    rtpStreams;
    constructor(base = null, rtpStreams = []) {
        this.base = base;
        this.rtpStreams = rtpStreams;
    }
    pack(builder) {
        const base = (this.base !== null ? this.base.pack(builder) : 0);
        const rtpStreams = PipeConsumerDump.createRtpStreamsVector(builder, builder.createObjectOffsetList(this.rtpStreams));
        return PipeConsumerDump.createPipeConsumerDump(builder, base, rtpStreams);
    }
}
exports.PipeConsumerDumpT = PipeConsumerDumpT;
