#ifndef CONFIG_H #define CONFIG_H /** * @file config.h * @brief 项目配置管理头文件 * * 本文件定义ISUP平台客户端的所有运行时配置参数, * 包括服务器地址、设备信息、流媒体配置等。 */ #include "common.h" /* ============================================================ * CMS注册服务器配置 * ============================================================ */ typedef struct { char server_ip[MAX_IP_SIZE]; /* CMS服务器IP地址 */ short server_port; /* CMS服务器端口 */ char device_id[MAX_DEVICE_ID]; /* 设备ID(序列号) */ char protocol_version[16]; /* 协议版本 */ char encrypt_key[32]; /* 加密密钥 */ int enable; /* 是否启用 */ int auto_reconnect; /* 是否自动重连 */ int reconnect_interval; /* 重连间隔(秒) */ } CMSConfig; /* ============================================================ * SMS流媒体服务器配置 * ============================================================ */ typedef struct { char listen_ip[MAX_IP_SIZE]; /* 监听IP */ short listen_port; /* 监听端口 */ int max_streams; /* 最大流数量 */ int stream_timeout; /* 流超时时间(秒) */ } SMSConfig; /* ============================================================ * 报警服务器配置 * ============================================================ */ typedef struct { char listen_ip[MAX_IP_SIZE]; /* 监听IP */ short listen_port; /* 监听端口 */ int enable; /* 是否启用 */ } AlarmConfig; /* ============================================================ * RTMP推流配置(zlmediakit) * ============================================================ */ typedef struct { char rtmp_server[MAX_IP_SIZE]; /* RTMP服务器地址 */ short rtmp_port; /* RTMP端口 */ char app_name[64]; /* 应用名称 */ char stream_key[128]; /* 流密钥/流名称 */ int enable; /* 是否启用推流 */ int auto_start; /* 设备上线自动推流 */ int reconnect; /* 断线重连 */ int reconnect_interval; /* 重连间隔(秒) */ } RTMPConfig; /* ============================================================ * 录像回放配置 * ============================================================ */ typedef struct { int enable; /* 是否启用回放 */ int max_concurrent; /* 最大并发回放数 */ char save_path[MAX_PATH_SIZE]; /* 录像保存路径 */ int record_duration; /* 单次回放最长时长(秒) */ } PlaybackConfig; /* ============================================================ * 模拟图片/视频配置 * ============================================================ */ typedef struct { int enable; /* 是否启用模拟模式 */ char image_dir[MAX_PATH_SIZE]; /* 模拟图片目录 */ int width; /* 模拟视频宽度 */ int height; /* 模拟视频高度 */ int fps; /* 帧率 */ int bitrate; /* 码率(bps) */ int gop_size; /* GOP大小 */ int test_image_count; /* 测试图片数量 */ } SimConfig; /* ============================================================ * 全局配置结构 * ============================================================ */ typedef struct { CMSConfig cms; /* CMS注册配置 */ SMSConfig sms; /* SMS流媒体配置 */ AlarmConfig alarm; /* 报警配置 */ RTMPConfig rtmp; /* RTMP推流配置 */ PlaybackConfig playback; /* 录像回放配置 */ SimConfig sim; /* 模拟配置 */ char log_file[MAX_PATH_SIZE]; /* 日志文件路径 */ int log_level; /* 日志级别 */ int daemon_mode; /* 守护进程模式 */ int pid_file[MAX_PATH_SIZE]; /* PID文件路径 */ } AppConfig; /* ============================================================ * 配置加载/保存函数声明 * ============================================================ */ /** * @brief 加载配置文件 * @param config 配置结构指针 * @param config_file 配置文件路径 * @return SUCCESS成功, FAILURE失败 */ int config_load(AppConfig* config, const char* config_file); /** * @brief 保存配置到文件 * @param config 配置结构指针 * @param config_file 配置文件路径 * @return SUCCESS成功, FAILURE失败 */ int config_save(const AppConfig* config, const char* config_file); /** * @brief 使用默认配置初始化 * @param config 配置结构指针 */ void config_init_default(AppConfig* config); /** * @brief 打印配置信息 * @param config 配置结构指针 */ void config_print(const AppConfig* config); /* ============================================================ * 默认配置值(与图片中的设备配置对应) * ============================================================ * 服务器地址: 117.131.63.98 * 端口: 7031 * 设备ID: AX5324540 * 协议版本: ISUP5.0 * 加密密钥: abc12345 * ============================================================ */ #endif /* CONFIG_H */