Add WebRTC support using libdatachannel

The WebRTC is exposed via `/video.html` endpoint
and enabled by default as long as h264 stream
is available.
This commit is contained in:
Kamil Trzcinski
2022-08-31 19:04:54 +02:00
parent ff81088824
commit 5ee0bee59f
19 changed files with 644 additions and 87 deletions

View File

@ -14,6 +14,9 @@
#include "http.h"
#include "util/opts/log.h"
#define HEADER_RANGE "Range:"
#define HEADER_CONTENT_LENGTH "Content-Length:"
static int http_listen(int port, int maxcons)
{
struct sockaddr_in server = {0};
@ -92,6 +95,7 @@ static void http_process(http_worker_t *worker, FILE *stream)
}
worker->range_header[0] = 0;
worker->content_length = -1;
// Consume headers
for(int i = 0; i < 50; i++) {
@ -101,9 +105,12 @@ static void http_process(http_worker_t *worker, FILE *stream)
if (line[0] == '\r' && line[1] == '\n')
break;
if (strcasestr(line, "Range:") == line) {
if (strcasestr(line, HEADER_RANGE) == line) {
strcpy(worker->range_header, line);
}
if (strcasestr(line, HEADER_CONTENT_LENGTH) == line) {
worker->content_length = atoi(line + strlen(HEADER_CONTENT_LENGTH));
}
}
worker->current_method = NULL;