mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-28 09:43:13 +00:00
add support for opus audio mode AM_OPUS_OGG
This commit is contained in:
parent
02f55d1b21
commit
4303e831e2
1 changed files with 25 additions and 0 deletions
|
|
@ -2868,6 +2868,11 @@
|
|||
const audioMode = audioField.audio_mode;
|
||||
const audioBytes = audioField.audio_bytes;
|
||||
|
||||
// handle opus: AM_OPUS_OGG
|
||||
if(audioMode === 0x10){
|
||||
return this.decodeOpusAudioToBlobUrl(audioField.audio_bytes);
|
||||
}
|
||||
|
||||
// determine codec2 mode, or skip if unknown
|
||||
const codecMode = this.lxmfAudioModeToCodec2ModeMap[audioMode];
|
||||
if(!codecMode){
|
||||
|
|
@ -2898,6 +2903,26 @@
|
|||
return null;
|
||||
}
|
||||
},
|
||||
async decodeOpusAudioToBlobUrl(audioBytes) {
|
||||
try {
|
||||
|
||||
// convert base64 to uint8 array
|
||||
const opusAudioBytes = this.base64ToArrayBuffer(audioBytes);
|
||||
|
||||
// create blob from opus audio
|
||||
const blob = new Blob([opusAudioBytes], {
|
||||
type: "audio/opus",
|
||||
});
|
||||
|
||||
// create object url for blob
|
||||
return URL.createObjectURL(blob);
|
||||
|
||||
} catch(e) {
|
||||
// failed to decode opus audio
|
||||
console.log(e);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue