How xutopia77/media-server works
This is a C++ streaming media server. Its principal workflow is server startup, accepting or sourcing media, representing it as media packets, managing streams, and exposing playback through protocol-specific services. The README documents RTMP, WebRTC, HTTP-FLV, and HLS; the source tree also includes transcoding, file playback, and GB28181/SIP modules. The excerpts show MediaSrv starting several services and include some RTMP, file-demux, and HLS implementation details. Other connections are left unverified where the sampled evidence does not establish runtime calls.
Main entry points: MediaSrv.cpp Media server · StreamMgr.cpp Stream manager · FileDemux.cpp File demux · RtmpSrv.hpp RTMP service
Components 22
Server runtime
- Application entry
src/apps/main.cpp - Media server
src/media/MediaSrv.cpp
Media pipeline
- Stream manager
src/media/StreamMgr.cpp - Media packets
src/media/MediaPkt.hpp - File playback
src/fileOp/Fileplay.cpp - File demux
src/fileOp/FileDemux.cpp - Transcoding
src/transcode/transcode.cpp - Data buffer
src/utils/DataBuffer.hpp
Streaming protocols
- RTMP service
src/net/rtmp/RtmpSrv.hpp - RTMP client
src/net/rtmp/RtmpClientSession.cpp - WebRTC sessions
src/net/webrtc/RtcSession.cpp - HTTP-FLV service
src/net/httpflv/HttpflvSrv.hpp - HLS output
src/net/hls/HlsWorker.cpp - HTTP API
src/net/httpapi/HttpApiSrv.cpp - WebSocket service
src/net/websocket/WsSrv.cpp
Network and signaling
- GB28181 service
src/net/gb/GbSrv.cpp - SIP proxy
src/net/sip/SipProxy.cpp - Async I/O layer
src/uvpp/TcpCon.cpp
Media formats
- FLV mux and demux
src/format/flv/FlvDemux.cpp - MPEG-TS mux
src/format/mpegts/TsMux.cpp - H.264 parsing
src/format/H264Header.hpp
Other components
- Operator / client
Connections 28
- Operator / client → Application entry: starts
- Application entry → Media server: starts server
src/apps/main.cpp - Media server → RTMP service: starts service
src/media/MediaSrv.cpp - Media server → WebRTC sessions: starts service
src/media/MediaSrv.cpp - Media server → HTTP-FLV service: starts service
src/media/MediaSrv.cpp - Media server → HTTP API: starts service
src/media/MediaSrv.cpp - Media server → WebSocket service: starts service
src/media/MediaSrv.cpp - Media server → File playback: starts playback
src/media/MediaSrv.cpp - Media server → HLS output: configures output
- Media server → GB28181 service: starts service
src/media/MediaSrv.cpp - Media server → SIP proxy: configures signaling
src/media/MediaSrv.cpp - Operator / client → RTMP service: publishes or plays
- RTMP client → Operator / client: connects upstream
- File playback → File demux: reads media
src/fileOp/Fileplay.cpp - File demux → FLV mux and demux: demuxes FLV
src/fileOp/FileDemux.cpp - File demux → Media packets: emits packets
src/fileOp/FileDemux.cpp - File playback → Stream manager: uses stream manager
src/fileOp/Fileplay.cpp - Media packets → Stream manager: managed as streams
- Stream manager → RTMP service: serves streams
- Stream manager → WebRTC sessions: serves streams
- Stream manager → HTTP-FLV service: serves streams
- Stream manager → HLS output: feeds output
- Stream manager → Transcoding: transcodes streams
- HLS output → MPEG-TS mux: uses transport stream
- RTMP service → Async I/O layer: uses TCP I/O
- WebRTC sessions → Async I/O layer: uses async I/O
- File demux → H.264 parsing: parses video headers
src/fileOp/FileDemux.cpp - Media packets → Data buffer: stores payload
src/media/MediaPkt.hpp