# pedrosg94/rootencoder architecture

> Architecture diagram of the GitHub repository pedrosg94/rootencoder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pedrosg94/rootencoder
- Repository: https://github.com/pedrosg94/rootencoder

## Overview

RootEncoder is an Android audio/video streaming library. An application selects a source and stream API, prepares media capture and encoding, then sends encoded audio/video to a server over RTMP, RTSP, SRT, UDP/MPEG-TS, or WHIP; it can also record locally. The graph includes documented source, filter, recording, and monitoring capabilities. The README and file tree establish those product areas, but most implementation files were not sampled, so protocol-internal wiring is intentionally omitted.

Main entry points: [`library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt`](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt) (Protocol facades), [`library/src/main/java/com/pedro/library/base/StreamBase.kt`](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/base/StreamBase.kt) (Stream APIs), [`encoder/src/main/java/com/pedro/encoder/input/sources`](https://github.com/pedrosg94/rootencoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/sources) (Media sources), [`encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java`](https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java) (Media encoders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Streaming API"]
  node_streamapi["Stream APIs<br/>[StreamBase.kt]"]
  node_protocolapi["Protocol facades<br/>[RtmpStream.kt]"]
  node_recording["Recording"]
end

subgraph group_media["Media pipeline"]
  node_sources["Media sources"]
  node_extrasources["Extra sources"]
  node_camera["Camera capture"]
  node_microphone["Audio capture"]
  node_render["GL rendering<br/>[MainRender.kt]"]
  node_filters["Realtime filters"]
  node_encoders["Media encoders<br/>[VideoEncoder.java]"]
end

subgraph group_transport["Protocols"]
  node_rtmp["RTMP client<br/>[RtmpClient.kt]"]
  node_rtsp["RTSP client<br/>[CommandsManager.kt]"]
  node_srt["SRT client<br/>[CommandsManager.kt]"]
  node_udp["UDP transport<br/>[CommandManager.kt]"]
  node_whip["WHIP client<br/>[CommandsManager.kt]"]
end

subgraph group_support["Shared support"]
  node_common["Codec and frames<br/>[MediaFrame.kt]"]
  node_stats["Stream statistics"]
  node_flvrecord["FLV recording"]
end

node_app(("Android app"))
node_server(("Media server"))

node_app -->|"configures"| node_streamapi
node_streamapi -->|"selects source"| node_sources
node_streamapi -->|"prepares encoding"| node_encoders
node_streamapi -->|"starts stream"| node_protocolapi
node_sources -->|"captures video"| node_camera
node_sources -->|"captures audio"| node_microphone
node_extrasources -.->|"provides sources"| node_sources
node_sources -->|"provides frames"| node_render
node_render -->|"applies effects"| node_filters
node_render -->|"renders video"| node_encoders
node_microphone -->|"provides audio"| node_encoders
node_encoders -->|"emits frames"| node_common
node_protocolapi -->|"dispatches RTMP"| node_rtmp
node_protocolapi -->|"dispatches RTSP"| node_rtsp
node_protocolapi -->|"dispatches SRT"| node_srt
node_protocolapi -->|"dispatches UDP"| node_udp
node_protocolapi -->|"dispatches WHIP"| node_whip
node_rtmp -->|"streams media"| node_server
node_rtsp -->|"streams media"| node_server
node_srt -->|"streams media"| node_server
node_udp -->|"streams media"| node_server
node_whip -->|"streams media"| node_server
node_streamapi -->|"starts recording"| node_recording
node_recording -->|"selects FLV muxer"| node_flvrecord
node_common -->|"tracks throughput"| node_stats

click node_streamapi "https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/base/StreamBase.kt"
click node_protocolapi "https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt"
click node_recording "https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/base/recording/RecordController.kt"
click node_sources "https://github.com/pedrosg94/rootencoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/sources"
click node_extrasources "https://github.com/pedrosg94/rootencoder/tree/master/extra-sources/src/main/java/com/pedro/extrasources"
click node_camera "https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/video/Camera2ApiManager.kt"
click node_microphone "https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/audio/MicrophoneManager.java"
click node_render "https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/MainRender.kt"
click node_filters "https://github.com/pedrosg94/rootencoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/filters"
click node_encoders "https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java"
click node_rtmp "https://github.com/pedrosg94/rootencoder/blob/master/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt"
click node_rtsp "https://github.com/pedrosg94/rootencoder/blob/master/rtsp/src/main/java/com/pedro/rtsp/rtsp/commands/CommandsManager.kt"
click node_srt "https://github.com/pedrosg94/rootencoder/blob/master/srt/src/main/java/com/pedro/srt/srt/CommandsManager.kt"
click node_udp "https://github.com/pedrosg94/rootencoder/blob/master/udp/src/main/java/com/pedro/udp/CommandManager.kt"
click node_whip "https://github.com/pedrosg94/rootencoder/blob/master/whip/src/main/java/com/pedro/whip/webrtc/CommandsManager.kt"
click node_common "https://github.com/pedrosg94/rootencoder/blob/master/common/src/main/java/com/pedro/common/frame/MediaFrame.kt"
click node_stats "https://github.com/pedrosg94/rootencoder/blob/master/common/src/main/java/com/pedro/common/StreamingStatsMonitor.kt"
click node_flvrecord "https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/util/FlvMuxerRecordController.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_streamapi,node_protocolapi,node_recording toneBlue
class node_sources,node_extrasources,node_camera,node_microphone,node_render,node_filters,node_encoders toneAmber
class node_rtmp,node_rtsp,node_srt,node_udp,node_whip,node_server toneMint
class node_common,node_stats,node_flvrecord toneRose
class node_app toneIndigo
```

## Components

### Streaming API

- [Stream APIs](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/base/StreamBase.kt): `library/src/main/java/com/pedro/library/base/StreamBase.kt`
- [Protocol facades](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt): `library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt`
- [Recording](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/base/recording/RecordController.kt): `library/src/main/java/com/pedro/library/base/recording/RecordController.kt`

### Media pipeline

- [Media sources](https://github.com/pedrosg94/rootencoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/sources): `encoder/src/main/java/com/pedro/encoder/input/sources`
- [Extra sources](https://github.com/pedrosg94/rootencoder/tree/master/extra-sources/src/main/java/com/pedro/extrasources): `extra-sources/src/main/java/com/pedro/extrasources`
- [Camera capture](https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/video/Camera2ApiManager.kt): `encoder/src/main/java/com/pedro/encoder/input/video/Camera2ApiManager.kt`
- [Audio capture](https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/audio/MicrophoneManager.java): `encoder/src/main/java/com/pedro/encoder/input/audio/MicrophoneManager.java`
- [GL rendering](https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/MainRender.kt): `encoder/src/main/java/com/pedro/encoder/input/gl/render/MainRender.kt`
- [Realtime filters](https://github.com/pedrosg94/rootencoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/filters): `encoder/src/main/java/com/pedro/encoder/input/gl/render/filters`
- [Media encoders](https://github.com/pedrosg94/rootencoder/blob/master/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java): `encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java`

### Protocols

- [RTMP client](https://github.com/pedrosg94/rootencoder/blob/master/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt): `rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt`
- [RTSP client](https://github.com/pedrosg94/rootencoder/blob/master/rtsp/src/main/java/com/pedro/rtsp/rtsp/commands/CommandsManager.kt): `rtsp/src/main/java/com/pedro/rtsp/rtsp/commands/CommandsManager.kt`
- [SRT client](https://github.com/pedrosg94/rootencoder/blob/master/srt/src/main/java/com/pedro/srt/srt/CommandsManager.kt): `srt/src/main/java/com/pedro/srt/srt/CommandsManager.kt`
- [UDP transport](https://github.com/pedrosg94/rootencoder/blob/master/udp/src/main/java/com/pedro/udp/CommandManager.kt): `udp/src/main/java/com/pedro/udp/CommandManager.kt`
- [WHIP client](https://github.com/pedrosg94/rootencoder/blob/master/whip/src/main/java/com/pedro/whip/webrtc/CommandsManager.kt): `whip/src/main/java/com/pedro/whip/webrtc/CommandsManager.kt`

### Shared support

- [Codec and frames](https://github.com/pedrosg94/rootencoder/blob/master/common/src/main/java/com/pedro/common/frame/MediaFrame.kt): `common/src/main/java/com/pedro/common/frame/MediaFrame.kt`
- [Stream statistics](https://github.com/pedrosg94/rootencoder/blob/master/common/src/main/java/com/pedro/common/StreamingStatsMonitor.kt): `common/src/main/java/com/pedro/common/StreamingStatsMonitor.kt`
- [FLV recording](https://github.com/pedrosg94/rootencoder/blob/master/library/src/main/java/com/pedro/library/util/FlvMuxerRecordController.kt): `library/src/main/java/com/pedro/library/util/FlvMuxerRecordController.kt`

### Other components

- **Android app**
- **Media server**

## Connections

- Android app → Stream APIs: configures
- Stream APIs → Media sources: selects source
- Stream APIs → Media encoders: prepares encoding
- Stream APIs → Protocol facades: starts stream
- Media sources → Camera capture: captures video
- Media sources → Audio capture: captures audio
- Extra sources → Media sources: provides sources
- Media sources → GL rendering: provides frames
- GL rendering → Realtime filters: applies effects
- GL rendering → Media encoders: renders video
- Audio capture → Media encoders: provides audio
- Media encoders → Codec and frames: emits frames
- Protocol facades → RTMP client: dispatches RTMP
- Protocol facades → RTSP client: dispatches RTSP
- Protocol facades → SRT client: dispatches SRT
- Protocol facades → UDP transport: dispatches UDP
- Protocol facades → WHIP client: dispatches WHIP
- RTMP client → Media server: streams media
- RTSP client → Media server: streams media
- SRT client → Media server: streams media
- UDP transport → Media server: streams media
- WHIP client → Media server: streams media
- Stream APIs → Recording: starts recording
- Recording → FLV recording: selects FLV muxer
- Codec and frames → Stream statistics: tracks throughput
