tessl install tessl/pypi-aiortc@1.13.0Python implementation of WebRTC and ORTC for real-time peer-to-peer communication
Agent Success
Agent success rate when using this tile
87%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.02x
Baseline
Agent success rate without this tile
85%
A cross-platform media capture library that abstracts hardware device access across different operating systems. The library should detect the current platform and use the appropriate device backend to capture audio and video from hardware devices.
@generates
The implementation should handle the platform-specific nuances of device access:
The library abstracts these platform differences and provides a simple interface for capturing media from hardware devices.
from typing import Optional
from aiortc.contrib.media import MediaPlayer
class DeviceCaptureConfig:
"""Configuration for device capture based on detected platform."""
def __init__(self, platform: Optional[str] = None):
"""
Initialize device capture configuration.
Args:
platform: Override platform detection (e.g., 'linux', 'darwin', 'win32')
If None, automatically detects the platform.
"""
pass
def get_audio_device_format(self) -> str:
"""
Get the appropriate audio device format for the current platform.
Returns:
Format string (e.g., 'alsa', 'avfoundation', 'dshow')
Raises:
RuntimeError: If platform is unsupported
"""
pass
def get_video_device_format(self) -> str:
"""
Get the appropriate video device format for the current platform.
Returns:
Format string (e.g., 'v4l2', 'avfoundation', 'dshow')
Raises:
RuntimeError: If platform is unsupported
"""
pass
def build_device_path(self, device_type: str, device_name: str) -> str:
"""
Build a platform-specific device path.
Args:
device_type: Either 'audio' or 'video'
device_name: Device name or identifier (e.g., 'default', '/dev/video0', '0')
Returns:
Formatted device path suitable for the platform
Raises:
ValueError: If device_type is invalid
RuntimeError: If platform is unsupported
"""
pass
class DeviceMediaCapture:
"""Captures media from hardware devices using platform-appropriate backends."""
def __init__(self, config: Optional[DeviceCaptureConfig] = None):
"""
Initialize device media capture.
Args:
config: Device capture configuration. If None, creates default config.
"""
pass
def create_audio_player(self, device: str = "default") -> MediaPlayer:
"""
Create a media player for an audio input device.
Args:
device: Device identifier (default: "default")
Returns:
MediaPlayer instance configured for the audio device
Raises:
RuntimeError: If unable to open the device
"""
pass
def create_video_player(self, device: str = "0") -> MediaPlayer:
"""
Create a media player for a video input device.
Args:
device: Device identifier (default: "0")
Returns:
MediaPlayer instance configured for the video device
Raises:
RuntimeError: If unable to open the device
"""
passProvides WebRTC implementation with MediaPlayer for device access across platforms.