mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-13 11:03:43 +00:00
http: zero_data option and X-UStreamer-Latency header
This commit is contained in:
@@ -50,6 +50,11 @@
|
|||||||
Without this option, when the frame series is completed, WebKit-based browsers<br>
|
Without this option, when the frame series is completed, WebKit-based browsers<br>
|
||||||
renders the last frame with a delay.
|
renders the last frame with a delay.
|
||||||
</li>
|
</li>
|
||||||
|
<br>
|
||||||
|
<li>
|
||||||
|
<b>zero_data=1</b><br>
|
||||||
|
Disables the actual sending of JPEG data and leaves only response headers.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ const char *const HTML_INDEX_PAGE = " \
|
|||||||
Without this option, when the frame series is completed, WebKit-based browsers<br> \
|
Without this option, when the frame series is completed, WebKit-based browsers<br> \
|
||||||
renders the last frame with a delay. \
|
renders the last frame with a delay. \
|
||||||
</li> \
|
</li> \
|
||||||
|
<br> \
|
||||||
|
<li> \
|
||||||
|
<b>zero_data=1</b><br> \
|
||||||
|
Disables the actual sending of JPEG data and leaves only response headers. \
|
||||||
|
</li> \
|
||||||
</ul> \
|
</ul> \
|
||||||
</li> \
|
</li> \
|
||||||
<br> \
|
<br> \
|
||||||
|
|||||||
@@ -368,12 +368,14 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
|
|||||||
|
|
||||||
for (stream_client_s * client = RUN(stream_clients); client != NULL; client = client->next) {
|
for (stream_client_s * client = RUN(stream_clients); client != NULL; client = client->next) {
|
||||||
assert(evbuffer_add_printf(buf,
|
assert(evbuffer_add_printf(buf,
|
||||||
"\"%s\": {\"fps\": %u, \"extra_headers\": %s, \"advance_headers\": %s, \"dual_final_frames\": %s}%s",
|
"\"%s\": {\"fps\": %u, \"extra_headers\": %s, \"advance_headers\": %s,"
|
||||||
|
" \"dual_final_frames\": %s, \"zero_data\": %s}%s",
|
||||||
client->id,
|
client->id,
|
||||||
client->fps,
|
client->fps,
|
||||||
bool_to_string(client->extra_headers),
|
bool_to_string(client->extra_headers),
|
||||||
bool_to_string(client->advance_headers),
|
bool_to_string(client->advance_headers),
|
||||||
bool_to_string(client->dual_final_frames),
|
bool_to_string(client->dual_final_frames),
|
||||||
|
bool_to_string(client->zero_data),
|
||||||
(client->next ? ", " : "")
|
(client->next ? ", " : "")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -462,10 +464,13 @@ static void _http_callback_stream(struct evhttp_request *request, void *v_server
|
|||||||
|
|
||||||
struct evkeyvalq params;
|
struct evkeyvalq params;
|
||||||
evhttp_parse_query(evhttp_request_get_uri(request), ¶ms);
|
evhttp_parse_query(evhttp_request_get_uri(request), ¶ms);
|
||||||
client->key = uri_get_string(¶ms, "key");
|
# define PARSE_PARAM(_type, _name) client->_name = uri_get_##_type(¶ms, #_name)
|
||||||
client->extra_headers = uri_get_true(¶ms, "extra_headers");
|
PARSE_PARAM(string, key);
|
||||||
client->advance_headers = uri_get_true(¶ms, "advance_headers");
|
PARSE_PARAM(true, extra_headers);
|
||||||
client->dual_final_frames = uri_get_true(¶ms, "dual_final_frames");
|
PARSE_PARAM(true, advance_headers);
|
||||||
|
PARSE_PARAM(true, dual_final_frames);
|
||||||
|
PARSE_PARAM(true, zero_data);
|
||||||
|
# undef PARSE_PARAM
|
||||||
evhttp_clear_headers(¶ms);
|
evhttp_clear_headers(¶ms);
|
||||||
|
|
||||||
uuid_t uuid;
|
uuid_t uuid;
|
||||||
@@ -592,7 +597,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
"Content-Length: %zu" RN
|
"Content-Length: %zu" RN
|
||||||
"X-Timestamp: %.06Lf" RN
|
"X-Timestamp: %.06Lf" RN
|
||||||
"%s",
|
"%s",
|
||||||
EX(frame->used),
|
(!client->zero_data ? EX(frame->used) : 0),
|
||||||
get_now_real(),
|
get_now_real(),
|
||||||
(client->extra_headers ? "" : RN)
|
(client->extra_headers ? "" : RN)
|
||||||
));
|
));
|
||||||
@@ -610,6 +615,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
"X-UStreamer-Expose-Cmp-Time: %.06Lf" RN
|
"X-UStreamer-Expose-Cmp-Time: %.06Lf" RN
|
||||||
"X-UStreamer-Expose-End-Time: %.06Lf" RN
|
"X-UStreamer-Expose-End-Time: %.06Lf" RN
|
||||||
"X-UStreamer-Send-Time: %.06Lf" RN
|
"X-UStreamer-Send-Time: %.06Lf" RN
|
||||||
|
"X-UStreamer-Latency: %.06Lf" RN
|
||||||
RN,
|
RN,
|
||||||
bool_to_string(EX(frame->online)),
|
bool_to_string(EX(frame->online)),
|
||||||
EX(dropped),
|
EX(dropped),
|
||||||
@@ -622,12 +628,15 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
EX(expose_begin_ts),
|
EX(expose_begin_ts),
|
||||||
EX(expose_cmp_ts),
|
EX(expose_cmp_ts),
|
||||||
EX(expose_end_ts),
|
EX(expose_end_ts),
|
||||||
now
|
now,
|
||||||
|
now - EX(frame->grab_ts)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!evbuffer_add(buf, (void *)EX(frame->data), EX(frame->used)));
|
if (!client->zero_data) {
|
||||||
|
assert(!evbuffer_add(buf, (void *)EX(frame->data), EX(frame->used)));
|
||||||
|
}
|
||||||
assert(evbuffer_add_printf(buf, RN "--" BOUNDARY RN));
|
assert(evbuffer_add_printf(buf, RN "--" BOUNDARY RN));
|
||||||
|
|
||||||
if (client->advance_headers) {
|
if (client->advance_headers) {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ typedef struct stream_client_sx {
|
|||||||
bool extra_headers;
|
bool extra_headers;
|
||||||
bool advance_headers;
|
bool advance_headers;
|
||||||
bool dual_final_frames;
|
bool dual_final_frames;
|
||||||
|
bool zero_data;
|
||||||
|
|
||||||
char id[37]; // ex. "1b4e28ba-2fa1-11d2-883f-0016d3cca427" + "\0"
|
char id[37]; // ex. "1b4e28ba-2fa1-11d2-883f-0016d3cca427" + "\0"
|
||||||
bool need_initial;
|
bool need_initial;
|
||||||
|
|||||||
Reference in New Issue
Block a user