Test.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "API/WebAPI.h"
  2. #include <ctpl_stl.h>
  3. #include <Logging.h>
  4. #include <HttpServer.h>
  5. #include <iostream>
  6. #include <sstream>
  7. int main(int argc, char** argv)
  8. {
  9. try
  10. {
  11. Logging::OpenLog();
  12. Logging::SetLogMask(Logging::Severity::Debug);
  13. int port(8000);
  14. ctpl::thread_pool threadPool(6);
  15. std::string ffmpeg = "ffmpeg";
  16. Http::HttpServer::CallbackMethod callback = std::bind(&StreamRecoder::API::WebAPI::ProcessQuery, &threadPool, ffmpeg, std::placeholders::_1, std::placeholders::_2);
  17. Http::HttpServer server(port, callback);
  18. Logging::Log(Logging::Severity::Info, "Startup Complete");
  19. server.Wait();
  20. Logging::Log(Logging::Severity::Info, "Stopping StreamRecoder...");
  21. Logging::CloseLog();
  22. }
  23. catch (const std::exception& e)
  24. {
  25. std::cerr << "Exception caught" << std::endl;
  26. std::stringstream ss;
  27. ss << "Type : " << typeid(e).name() << std::endl;
  28. ss << "ERROR: " << e.what() << std::endl;
  29. Logging::Log(Logging::Severity::Error, ss.str());
  30. Logging::CloseLog();
  31. return -1;
  32. }
  33. return 0;
  34. }