ArchitectureEnglish

Architecture Document

Detailed layered architecture, component boundaries and key flows for Endless.

Endless System Architecture

Version 1.0 · March 2026

Overview

Endless is structured as a strict layered architecture. Each layer exposes a well-defined interface to the layer above and depends only on the layer below. This design ensures hardware portability (swap SoC by reimplementing HAL), service modularity (compile only needed services), clear separation of concerns between media pipeline, AI services, and application logic, and a clean path for hardware/software customization.


Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│  APPLICATION LAYER                                               │
│                                                                  │
│  ┌──────────────┐ ┌──────────┐ ┌────────┐ ┌───────────────┐   │
│  │  Web UI      │ │ REST API │ │  ONVIF │ │   GB28181     │   │
│  │  (Vue 3)     │ │ (HTTP/S) │ │        │ │   (SIP/PS)    │   │
│  └──────────────┘ └──────────┘ └────────┘ └───────────────┘   │
├─────────────────────────────────────────────────────────────────┤
│  FOUNDATION SERVICES                                             │
│                                                                  │
│  ┌─────────────────┐  ┌───────────────────────────────────┐    │
│  │  Stream Service  │  │        AI Services                │    │
│  │  ┌────┐ ┌─────┐ │  │  ┌───────┐ ┌───────┐ ┌───────┐  │    │
│  │  │RTSP│ │WebRTC│ │  │  │ Agent │ │ Qwen  │ │Xiaozhi│  │    │
│  │  └────┘ └─────┘ │  │  └───────┘ └───────┘ └───────┘  │    │
│  │  ┌────────────┐  │  └───────────────────────────────────┘    │
│  │  │    RTMP    │  │                                            │
│  │  └────────────┘  │                                            │
│  └─────────────────┘                                            │
├─────────────────────────────────────────────────────────────────┤
│  BASE BUSINESS LAYER                                             │
│                                                                  │
│  ┌───────┐ ┌──────┐ ┌───────┐ ┌──────┐ ┌──────┐ ┌────────┐   │
│  │ Media │ │Record│ │Storage│ │File  │ │Upgrad│ │  Rule  │   │
│  │Service│ │ Mgr  │ │  Mgr  │ │ Mgr  │ │  e   │ │ Engine │   │
│  └───────┘ └──────┘ └───────┘ └──────┘ └──────┘ └────────┘   │
├─────────────────────────────────────────────────────────────────┤
│  BASE SOFTWARE LAYER                                             │
│                                                                  │
│  ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌────────┐ ┌──────┐  │
│  │Config Mgr│ │ Event Bus │ │ GStreamer  │ │ FFmpeg │ │SQLite│  │
│  └──────────┘ └──────────┘ └───────────┘ └────────┘ └──────┘  │
│  ┌──────────┐ ┌──────────┐ ┌───────────┐                        │
│  │ OpenSSL  │ │  spdlog  │ │   libcurl │                        │
│  └──────────┘ └──────────┘ └───────────┘                        │
├─────────────────────────────────────────────────────────────────┤
│  HAL — Hardware Abstraction Layer (pure C interface)             │
│                                                                  │
│  ┌───────┐ ┌───────┐ ┌────────┐ ┌────────────┐ ┌───────────┐  │
│  │ Video │ │ Audio │ │  USB   │ │AI Accel    │ │Peripheral │  │
│  │ (MPP) │ │       │ │(Audio) │ │(NPU/DSP)   │ │GPIO/IR/WDT│  │
│  └───────┘ └───────┘ └────────┘ └────────────┘ └───────────┘  │
├─────────────────────────────────────────────────────────────────┤
│  KERNEL LAYER: Linux 5.10                                        │
│  SoC drivers, V4L2, ALSA, USB, network, watchdog               │
├─────────────────────────────────────────────────────────────────┤
│  HARDWARE                                                        │
│  Hi3516CV610 · Hi3516CV608 · Hi3519DV500 · QEMU aarch64        │
└─────────────────────────────────────────────────────────────────┘

Layer Descriptions

1. Hardware Layer

Supported SoCs:

SoCSeriesNPUTarget
Hisilicon 3516CV610CV6xxYesCommercial IP camera (Product PA)
Hisilicon 3516CV608CV6xxYesEntry-level IP camera
Hisilicon 3519DV500DV5xxYesHigh-end AI camera
QEMU aarch64—EmulatedDevelopment & CI (Product PB)

All SoCs share the Hisilicon MPP (Media Processing Platform) SDK for video/audio pipeline access.

2. Kernel Layer

  • Base: Linux 5.10 LTS
  • Build system: Buildroot (generates full root filesystem)
  • Key drivers: MPP video driver, ALSA audio, USB audio gadget, watchdog, I2C, GPIO, RTC, IR-CUT
  • Network stack: Standard Linux TCP/IP, conntrack, iptables

