diff --git a/src/__tests__/atem.spec.ts b/src/__tests__/atem.spec.ts index 13927c2e..9f8bd000 100644 --- a/src/__tests__/atem.spec.ts +++ b/src/__tests__/atem.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Atem, DEFAULT_MTU, DEFAULT_PORT } from '../atem' +import { Atem, DEFAULT_MAX_PACKET_SIZE, DEFAULT_PORT } from '../atem' import { CutCommand } from '../commands' import { promisify } from 'util' import { EventEmitter } from 'events' @@ -35,14 +35,14 @@ describe('Atem', () => { disableMultithreaded: true, log: (conn as any)._log, port: DEFAULT_PORT, - packetMtu: DEFAULT_MTU, + maxPacketSize: DEFAULT_MAX_PACKET_SIZE, }) } finally { await conn.destroy() } }) test('constructor test 2', async () => { - const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23, packetMtu: 500 }) + const conn = new Atem({ debugBuffers: true, address: 'test1', port: 23, maxPacketSize: 500 }) try { const socket = (conn as any).socket as AtemSocket @@ -56,7 +56,7 @@ describe('Atem', () => { disableMultithreaded: false, log: (conn as any)._log, port: 23, - packetMtu: 500, + maxPacketSize: 500, }) } finally { await conn.destroy() diff --git a/src/atem.ts b/src/atem.ts index 4bd5f0d9..1e8deec5 100644 --- a/src/atem.ts +++ b/src/atem.ts @@ -62,7 +62,7 @@ export interface AtemOptions { /** * Maximum size of packets to transmit */ - packetMtu?: number + maxPacketSize?: number } export type AtemEvents = { @@ -89,7 +89,7 @@ export enum AtemConnectionStatus { } export const DEFAULT_PORT = 9910 -export const DEFAULT_MTU = 1500 +export const DEFAULT_MAX_PACKET_SIZE = 1416 // Matching ATEM software export class BasicAtem extends EventEmitter { private readonly socket: AtemSocket @@ -109,7 +109,7 @@ export class BasicAtem extends EventEmitter { port: options?.port || DEFAULT_PORT, disableMultithreaded: options?.disableMultithreaded ?? false, childProcessTimeout: options?.childProcessTimeout || 600, - packetMtu: options?.packetMtu ?? DEFAULT_MTU, + maxPacketSize: options?.maxPacketSize ?? DEFAULT_MAX_PACKET_SIZE, }) this.dataTransferManager = new DT.DataTransferManager(this.sendCommands.bind(this)) diff --git a/src/lib/__tests__/atemSocket.spec.ts b/src/lib/__tests__/atemSocket.spec.ts index 346805b5..b146ec91 100644 --- a/src/lib/__tests__/atemSocket.spec.ts +++ b/src/lib/__tests__/atemSocket.spec.ts @@ -108,7 +108,7 @@ describe('AtemSocket', () => { port: 890, disableMultithreaded: true, childProcessTimeout: 100, - packetMtu: 1500, + maxPacketSize: 1416, }) } diff --git a/src/lib/atemSocket.ts b/src/lib/atemSocket.ts index fc6ff419..26cb0d9f 100644 --- a/src/lib/atemSocket.ts +++ b/src/lib/atemSocket.ts @@ -13,7 +13,7 @@ export interface AtemSocketOptions { debugBuffers: boolean disableMultithreaded: boolean childProcessTimeout: number - packetMtu: number + maxPacketSize: number } export type AtemSocketEvents = { @@ -29,7 +29,7 @@ export class AtemSocket extends EventEmitter { private readonly _debugBuffers: boolean private readonly _disableMultithreaded: boolean private readonly _childProcessTimeout: number - private readonly _packetMtu: number + private readonly _maxPacketSize: number private readonly _commandParser: CommandParser = new CommandParser() private _nextPacketTrackingId = 0 @@ -47,7 +47,7 @@ export class AtemSocket extends EventEmitter { this._debugBuffers = options.debugBuffers this._disableMultithreaded = options.disableMultithreaded this._childProcessTimeout = options.childProcessTimeout - this._packetMtu = options.packetMtu + this._maxPacketSize = options.maxPacketSize } public async connect(address?: string, port?: number): Promise { @@ -107,7 +107,7 @@ export class AtemSocket extends EventEmitter { public async sendCommands(commands: Array): Promise { if (!this._socketProcess) throw new Error('Socket process is not open') - const maxPacketSize = this._packetMtu - 28 - 12 // MTU minus UDP header and ATEM header + const maxPacketSize = this._maxPacketSize - 12 // MTU minus ATEM header const packetBuilder = new PacketBuilder(maxPacketSize, this._commandParser.version) for (const cmd of commands) {