How doris-duo/carlife-md-lib works
Purpose and Entry Points
This repository builds a cross-platform C++ dynamic library implementing the CarLife protocol for MD devices connecting to a head unit (HU). Its public embedding surface is LibSource/include/CCarLifeLib.h and LibSource/include/CCarLifeLibWrapper.h; the library implementation is LibSource/libwrapper/CCarLifeLib.cpp. LibSource/CarLifeLibTest.cpp is the standalone consumer/test entry point.
Library Facade and Lifecycle
CCarLifeLib exposes the MD-facing API and coordinates connection, channel setup, protocol traffic, and callbacks to the embedding device. The wrapper isolates callers from internal modules and transport details.
• LibSource/include/CCarLifeLib.h
• LibSource/include/CCarLifeLibWrapper.h
• LibSource/libwrapper/CCarLifeLib.cpp
Connection and Transport Boundary
Connection management establishes and owns the socket-level link to the HU. Socket abstractions allow platform-specific networking implementations while presenting a common interface to the protocol stack.
• LibSource/include/CConnectManager.h
• LibSource/utility/CConnectManager.cpp
• LibSource/include/ISocket.h
Transport implementations include IPv4 and IPv6 socket paths plus a connector layer:
• LibSource/utility/CSocketConnector.cpp
• LibSource/utility/socket.cpp
• LibSource/utility/socketv6.cpp
Setup, Framing, and Dispatch
The connection-setup module handles initial channel establishment. Received transport payloads pass through the package processor, which forms the boundary between raw socket bytes and protocol/module dispatch.
• LibSource/modules/CConnectionSetupModule.cpp
• LibSource/core/CTranRecvPackageProcess.cpp
• LibSource/include/CTranRecvPackageProcess.h
Logical CarLife Channels
Protocol traffic is split into dedicated channels rather than one monolithic handler. Command and control modules carry HU/MD interaction and input/control events; video, media, TTS, and VR modules carry rendering and voice-related streams.
• LibSource/modules/CCmdChannelModule.cpp
• LibSource/modules/CCtrlChannelModule.cpp
• LibSource/modules/CVideoChannelModule.cpp
Additional content-channel implementations:
• LibSource/modules/CMediaChannelModule.cpp
• LibSource/modules/CTTSChannelModule.cpp
• LibSource/modules/CVRChannelModule.cpp
Protocol Contract and Serialization
Protocol messages are defined as Protocol Buffers schemas, with checked-in generated C++ bindings. These schemas define the interoperability contract with the HU for authentication, connection errors, device/vehicle state, input, media metadata, video encoding, Bluetooth, and telemetry.
• LibSource/protobuf/proto/CarlifeAuthenRequestProto.proto
• LibSource/protobuf/proto/CarlifeTouchEventProto.proto
• LibSource/protobuf/proto/CarlifeVideoEncoderInfoProto.proto
Generated bindings are compiled from:
• LibSource/protobuf/cc/include/
• LibSource/protobuf/cc/src/
Runtime and Build Targets
The runtime is native C++ with sockets and protobuf 2.5.0 (protobuf-2.5.0.tar.gz). Makefile variants indicate Linux and QNX support, consistent with embedded MD deployment. Build orchestration is rooted at:
• LibSource/Makefile
• LibSource/Makefile.linux
• LibSource/Makefile.qnx
No cloud, database, or web service infrastructure is represented; the principal external system is the connected HU over the CarLife socket protocol.
Main entry points: CTranRecvPackageProcess.cpp Receive Package Processor · CConnectManager.cpp Connection Manager · CCarLifeLib.cpp Library Facade · CCarLifeLib.h Public API
Components 16
Embedding Surface
- Public API · MD-facing embedding API and wrapper.
LibSource/include/CCarLifeLib.h - Library Facade · Coordinates lifecycle, protocol traffic, and device callbacks.
LibSource/libwrapper/CCarLifeLib.cpp
Connection & Transport
- Connection Manager · Owns the socket-level HU link.
LibSource/utility/CConnectManager.cpp - Socket Abstraction · Common interface for platform networking.
LibSource/include/ISocket.h - IPv4 / IPv6 Sockets · Platform socket and connector paths.
LibSource/utility/socket.cpp
Protocol Processing
- Channel Setup · Establishes initial logical channels.
LibSource/modules/CConnectionSetupModule.cpp - Receive Package Processor · Converts raw transport payloads into module dispatch.
LibSource/core/CTranRecvPackageProcess.cpp
Logical Channels
- Command Channel · Carries HU/MD commands.
LibSource/modules/CCmdChannelModule.cpp - Control Channel · Handles input and control events.
LibSource/modules/CCtrlChannelModule.cpp - Video Channel · Carries rendering/video stream traffic.
LibSource/modules/CVideoChannelModule.cpp - Media, TTS & VR Channels · Carries media and voice-related streams.
LibSource/modules/CMediaChannelModule.cpp
Protocol Contract
- Protobuf Schemas · HU interoperability messages for auth, input, video, state, and telemetry.
LibSource/protobuf/proto/CarlifeAuthenRequestProto.proto - Generated Protobuf C++ · Checked-in C++ bindings compiled into the library.
Other components
- Standalone Consumer · Example consumer of the library API.
LibSource/CarLifeLibTest.cpp - Head Unit · Connected HU over the CarLife socket protocol.
- Linux / QNX Build · Build orchestration for embedded native targets.
LibSource/Makefile
Connections 19
- Standalone Consumer → Public API: embeds
- Public API → Library Facade: implemented by
- Library Facade → Connection Manager: manages connection
- Connection Manager → Socket Abstraction: uses
- Socket Abstraction → IPv4 / IPv6 Sockets: implemented by
- IPv4 / IPv6 Sockets → Head Unit: socket link
- Connection Manager → Channel Setup: initializes
- Connection Manager → Receive Package Processor: delivers received bytes
- Receive Package Processor → Command Channel: dispatches commands
- Receive Package Processor → Control Channel: dispatches control
- Receive Package Processor → Video Channel: dispatches video
- Receive Package Processor → Media, TTS & VR Channels: dispatches media and voice
- Channel Setup → Generated Protobuf C++: serializes setup messages
- Command Channel → Generated Protobuf C++: serializes protocol messages
- Control Channel → Generated Protobuf C++: serializes protocol messages
- Video Channel → Generated Protobuf C++: serializes protocol messages
- Media, TTS & VR Channels → Generated Protobuf C++: serializes protocol messages
- Protobuf Schemas → Generated Protobuf C++: generates
- Linux / QNX Build → Library Facade: builds