3. HAL — Hardware Abstraction Layer

The HAL exposes pure C interfaces to isolate all hardware-specific code. Upper layers never call MPP or SoC SDK directly.

Key HAL subsystems:

SubsystemResponsibility
hal/mpp/Video capture, encode, decode (H.264/H.265/MJPEG), VENC/VPSS pipeline
hal/ai/NPU model loading, inference scheduling, result extraction
hal/peripheral/GPIO alarm I/O, IR-CUT switching, RTC clock, watchdog
hal/mpp/audio/Audio capture, playback, encoding (AAC/G.711/Opus)
hal/common/Platform-shared utilities

Porting to a new SoC mainly requires implementing HAL interfaces for that platform, while upper layers stay mostly unchanged; new board peripherals can also be extended independently in HAL and device configuration.

4. Base Software Layer

Provides shared infrastructure for all business services and a stable base for software tailoring and feature-level customization:

ComponentRole
Config ManagerJSON-based hierarchical configuration, hot reload, path validation
Event BusPublish-subscribe event dispatch, cross-service decoupling
GStreamer 1.18Media pipeline: WebRTC (ICE/DTLS/SRTP), RTSP source, audio/video mux
FFmpeg 4.xCodec processing, format conversion, thumbnail extraction
SQLite 3.xRecording index, event log, configuration cache
OpenSSL 1.1.1TLS for HTTPS/WSS, certificate management, data encryption
spdlogStructured async logging with rotation
libcurl 7.xHTTP client for cloud AI API calls

5. Base Business Layer

Core device functionality implemented as independent C++ services:

ServiceLocationKey responsibility
Media Servicebase/media/Audio/video stream management, priority scheduling, interrupt/resume
Record Managerbase/record/Continuous recording, time-indexed MP4 segments, loop-overwrite policy
Storage Managerbase/storage/SD card lifecycle, format, hot-plug, space monitoring
File Managerbase/file_manager/Recording file CRUD, download API
Upgrade Servicebase/upgrade/Chunked firmware upload, signature verification, progress reporting
Rule Enginebase/rule_engine/Event-condition-action rules (e.g., AI detection → record + notify)
Discoverybase/discovery/mDNS-based LAN device discovery
Database Servicebase/database/SQLite abstraction layer, schema migration
Algo Managerbase/algo/AI algorithm lifecycle, model hot-load, label management
System Servicebase/system_service/Watchdog feeding, system status, reboot, factory reset
Networkbase/network/Ethernet config (DHCP/static), NTP sync
Web Serverbase/web_server/HTTP/HTTPS/WebSocket server, request routing

6. Foundation Services

Higher-level services that compose base layer capabilities:

6.1 Stream Service (foundation/stream_service/)

Manages all outbound media streams:

ProtocolImplementation
RTSPGStreamer rtspclientsink / custom RTSP server
WebRTCGStreamer WebRTC plugin, ICE/STUN/TURN negotiation, signaling via WebSocket
RTMPGStreamer rtmpsink, supports RTMPS (TLS)

The stream service arbitrates between stream consumers (RTSP clients, WebRTC browsers, RTMP destinations) and the single GStreamer source pipeline from HAL.

6.2 AI Services

ServiceLocationDescription
Agentfoundation/agent/Multi-modal AI agent: voice input → LLM reasoning → tool call → voice output
Qwenfoundation/qwen/Qwen3-Omni SDK adapter: real-time audio + video → text/speech response
Aliyunfoundation/aliyun/Alibaba Cloud Qwen-VL REST client: snapshot → image understanding
Xiaozhifoundation/xiaozhi/Xiaozhi AI voice dialog: speech-to-text → dialog → text-to-speech
MCPfoundation/mcp/Model Context Protocol server for agent tool exposure

6.3 Protocol Services

ServiceLocationStandard
ONVIFfoundation/onvif/WS-Discovery, ONVIF media/device profile
GB28181foundation/gb28181/SIP UA, PS stream, catalog and real-play
RESTful APIfoundation/restful/JWT-secured HTTP API, full device control
Protocolfoundation/protocol/Abstract protocol adapter (WebSocket event framing)

7. Application Layer

Web UI (foundation/web_page/)

Single-page application built with Vue 3:

ModulePathFunction
Live Previewcomponents/live/WebRTC player, AI detection overlay, screenshot
Configurationcomponents/camera/Video, audio, OSD parameter forms
Networkcomponents/network/Ethernet, RTSP/RTMP, GB28181, ONVIF config
Intelligencecomponents/intelligence/Algorithm enable/disable, model upload, label editor
Agentcomponents/agent/AI agent chat UI, Qwen config, voice testing
Playbackcomponents/record/Recording timeline, segment playback, download
Systemcomponents/system/User management, upgrade, web terminal, factory reset

RESTful API

