Fix Stream not starting on first app
This commit is contained in:
+4
-1
@@ -516,6 +516,9 @@ void launch(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> respons
|
|||||||
current_appid = appid;
|
current_appid = appid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Needed to determine if session must be closed when no process is running in proc::proc
|
||||||
|
launch_session.has_process = current_appid >= 0;
|
||||||
|
|
||||||
auto clientID = args.at("uniqueid"s);
|
auto clientID = args.at("uniqueid"s);
|
||||||
launch_session.gcm_key = *util::from_hex<crypto::aes_t>(args.at("rikey"s), true);
|
launch_session.gcm_key = *util::from_hex<crypto::aes_t>(args.at("rikey"s), true);
|
||||||
uint32_t prepend_iv = util::endian::big<uint32_t>(util::from_view(args.at("rikeyid"s)));
|
uint32_t prepend_iv = util::endian::big<uint32_t>(util::from_view(args.at("rikeyid"s)));
|
||||||
@@ -534,6 +537,7 @@ void launch(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> respons
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
g.disable();
|
||||||
tree.put("root.<xmlattr>.status_code", 200);
|
tree.put("root.<xmlattr>.status_code", 200);
|
||||||
tree.put("root.gamesession", 1);
|
tree.put("root.gamesession", 1);
|
||||||
|
|
||||||
@@ -541,7 +545,6 @@ void launch(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> respons
|
|||||||
|
|
||||||
pt::write_xml(data, tree);
|
pt::write_xml(data, tree);
|
||||||
response->write(data.str());
|
response->write(data.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
+8
-4
@@ -115,6 +115,8 @@ struct session_t {
|
|||||||
|
|
||||||
crypto::aes_t gcm_key;
|
crypto::aes_t gcm_key;
|
||||||
crypto::aes_t iv;
|
crypto::aes_t iv;
|
||||||
|
|
||||||
|
bool has_process;
|
||||||
} session;
|
} session;
|
||||||
std::atomic_bool has_session;
|
std::atomic_bool has_session;
|
||||||
|
|
||||||
@@ -547,7 +549,7 @@ void controlThread(video::idr_event_t idr_events) {
|
|||||||
stop(session);
|
stop(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!proc::proc.running()) {
|
if(session.has_process && !proc::proc.running()) {
|
||||||
std::cout << "Process terminated"sv << std::endl;
|
std::cout << "Process terminated"sv << std::endl;
|
||||||
|
|
||||||
std::uint16_t reason = 0x0100;
|
std::uint16_t reason = 0x0100;
|
||||||
@@ -898,7 +900,7 @@ void cmd_announce(host_t &host, peer_t peer, msg_t &&req) {
|
|||||||
respond(host, peer, &option, 503, "Service Unavailable", req->sequenceNumber, {});
|
respond(host, peer, &option, 503, "Service Unavailable", req->sequenceNumber, {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto launch_session { *launch_event.pop() };
|
auto launch_session { launch_event.pop() };
|
||||||
|
|
||||||
std::string_view payload { req->payload, (size_t)req->payloadLength };
|
std::string_view payload { req->payload, (size_t)req->payloadLength };
|
||||||
|
|
||||||
@@ -965,12 +967,14 @@ void cmd_announce(host_t &host, peer_t peer, msg_t &&req) {
|
|||||||
|
|
||||||
has_session.store(true);
|
has_session.store(true);
|
||||||
|
|
||||||
auto &gcm_key = launch_session.gcm_key;
|
auto &gcm_key = launch_session->gcm_key;
|
||||||
auto &iv = launch_session.iv;
|
auto &iv = launch_session->iv;
|
||||||
|
|
||||||
std::copy(std::begin(gcm_key), std::end(gcm_key), std::begin(session.gcm_key));
|
std::copy(std::begin(gcm_key), std::end(gcm_key), std::begin(session.gcm_key));
|
||||||
std::copy(std::begin(iv), std::end(iv), std::begin(session.iv));
|
std::copy(std::begin(iv), std::end(iv), std::begin(session.iv));
|
||||||
|
|
||||||
|
session.has_process = launch_session->has_process;
|
||||||
|
|
||||||
session.pingTimeout = std::chrono::steady_clock::now() + config::stream.ping_timeout;
|
session.pingTimeout = std::chrono::steady_clock::now() + config::stream.ping_timeout;
|
||||||
|
|
||||||
session.video_packets = std::make_shared<video::packet_queue_t::element_type>();
|
session.video_packets = std::make_shared<video::packet_queue_t::element_type>();
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace stream {
|
|||||||
struct launch_session_t {
|
struct launch_session_t {
|
||||||
crypto::aes_t gcm_key;
|
crypto::aes_t gcm_key;
|
||||||
crypto::aes_t iv;
|
crypto::aes_t iv;
|
||||||
|
|
||||||
|
bool has_process;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern safe::event_t<launch_session_t> launch_event;
|
extern safe::event_t<launch_session_t> launch_event;
|
||||||
|
|||||||
Reference in New Issue
Block a user