BaseOutputTransport: resolve media sender via type(self).MediaSender - #5176
Open
shivgargsquad wants to merge 1 commit into
Open
BaseOutputTransport: resolve media sender via type(self).MediaSender#5176shivgargsquad wants to merge 1 commit into
shivgargsquad wants to merge 1 commit into
Conversation
Allows transport subclasses to provide a custom MediaSender implementation by shadowing the inner class, completing the per-destination sender model introduced in pipecat-ai#1697. Fully backward compatible: resolves to BaseOutputTransport.MediaSender unless a subclass deliberately shadows it. Closes pipecat-ai#5166
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolve the media sender class from the transport's type at both construction sites in
set_transport_ready()(base_output.py), instead of hardcodingBaseOutputTransport.MediaSender:This lets a transport subclass provide its own sender implementation by shadowing the inner class — the same extension pattern the class already uses for destinations (
register_audio_destination), per-destination mixers, and delivery (write_audio_frame). It completes the per-destination sender model introduced in #1697: the sender becomes a per-transport extension point.Compatibility
Fully backward compatible.
type(self).MediaSenderresolves toBaseOutputTransport.MediaSenderunless a subclass deliberately shadows the inner class; no behavior change for any existing transport.Use case
Telephony platform (FastAPI websocket transport, multiple carriers) where transport-specific behavior genuinely lives in the sender layer: per-carrier audio pacing interacting with the sender's clock task, clearing buffered audio on programmatic (non-VAD) interruption without the bot-stopped-speaking lifecycle (same need as #3872), and observability on bot speech start/stop from inside the audio task loop. Today the only way to express these is post-construction mutation of
_media_senders, which #3872's workaround shows is already happening in the wild.Tests
Added
TestBaseOutputTransportCustomMediaSendercovering:BaseOutputTransport.MediaSenderMediaSenderis used for both the default sender and per-destination sendersCloses #5166