mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-02 05:36:31 +00:00
refactoring, html fixes
This commit is contained in:
6
Makefile
6
Makefile
@@ -29,8 +29,8 @@ install: $(PROG)
|
||||
|
||||
|
||||
regen:
|
||||
tools/make-jpeg-h.py src/data/blank.jpeg src/data/blank.h BLANK 640 480
|
||||
tools/make-html-h.py src/data/index.html src/data/html_index.h HTML_INDEX_PAGE
|
||||
tools/make-jpeg-h.py src/data/blank.jpeg src/data/blank_jpeg.h BLANK 640 480
|
||||
tools/make-html-h.py src/data/index.html src/data/index_html.h HTML_INDEX_PAGE
|
||||
|
||||
|
||||
$(PROG): $(OBJECTS)
|
||||
@@ -57,7 +57,7 @@ push:
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
|
||||
clean-all: clean
|
||||
clean:
|
||||
rm -f src/*.o src/{jpeg,omx}/*.o vgcore.* $(PROG)
|
||||
rm -rf pkg src/$(PROG)-* src/v*.tar.gz v*.tar.gz $(PROG)-*.pkg.tar.xz
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=\"utf-8\">
|
||||
<meta charset="utf-8" />
|
||||
<title>uStreamer</title>
|
||||
</head>
|
||||
|
||||
@@ -11,35 +11,35 @@
|
||||
<hr>
|
||||
<ul>
|
||||
<li>
|
||||
<a href=\"/ping\"><b>/ping</b></a><br>
|
||||
<a href="/ping"><b><samp>/ping</samp></b></a><br>
|
||||
Get JSON structure with state of the server.
|
||||
</li>
|
||||
<br>
|
||||
<li>
|
||||
<a href=\"/snapshot\"><b>/snapshot</b></a><br>
|
||||
Get a current actual image from server.
|
||||
<a href="/snapshot"><b><samp>/snapshot</samp></b></a><br>
|
||||
Get a current actual image from the server.
|
||||
</li>
|
||||
<br>
|
||||
<li>
|
||||
<a href=\"/stream\"><b>/stream</b></a><br>
|
||||
<a href="/stream"><b><samp>/stream</samp></b></a><br>
|
||||
Get a live stream. Query params:<br>
|
||||
<br>
|
||||
<ul>
|
||||
<li>
|
||||
<i>extra_headers=1</i><br>
|
||||
Add X-UStreamer-* headers to /stream handle (like on <a href=\"/snapshot\">/snapshot</a>).
|
||||
<b><samp>extra_headers=1</samp></b><br>
|
||||
Add <samp>X-UStreamer-*</samp> headers to /stream handle (like on <a href="/snapshot"><samp>/snapshot</samp></a>).
|
||||
</li>
|
||||
<br>
|
||||
<li>
|
||||
<i>advance_headers=1</i><br>
|
||||
<b><samp>advance_headers=1</samp></b><br>
|
||||
Enable workaround for Chromium/Blink
|
||||
<a href=\"https://bugs.chromium.org/p/chromium/issues/detail?id=527446\">Bug #527446</a>.
|
||||
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=527446">Bug #527446</a>.
|
||||
</li>
|
||||
<br>
|
||||
<li>
|
||||
<i>dual_final_frames=1</i><br>
|
||||
Enable workaround for Safari/WebKit bug when using option --drop-same-frames.<br>
|
||||
Without this option, when the frame series is completed, WebKit-based browser<br>
|
||||
<b><samp>dual_final_frames=1</samp></b><br>
|
||||
Enable workaround for Safari/WebKit bug when using option <samp>--drop-same-frames</samp>.<br>
|
||||
Without this option, when the frame series is completed, WebKit-based browsers<br>
|
||||
renders the last one with a delay.
|
||||
</li>
|
||||
</ul>
|
||||
@@ -48,6 +48,6 @@
|
||||
</ul>
|
||||
<br>
|
||||
<hr>
|
||||
<a href=\"https://github.com/pi-kvm/ustreamer\">Sources & docs</a>
|
||||
<a href="https://github.com/pi-kvm/ustreamer">Sources & docs</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -29,7 +29,7 @@ const char *HTML_INDEX_PAGE = " \
|
||||
\
|
||||
<html> \
|
||||
<head> \
|
||||
<meta charset=\"utf-8\"> \
|
||||
<meta charset=\"utf-8\" /> \
|
||||
<title>uStreamer</title> \
|
||||
</head> \
|
||||
\
|
||||
@@ -38,35 +38,35 @@ const char *HTML_INDEX_PAGE = " \
|
||||
<hr> \
|
||||
<ul> \
|
||||
<li> \
|
||||
<a href=\"/ping\"><b>/ping</b></a><br> \
|
||||
<a href=\"/ping\"><b><samp>/ping</samp></b></a><br> \
|
||||
Get JSON structure with state of the server. \
|
||||
</li> \
|
||||
<br> \
|
||||
<li> \
|
||||
<a href=\"/snapshot\"><b>/snapshot</b></a><br> \
|
||||
Get a current actual image from server. \
|
||||
<a href=\"/snapshot\"><b><samp>/snapshot</samp></b></a><br> \
|
||||
Get a current actual image from the server. \
|
||||
</li> \
|
||||
<br> \
|
||||
<li> \
|
||||
<a href=\"/stream\"><b>/stream</b></a><br> \
|
||||
<a href=\"/stream\"><b><samp>/stream</samp></b></a><br> \
|
||||
Get a live stream. Query params:<br> \
|
||||
<br> \
|
||||
<ul> \
|
||||
<li> \
|
||||
<i>extra_headers=1</i><br> \
|
||||
Add X-UStreamer-* headers to /stream handle (like on <a href=\"/snapshot\">/snapshot</a>). \
|
||||
<b><samp>extra_headers=1</samp></b><br> \
|
||||
Add <samp>X-UStreamer-*</samp> headers to /stream handle (like on <a href=\"/snapshot\"><samp>/snapshot</samp></a>). \
|
||||
</li> \
|
||||
<br> \
|
||||
<li> \
|
||||
<i>advance_headers=1</i><br> \
|
||||
<b><samp>advance_headers=1</samp></b><br> \
|
||||
Enable workaround for Chromium/Blink \
|
||||
<a href=\"https://bugs.chromium.org/p/chromium/issues/detail?id=527446\">Bug #527446</a>. \
|
||||
</li> \
|
||||
<br> \
|
||||
<li> \
|
||||
<i>dual_final_frames=1</i><br> \
|
||||
Enable workaround for Safari/WebKit bug when using option --drop-same-frames.<br> \
|
||||
Without this option, when the frame series is completed, WebKit-based browser<br> \
|
||||
<b><samp>dual_final_frames=1</samp></b><br> \
|
||||
Enable workaround for Safari/WebKit bug when using option <samp>--drop-same-frames</samp>.<br> \
|
||||
Without this option, when the frame series is completed, WebKit-based browsers<br> \
|
||||
renders the last one with a delay. \
|
||||
</li> \
|
||||
</ul> \
|
||||
14
src/http.c
14
src/http.c
@@ -43,8 +43,8 @@
|
||||
#include "stream.h"
|
||||
#include "http.h"
|
||||
|
||||
#include "data/html_index.h"
|
||||
#include "data/blank.h"
|
||||
#include "data/index_html.h"
|
||||
#include "data/blank_jpeg.h"
|
||||
|
||||
|
||||
static bool _http_get_param_true(struct evkeyvalq *params, const char *key);
|
||||
@@ -192,7 +192,7 @@ static void _http_callback_ping(struct evhttp_request *request, void *v_server)
|
||||
" \"stream\": {\"queued_fps\": %u, \"clients\": %u, \"clients_stat\": {",
|
||||
(server->fake_width ? server->fake_width : server->run->exposed->width),
|
||||
(server->fake_height ? server->fake_height : server->run->exposed->height),
|
||||
(server->run->exposed->online ? "true" : "false"),
|
||||
bool_to_string(server->run->exposed->online),
|
||||
server->run->stream->encoder->quality,
|
||||
server->run->exposed->captured_fps,
|
||||
server->run->exposed->queued_fps,
|
||||
@@ -203,8 +203,8 @@ static void _http_callback_ping(struct evhttp_request *request, void *v_server)
|
||||
"\"%s\": {\"fps\": %u, \"advance_headers\": %s, \"dual_final_frames\": %s}%s",
|
||||
client->id,
|
||||
client->fps,
|
||||
(client->advance_headers ? "true" : "false"),
|
||||
(client->dual_final_frames ? "true" : "false"),
|
||||
bool_to_string(client->advance_headers),
|
||||
bool_to_string(client->dual_final_frames),
|
||||
(client->next ? ", " : "")
|
||||
));
|
||||
}
|
||||
@@ -237,7 +237,7 @@ static void _http_callback_snapshot(struct evhttp_request *request, void *v_serv
|
||||
|
||||
ADD_TIME_HEADER("X-Timestamp", get_now_real());
|
||||
|
||||
ADD_HEADER("X-UStreamer-Online", (EXPOSED(online) ? "true" : "false"));
|
||||
ADD_HEADER("X-UStreamer-Online", bool_to_string(EXPOSED(online)));
|
||||
ADD_TIME_HEADER("X-UStreamer-Grab-Time", EXPOSED(picture.grab_time));
|
||||
ADD_TIME_HEADER("X-UStreamer-Encode-Begin-Time", EXPOSED(picture.encode_begin_time));
|
||||
ADD_TIME_HEADER("X-UStreamer-Encode-End-Time", EXPOSED(picture.encode_end_time));
|
||||
@@ -406,7 +406,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
||||
"X-UStreamer-Expose-End-Time: %.06Lf" RN
|
||||
"X-UStreamer-Send-Time: %.06Lf" RN
|
||||
RN,
|
||||
(EXPOSED(online) ? "true" : "false"),
|
||||
bool_to_string(EXPOSED(online)),
|
||||
client->fps,
|
||||
EXPOSED(picture.grab_time),
|
||||
EXPOSED(picture.encode_begin_time),
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
@@ -57,6 +58,10 @@
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
|
||||
INLINE char *bool_to_string(const bool flag) {
|
||||
return (flag ? "true" : "false");
|
||||
}
|
||||
|
||||
INLINE unsigned max_u(unsigned a, unsigned b) {
|
||||
return (a > b ? a : b);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ def main():
|
||||
text = html_file.read()
|
||||
|
||||
text = text.strip()
|
||||
text = text.replace("\"", "\\\"")
|
||||
text = text.replace("%VERSION%", "\" VERSION \"")
|
||||
text = textwrap.indent(text, "\t", (lambda line: True))
|
||||
text = "\n".join(("%s \\" if line.strip() else "%s\\") % (line) for line in text.split("\n"))
|
||||
|
||||
Reference in New Issue
Block a user