Improve HTTP support (to better handle params) and redirect /video params

This commit is contained in:
Kamil Trzcinski
2022-09-07 11:15:09 +02:00
parent 5801152b03
commit f08421a796
6 changed files with 68 additions and 37 deletions

View File

@ -18,7 +18,7 @@ static const char *const VIDEO_HEADER =
buffer_lock_t *http_h264_buffer_for_res(http_worker_t *worker)
{
if (strstr(worker->client_method, HTTP_LOW_RES_PARAM) && http_jpeg_lowres.buf_list)
if (strstr(worker->request_params, HTTP_LOW_RES_PARAM) && http_h264_lowres.buf_list)
return &http_h264_lowres;
else
return &http_h264;

View File

@ -22,7 +22,7 @@ static const char *const LOCATION_REDIRECT =
"HTTP/1.0 307 Temporary Redirect\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Connection: close\r\n"
"Location: %s\r\n"
"Location: %s?%s\r\n"
"\r\n";
void http_m3u8_video(struct http_worker_s *worker, FILE *stream)
@ -35,12 +35,12 @@ void http_detect_video(struct http_worker_s *worker, FILE *stream)
{
if (strstr(worker->user_agent, "Safari/") && !strstr(worker->user_agent, "Chrome/") && !strstr(worker->user_agent, "Chromium/")) {
// Safari only supports m3u8
fprintf(stream, LOCATION_REDIRECT, "video.m3u8");
fprintf(stream, LOCATION_REDIRECT, "video.m3u8", worker->request_params);
} else if (strstr(worker->user_agent, "Firefox/")) {
// Firefox only supports mp4
fprintf(stream, LOCATION_REDIRECT, "video.mp4");
fprintf(stream, LOCATION_REDIRECT, "video.mp4", worker->request_params);
} else {
// Chrome offers best latency with mkv
fprintf(stream, LOCATION_REDIRECT, "video.mkv");
fprintf(stream, LOCATION_REDIRECT, "video.mkv", worker->request_params);
}
}

View File

@ -22,7 +22,7 @@ static const char *const STREAM_BOUNDARY = "\r\n"
buffer_lock_t *http_jpeg_buffer_for_res(http_worker_t *worker)
{
if (strstr(worker->client_method, HTTP_LOW_RES_PARAM) && http_jpeg_lowres.buf_list)
if (strstr(worker->request_params, HTTP_LOW_RES_PARAM) && http_jpeg_lowres.buf_list)
return &http_jpeg_lowres;
else
return &http_jpeg;