JUCE StreamDeck Support

To whom it may concern,

I’m going to embark on a journey to write a StreamDeck plugin using JUCE including all that comes with it.
I want to use this thread to document a few steps and lessons learned, as well as to gather some feedback for the path I’m taking.

Upfront: while I have a lot of experience working with JUCE, I have next to no experience working with the web sockets and everything that comes with it (which is kind of important since Elgato is using it to communicate with the plugin process).

What I have gathered so far
Start point is gonna be this plugin template: GitHub - fredemmott/StreamDeck-CPPSDK: A fork of Elgato's C++ StreamDeck SDK, focussing on reusability
On a lower level, this library uses the Websocket++ library to initiate the web socket client. This tutorial was my starting point to understand how it is working and what I have to be carful about when working with it: WebSocket++: Utility Client Example Application Tutorial

First Goals

  • We want to be able to use the JUCE message loop. Not because we are running a UI, but to allow for extra flexibility with what ever we want to accomplish and to stay as close as possible to the JUCE side, and as far away from the “StreamDeck” side as possible. From what I’ve read so far, this is not gonna be a problem. Every stream deck plugin is launched as a separate process, using the websocket::run as the (blocking) main event loop (StreamDeck-CPPSDK/StreamDeckSDK/ESDConnectionManager.cpp at f2875f226c7981e33e07a2a8297e1d4f7b81e56b · fredemmott/StreamDeck-CPPSDK · GitHub). We will pawn that off to an I/O thread, which is coincidentally also how the above tutorial is set up and use juce::MessageManager as the main event loop including all the features that it brings. That means, wrapping all the callbacks for incoming messages into MessageManager::callAsync. Sending upstream is already ensured thread-safe by the Websocket++ library (Step 6 “Messages are sent using endpoint::send . This is a thread safe method that may be called from anywhere to queue a message for sending on the specified connection. There are three send overloads for use with different scenarios.”).
  • The StreamDeck SDK is using a different libraries to work on JSON based objects (to transmit and receive the metadata concerning key presses etc.). This is to be wrapped to the JUCE friendly ValueTree.
2 Likes