#pragma once

#include <cstdint>
#include <string>
#include <vector>

/** One UDPStreamer source (label, host, port). */
struct SourceConfig {
    std::string label           = "Source";
    std::string host            = "localhost";
    uint16_t    port            = 44500;
    std::string multicast_group = "";   /**< "" = unicast; e.g. "239.0.0.1" */
    uint16_t    data_port       = 0;    /**< 0 = port+1 in multicast mode */
};

/** Display settings. */
struct DisplayConfig {
    int fps            = 60;
    int width          = 1400;
    int height         = 900;
    int opengl_version = 2;
};

/** Trigger defaults. */
struct TriggerConfig {
    double pretrigger_sec  = 0.01;   //  10 ms
    double posttrigger_sec = 0.09;   //  90 ms
};

/** Full application configuration. */
struct AppConfig {
    std::vector<SourceConfig> sources;
    DisplayConfig             display;
    TriggerConfig             trigger;
};

/**
 * Parse an INI-style config file.
 *
 * Supported sections:
 *   [display]   fps, width, height, opengl_version
 *   [trigger]   pretrigger_sec, posttrigger_sec
 *   [source.N]  label, host, port
 *
 * Throws std::runtime_error on file open failure.
 * Returns empty sources list if no [source.N] sections are present
 * (caller may add sources from CLI args).
 */
AppConfig parse_ini(const std::string& path);
