How sipwise/rtpengine works
Based on our review of the file tree and README, the project is the Sipwise NGCP rtpengine—a specialized media proxy designed for handling RTP (and other UDP-based media) traffic for use with SIP proxies like Kamailio. It is a high-performance, real-time media forwarding and processing engine that incorporates both userspace (the daemon and recording processes) and kernel-level components (for offloaded packet forwarding).
Overall System View
• Project as a full media processing engine that sits between SIP proxy systems (like Kamailio) and the actual media endpoints.
• Two main operation paths: regular RTP/media handling via the primary daemon and call recording via the dedicated recording daemon.
• That there is support for both userspace operations and optional in-kernel packet forwarding via the kernel module.
Main Components
• Daemon Process:
– Represented by the files in the “daemon” directory.
– Responsible for core RTP processing, SDP rewriting, transcoding, bridging between IPv4 and IPv6 (and different network interfaces), and providing several protocol supports (including ICE, SRTP, and RTCP variants).
– Show submodules such as components for control (both TCP and UDP), logging, media socket handling, and network interfaces.
• Recording Daemon:
– Found in the “recording-daemon” folder.
– Handles call recording, media stream mixing, file handling, and logging for media recordings.
• Kernel Module:
– Located in “kernel-module”.
– This component provides in-kernel packet forwarding for efficient, lower latency, and CPU-efficient processing.
• Shared Libraries:
– Include “lib” and “include” directories, which offer common functionalities (e.g. helper functions, logging libraries, codec support, network abstractions) that are used across both daemon and recording processes.
• Packaging, Build, and Testing Tools:
– Represent artifacts from “debian”, “pkg”, “Makefile”, and “tests”, which manage the build, deployment, unit tests, and integration tests.
– Although not part of runtime, they indicate architectural concerns regarding portability, deployment, and correctness.
• External Interfaces:
– HTTP/WebSocket interfaces, as well as Janus and MQTT (in “daemon/mqtt.c” and “daemon/websocket.c”), which indicate how the rtpengine can be controlled and interfaced with other systems.
– Any indicated REST or control protocols such as the NGControl Protocol and TCP-NG Control Protocol.
Data Flow and External Relationships
• Incoming Media Traffic:
– Indicate how the main daemon receives and processes these packets.
• Processing Pipeline:
– Show the internal flow within the daemon, including packet parsing, SDP rewriting, codec/transcoding logic, and forwarding to media processing sub-components.
– Include a conditional branch where if the kernel module is available it intercepts or speeds up packet forwarding.
• Recording and Transcoding:
– Illustrate how the libraries support both real-time transmission and handling of recorded content.
• Control and Management:
– Mark control sockets (CLI, WebSocket, etc.) and external control interfaces.
– Indicate how configuration (files in “etc” and “debian/…” configuration scripts) plays into setting up the proper behaviors.
Architectural Patterns and Technologies
• Multi-threaded design used to achieve low latency.
• Plugin-like extensibility via shared libraries (from “lib” and “include”) and external modules (e.g., Janus interface support).
• Major communication patterns (point-to-point between modules, client-server interactions with control protocols).