Ham Radio simulator: live streaming microphone audio between 2 browsers, connected via ubuntu 22
1
vote
1
answer
163
views
I am trying to simulate a radio with a PTT button.
Connected users should be able to live voice chat in the group, one at a time, while holding a button.
I have a Ubuntu 22.04 server running, with nginx, but unfortunately nothing seems to work.
I don't know exactly what a good method should be.
I tried using sockets but i keep getting console errors (on Firefox) like:
Media resource blob:https://mywebsite could not be decoded, error: Error Code: NS_ERROR_DOM_MEDIA_METADATA_ERR (0x806e0006)
How exactly would a live audio browser transmission protocol look like?
async function startTransmission() {
if (!mediaStream) {
try {
mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });
mediaRecorder = new MediaRecorder(mediaStream, { mimeType: "audio/webm;codecs=opus" });
mediaRecorder.ondataavailable = (event) => {
if (event.data.size > 0) {
socket.emit("audio-stream", event.data);
}
};
mediaRecorder.start(300); // Send audio in 300ms chunks
logMessage("🔊 Transmitting Audio...");
} catch (error) {
console.error("Microphone access denied:", error);
logMessage("⚠️ Microphone access denied.");
}
}}
and server:
socket.on("audio-stream", (audioData) => {
io.emit("receive-audio", {
audioData,
mimeType: "audio/webm;codecs=opus",
senderId: socket.id // Send the sender's ID so they can ignore their own audio
});});
Asked by George Stefan Kudor-Ghitescu
(11 rep)
Feb 22, 2025, 04:24 AM
Last activity: Feb 25, 2025, 11:28 AM
Last activity: Feb 25, 2025, 11:28 AM