# nariakiiwatani/ofxndi architecture

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

- Interactive diagram: https://gitdiagram.com/nariakiiwatani/ofxndi
- Repository: https://github.com/nariakiiwatani/ofxndi

## Overview

##### Project type and purpose
- This is an open-source C++ addon (“ofxNDI”) for the openFrameworks toolkit that wraps the NewTek NDI (Network Device Interface) SDK.
- Its primary goal is to let openFrameworks apps send, receive, record, route, and otherwise manipulate audio/video streams over IP using NDI.

##### High-level file-structure analysis
- Top level
– example-* folders: multiple live examples (senders, receivers, router, recorder, videograbber, videocaster).
– libs/NDI: upstream NewTek NDI SDK headers + platform libs.
– src/: the actual addon source—core wrapper classes (ofxNDIReceiver, ofxNDISender, Finder, Recorder, Router, Genlock, PTZ, etc.) and a utils subfolder.
– redist/: packaged installers for redistribution (Mac).
– addon_config.mk, windows-copy-to-bin: build/deployment scripts for different platforms.
- Patterns
– Modular C++ classes each encapsulating one NDI SDK feature.
– Examples structured as standalone openFrameworks apps that link against the addon.
– Cross-platform support via platform-specific library folders under libs/NDI.

##### README insights
- Confirms cross-platform support (Mac, iOS*, Linux, Windows), missing iOS libs due to size.
- Warns that some SDK features are untested, and mobile receivers aren’t supported by the SDK.

##### Main components
a. openFrameworks Application Layer
- ofApp (main.cpp → ofApp.cpp/h) for each example.
- Your own OF-based UI/rendering logic that calls into ofxNDI classes.
b. ofxNDI Addon Layer
- Core modules:
– NDIFinder: discovers available sources on the network
– ofxNDISender / SendStream: wraps NDI send API
– ofxNDIReceiver / RecvStream: wraps NDI receive API
– ofxNDIRecorder: records streams to disk
– ofxNDIRouter: implements NDI routing (program → preview busses)
– ofxNDIGenlock, ofxNDIPTZ: advanced sync and camera controls
- Utilities: VideoCaster, VideoGrabber for seamless OF integration
c. NDI SDK Native Layer
- libs/NDI/include + libs/NDI/lib: the official NewTek NDI C/C++ libraries
- Platform-specific binaries (osx, windows, linux)
d. NDI Network Fabric
- Represents the UDP multicast/unicast flows carrying compressed frames/audio
e. Build & Deployment
- addon_config.mk (Linux/Mac MAKE build)
- windows-copy-to-bin (Windows post-build script)
- redist installers (Mac PKG)

##### Relationships and data flows
- For receive: NDI Network → NDI.SDK → ofxNDIReceiver → ofApp
- NDIFinder polls over the network to discover live sources → application
- Recorder / Router classes sit beside Sender/Receiver, hooking into the same NDI SDK and network flows
- Utilities wrap low-level frame buffers into OF textures/sounds

##### Architectural patterns & design principles
- Layered architecture:
– Presentation (OF application)
– Adapter/Wrapper (ofxNDI addon classes)
– Third-party SDK (NDI native libs)
- Single-responsibility: each class handles one SDK feature
- Dependency isolation: no direct NDI SDK calls in examples—everything goes through the wrapper

## Diagram (Mermaid)

```mermaid
graph TD
    %% Layers
    subgraph "openFrameworks Application Layer"
        direction TB
        EA1["example-audio-receiver"]:::app
        EA2["example-audio-sender"]:::app
        EA3["example-receiver-as-videograbber"]:::app
        EA4["example-receiver"]:::app
        EA5["example-recorder"]:::app
        EA6["example-router"]:::app
        EA7["example-send-h264"]:::app
        EA8["example-sender"]:::app
        EA9["example-videocaster"]:::app
    end

    subgraph "ofxNDI Addon Layer"
        direction TB
        subgraph "Core Modules"
            direction TB
            CM1["ofxNDIFinder"]:::addon
            CM2["ofxNDISender"]:::addon
            CM3["ofxNDIReceiver"]:::addon
            CM4["ofxNDIRecorder"]:::addon
            CM5["ofxNDIRouter"]:::addon
            CM6["ofxNDIGenlock"]:::addon
            CM7["ofxNDIPTZ"]:::addon
            CM8["ofxNDIFrame"]:::addon
            CM9["ofxNDIFrameCompressed"]:::addon
            CM10["ofxNDI.h"]:::addon
        end
        subgraph "Utilities"
            direction TB
            U1["VideoCaster"]:::addon
            U2["VideoGrabber"]:::addon
        end
    end

    subgraph "NDI SDK & Network"
        direction TB
        SDK["NDI SDK (libs/NDI)"]:::sdk
        Net[[NDI Network]]:::net
    end

    %% Data Flows
    EA1 -->|uses| CM2
    EA2 -->|uses| CM2
    EA8 -->|uses| CM2
    CM2 -->|wrapped send API| SDK
    SDK -->|streams via| Net
    Net -->|feeds| CM3
    CM3 -->|delivers frames| EA1
    EA3 -->|uses| U2
    EA9 -->|uses| U1
    CM4 -->|records via| SDK
    CM5 -->|routes via| SDK

    %% Click Events - Application Examples
    click EA1 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-audio-receiver/src/main.cpp"
    click EA2 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-audio-sender/src/main.cpp"
    click EA3 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-receiver-as-videograbber/src/main.cpp"
    click EA4 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-receiver/src/main.cpp"
    click EA5 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-recorder/src/main.cpp"
    click EA6 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-router/src/main.cpp"
    click EA7 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-send-h264/src/main.cpp"
    click EA8 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-sender/src/main.cpp"
    click EA9 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/example-videocaster/src/main.cpp"

    %% Click Events - ofxNDI Addon Core
    click CM1 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIFinder.h"
    click CM2 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDISender.h"
    click CM3 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIReceiver.h"
    click CM4 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIRecorder.h"
    click CM5 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIRouter.h"
    click CM6 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIGenlock.h"
    click CM7 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIPTZ.h"
    click CM8 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIFrame.h"
    click CM9 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDIFrameCompressed.h"
    click CM10 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/ofxNDI.h"

    %% Click Events - Utilities
    click U1 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/utils/ofxNDIVideoCaster.h"
    click U2 "https://github.com/nariakiiwatani/ofxndi/blob/NDI5/src/utils/ofxNDIVideoGrabber.h"

    %% Click Events - SDK
    click SDK "https://github.com/nariakiiwatani/ofxndi/tree/NDI5/libs/NDI/include"

    %% Styles
    classDef app fill:#9f6,stroke:#333,stroke-width:1px
    classDef addon fill:#6cf,stroke:#333,stroke-width:1px
    classDef sdk fill:#f96,stroke:#333,stroke-width:1px
    classDef net fill:#ccc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
