Add support for periodic ping
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
namespace nvhttp {
|
namespace nvhttp {
|
||||||
|
|
||||||
constexpr auto VERSION = "7.1.404.0";
|
constexpr auto VERSION = "7.1.415.0";
|
||||||
constexpr auto GFE_VERSION = "3.12.0.1";
|
constexpr auto GFE_VERSION = "3.12.0.1";
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <moonlight-common-c/src/Video.h>
|
|
||||||
#include <moonlight-common-c/src/RtpAudioQueue.h>
|
#include <moonlight-common-c/src/RtpAudioQueue.h>
|
||||||
|
#include <moonlight-common-c/src/Video.h>
|
||||||
#include <rs.h>
|
#include <rs.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ extern "C" {
|
|||||||
#define IDX_INPUT_DATA 5
|
#define IDX_INPUT_DATA 5
|
||||||
#define IDX_RUMBLE_DATA 6
|
#define IDX_RUMBLE_DATA 6
|
||||||
#define IDX_TERMINATION 7
|
#define IDX_TERMINATION 7
|
||||||
|
#define IDX_PERIODIC_PING 8
|
||||||
|
|
||||||
static const short packetTypes[] = {
|
static const short packetTypes[] = {
|
||||||
0x0305, // Start A
|
0x0305, // Start A
|
||||||
@@ -43,6 +44,7 @@ static const short packetTypes[] = {
|
|||||||
0x0206, // Input data
|
0x0206, // Input data
|
||||||
0x010b, // Rumble data
|
0x010b, // Rumble data
|
||||||
0x0100, // Termination
|
0x0100, // Termination
|
||||||
|
0x0200, // Periodic Ping
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace asio = boost::asio;
|
namespace asio = boost::asio;
|
||||||
@@ -418,6 +420,8 @@ std::vector<uint8_t> replace(const std::string_view &original, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
void controlBroadcastThread(control_server_t *server) {
|
void controlBroadcastThread(control_server_t *server) {
|
||||||
|
server->map(packetTypes[IDX_PERIODIC_PING], [](session_t *session, const std::string_view &payload) {});
|
||||||
|
|
||||||
server->map(packetTypes[IDX_START_A], [&](session_t *session, const std::string_view &payload) {
|
server->map(packetTypes[IDX_START_A], [&](session_t *session, const std::string_view &payload) {
|
||||||
BOOST_LOG(debug) << "type [IDX_START_A]"sv;
|
BOOST_LOG(debug) << "type [IDX_START_A]"sv;
|
||||||
});
|
});
|
||||||
@@ -778,13 +782,13 @@ void audioBroadcastThread(udp::socket &sock) {
|
|||||||
BOOST_LOG(verbose) << "Audio ["sv << sequenceNumber << "] :: send..."sv;
|
BOOST_LOG(verbose) << "Audio ["sv << sequenceNumber << "] :: send..."sv;
|
||||||
|
|
||||||
// initialize the FEC header at the beginning of the FEC block
|
// initialize the FEC header at the beginning of the FEC block
|
||||||
if (sequenceNumber % RTPA_DATA_SHARDS == 0) {
|
if(sequenceNumber % RTPA_DATA_SHARDS == 0) {
|
||||||
audio_fec_packet->fecHeader.baseSequenceNumber = util::endian::big(sequenceNumber);
|
audio_fec_packet->fecHeader.baseSequenceNumber = util::endian::big(sequenceNumber);
|
||||||
audio_fec_packet->fecHeader.baseTimestamp = util::endian::big(timestamp);
|
audio_fec_packet->fecHeader.baseTimestamp = util::endian::big(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate parity shards at the end of the FEC block
|
// generate parity shards at the end of the FEC block
|
||||||
if ((sequenceNumber + 1) % RTPA_DATA_SHARDS == 0) {
|
if((sequenceNumber + 1) % RTPA_DATA_SHARDS == 0) {
|
||||||
reed_solomon_encode(rs.get(), shards_p.begin(), RTPA_TOTAL_SHARDS, packet_data.size());
|
reed_solomon_encode(rs.get(), shards_p.begin(), RTPA_TOTAL_SHARDS, packet_data.size());
|
||||||
|
|
||||||
for(auto x = 0; x < RTPA_FEC_SHARDS; ++x) {
|
for(auto x = 0; x < RTPA_FEC_SHARDS; ++x) {
|
||||||
@@ -792,7 +796,7 @@ void audioBroadcastThread(udp::socket &sock) {
|
|||||||
audio_fec_packet->fecHeader.fecShardIndex = x;
|
audio_fec_packet->fecHeader.fecShardIndex = x;
|
||||||
memcpy(audio_fec_packet->payload(), shards_p[RTPA_DATA_SHARDS + x], packet_data.size());
|
memcpy(audio_fec_packet->payload(), shards_p[RTPA_DATA_SHARDS + x], packet_data.size());
|
||||||
sock.send_to(asio::buffer((char *)audio_fec_packet.get(), sizeof(audio_fec_packet_raw_t) + packet_data.size()), session->audio.peer);
|
sock.send_to(asio::buffer((char *)audio_fec_packet.get(), sizeof(audio_fec_packet_raw_t) + packet_data.size()), session->audio.peer);
|
||||||
BOOST_LOG(verbose) << "Audio FEC ["sv << (sequenceNumber & ~(RTPA_DATA_SHARDS - 1)) << ' ' << x <<"] :: send..."sv;
|
BOOST_LOG(verbose) << "Audio FEC ["sv << (sequenceNumber & ~(RTPA_DATA_SHARDS - 1)) << ' ' << x << "] :: send..."sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user