How barry-ran/qtscrcpycore works
Project type and purpose
• This is a C++ “core” library for Android real-time display and control (used by QtScrcpy).
• It wraps ADB, launches a server on the device, captures H.264 video over TCP, decodes it via FFmpeg, and forwards user input back to the device.
File structure to extract major components
• Top-level files:
– CMakeLists.txt – build configuration
– include/*.h – public API surface (QtScrcpyCore.h, adbprocess)
• src/adb – manages ADB process and forwarding
• src/devicemanage – device enumeration and lifecycle
• src/device – core device interaction, subdivided into:
– server (starts scrcpy-server on the device, handles sockets)
– demuxer → decoder → frame conversion → fps counting
– controller (input conversion pipelines + message sending)
– filehandler (pull/push files)
– recorder (record local copy of the stream)
• src/common – shared events & types
• src/third_party – embedded ADB binaries, FFmpeg headers/libs, scrcpy-server JAR
README for technical stack
• External dependencies: Android platform via ADB, FFmpeg for media processing, scrcpy-server code on the device.
• Build target: a static or shared C++ library exposing a simple API to Qt UI or other clients.
a. Host-side modules (QtScrcpyCore library)
1. ADB Manager
2. Device Manager
3. Server Launcher
4. TCP Video Socket & Control Socket
5. Demuxer → Decoder → Frame Converter → FPS Counter
6. Input Controller (event queue, converter, sender)
7. File Handler
8. Recorder
b. Device-side component
– scrcpy-server (runs on Android, listens on sockets)
c. External services/dependencies
– ADB binary (platform tool)
– FFmpeg libs (libavformat, libavcodec, etc.)
Relationships and data flows
• ADB Manager → launches scrcpy-server on device, sets up port forwarding
• TCP sockets:
– Video data socket: scrcpy-server → host → Demuxer
– Control socket: host Input Controller → scrcpy-server
• Demuxer hands elementary streams to Decoder → produces raw frames → Frame Converter → hands bitmaps to UI/rendering (in Qt layer)
• File Handler uses ADB channels to pull/push files
• Recorder taps decoded frames stream and writes to disk
• Device Manager notifies library clients of connect/disconnect events
Architectural patterns
• Pipeline pattern in media processing (demuxer→decoder→converter)
• Adapter pattern in Input Controller (generic events → device-specific control messages)
• Facade in public API (QtScrcpyCore.h exposes simple interface over all submodules)