# winshining/nginx-http-flv-module architecture

> Architecture diagram of the GitHub repository winshining/nginx-http-flv-module, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/winshining/nginx-http-flv-module
- Repository: https://github.com/winshining/nginx-http-flv-module

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core NGINX Server
b) RTMP Module Components
c) HTTP-FLV Module Components
d) Streaming Protocols Support
e) Media Processing Components
f) Control & Statistics Components

##### Special Features to Highlight

- Virtual Host Support
- Statistics Module
- Control Module
- GOP Cache
- Auto-Push Feature

##### Technical Details

Annotations for:
- Port configurations (1935 for RTMP, 80/443 for HTTP)
- Supported codecs (H.264, AAC/MP3)
- Module dependencies
- Configuration paths

##### Implementation Notes

- The modular architecture
- Stream processing pipeline
- Protocol conversion points
- Monitoring and control interfaces

##### Specific Components Detail

**[HTTP-FLV Module]**
- Chunked transfer handling
- CORS support
- Live streaming handler

**[RTMP Core]**
- Connection management
- Protocol handling
- Stream multiplexing

**[Media Processing]**
- GOP cache
- Format conversion
- Stream packaging

##### Integration Points

Integration with:
- NGINX core
- External players (VLC, flv.js, etc.)
- Publishing tools (FFmpeg, OBS)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        HTTP_CLIENTS["HTTP/HTTPS Clients"]
        RTMP_CLIENTS["RTMP Clients"]
    end

    %% Protocol Handlers Layer
    subgraph "Protocol Handlers"
        HTTP_FLV["HTTP-FLV Handler"]:::handler
        RTMP_CORE["RTMP Core"]:::core
    end

    %% Media Processing Layer
    subgraph "Media Processing"
        GOP_CACHE["GOP Cache"]:::processing
        STREAM_PROC["Stream Processing"]:::processing
        CMD_HANDLER["Command Handler"]:::processing
        CODEC_PROC["Codec Processing"]:::processing
        MPEGTS["MPEGTS Handler"]:::format
        MP4["MP4 Handler"]:::format
    end

    %% Stream Distribution Layer
    subgraph "Stream Distribution"
        LIVE["Live Streaming"]:::distribution
        RECORD["Recording"]:::distribution
        RELAY["Stream Relay"]:::distribution
        AUTO_PUSH["Auto-Push"]:::distribution
    end

    %% Output Protocols Layer
    subgraph "Output Protocols"
        RTMP_OUT["RTMP Output"]:::output
        FLV_OUT["HTTP-FLV Output"]:::output
        HLS["HLS Output"]:::output
        DASH["DASH Output"]:::output
    end

    %% Control Components
    subgraph "Control & Monitoring"
        STATS["Statistics Module"]:::control
        CONTROL["Control Module"]:::control
    end

    %% Relationships
    HTTP_CLIENTS --> HTTP_FLV
    RTMP_CLIENTS --> RTMP_CORE
    
    HTTP_FLV --> STREAM_PROC
    RTMP_CORE --> STREAM_PROC
    
    STREAM_PROC --> GOP_CACHE
    STREAM_PROC --> CMD_HANDLER
    STREAM_PROC --> CODEC_PROC
    
    GOP_CACHE --> LIVE
    CODEC_PROC --> LIVE
    
    LIVE --> RTMP_OUT
    LIVE --> FLV_OUT
    LIVE --> HLS
    LIVE --> DASH
    
    LIVE --> RECORD
    LIVE --> RELAY
    LIVE --> AUTO_PUSH
    
    HLS --> MPEGTS
    DASH --> MP4
    
    CONTROL -.-> STREAM_PROC
    STATS -.-> STREAM_PROC

    %% Click Events
    click HTTP_FLV "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_http_flv_live_module.c"
    click RTMP_CORE "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp.c"
    click GOP_CACHE "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_gop_cache_module.c"
    click LIVE "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_live_module.c"
    click HLS "https://github.com/winshining/nginx-http-flv-module/blob/master/hls/ngx_rtmp_hls_module.c"
    click DASH "https://github.com/winshining/nginx-http-flv-module/blob/master/dash/ngx_rtmp_dash_module.c"
    click STATS "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_stat_module.c"
    click CONTROL "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_control_module.c"
    click RECORD "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_record_module.c"
    click AUTO_PUSH "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_auto_push_module.c"
    click MPEGTS "https://github.com/winshining/nginx-http-flv-module/blob/master/hls/ngx_rtmp_mpegts.c"
    click MP4 "https://github.com/winshining/nginx-http-flv-module/blob/master/dash/ngx_rtmp_mp4.c"
    click CMD_HANDLER "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_cmd_module.c"
    click CODEC_PROC "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_codec_module.c"
    click RELAY "https://github.com/winshining/nginx-http-flv-module/blob/master/ngx_rtmp_relay_module.c"

    %% Styles
    classDef handler fill:#3498db
    classDef core fill:#2ecc71
    classDef processing fill:#27ae60
    classDef format fill:#16a085
    classDef distribution fill:#e67e22
    classDef output fill:#e74c3c
    classDef control fill:#95a5a6

    %% Legend
    subgraph Legend
        L1["Protocol Handler"]:::handler
        L2["Core Component"]:::core
        L3["Processing Module"]:::processing
        L4["Format Handler"]:::format
        L5["Distribution"]:::distribution
        L6["Output Protocol"]:::output
        L7["Control & Monitoring"]:::control
    end
```
