Python implementation of WebRTC and ORTC for real-time peer-to-peer communication
87
Build a system that transmits audio data over RTP using WebRTC peer-to-peer connections with capability to monitor transmission statistics and dynamically replace audio sources.
Your implementation should:
@generates
from aiortc import RTCPeerConnection, AudioStreamTrack, RTCConfiguration
class AudioTransmitter:
"""Manages audio transmission over WebRTC RTP."""
def __init__(self, config: RTCConfiguration = None):
"""Initialize the audio transmitter with optional configuration."""
pass
async def start_transmission(self, audio_track: AudioStreamTrack):
"""
Start transmitting an audio track.
Parameters:
- audio_track: The audio track to transmit
"""
pass
async def replace_audio_source(self, new_track: AudioStreamTrack):
"""
Replace the current audio track with a new one without renegotiation.
Parameters:
- new_track: The new audio track to transmit
"""
pass
async def get_transmission_stats(self) -> dict:
"""
Get current transmission statistics.
Returns:
dict with keys:
- packets_sent (int): Number of RTP packets sent
- bytes_sent (int): Total bytes transmitted
"""
pass
def get_supported_audio_codecs(self) -> list:
"""
Get list of supported audio codec names.
Returns:
list of str: Codec names (e.g., ["opus", "PCMU", "PCMA"])
"""
pass
async def close(self):
"""Close the connection and clean up resources."""
passProvides WebRTC implementation including RTCPeerConnection and RTP sender capabilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-aiortcdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10