or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aiortc@1.13.x
tile.json

tessl/pypi-aiortc

tessl install tessl/pypi-aiortc@1.13.0

Python 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%

task.mdevals/scenario-6/

Device Media Capture Abstraction

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.

Capabilities

Platform detection and device configuration

  • It detects the current platform (Linux, macOS, Windows) and returns the appropriate device format @test
  • It constructs the correct device path for Linux v4l2 video devices @test
  • It constructs the correct device path for macOS avfoundation devices @test
  • It constructs the correct device path for Windows DirectShow devices @test

Audio device capture

  • It creates a media player for the default audio input device on the detected platform @test
  • It provides an audio track from the captured audio device @test

Video device capture

  • It creates a media player for a video device using platform-specific format @test
  • It provides a video track from the captured video device @test

Error handling

  • It raises an appropriate error when an invalid device is specified @test
  • It raises an appropriate error when the platform is unsupported @test

Implementation

@generates

The implementation should handle the platform-specific nuances of device access:

  • Linux uses v4l2 for video and alsa/pulse for audio
  • macOS uses avfoundation for both audio and video
  • Windows uses dshow (DirectShow) for both audio and video

The library abstracts these platform differences and provides a simple interface for capturing media from hardware devices.

API

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
        """
        pass

Dependencies { .dependencies }

aiortc { .dependency }

Provides WebRTC implementation with MediaPlayer for device access across platforms.