Add -snapshot.height
, -stream.height
and -video.height
This commit is contained in:

committed by
Kamil Trzcinski

parent
c18561c9f8
commit
ca08adb62f
@ -76,7 +76,7 @@ class Client
|
||||
{
|
||||
public:
|
||||
Client(std::shared_ptr<rtc::PeerConnection> pc_)
|
||||
: pc(pc_), use_low_res(false)
|
||||
: pc(pc_)
|
||||
{
|
||||
id.resize(20);
|
||||
for (auto & c : id) {
|
||||
@ -91,18 +91,16 @@ public:
|
||||
free(name);
|
||||
}
|
||||
|
||||
bool wantsFrame(bool low_res) const
|
||||
bool wantsFrame() const
|
||||
{
|
||||
if (!pc || !video)
|
||||
return false;
|
||||
if (pc->state() != rtc::PeerConnection::State::Connected)
|
||||
return false;
|
||||
if (use_low_res != low_res)
|
||||
return false;
|
||||
return video->wantsFrame();
|
||||
}
|
||||
|
||||
void pushFrame(buffer_t *buf, bool low_res)
|
||||
void pushFrame(buffer_t *buf)
|
||||
{
|
||||
auto self = this;
|
||||
|
||||
@ -110,10 +108,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_low_res != low_res) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!had_key_frame) {
|
||||
if (!buf->flags.is_keyframe) {
|
||||
device_video_force_key(buf->buf_list->dev);
|
||||
@ -136,7 +130,6 @@ public:
|
||||
std::mutex lock;
|
||||
std::condition_variable wait_for_complete;
|
||||
bool had_key_frame;
|
||||
bool use_low_res;
|
||||
};
|
||||
|
||||
std::shared_ptr<Client> findClient(std::string id)
|
||||
@ -232,9 +225,7 @@ static bool webrtc_h264_needs_buffer(buffer_lock_t *buf_lock)
|
||||
{
|
||||
std::unique_lock lk(webrtc_clients_lock);
|
||||
for (auto client : webrtc_clients) {
|
||||
if (client->wantsFrame(false))
|
||||
return true;
|
||||
if (!http_h264_lowres.buf_list && client->wantsFrame(true))
|
||||
if (client->wantsFrame())
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -245,31 +236,8 @@ static void webrtc_h264_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
||||
{
|
||||
std::unique_lock lk(webrtc_clients_lock);
|
||||
for (auto client : webrtc_clients) {
|
||||
if (client->wantsFrame(false))
|
||||
client->pushFrame(buf, false);
|
||||
if (!http_h264_lowres.buf_list && client->wantsFrame(true))
|
||||
client->pushFrame(buf, true);
|
||||
}
|
||||
}
|
||||
|
||||
static bool webrtc_h264_low_res_needs_buffer(buffer_lock_t *buf_lock)
|
||||
{
|
||||
std::unique_lock lk(webrtc_clients_lock);
|
||||
for (auto client : webrtc_clients) {
|
||||
if (client->wantsFrame(true))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void webrtc_h264_low_res_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
||||
{
|
||||
std::unique_lock lk(webrtc_clients_lock);
|
||||
for (auto client : webrtc_clients) {
|
||||
if (client->wantsFrame(true)) {
|
||||
client->pushFrame(buf, true);
|
||||
}
|
||||
if (client->wantsFrame())
|
||||
client->pushFrame(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,9 +247,6 @@ static void http_webrtc_request(http_worker_t *worker, FILE *stream, const nlohm
|
||||
LOG_INFO(client.get(), "Stream requested.");
|
||||
|
||||
client->video = addVideo(client->pc, webrtc_client_video_payload_type, rand(), "video", "");
|
||||
if (message.contains("res")) {
|
||||
client->use_low_res = (message["res"] == "low");
|
||||
}
|
||||
|
||||
try {
|
||||
{
|
||||
@ -418,10 +383,8 @@ extern "C" void http_webrtc_offer(http_worker_t *worker, FILE *stream)
|
||||
|
||||
extern "C" void webrtc_server()
|
||||
{
|
||||
buffer_lock_register_check_streaming(&http_h264, webrtc_h264_needs_buffer);
|
||||
buffer_lock_register_notify_buffer(&http_h264, webrtc_h264_capture);
|
||||
buffer_lock_register_check_streaming(&http_h264_lowres, webrtc_h264_low_res_needs_buffer);
|
||||
buffer_lock_register_notify_buffer(&http_h264_lowres, webrtc_h264_low_res_capture);
|
||||
buffer_lock_register_check_streaming(&video_lock, webrtc_h264_needs_buffer);
|
||||
buffer_lock_register_notify_buffer(&video_lock, webrtc_h264_capture);
|
||||
}
|
||||
|
||||
#else // USE_LIBDATACHANNEL
|
||||
|
Reference in New Issue
Block a user