webrtc: accept iceServers: [] provided in POST /webrtc, support trickle ICE

Thanks https://github.com/ayufan/camera-streamer/pull/65
This commit is contained in:
Kamil Trzcinski
2023-06-13 20:34:45 +02:00
parent e8ffe47343
commit 272b16ee1c
7 changed files with 239 additions and 104 deletions

27
util/http/json.hh Normal file
View File

@ -0,0 +1,27 @@
#pragma once
extern "C" {
#include "http.h"
}
#include <stdio.h>
#include <nlohmann/json.hpp>
inline nlohmann::json http_parse_json_body(http_worker_t *worker, FILE *stream, unsigned max_body_size)
{
std::string text;
size_t i = 0;
size_t n = (size_t)worker->content_length;
if (n < 0 || n > max_body_size)
n = max_body_size;
text.resize(n);
while (i < n && !feof(stream)) {
i += fread(&text[i], 1, n-i, stream);
}
text.resize(i);
return nlohmann::json::parse(text);
}