mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
add ability to set audio profile before starting a call
This commit is contained in:
parent
81e24e3824
commit
8cedecaa4f
2 changed files with 58 additions and 2 deletions
21
meshchat.py
21
meshchat.py
|
|
@ -20,6 +20,7 @@ import RNS
|
|||
import RNS.vendor.umsgpack as msgpack
|
||||
from LXMF import LXMRouter
|
||||
from LXST import Telephone
|
||||
from LXST.Primitives.Telephony import Profiles
|
||||
from aiohttp import web, WSMessage, WSMsgType, WSCloseCode
|
||||
from peewee import SqliteDatabase
|
||||
from serial.tools import list_ports
|
||||
|
|
@ -412,6 +413,7 @@ class ReticulumMeshChat:
|
|||
timeout_seconds = int(request.query.get("timeout", 15))
|
||||
input_device_name = request.query.get("input_device_name", None)
|
||||
output_device_name = request.query.get("output_device_name", None)
|
||||
audio_profile_id = int(request.query.get("audio_profile_id", None))
|
||||
|
||||
# convert hash to bytes
|
||||
identity_hash = bytes.fromhex(identity_hash_hex)
|
||||
|
|
@ -462,7 +464,7 @@ class ReticulumMeshChat:
|
|||
self.telephone.set_speaker(output_device_name)
|
||||
|
||||
# initiate call
|
||||
AsyncUtils.run_async(asyncio.to_thread(self.telephone.call, destination_identity, None))
|
||||
AsyncUtils.run_async(asyncio.to_thread(self.telephone.call, destination_identity, audio_profile_id))
|
||||
|
||||
return web.json_response({
|
||||
"message": "Calling...",
|
||||
|
|
@ -499,6 +501,23 @@ class ReticulumMeshChat:
|
|||
"output_devices": output_devices,
|
||||
})
|
||||
|
||||
# serve list of available audio profiles
|
||||
@routes.get("/api/v1/telephone/audio-profiles")
|
||||
async def index(request):
|
||||
|
||||
# get audio profiles
|
||||
audio_profiles = []
|
||||
for available_profile in Profiles.available_profiles():
|
||||
audio_profiles.append({
|
||||
"id": available_profile,
|
||||
"name": Profiles.profile_name(available_profile)
|
||||
})
|
||||
|
||||
return web.json_response({
|
||||
"default_audio_profile_id": Profiles.DEFAULT_PROFILE,
|
||||
"audio_profiles": audio_profiles,
|
||||
})
|
||||
|
||||
# fetch com ports
|
||||
@routes.get("/api/v1/comports")
|
||||
async def index(request):
|
||||
|
|
|
|||
|
|
@ -125,6 +125,18 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<div class="my-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<select v-model="selectedAudioProfileId" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white dark:focus:ring-blue-600 dark:focus:border-blue-600">
|
||||
<option v-for="audioProfile in audioProfiles" :value="audioProfile.id">{{ audioProfile.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex p-1 dark:bg-zinc-700 dark:border-zinc-600">
|
||||
<div>
|
||||
|
|
@ -241,10 +253,12 @@ export default {
|
|||
|
||||
selectedInputDevice: null,
|
||||
selectedOutputDevice: null,
|
||||
|
||||
inputDevices: [],
|
||||
outputDevices: [],
|
||||
|
||||
selectedAudioProfileId: null,
|
||||
audioProfiles: [],
|
||||
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
|
|
@ -252,6 +266,7 @@ export default {
|
|||
// update config
|
||||
this.getConfig();
|
||||
this.getAudioDevices();
|
||||
this.getAudioProfiles();
|
||||
this.getTelephoneStatus();
|
||||
|
||||
// update telephone status every second
|
||||
|
|
@ -296,6 +311,12 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
// make sure audio profile provided
|
||||
if(!this.selectedAudioProfileId) {
|
||||
alert("Please select audio quality.");
|
||||
return;
|
||||
}
|
||||
|
||||
// show loading
|
||||
this.isInitiatingCall = true;
|
||||
|
||||
|
|
@ -307,6 +328,7 @@ export default {
|
|||
timeout: 15, // how long to attempt to initiate call
|
||||
input_device_name: this.selectedInputDevice,
|
||||
output_device_name: this.selectedOutputDevice,
|
||||
audio_profile_id: this.selectedAudioProfileId,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -387,6 +409,21 @@ export default {
|
|||
console.error(e);
|
||||
}
|
||||
},
|
||||
async getAudioProfiles() {
|
||||
try {
|
||||
|
||||
// fetch audio profiles
|
||||
const response = await axios.get("/api/v1/telephone/audio-profiles");
|
||||
|
||||
// update ui
|
||||
this.selectedAudioProfileId = response.data.default_audio_profile_id;
|
||||
this.audioProfiles = response.data.audio_profiles;
|
||||
|
||||
} catch(e) {
|
||||
// do nothing on error
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
async getTelephoneStatus() {
|
||||
try {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue