# yuan631111976/qtavplayer architecture

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

- Interactive diagram: https://gitdiagram.com/yuan631111976/qtavplayer
- Repository: https://github.com/yuan631111976/qtavplayer

## Overview

This repository is a Qt/QML multimedia player using FFmpeg for playback and OpenGL for video rendering. The documented workflow is to set a media source on AVPlayer, control playback or seek, and connect one or more AVOutput components to display video; audio uses Qt Multimedia. The graph includes the decoder’s packet/frame buffering and the bundled FFmpeg API boundaries. Source excerpts are partial, so some internal calls and the exact audio/render handoff are not verified; those relationships are omitted or marked unverified.

Main entry points: [`AVPlayer.cpp`](https://github.com/yuan631111976/qtavplayer/blob/master/AVPlayer.cpp) (AVPlayer), [`AVDecoder.cpp`](https://github.com/yuan631111976/qtavplayer/blob/master/AVDecoder.cpp) (AVDecoder), [`AVOutput.cpp`](https://github.com/yuan631111976/qtavplayer/blob/master/AVOutput.cpp) (AVOutput), [`AVDefine.h`](https://github.com/yuan631111976/qtavplayer/blob/master/AVDefine.h) (Playback states)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_qml["QML interface"]
  node_player["AVPlayer<br/>[AVPlayer.cpp]"]
  node_output["AVOutput<br/>[AVOutput.cpp]"]
end

subgraph group_playback["Playback control"]
  node_states["Playback states<br/>[AVDefine.h]"]
end

subgraph group_media["Media processing"]
  node_decoder["AVDecoder<br/>[AVDecoder.cpp]"]
  node_queues["Packet and frame queues<br/>[AVDecoder.h]"]
  node_format["FFmpeg demuxing<br/>[avformat.h]"]
  node_codec["FFmpeg codecs<br/>[avcodec.h]"]
  node_frames["FFmpeg frame formats<br/>[frame.h]"]
end

subgraph group_output["Media output"]
  node_video["OpenGL video rendering<br/>[AVOutput.cpp]"]
  node_audio["Qt audio output<br/>[AVPlayer.cpp]"]
end

node_host(("QML application"))

node_host -->|"creates and controls"| node_player
node_host -->|"connects source"| node_output
node_player -.->|"reports status"| node_states
node_player -.->|"delegates playback"| node_decoder
node_decoder -.->|"demuxes media"| node_format
node_decoder -.->|"decodes streams"| node_codec
node_decoder -->|"buffers packets and frames"| node_queues
node_decoder -.->|"produces decoded frames"| node_frames
node_output -->|"renders video"| node_video
node_player -->|"plays audio"| node_audio
node_player -->|"supplies video source"| node_output

click node_player "https://github.com/yuan631111976/qtavplayer/blob/master/AVPlayer.cpp"
click node_output "https://github.com/yuan631111976/qtavplayer/blob/master/AVOutput.cpp"
click node_states "https://github.com/yuan631111976/qtavplayer/blob/master/AVDefine.h"
click node_decoder "https://github.com/yuan631111976/qtavplayer/blob/master/AVDecoder.cpp"
click node_queues "https://github.com/yuan631111976/qtavplayer/blob/master/AVDecoder.h"
click node_format "https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavformat/avformat.h"
click node_codec "https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavcodec/avcodec.h"
click node_video "https://github.com/yuan631111976/qtavplayer/blob/master/AVOutput.cpp"
click node_audio "https://github.com/yuan631111976/qtavplayer/blob/master/AVPlayer.cpp"
click node_frames "https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavutil/frame.h"

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_player,node_output toneBlue
class node_states toneAmber
class node_decoder,node_queues,node_format,node_codec,node_frames toneMint
class node_video,node_audio toneRose
class node_host toneIndigo
```

## Components

### QML interface

- [AVPlayer](https://github.com/yuan631111976/qtavplayer/blob/master/AVPlayer.cpp): `AVPlayer.cpp`
- [AVOutput](https://github.com/yuan631111976/qtavplayer/blob/master/AVOutput.cpp): `AVOutput.cpp`

### Playback control

- [Playback states](https://github.com/yuan631111976/qtavplayer/blob/master/AVDefine.h): `AVDefine.h`

### Media processing

- [AVDecoder](https://github.com/yuan631111976/qtavplayer/blob/master/AVDecoder.cpp): `AVDecoder.cpp`
- [Packet and frame queues](https://github.com/yuan631111976/qtavplayer/blob/master/AVDecoder.h): `AVDecoder.h`
- [FFmpeg demuxing](https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavformat/avformat.h): `libs/include/libavformat/avformat.h`
- [FFmpeg codecs](https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavcodec/avcodec.h): `libs/include/libavcodec/avcodec.h`
- [FFmpeg frame formats](https://github.com/yuan631111976/qtavplayer/blob/master/libs/include/libavutil/frame.h): `libs/include/libavutil/frame.h`

### Media output

- [OpenGL video rendering](https://github.com/yuan631111976/qtavplayer/blob/master/AVOutput.cpp): `AVOutput.cpp`
- [Qt audio output](https://github.com/yuan631111976/qtavplayer/blob/master/AVPlayer.cpp): `AVPlayer.cpp`

### Other components

- **QML application**

## Connections

- QML application → AVPlayer: creates and controls
- QML application → AVOutput: connects source
- AVPlayer → Playback states: reports status
- AVPlayer → AVDecoder: delegates playback
- AVDecoder → FFmpeg demuxing: demuxes media
- AVDecoder → FFmpeg codecs: decodes streams
- AVDecoder → Packet and frame queues: buffers packets and frames (evidence: `AVDecoder.h`)
- AVDecoder → FFmpeg frame formats: produces decoded frames
- AVOutput → OpenGL video rendering: renders video (evidence: `AVOutput.cpp`)
- AVPlayer → Qt audio output: plays audio (evidence: `AVPlayer.cpp`)
- AVPlayer → AVOutput: supplies video source
