Replies: 6 comments 16 replies
-
Hi! Thank you for this detailed explanation. Basically this would make it possible to have a server API? I think we thought about this a while ago, but never got further than having a vague idea. Having an API would make Jamulus a lot more flexible! In theory this could be extended to also control Jamulus clients, I think? |
Beta Was this translation helpful? Give feedback.
-
Cool! Personally, I've rather thought of some HTTP API. I haven't thought about MQTT and I've never used it so far. I guess at least for the pubsub model, HTTP is less tuned (e.g. "stream all recording events to me"). Can you describe what your reasoning for choosing MQTT was? How is (cross-platform) library support? How complex is it, what licenses would be involved? Are there similar use cases where MQTT is used? |
Beta Was this translation helpful? Give feedback.
-
My goal is clear - move to a Controller/Service model, with the Controller layer replaceable and the Service layer exposing a full API. The aim would be to allow replacing the existing Client and Server GUIs with a variety of remote control interfaces, as needed. |
Beta Was this translation helpful? Give feedback.
-
Maybe MIDI channels between the server and all clients, and also to and from the 'external world' via midi inputs and outputs, could be an alternative system. For Jamulus control sysex messages could be defined. The same system could also be used for messaging between musicians, e.g. instrument remote control, timing, etc. |
Beta Was this translation helpful? Give feedback.
-
I've added the code for publishing/subscribing to an mqtt broker to branch jamulus-mqtt on my fork of jamulus: This code is intended for testing and as 'proof of principal', it's not ready for prime time yet, but does demonstrate how you can have your jamulus server send and receive messaged over mqtt. The new code has some additional dependencies which need to be installed to get it to compile. qtmqtt libraryThe GPL version of qtmqtt needs to be downloaded, compiled, and installed. On ubuntu running QT v5.12.8 the corresponding version of qtmqtt is v5.15.10. I cloned the mqtt code into a folder in parallel with my jamulus project directory:
After installing qtmqtt you should be able to compile the project from branch jamulus-mqtt. New command line argumentsmqtt code adds two new command line arguments:
When code is added to enable activation of recording or other functionality on the server my idea is to add a second pair of arguments so that the "read-only" functionality can be enabled without having to enable state changing functionality. So to connect to a local mqtt broker on the default port you can start jamulus as:
Jamulus will publish messages using topics starting jamulus/port_number/, except for the topic jamulus/pingack used to respond to incoming jamulus/ping messages. The content of the messages published by jamulus is in JSON format Testing mqtt messaging with mosquitto mqtt brokerEclipse mosquitto (https://mosquitto.org/) provides an open source implementation of an mqtt broker and tools and is available for Linux, Windows, and Mac. To install the latest version of mosquitto (v2.0.10) add the mosquitto-dev PPA to your repositories
With mosquitto running you can start Jamulus and it will connect to the broker - you can check the mosquitto logs to confirm that jamulus has connected. On my installation:
A more convenient way to test the codes is to connect another client to the mqtt broker and subscribe to the topic jamulus/# to receive notification of all messages published by jamulus. You can do this using the mosquitto_sub utility, which has to be installed separately from mosquitto:
'#' is a wildcard that subscribes to all topics beginning with jamulus/. If you connect a client to the jamulus server you should see messages appearing the in mosquitto_sub console. The mosquitto clients tools also include mosquitto_pub, which is used to publish messages to a broker, indicating the topic to publish too and the content of the message. We can use mosquitto_pub in a separate terminal to publish messages requesting state information from jamulus:
These messages should appear in the mosquito_sub terminal, along with the responses from jamulus. I hope that's all clear, let me know of any problems encountered or if further information is required. |
Beta Was this translation helpful? Give feedback.
-
There’s also another approach: #1847 which might be interesting cc: @cdmahoney |
Beta Was this translation helpful? Give feedback.
-
Proposal
Currently the only way to extend the functionality of Jamulus is by modifying the source code, or running external applications on the server that "know" where jamulus resources are, and can start systems programs and/or services in order to start/stop recording, download recordings, etc. As far as I am aware there is no way for these external applications to determine automatically the running Jamulus servers, or the current connections of those servers.
This proposal is to add inter process communication to Jamulus using the mqtt protocol. This would enable external applications to receive information and communicate with Jamulus in a platform-independant way.
MQTT subscriptions, publications, topics, and message format
There would be two separate options configurable when starting a Jamulus server:
This would enable a server to publish messages while not subscribing to messages which might for example start or stop recording on the server.
The Jamulus server would publish messages using topics such as:
jamulus/22124/recording/start
jamulus/22124/recording/stop
jamulus/22124/newconnection
jamulus/22124/channelinfo
"22124" would be replaced by the server's port number.
The Jamulus server would subscribe to topic:
jamulus/22124/request/#
Client code would send messages with topics such as:
jamulus/22124/request/configuration
jamulus/22124/request/connections
For messages which might change the state of the server Jamulus would subscribe to topic:
jamulus/22124/put/#
In all cases message content would be in JSON format.
Use cases
Examples of use cases for this functionality would be an application to provide detailed logging of Jamulus events, or a web-application providing a user-friendly interface to the server state, and the ability to start and stop Jamulus recordings.
In both cases, by subscribing and optionally publishing to an mqtt broker, the applications could determine which Jamulus servers are running, and obtain information about the current state of the servers. The applications would not need to know in advance the ports used by the servers, or the folders used for example to store recordings.
Implementation
I have a proof-of-concept implementation which I could publish as a fork of Jamulus (I implemented the functionality before making the proposal to avoid proposing something that I wasn't then able to implement - this has been my first experience with the Jamulus code base.)
The MQTT implementation is based on the current recording module implementation. A subfolder contains the implementation of the mqtt controller and mqtt connections for publish and subscribe. Changes to the core Jamulus code are minimal, and can be divided into two groups:
Attached is a screenshot of MQTT Explorer showing messages from a Jamulus session.
Beta Was this translation helpful? Give feedback.
All reactions