12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <iostream>
- #include "config.h"
- #include "reporter.h"
- #include "rtsp_client.h"
- #include "scheduler.h"
- using namespace jtjai_media;
- int main() {
- std::cout << "测试报告生成功能" << std::endl;
-
- // 加载配置
- ConfigManager config_mgr;
- if (!config_mgr.load_from_file("/Users/wenhongquan/CLionProjects/jtjai_media/config.json")) {
- std::cerr << "无法加载配置文件" << std::endl;
- return 1;
- }
-
- // 创建一些模拟的统计数据
- std::vector<RTSPClientStats> mock_stats;
-
- // 模拟第一个流 - 不可用
- RTSPClientStats stats1;
- stats1.stream_index = 0;
- stats1.rtsp_url = "rtsp://test1.example.com:554/live/stream1";
- stats1.output_file = "./output/test_stream1.mp4";
- stats1.status = RTSPClientStatus::STREAM_UNAVAILABLE;
- stats1.error_message = "流不可用或地址错误";
- stats1.start_time = std::chrono::system_clock::now();
- stats1.end_time = stats1.start_time + std::chrono::seconds(3);
- stats1.duration_seconds = 15;
- stats1.bytes_received = 0;
- stats1.frames_received = 0;
- mock_stats.push_back(stats1);
-
- // 模拟第二个流 - 不可用
- RTSPClientStats stats2;
- stats2.stream_index = 1;
- stats2.rtsp_url = "rtsp://test2.example.com:554/live/stream2";
- stats2.output_file = "./output/test_stream2.mp4";
- stats2.status = RTSPClientStatus::STREAM_UNAVAILABLE;
- stats2.error_message = "流不可用或地址错误";
- stats2.start_time = std::chrono::system_clock::now();
- stats2.end_time = stats2.start_time + std::chrono::seconds(3);
- stats2.duration_seconds = 20;
- stats2.bytes_received = 0;
- stats2.frames_received = 0;
- mock_stats.push_back(stats2);
-
- // 创建调度器统计数据
- StreamScheduler::SchedulerStats scheduler_stats;
- scheduler_stats.total_tasks = 2;
- scheduler_stats.completed_tasks = 0;
- scheduler_stats.failed_tasks = 2;
- scheduler_stats.cancelled_tasks = 0;
- scheduler_stats.max_concurrent_used = 2;
- scheduler_stats.completion_rate = 0.0;
- scheduler_stats.start_time = std::chrono::system_clock::now();
- scheduler_stats.end_time = scheduler_stats.start_time + std::chrono::seconds(10);
-
- // 生成报告
- ResultReporter reporter(config_mgr);
-
- std::cout << "开始生成报告..." << std::endl;
- if (reporter.generate_report(mock_stats, scheduler_stats)) {
- std::cout << "报告生成成功!" << std::endl;
- } else {
- std::cout << "报告生成失败!" << std::endl;
- return 1;
- }
-
- return 0;
- }
|