Prevent clients from starting an HEVC stream if HEVC is disabled

This commit is contained in:
loki 2020-01-21 20:11:35 +01:00
parent 96698153af
commit 0bfa93814b

View File

@ -880,8 +880,15 @@ void cmd_describe(host_t &host, peer_t peer, msg_t&& req) {
auto seqn_str = std::to_string(req->sequenceNumber);
option.content = const_cast<char*>(seqn_str.c_str());
// FIXME: Moonlight will accept the payload, but the value of the option is not correct
respond(host, peer, &option, 200, "OK", req->sequenceNumber, "sprop-parameter-sets=AAAAAU;surround-params=NONE"sv);
std::string_view payload;
if(config::video.hevc_mode == 0) {
payload = "surround-params=NONE"sv;
}
else {
payload = "sprop-parameter-sets=AAAAAU;surround-params=NONE"sv;
}
respond(host, peer, &option, 200, "OK", req->sequenceNumber, payload);
}
void cmd_setup(host_t &host, peer_t peer, msg_t &&req) {
@ -1019,6 +1026,14 @@ void cmd_announce(host_t &host, peer_t peer, msg_t &&req) {
return;
}
if(session.config.monitor.videoFormat != 0 && config::video.hevc_mode == 0) {
BOOST_LOG(error) << "HEVC is disabled, yet the client requested HEVC"sv;
respond(host, peer, &option, 400, "BAD REQUEST", req->sequenceNumber, {});
return;
}
auto &gcm_key = launch_session->gcm_key;
auto &iv = launch_session->iv;