Full API surface over HTTP/HTTPS. JWT tokens obtained via challenge-response login. Token auto-refresh on expiry.

API groups: auth, config, device, network, media, record, upgrade, algo, agent, event, log.

8. Customization Path

  • Hardware customization: add SoCs, board profiles, and peripherals such as GPIO, USB audio, IR-CUT, and watchdog primarily under device/ and hal/
  • Software customization: tailor streaming, AI, storage, protocol, web UI, and API modules primarily under base/, foundation/, and applications/
  • Delivery composition: combine hardware platforms, protocol capabilities, AI services, and front-end experience into customer-specific product variants

Key Data Flows

Video Preview (WebRTC)

Camera Sensor
    → HAL Video Capture (MPP VENC)
    → GStreamer pipeline (H.264 encode)
    → Stream Service WebRTC publisher
    → ICE/DTLS negotiation (WebSocket signaling at /v1/webrtc)
    → Browser WebRTC receiver
    → Canvas render + AI overlay

AI Detection (Local)

HAL Video Frame (YUV)
    → HAL AI Accelerator (NPU inference, YOLOv8)
    → Algo Manager (result parsing, label mapping)
    → Event Bus (detection event published)
    → Rule Engine (trigger check)
    → WebSocket push to browser / Record annotation

Voice Agent Interaction

USB Microphone
    → HAL Audio Capture
    → Xiaozhi / Qwen3-Omni (speech recognition)
    → Agent (intent parsing, tool selection)
    → Tool call: snapshot → Qwen-VL (image analysis)
    → Agent (compose response)
    → TTS → HAL Audio Playback → Speaker

Firmware Upgrade

Browser → POST /v1/upgrade/upload (multipart, chunked)
    → Upgrade Service (signature verify)
    → Flash write
    → System reboot
    → WebSocket progress events during all phases

Directory Structure

endless/
├── applications/endless/     # Main IPC application (service wiring, main loop)
├── base/                     # Base business services (media, record, storage …)
├── common/utils/             # Shared utilities (thread pool, memory pool, log)
├── device/                   # Board & SoC configuration
│   ├── board/3516cv610/      # Kernel config, rootfs overlay, product definition
│   ├── board/3516cv608/
│   ├── board/3519dv500/
│   └── qemu/                 # QEMU overlay, test assets
├── foundation/               # Higher-level services
│   ├── agent/                # AI Agent
│   ├── aliyun/               # Alibaba Cloud Qwen integration
│   ├── qwen/                 # Qwen SDK
│   ├── xiaozhi/              # Xiaozhi AI voice
│   ├── mcp/                  # MCP protocol
│   ├── gb28181/              # GB28181
│   ├── onvif/                # ONVIF
│   ├── restful/              # REST API
│   ├── stream_service/       # RTSP / WebRTC / RTMP
│   ├── web_page/             # Vue 3 frontend
│   └── protocol/             # Protocol abstraction
├── hal/                      # Hardware Abstraction Layer
│   ├── mpp/                  # Video/audio MPP
│   ├── ai/                   # NPU / AI accelerator
│   └── peripheral/           # GPIO, IR-CUT, watchdog, RTC
├── third_party/              # Vendored dependencies
├── docs/                     # Project documentation
├── build.sh                  # Top-level build script
└── CMakeLists.txt            # Root CMake

Build System

Build Commands

# Format: ./build.sh <product> <command> [mode]
./build.sh pa build release    # 3516CV610 release build
./build.sh pa all release      # Build + package firmware image
./build.sh pb build debug      # QEMU aarch64 debug build

Outputs

PathContent
out/bin/Executable binaries
out/lib/Shared libraries
out/web_page/Built Vue.js frontend
out/image/Flashable firmware image (when using all)

Toolchains

PlatformCompilerPath
3516CV610 / 3516CV608arm-v01c02-linux-musleabi-gccdevice/soc/hisilicon/3516cv610
aarch64 (QEMU)aarch64-linux-gnu-gccSystem or Buildroot

Performance Targets

MetricTarget
WebRTC latency< 500 ms
RTSP latency< 1 s
AI detection accuracy> 85 % (person/vehicle)
24h recording capacity32 GB SD card, 1080p, 1 Mbps
CPU usage (normal)< 70 %
Memory footprint< 256 MB
Cold boot time< 60 s
Concurrent RTSP clients5
System stability target7-day continuous operation without restart

Security Design

AreaMechanism
TransportTLS 1.2+ for all HTTPS and WSS
AuthenticationChallenge-response (HMAC-SHA256), anti-brute-force lockout
SessionJWT with short expiry + refresh token rotation
Config storageAES encryption for secrets
Firmware integrityRSA signature verification before flash
Secure bootPlatform-dependent (Hisilicon eFuse-based)
Vulnerability mgmtPeriodic dependency audit, Buildroot security patches

Contact