2019-12-03 19:23:33 +00:00
|
|
|
//
|
|
|
|
// Created by loki on 5/30/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <thread>
|
2019-12-08 18:21:27 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <iostream>
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
#include "nvhttp.h"
|
|
|
|
#include "stream.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <rs.h>
|
|
|
|
}
|
|
|
|
|
2019-12-03 22:19:00 +00:00
|
|
|
#include "config.h"
|
2019-12-14 22:57:04 +00:00
|
|
|
|
|
|
|
#include "process.h"
|
|
|
|
|
2019-12-03 19:23:33 +00:00
|
|
|
using namespace std::literals;
|
2019-12-03 22:19:00 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2019-12-14 22:57:04 +00:00
|
|
|
std::vector<proc::cmd_t> pre_cmds {
|
|
|
|
{ "echo pre-1", "echo post-1" },
|
|
|
|
{ "echo pre-2", "" },
|
|
|
|
{ "echo pre-3", "echo post-3" }
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unordered_map<std::string, proc::ctx_t> map {
|
|
|
|
{ "echo", { std::move(pre_cmds), R"(echo \"middle\")", "output.txt" } }
|
|
|
|
};
|
|
|
|
|
|
|
|
boost::process::environment env = boost::this_process::environment();
|
|
|
|
proc::proc_t proc(std::move(env), std::move(map));
|
|
|
|
|
|
|
|
proc.execute("echo"s);
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(50ms);
|
|
|
|
|
|
|
|
proc.execute("echo"s);
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(50ms);
|
|
|
|
return proc.running();
|
|
|
|
|
2019-12-03 22:19:00 +00:00
|
|
|
if(argc > 1) {
|
2019-12-08 18:21:27 +00:00
|
|
|
if(!std::filesystem::exists(argv[1])) {
|
2019-12-14 22:57:04 +00:00
|
|
|
std::cout << "Error: Couldn't find configuration file ["sv << argv[1] << ']' << std::endl;
|
2019-12-08 18:21:27 +00:00
|
|
|
return 7;
|
|
|
|
}
|
|
|
|
|
2019-12-03 22:19:00 +00:00
|
|
|
config::parse_file(argv[1]);
|
|
|
|
}
|
|
|
|
|
2019-12-03 19:23:33 +00:00
|
|
|
reed_solomon_init();
|
|
|
|
|
|
|
|
std::thread httpThread { nvhttp::start };
|
|
|
|
std::thread rtpThread { stream::rtpThread };
|
|
|
|
|
|
|
|
httpThread.join();
|
|
|
|
rtpThread.join();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|