ENGINEERING CASE STUDY

BabeView — Multi-Camera Real-Time P2P Hub & Open Showcase

BabeView is a multi-source (N-to-1) monitoring hub built in Flutter at JHH Solutions to solve a real systems challenge: continuous baby monitoring with sub-50 ms LAN latency, bidirectional (Full-Duplex) audio, and unified simultaneous playback across repurposed smartphones (Baby Units) and dedicated IP security cameras (RTSP/ONVIF) on a single Parent Unit — operating 100% LAN-First (Zero-Cloud).

186 Dart Files in 4-Layer DDD
95 Suites Automated Test Suites
~30 ms WebRTC P2P LAN Latency
12 ADRs 27 Public Clean Code Slices

Zero-Config Pairing & Live Monitoring Flow

Designed to eliminate manual IP or port configuration: any device on the local Wi-Fi can act as a Baby Unit (transmitter) or Parent Unit (multi-camera receiver), discovering peers automatically via mDNS.

BabeView — Role selection between Baby Unit and Parent Unit
1. Dynamic Role
Any device operates as transmitter or receiver.
BabeView — Automatic mDNS device discovery on Wi-Fi
2. mDNS Discovery
Zero-config LAN scan via nsd with manual IP fallback.
BabeView — Active Baby Unit streaming HD video and audio via WebRTC
3. Active Baby Unit
HD capture, ambient mic, and front/rear lens switch.
BabeView — Parent Unit monitoring at 30ms latency with audio meter
4. Parent Unit (~30 ms)
Live latency telemetry, audio envelope, and two-way talk.

Polymorphic Multi-Source Architecture (IMediaSource)

To prevent presentation widgets from coupling to RTCVideoRenderer (WebRTC) or native C/C++ Player handles (media_kit), BabeView enforces Domain-Driven Design (DDD) with zero external dependencies in domain/, converging all heterogeneous streams behind a single IMediaSource contract:

Stage 01

LAN Discovery

mDNS nsd & IP Scan

Stage 02

Signaling & Handshake

WebRTC / RTSP Auth

Stage 03

Native Engines

flutter_webrtc & media_kit

Stage 04

Domain Contract

IMediaSource & Capabilities

Stage 05

Reactive Orchestration

MediaSourceManager + Riverpod 3

Stage 06

Agnostic Rendering

CameraGridView 2x2 & Carousel

Concrete ImplementationProtocol / EngineSupported CapabilitiesReal-World Role
WebRTCPeerMediaSourceflutter_webrtc (UDP/SRTP P2P)HD Video, Full-Duplex Audio, ICE ReconnectionRepurposed smartphone or tablet as Baby Unit
RTSPMediaSourcemedia_kit (C/C++ H.264/H.265 bindings)Hardware decoding, RTSP Auth, ONVIF supportDedicated nursery IP security cameras
LocalCameraMediaSourcecamera (Native hardware I/O)Zoom control, front/rear lens switchingLocal framing preview and hardware diagnostics

Reliability Engineering, Lifecycle & Memory Safety

Decoding up to 4 simultaneous video streams on mobile hardware demands strict lifecycle discipline to avoid memory leaks and thermal throttling:

  • Protocol-Agnostic Presentation: CameraGridView, CameraCarouselView, and MediaSourceRenderer consume reactive state exposed by MediaSourceManager under Riverpod 3, never instantiating raw players directly.
  • Deterministic Teardown (dispose()): Switching between carousel and 2x2 grid views deterministically releases native textures, C/C++ decoders, and orphaned peer connections — backed by 69 internal engineering docs including camera-switch freeze post-mortems.
  • Wi-Fi Drop Resilience & Android 14+ (API 34+) Lifecycle: ConnectionService leverages an injectable ReconnectionClock with exponential backoff ([2s, 4s, 8s, 16s]) alongside typed Android 14+ ForegroundService declarations (camera|microphone for Baby Units and mediaPlayback for Parent Units).
  • Binary TCP Framing, Constant-Time PIN & Procedural DSP Audio: 4-Byte Big-Endian Length-Prefixed TCP signaling for >90 KB WebRTC SDP offers, optical QR/PIN pairing hardened with bitwise XOR constantTimePinEquals, and a 100% pure-Dart procedural 16-bit PCM WAV synthesizer (Paul Kellet Pink Noise modulated by a 60 BPM breathing LFO, Brown Noise, and a zero-click 120 ms crossfaded C-Major pentatonic music box).
Audit All 12 ADRs, C4 Diagrams & 27 Clean Code Slices on GitHub

Inspect authentic production slices (WebRTC P2P, media_kit RTSP, 4-Byte TCP Framing, ONVIF Multicast, Constant-Time PIN, and Procedural WAV DSP) paired with their automated test suites.