UNPKG

mediasoup

Version:

Cutting Edge WebRTC Video Conferencing

161 lines (160 loc) 7.51 kB
"use strict"; // automatically generated by the FlatBuffers compiler, do not modify Object.defineProperty(exports, "__esModule", { value: true }); exports.ConsumeDataRequestT = exports.ConsumeDataRequest = 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 type_1 = require("../../fbs/data-producer/type"); const sctp_stream_parameters_1 = require("../../fbs/sctp-parameters/sctp-stream-parameters"); class ConsumeDataRequest { bb = null; bb_pos = 0; __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsConsumeDataRequest(bb, obj) { return (obj || new ConsumeDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsConsumeDataRequest(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new ConsumeDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } dataConsumerId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } dataProducerId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } type() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.readUint8(this.bb_pos + offset) : type_1.Type.SCTP; } sctpStreamParameters(obj) { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? (obj || new sctp_stream_parameters_1.SctpStreamParameters()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } label(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } protocol(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } paused() { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; } subchannels(index) { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? this.bb.readUint16(this.bb.__vector(this.bb_pos + offset) + index * 2) : 0; } subchannelsLength() { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } subchannelsArray() { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? new Uint16Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; } static startConsumeDataRequest(builder) { builder.startObject(8); } static addDataConsumerId(builder, dataConsumerIdOffset) { builder.addFieldOffset(0, dataConsumerIdOffset, 0); } static addDataProducerId(builder, dataProducerIdOffset) { builder.addFieldOffset(1, dataProducerIdOffset, 0); } static addType(builder, type) { builder.addFieldInt8(2, type, type_1.Type.SCTP); } static addSctpStreamParameters(builder, sctpStreamParametersOffset) { builder.addFieldOffset(3, sctpStreamParametersOffset, 0); } static addLabel(builder, labelOffset) { builder.addFieldOffset(4, labelOffset, 0); } static addProtocol(builder, protocolOffset) { builder.addFieldOffset(5, protocolOffset, 0); } static addPaused(builder, paused) { builder.addFieldInt8(6, +paused, +false); } static addSubchannels(builder, subchannelsOffset) { builder.addFieldOffset(7, subchannelsOffset, 0); } static createSubchannelsVector(builder, data) { builder.startVector(2, data.length, 2); for (let i = data.length - 1; i >= 0; i--) { builder.addInt16(data[i]); } return builder.endVector(); } static startSubchannelsVector(builder, numElems) { builder.startVector(2, numElems, 2); } static endConsumeDataRequest(builder) { const offset = builder.endObject(); builder.requiredField(offset, 4); // data_consumer_id builder.requiredField(offset, 6); // data_producer_id return offset; } unpack() { return new ConsumeDataRequestT(this.dataConsumerId(), this.dataProducerId(), this.type(), (this.sctpStreamParameters() !== null ? this.sctpStreamParameters().unpack() : null), this.label(), this.protocol(), this.paused(), this.bb.createScalarList(this.subchannels.bind(this), this.subchannelsLength())); } unpackTo(_o) { _o.dataConsumerId = this.dataConsumerId(); _o.dataProducerId = this.dataProducerId(); _o.type = this.type(); _o.sctpStreamParameters = (this.sctpStreamParameters() !== null ? this.sctpStreamParameters().unpack() : null); _o.label = this.label(); _o.protocol = this.protocol(); _o.paused = this.paused(); _o.subchannels = this.bb.createScalarList(this.subchannels.bind(this), this.subchannelsLength()); } } exports.ConsumeDataRequest = ConsumeDataRequest; class ConsumeDataRequestT { dataConsumerId; dataProducerId; type; sctpStreamParameters; label; protocol; paused; subchannels; constructor(dataConsumerId = null, dataProducerId = null, type = type_1.Type.SCTP, sctpStreamParameters = null, label = null, protocol = null, paused = false, subchannels = []) { this.dataConsumerId = dataConsumerId; this.dataProducerId = dataProducerId; this.type = type; this.sctpStreamParameters = sctpStreamParameters; this.label = label; this.protocol = protocol; this.paused = paused; this.subchannels = subchannels; } pack(builder) { const dataConsumerId = (this.dataConsumerId !== null ? builder.createString(this.dataConsumerId) : 0); const dataProducerId = (this.dataProducerId !== null ? builder.createString(this.dataProducerId) : 0); const sctpStreamParameters = (this.sctpStreamParameters !== null ? this.sctpStreamParameters.pack(builder) : 0); const label = (this.label !== null ? builder.createString(this.label) : 0); const protocol = (this.protocol !== null ? builder.createString(this.protocol) : 0); const subchannels = ConsumeDataRequest.createSubchannelsVector(builder, this.subchannels); ConsumeDataRequest.startConsumeDataRequest(builder); ConsumeDataRequest.addDataConsumerId(builder, dataConsumerId); ConsumeDataRequest.addDataProducerId(builder, dataProducerId); ConsumeDataRequest.addType(builder, this.type); ConsumeDataRequest.addSctpStreamParameters(builder, sctpStreamParameters); ConsumeDataRequest.addLabel(builder, label); ConsumeDataRequest.addProtocol(builder, protocol); ConsumeDataRequest.addPaused(builder, this.paused); ConsumeDataRequest.addSubchannels(builder, subchannels); return ConsumeDataRequest.endConsumeDataRequest(builder); } } exports.ConsumeDataRequestT = ConsumeDataRequestT;