feat(platform): wire VoiceCaptureFeed and ingestVoiceCapture API

Attach capture feed to VoiceMediaHub on guild load, reset on voice leave,
and accept base64 PCM chunks from the Pear UI for live microphone send.
This commit is contained in:
Raven Scott
2026-05-21 22:17:17 -04:00
parent 35ee850d17
commit 0ec5bbfe56
2 changed files with 20 additions and 3 deletions
+17 -1
View File
@@ -15,6 +15,7 @@ const { PearcordAttachments } = require('pearcord-attachments')
const { PearcordModeration } = require('pearcord-moderation')
const { PearcordVoice } = require('pearcord-voice')
const { VoiceMediaHub } = require('pearcord-voice-media')
const { VoiceCaptureFeed } = require('pearcord-voice-capture')
const { PearcordSlashRegistry, parseSlashInvocation } = require('pearcord-commands')
const { PearcordEmojiRegistry } = require('pearcord-emoji')
const { BotEventFanout, BOT_EVENTS } = require('pearcord-bot-events')
@@ -83,6 +84,7 @@ class PearcordPlatform extends EventEmitter {
this.moderation = null
this.voice = null
this.voiceMedia = null
this.voiceCapture = null
this.screenShare = null
this.announcements = null
this.boosts = null
@@ -357,6 +359,7 @@ class PearcordPlatform extends EventEmitter {
this.guild.sendVoiceMedia(mediaLeave)
}
}
this.voiceCapture?.reset()
if (gossip && payload && this.guild) this.guild.gossipVoiceState(payload)
return payload
}
@@ -1208,7 +1211,12 @@ class PearcordPlatform extends EventEmitter {
userId: user.id
})
await this.voice.ready()
this.voiceMedia = new VoiceMediaHub({ guildId, userId: user.id })
this.voiceCapture = new VoiceCaptureFeed()
this.voiceMedia = new VoiceMediaHub({
guildId,
userId: user.id,
captureFeed: this.voiceCapture
})
this.guild?.setVoiceMediaHub(this.voiceMedia)
this.voiceMedia.on('peer', () => this.emit('voice-media'))
this.voiceMedia.on('rtt', () => this.emit('voice-media'))
@@ -1439,6 +1447,13 @@ class PearcordPlatform extends EventEmitter {
return payload
}
ingestVoiceCapture (pcmBase64) {
if (!this.voiceCapture || !this.voiceMedia?.channelId) return false
if (this.voiceMedia.muted || this.voiceMedia.deafened) return false
const buf = Buffer.from(String(pcmBase64 || ''), 'base64')
return this.voiceCapture.push(buf)
}
async leaveVoiceChannel () {
const guild = this.guild?.guild
const payload = await this._leaveVoice({ gossip: true })
@@ -3300,6 +3315,7 @@ class PearcordPlatform extends EventEmitter {
this.messages = null
this.voice = null
this.voiceMedia = null
this.voiceCapture = null
this.screenShare = null
this.announcements = null
this.boosts = null
+3 -2
View File
@@ -38,8 +38,9 @@
"pearcord-stage": "file:../pearcord-stage",
"pearcord-automod": "file:../pearcord-automod",
"pearcord-screen-share": "file:../pearcord-screen-share",
"pearcord-announcements": "git+https://git.ssh.surf/pearcord/pearcord-announcements.git#main",
"pearcord-boosts": "git+https://git.ssh.surf/pearcord/pearcord-boosts.git#main",
"pearcord-announcements": "file:../pearcord-announcements",
"pearcord-boosts": "file:../pearcord-boosts",
"pearcord-voice-capture": "file:../pearcord-voice-capture",
"hyperswarm": "^4.11.6",
"pearcord-shared": "file:../pearcord-shared"
}