Pair and connect with Moonlight-iOS

This commit is contained in:
loki 2020-04-17 18:42:55 +02:00
parent c7d6e959e0
commit 5a4055f313
3 changed files with 23 additions and 5 deletions

View File

@ -168,7 +168,15 @@ void update_id_client(const std::string &uniqueID, std::string &&cert, op_e op)
}
void getservercert(pair_session_t &sess, pt::ptree &tree, const std::string &pin) {
auto salt = util::from_hex<std::array<uint8_t, 16>>(sess.async_insert_pin.salt, true);
if(sess.async_insert_pin.salt.size() < 32) {
tree.put("root.paired", 0);
tree.put("root.<xmlattr>.status_code", 400);
return;
}
std::string_view salt_view { sess.async_insert_pin.salt.data(), 32 };
auto salt = util::from_hex<std::array<uint8_t, 16>>(salt_view, true);
auto key = crypto::gen_aes_key(*salt, pin);
sess.cipher_key = std::make_unique<crypto::aes_t>(key);
@ -484,7 +492,7 @@ void serverinfo(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> res
auto current_appid = proc::proc.running();
tree.put("root.PairStatus", pair_status);
tree.put("root.currentgame", current_appid >= 0 ? current_appid + 1 : 0);
tree.put("root.state", "_SERVER_BUSY");
tree.put("root.state", current_appid >= 0 ? "_SERVER_BUSY" : "_SERVER_FREE");
std::ostringstream data;

View File

@ -451,7 +451,7 @@ public:
other._own_ptr = false;
}
wrap_ptr &operator=(wrap_ptr &&other) {
wrap_ptr &operator=(wrap_ptr &&other) noexcept {
if(_own_ptr) {
delete _p;
}
@ -484,6 +484,14 @@ public:
return *this;
}
~wrap_ptr() {
if(_own_ptr) {
delete _p;
}
_own_ptr = false;
}
const reference operator*() const {
return *_p;
}

View File

@ -545,7 +545,7 @@ std::optional<session_t> make_session(const encoder_t &encoder, const config_t &
ctx->keyint_min = ctx->gop_size;
if(config.numRefFrames == 0) {
ctx->refs = video_format[encoder_t::REF_FRAMES_AUTOSELECT] ? 0 : 1;
ctx->refs = video_format[encoder_t::REF_FRAMES_AUTOSELECT] ? 0 : 16;
}
else {
// Some client decoders have limits on the number of reference frames
@ -987,6 +987,7 @@ void capture_async(
int frame_nr = 1;
int key_frame_nr = 1;
while(!shutdown_event->peek() && images->running()) {
// Wait for the display to be ready
std::shared_ptr<platf::display_t> display;
@ -1028,7 +1029,8 @@ void capture(
idr_event_t idr_events,
config_t config,
void *channel_data) {
idr_events->raise(std::make_pair(0, 1));
if(encoders.front().system_memory) {
capture_async(shutdown_event, packets, idr_events, config, channel_data);
}