From 1885f5697fe88630fd9018ba4047b251738c79ce Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 11 May 2018 01:50:18 +0200 Subject: [PATCH] generate voctomix and cm-config based on detected format --- HttpServer.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++- HttpServer.h | 6 ++++ rc/style.css | 3 ++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/HttpServer.cpp b/HttpServer.cpp index 768c835..54d77d3 100644 --- a/HttpServer.cpp +++ b/HttpServer.cpp @@ -95,6 +95,9 @@ int HttpServer::requestHandler( else if(method == "GET" && url.find("/capture/") == 0) { return captureRequestHandler(url.substr(sizeof("/capture/") - 1), responseHeaders, responseBody); } + else if(method == "GET" && url.find("/config/") == 0) { + return configRequestHandler(url.substr(sizeof("/config/") - 1), responseHeaders, responseBody); + } else { return MHD_HTTP_NOT_FOUND; @@ -145,6 +148,69 @@ int HttpServer::captureRequestHandler( return MHD_HTTP_NOT_FOUND; } +int HttpServer::configRequestHandler( + std::string filename, + std::map* responseHeaders, + std::stringstream* responseBody +) { + std::string index_str = filename; + unsigned long index; + try { + index = std::stoul(index_str); + } + catch(std::invalid_argument) { + return MHD_HTTP_NOT_FOUND; + } + catch(std::out_of_range) { + return MHD_HTTP_NOT_FOUND; + } + + if(index < m_deviceProbers.size()) + { + DeviceProber *deviceProber = m_deviceProbers[index]; + (*responseHeaders)["Content-Type"] = "text/html; charset=UTF-8"; + + (*responseBody) << +"" +"" +" " +" " +" " +" " +"

Configuration-Snippets

" +"

for the c3voc cm

" +" " +"…\n" +" -\n" +" # " << deviceProber->GetDeviceName() << "\n" +" name: cam" << (index+1) << "\n" +" type: decklink-internal\n" +" devicenumber: " << index << "\n" +" video_connection: " << videoConnectionToString(deviceProber->GetActiveConnection()) << "\n" +" video_mode: \"" << deviceProber->GetDetectedMode() << "\"\n" +"…" +" " +"" +"

for voctocore/config.ini

" +" " +"…\n" +"# " << deviceProber->GetDeviceName() << "\n" +"[source.cam" << (index+1) << "]\n" +"kind = decklink\n" +"devicenumber = " << index << "\n" +"video_connection = " << videoConnectionToString(deviceProber->GetActiveConnection()) << "\n" +"video_mode = " << deviceProber->GetDetectedMode() << "\n" +"audio_connection = embedded\n" +"deinterlace = assume-progressive\n" +"…" +" " +" " +""; + return MHD_HTTP_OK; + } + return MHD_HTTP_NOT_FOUND; +} + int HttpServer::indexRequestHandler( std::map* responseHeaders, std::stringstream* responseBody @@ -156,7 +222,7 @@ int HttpServer::indexRequestHandler( "" " " " " -" " +" " " " " " "

DecklinkDebugger on " << m_hostname << "

" @@ -170,6 +236,7 @@ int HttpServer::indexRequestHandler( " Detected Mode" " Pixel Format" " Capture" +" Config" " " " "; @@ -205,6 +272,18 @@ int HttpServer::indexRequestHandler( (*responseBody) << " " +" "; + + if(deviceProber->GetSignalDetected()) + { + (*responseBody) << +" " +" Config-Snippets" +" "; + } + + (*responseBody) << +" " " "; deviceIndex++; diff --git a/HttpServer.h b/HttpServer.h index e4c2116..c4ab218 100644 --- a/HttpServer.h +++ b/HttpServer.h @@ -46,6 +46,12 @@ class HttpServer std::stringstream* responseBody ); + int configRequestHandler( + std::string filename, + std::map* responseHeaders, + std::stringstream* responseBody + ); + private: int32_t m_refCount; std::vector m_deviceProbers; diff --git a/rc/style.css b/rc/style.css index b0f5b38..1b7a640 100644 --- a/rc/style.css +++ b/rc/style.css @@ -28,3 +28,6 @@ table td img { width: 160px; height: 90px; } +code { + white-space: pre; +}