diff --git a/main.cc b/main.cc index 3285055..b453836 100644 --- a/main.cc +++ b/main.cc @@ -74,7 +74,7 @@ static void *thread_video(void *ignored_argument) { } Lock(); inputimage.CopyTo(¤timage, config.web_width, config.web_height); - if (inputfloatfilter.AddScaledImage(&inputfloat, 0.5, 0.5) == 0) + if (inputfloatfilter.AddScaledImage(&inputfloat, 0.6, 0.4) == 0) inputfloat.CopyTo(&inputfloatfilter); inputfloatfilter.CopyTo(¤timagefloat); UnLock(); @@ -184,6 +184,15 @@ static void sig_int(int sig) { printf ("\n\nSignal Int\n\n"); running = 0; -} +}; + +int isfile(std::string fname) { + struct stat st; + + if (stat (fname.c_str(), &st) == -1) return 0; + if ((st.st_mode & S_IFMT) == S_IFREG) return 1; + + return 0; +}; diff --git a/miniwebcam.h b/miniwebcam.h index dfb806e..565b13a 100644 --- a/miniwebcam.h +++ b/miniwebcam.h @@ -25,6 +25,7 @@ class WebCamServer : public WebServer { void ErrorExit(std::string text, int errorcode); int Lock(); int UnLock(); +int isfile(std::string fname); extern VideoFrame inputimage; extern VideoFrame currentimage; diff --git a/webserver.cc b/webserver.cc index 220faba..57d31e2 100644 --- a/webserver.cc +++ b/webserver.cc @@ -5,8 +5,7 @@ #include "UDPTCPNetwork.h" #include "inmemorytar.h" -std::string GenerateHtmlFile(); -InMemoryFile GenerateJpgFile(VideoFrame *vf); +// InMemoryFile GenerateJpgFile(VideoFrame *vf); InMemoryTar assets; int WebCamServer::HandleRequest (WebRequestBuffer *requestbuffer, WebServerClient *webclient) { @@ -35,18 +34,15 @@ int WebCamServer::HandleRequest (WebRequestBuffer *requestbuffer, WebServerClien (void*) jpgfile.mem, jpgfile.memsize) != 1) return 0; } + else if (isfile("www"+request)) { + if (webclient->SendResponseFile(requestbuffer, request, "") != 1) return 0; + } else if (assets.FindFile("www"+request, &imf_do_not_free)) { if (imf_do_not_free == NULL) return 0; if (webclient->SendResponseFileFromMemory(requestbuffer, request, "", (void*) imf_do_not_free->mem, imf_do_not_free->memsize) != 1) return 0; } - else if (request.find("/index.html") != std::string::npos) { - std::string htmlfile = GenerateHtmlFile(); - if (webclient->SendResponseFileFromMemory(requestbuffer, request, "", - (void*) htmlfile.c_str(), - strlen(htmlfile.c_str())) != 1) return 0; - } else { return 0; } @@ -55,11 +51,3 @@ int WebCamServer::HandleRequest (WebRequestBuffer *requestbuffer, WebServerClien return 1; }; - -std::string GenerateHtmlFile() { - std::string res; - res = "MiniWebCamERROR"; - res += ""; - return res; -}; - diff --git a/www/default.css b/www/default.css new file mode 100644 index 0000000..810e7ef --- /dev/null +++ b/www/default.css @@ -0,0 +1,4 @@ +body { + background-color: #444; + color: #BBB; +} diff --git a/www/index.html b/www/index.html index 31c8d62..221e5f6 100644 --- a/www/index.html +++ b/www/index.html @@ -1,24 +1,38 @@ MiniWebCam + + + - + +
+ +
+
- + +
+ +
+ +
+ +
+ + +