int main(int argc, char** argv){ int ret = ERROR_SUCCESS; bool show_help = false, show_version = false; string url; int threads = DefaultThread; double start = DefaultStartupSeconds, delay = DefaultDelaySeconds, error = DefaultErrorSeconds; double report = DefaultReportSeconds; int count = DefaultCount; string input; if((ret = discovery_options(argc, argv, show_help, show_version, url, threads, start, delay, error, report, count, input)) != ERROR_SUCCESS){ Error("discovery options failed. ret=%d", ret); return ret; } if(show_help){ help(argv); } if(show_version){ version(); } Trace("params url=%s, threads=%d, start=%.2f, delay=%.2f, error=%.2f, report=%.2f, count=%d", url.c_str(), threads, start, delay, error, report, count); StFarm farm; if((ret = farm.Initialize(report)) != ERROR_SUCCESS){ Error("initialize the farm failed. ret=%d", ret); return ret; } for(int i = 0; i < threads; i++){ StRtmpPublishTask* task = new StRtmpPublishTask(); char index[16]; snprintf(index, sizeof(index), "%d", i); std::string _index = index; std::string rtmp_url = url; size_t pos = std::string::npos; if ((pos = rtmp_url.find("{i}")) != std::string::npos) { rtmp_url = rtmp_url.replace(pos, pos + 3, _index); } if((ret = task->Initialize(input, rtmp_url, start, delay, error, count)) != ERROR_SUCCESS){ Error("initialize task failed, input=%s, url=%s, ret=%d", input.c_str(), rtmp_url.c_str(), ret); return ret; } if((ret = farm.Spawn(task)) != ERROR_SUCCESS){ Error("st farm spwan task failed, ret=%d", ret); return ret; } } farm.WaitAll(); return 0; }
int main(int argc, char** argv){ int ret = ERROR_SUCCESS; bool show_help = false, show_version = false; string url; bool vod = DefaultVod; int threads = DefaultThread; double start = DefaultStartupSeconds, delay = DefaultDelaySeconds, error = DefaultErrorSeconds; double report = DefaultReportSeconds; int count = DefaultCount; if((ret = discovery_options(argc, argv, show_help, show_version, url, vod, threads, start, delay, error, report, count)) != ERROR_SUCCESS){ Error("discovery options failed. ret=%d", ret); return ret; } Trace("params url=%s, vod=%d, threads=%d, start=%.2f, delay=%.2f, error=%.2f, report=%.2f, count=%d", url.c_str(), vod, threads, start, delay, error, report, count); if(show_help){ help(argv); } if(show_version){ version(); } StFarm farm; if((ret = farm.Initialize(report)) != ERROR_SUCCESS){ Error("initialize the farm failed. ret=%d", ret); return ret; } for(int i = 0; i < threads; i++){ StHlsTask* task = new StHlsTask(); if((ret = task->Initialize(url, vod, start, delay, error, count)) != ERROR_SUCCESS){ Error("initialize task failed, url=%s, ret=%d", url.c_str(), ret); return ret; } if((ret = farm.Spawn(task)) != ERROR_SUCCESS){ Error("st farm spwan task failed, ret=%d", ret); return ret; } } farm.WaitAll(); return 0; }