Fix WebRTC connection for receive-only bots (whisper bot)
- Add receive-only transceivers for bots with no local media tracks - Resolves ICE gathering timeout issues for whisper bot - Enables proper SDP negotiation for audio/video reception - Whisper bot can now establish WebRTC connections successfully The whisper bot is receive-only (transcribes audio, doesn't send media) but WebRTC negotiation failed without proper transceivers. This fix automatically adds recvonly audio/video transceivers when a bot has no local tracks, allowing proper connection establishment.
This commit is contained in:
parent
795e9b1d67
commit
1074eb48dc
@ -812,8 +812,20 @@ class WebRTCSignalingClient:
|
||||
transceiver = pc.addTransceiver(track, direction="sendrecv")
|
||||
logger.debug(f"_handle_add_peer: Added transceiver for {track.kind}, mid: {transceiver.mid}")
|
||||
|
||||
# Create offer if needed
|
||||
# For bots with no local tracks (like whisper), add receive-only transceivers
|
||||
# to ensure proper SDP negotiation for incoming audio/video
|
||||
if not self.local_tracks:
|
||||
logger.info(f"_handle_add_peer: No local tracks for {peer_name}, adding receive-only transceivers")
|
||||
# Add receive-only audio transceiver for bots that need to receive audio
|
||||
audio_transceiver = pc.addTransceiver("audio", direction="recvonly")
|
||||
logger.debug(f"_handle_add_peer: Added receive-only audio transceiver, mid: {audio_transceiver.mid}")
|
||||
# Add receive-only video transceiver to handle any incoming video
|
||||
video_transceiver = pc.addTransceiver("video", direction="recvonly")
|
||||
logger.debug(f"_handle_add_peer: Added receive-only video transceiver, mid: {video_transceiver.mid}")
|
||||
|
||||
# Create offer if instructed by server coordination
|
||||
if should_create_offer:
|
||||
logger.info(f"Creating offer for {peer_name} as instructed by server")
|
||||
await self._create_and_send_offer(peer_id, peer_name, pc)
|
||||
|
||||
if self.on_peer_added:
|
||||
|
Loading…
x
Reference in New Issue
Block a user