nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

feat: command batching SOFIE-2549 #157

Closed Julusian closed 9 months ago

Julusian commented 9 months ago

feature

When sending commands to the atem, it is only possible to send one per packet.

The sendCommands method is now exposed, allowing for sending multiple commands in one packet. Each call to the method will result in packets being sent, no buffering/debouncing is performed between calls. Commands are packed into packets in order, up to a defined byte limit per packet.

The maximum packet size is defined based on the packetMtu property supplied to the constructor. Care should be taken when setting this, as any upload transfers do not fully respect this value and will result in packets failing to send.

This partially covers https://github.com/nrkno/sofie-atem-connection/issues/140, but only solves the case of constructing the commands manually (or with atem-state), not usage through the methods provided on the Atem class.
A friendlier batching api can be built on top of this work by someone later.

I have tested this against a Constellation 2ME HD by sending a pair of MixEffectKeyDVECommand commands multiple time at once, enough so that it spans multiple packets. The packets were acked, indicating that they were transmitted and received successfully.

codecov-commenter commented 9 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (9f87cc1) 86.29% compared to head (fc1256e) 86.38%. Report is 1 commits behind head on master.

Files Patch % Lines
src/atem.ts 95.00% 1 Missing :warning:
src/lib/atemSocket.ts 94.73% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #157 +/- ## ========================================== + Coverage 86.29% 86.38% +0.09% ========================================== Files 180 181 +1 Lines 5814 5853 +39 Branches 958 965 +7 ========================================== + Hits 5017 5056 +39 Misses 775 775 Partials 22 22 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.