$ show mazupo/pi-webrtc
This repository contains a native WebRTC streaming application designed for Raspberry Pi and NVIDIA Jetson platforms. It captures video from various camera sources (libcamera, libargus, V4L2) and audio from PulseAudio/ALSA, encodes the streams using hardware acceleration when available or software fallbacks, and transmits them via WebRTC with multiple signaling options (MQTT, WebSocket, HTTP/WHEP). The application includes recording capabilities, snapshot functionality, and IPC for local control. The architecture is modular with clearly separated concerns for capture, encoding, signaling, and real-time communication.
The LLM identified 5 files worth highlighting for reuse:
A generic thread-safe queue implementation with blocking pop with timeout capability. Demonstrates proper condition variable usage and RAII principles. Can be extracted and used in any multithreaded C++ project with minimal modification.
A clean implementation of the observer pattern using modern C++ techniques with shared_ptr/weak_ptr for safe memory management. Provides a reusable event system that could be integrated into any C++ application needing loose coupling between components.
Comprehensive wrapper around the V4L2 (Video4Linux2) API providing utility functions for device enumeration, format negotiation, buffer management, and stream control. Eliminates boilerplate V4L2 code while maintaining full access to hardware capabilities.
Custom implementation of WebRTC's AudioDeviceModule interface that bridges the application's audio capturers (PulseAudio/ALSA) with WebRTC's audio processing pipeline. Demonstrates proper audio format conversion and thread-safe callback handling.
Abstract interface defining a common contract for hardware acceleration components (encoders, scalers, decoders). Enables pluggable architecture where different hardware backends (V4L2, Jetson) can be swapped without changing client code.