mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge pull request #937 from Pax1601/srs-integration
Added packetID handling
This commit is contained in:
@@ -3,6 +3,7 @@ import { Unit } from "../unit/unit";
|
|||||||
import { Filter, Noise } from "./audiolibrary";
|
import { Filter, Noise } from "./audiolibrary";
|
||||||
import { AudioPacket } from "./audiopacket";
|
import { AudioPacket } from "./audiopacket";
|
||||||
|
|
||||||
|
let packetID = 0;
|
||||||
const MAX_DISTANCE = 1852; // Ignore clients that are further away than 1NM, to save performance.
|
const MAX_DISTANCE = 1852; // Ignore clients that are further away than 1NM, to save performance.
|
||||||
|
|
||||||
export class AudioUnitPipeline {
|
export class AudioUnitPipeline {
|
||||||
@@ -107,6 +108,7 @@ export class AudioUnitPipeline {
|
|||||||
|
|
||||||
let audioPacket = new AudioPacket();
|
let audioPacket = new AudioPacket();
|
||||||
audioPacket.setAudioData(new Uint8Array(arrayBuffer));
|
audioPacket.setAudioData(new Uint8Array(arrayBuffer));
|
||||||
|
audioPacket.setPacketID(packetID++);
|
||||||
audioPacket.setFrequencies([
|
audioPacket.setFrequencies([
|
||||||
{
|
{
|
||||||
frequency: 100,
|
frequency: 100,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { AudioSink } from "./audiosink";
|
|||||||
import { AudioPacket } from "./audiopacket";
|
import { AudioPacket } from "./audiopacket";
|
||||||
import { getApp } from "../olympusapp";
|
import { getApp } from "../olympusapp";
|
||||||
|
|
||||||
|
let packetID = 0;
|
||||||
|
|
||||||
/* Radio sink, basically implements a simple SRS Client in Olympus. Does not support encryption at this moment */
|
/* Radio sink, basically implements a simple SRS Client in Olympus. Does not support encryption at this moment */
|
||||||
export class RadioSink extends AudioSink {
|
export class RadioSink extends AudioSink {
|
||||||
#encoder: AudioEncoder;
|
#encoder: AudioEncoder;
|
||||||
@@ -102,6 +104,7 @@ export class RadioSink extends AudioSink {
|
|||||||
if (this.#ptt) {
|
if (this.#ptt) {
|
||||||
let audioPacket = new AudioPacket();
|
let audioPacket = new AudioPacket();
|
||||||
audioPacket.setAudioData(new Uint8Array(arrayBuffer));
|
audioPacket.setAudioData(new Uint8Array(arrayBuffer));
|
||||||
|
audioPacket.setPacketID(packetID++);
|
||||||
audioPacket.setFrequencies([{
|
audioPacket.setFrequencies([{
|
||||||
frequency: this.#frequency,
|
frequency: this.#frequency,
|
||||||
modulation: this.#modulation,
|
modulation: this.#modulation,
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { SRSRadioSetting } from "../interfaces";
|
|
||||||
import { AudioPacket } from "./audiopacket";
|
|
||||||
import { CapturePipeline } from "./capturepipeline";
|
|
||||||
|
|
||||||
export class MicrophoneHandler {
|
|
||||||
#socket: WebSocket;
|
|
||||||
#setting: SRSRadioSetting;
|
|
||||||
|
|
||||||
constructor(socket, setting) {
|
|
||||||
this.#socket = socket;
|
|
||||||
this.#setting = setting;
|
|
||||||
|
|
||||||
console.log("Starting microphone handler");
|
|
||||||
|
|
||||||
const pipeline = new CapturePipeline();
|
|
||||||
|
|
||||||
navigator.mediaDevices.enumerateDevices()
|
|
||||||
.then(function(devices) {
|
|
||||||
devices.forEach(function(device) {
|
|
||||||
console.log(device.kind + ": " + device.label +
|
|
||||||
" id = " + device.deviceId);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
pipeline.connect().then(() => {
|
|
||||||
pipeline.onencoded = (data) => {
|
|
||||||
let buffer = new ArrayBuffer(data.byteLength);
|
|
||||||
data.copyTo(buffer);
|
|
||||||
let packet = new AudioPacket(new Uint8Array(buffer), this.#setting);
|
|
||||||
this.#socket.send(packet.getArray());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user