# lien/exoplayer architecture

> Architecture diagram of the GitHub repository lien/exoplayer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lien/exoplayer
- Repository: https://github.com/lien/exoplayer

## Overview

- Core Library: This is the heart of ExoPlayer found in the “library” directory. It contains the player implementation, media extraction, renderers, track selection, DRM, and utility classes.
- Demo Applications: Located in the “demo” and “demo_ext” directories. These modules illustrate how to use the ExoPlayer library in a real Android app, complete with activities, UI layouts, and media handling.
- Playback Tests: The “playbacktests” module is used for testing quality, performance, and integration of playback functionalities.
- Third-Party Libraries: The “third_party” folder holds external jars (such as dexmaker, mockito, okhttp3, and okio) that the project depends on.
- Build/Configuration & Gradle: Global Gradle files (build.gradle, settings.gradle, gradlew scripts) and project configurations provide the infrastructure necessary to build, test, and deploy the project.

##### Relationships and Data Flow
- A directional flow where the Demo Applications depend on and interact with the Core Library.
- Within the Core Library, highlight different internal subsystems such as media decoding, extraction, DRM handling, error/exception management, and rendering.
- Playback Tests module as interacting with both the Core Library and certain extension components to validate various playback scenarios.
- Third-party libraries as external dependencies that are used by various modules (e.g., networking in extensions, mocking in testing).

##### Architectural Patterns and Design Principles
- Modularity: The project’s structure clearly separates core functionality from the demo implementation and optional extensions.
- Separation of Concerns: Distinct separation exists between media playback logic, UI demonstration, tests, and codec extensions.
- Extensibility: The design allows new codecs or data source types to be added as extensions without major modifications to the core library.
- Dependency Management: The use of Gradle build scripts and clear module boundaries reflects a focus on maintainability and versioning (e.g., dev-vX and release-vX branches).

## Diagram (Mermaid)

```mermaid
graph TD
    F["Third-Party Libraries"]:::thirdParty
    A["Build/Configuration & Gradle"]:::build

    subgraph "Demo Applications"
        C1["Demo App (demo)"]:::demo
        C2["Demo App (demo_ext)"]:::demo
    end

    E["Playback Tests"]:::test
    B["ExoPlayer Library"]:::core

    subgraph "Extension Modules"
        E1["FLAC Decoder"]:::ext
        E2["Opus Decoder"]:::ext
        E3["VP9 Decoder"]:::ext
        E4["OkHttp Networking"]:::ext
    end

    %% Connections
    F -->|"supports"| E
    F -->|"supports"| E1
    F -->|"supports"| E2
    F -->|"supports"| E3
    F -->|"supports"| E4

    A -->|"builds"| B

    C1 -->|"calls"| B
    C2 -->|"calls"| B

    E -->|"tests"| B

    B -->|"delegates"| E1
    B -->|"delegates"| E2
    B -->|"delegates"| E3
    B -->|"delegates"| E4

    %% Click Events
    click F "https://github.com/lien/exoplayer/tree/release-v1/third_party/"
    click A "https://github.com/lien/exoplayer/blob/release-v1/build.gradle"
    click C1 "https://github.com/lien/exoplayer/tree/release-v1/demo/"
    click C2 "https://github.com/lien/exoplayer/tree/release-v1/demo_ext/"
    click B "https://github.com/lien/exoplayer/tree/release-v1/library/"
    click E "https://github.com/lien/exoplayer/tree/release-v1/playbacktests/"
    click E1 "https://github.com/lien/exoplayer/tree/release-v1/extensions/flac/"
    click E2 "https://github.com/lien/exoplayer/tree/release-v1/extensions/opus/"
    click E3 "https://github.com/lien/exoplayer/tree/release-v1/extensions/vp9/"
    click E4 "https://github.com/lien/exoplayer/tree/release-v1/extensions/okhttp/"

    %% Styles
    classDef thirdParty fill:#dcd6f7,stroke:#333,stroke-width:2px;
    classDef build fill:#a8d5e2,stroke:#333,stroke-width:2px;
    classDef demo fill:#fff2b2,stroke:#333,stroke-width:2px;
    classDef test fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef core fill:#b3d9ff,stroke:#333,stroke-width:2px;
    classDef ext fill:#ffc2b3,stroke:#333,stroke-width:2px;
```
