Skip to content

Commit

Permalink
Merge pull request #277 from richard-austin/273-two-way-audio-does-no…
Browse files Browse the repository at this point in the history
…t-work-with-firefox

* Fix two way audio not working on Firefox (when browser is Firefox, …
  • Loading branch information
richard-austin committed Apr 6, 2024
2 parents 9138cfc + fedf837 commit 449e0b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
37 changes: 19 additions & 18 deletions client/src/app/video/AudioBackchannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,26 @@ export class AudioBackchannel {
mimeType,
}

const ff = navigator.userAgent.search("Firefox");
// @ts-ignore
this.recorder = new MediaRecorder(stream, options);
// fires every one second and passes a BlobEvent
this.recorder.ondataavailable = (event: any) => {
// get the Blob from the event
const blob: Blob = event.data;
blob.arrayBuffer().then((buff) => {
let data = new Uint8Array(buff);

if (data.length > 0) {
// and send that blob to the server...
this.client.publish({
destination: '/app/audio',
binaryBody: data,
headers: {"content-type": "application/octet-stream"}
});
}
});
};
this.recorder = new MediaRecorder(stream, ff == -1 ? options : undefined);
// fires every one second and passes a BlobEvent
this.recorder.ondataavailable = (event: any) => {
// get the Blob from the event
const blob: Blob = event.data;
blob.arrayBuffer().then((buff) => {
let data = new Uint8Array(buff);

if (data.length > 0) {
// and send that blob to the server...
this.client.publish({
destination: '/app/audio',
binaryBody: data,
headers: {"content-type": "application/octet-stream"}
});
}
});
};

this.recorder.onstop = () => {
this.recorder.ondataavailable = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ class RtspClient {
command.add("1")
command.add("-f")
command.add("rtp")
command.add("rtp://${h.getOriginAddress()}:${h.getServerPort()}?localaddr=${localAddr}&localport=${h.vacantPorts.port1}&streamtype=unicast".toString())
// Was using host rather than h.getOriginAddress() as the latter often came wrong from the device
// Left this comment here for future reference
command.add("rtp://${host}:${h.getServerPort()}?localaddr=${localAddr}&localport=${h.vacantPorts.port1}&streamtype=unicast".toString())

audioOutProc = new ProcessBuilder(command).start()
BufferedReader reader = audioOutProc.errorReader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.*;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down

0 comments on commit 449e0b3

Please sign in to comment.