mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-12-03 02:24:22 +00:00
refactor: make immutable globals const and remove unused frame
This commit is contained in:
5 files changed
+71
-13
No files matched your search
+2
-2
@@ -73,9 +73,9 @@ void on_signal(int sig, FN &&fn) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cmd to func.
|
||||
* @brief Immutable dispatch table for supported command-line subcommands.
|
||||
*/
|
||||
std::map<std::string_view, std::function<int(const char *name, int argc, char **argv)>> cmd_to_func {
|
||||
const std::map<std::string_view, std::function<int(const char *name, int argc, char **argv)>> cmd_to_func {
|
||||
{"creds"sv, [](const char *name, int argc, char **argv) {
|
||||
return args::creds(name, argc, argv);
|
||||
}},
|
||||
|
||||
+8
-8
@@ -18,15 +18,15 @@ namespace ip = boost::asio::ip;
|
||||
|
||||
namespace net {
|
||||
/**
|
||||
* @brief Pc ips v4.
|
||||
* @brief Immutable IPv4 loopback ranges classified as local to this PC.
|
||||
*/
|
||||
std::vector<ip::network_v4> pc_ips_v4 {
|
||||
const std::vector<ip::network_v4> pc_ips_v4 {
|
||||
ip::make_network_v4("127.0.0.0/8"sv),
|
||||
};
|
||||
/**
|
||||
* @brief Lan ips v4.
|
||||
* @brief Immutable IPv4 private, shared, and link-local ranges classified as LAN.
|
||||
*/
|
||||
std::vector<ip::network_v4> lan_ips_v4 {
|
||||
const std::vector<ip::network_v4> lan_ips_v4 {
|
||||
ip::make_network_v4("192.168.0.0/16"sv),
|
||||
ip::make_network_v4("172.16.0.0/12"sv),
|
||||
ip::make_network_v4("10.0.0.0/8"sv),
|
||||
@@ -35,15 +35,15 @@ namespace net {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Pc ips v6.
|
||||
* @brief Immutable IPv6 loopback ranges classified as local to this PC.
|
||||
*/
|
||||
std::vector<ip::network_v6> pc_ips_v6 {
|
||||
const std::vector<ip::network_v6> pc_ips_v6 {
|
||||
ip::make_network_v6("::1/128"sv),
|
||||
};
|
||||
/**
|
||||
* @brief Lan ips v6.
|
||||
* @brief Immutable IPv6 unique-local and link-local ranges classified as LAN.
|
||||
*/
|
||||
std::vector<ip::network_v6> lan_ips_v6 {
|
||||
const std::vector<ip::network_v6> lan_ips_v6 {
|
||||
ip::make_network_v6("fc00::/7"sv),
|
||||
ip::make_network_v6("fe80::/64"sv),
|
||||
};
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace platf {
|
||||
CVPixelBufferRelease((CVPixelBufferRef) data);
|
||||
}
|
||||
|
||||
util::safe_ptr<AVFrame, free_frame> av_frame; ///< AV frame.
|
||||
|
||||
int nv12_zero_device::convert(platf::img_t &img) {
|
||||
auto *av_img = (av_img_t *) &img;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace platf {
|
||||
int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) override;
|
||||
|
||||
private:
|
||||
util::safe_ptr<AVFrame, free_frame> av_frame;
|
||||
util::safe_ptr<AVFrame, free_frame> av_frame; ///< Frame retained by this device for zero-copy encoding.
|
||||
};
|
||||
|
||||
} // namespace platf
|
||||
@@ -9,6 +9,66 @@
|
||||
// local includes
|
||||
#include <src/network.h>
|
||||
|
||||
/**
|
||||
* @brief Address classifications supplied by the immutable IPv4 and IPv6 range tables.
|
||||
*/
|
||||
struct NetworkAddressTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, net::net_e>> {};
|
||||
|
||||
/**
|
||||
* @brief Preserve loopback, LAN, and WAN classification across each configured range.
|
||||
*/
|
||||
TEST_P(NetworkAddressTest, ClassifiesAddress) {
|
||||
const auto &[address, expected] = GetParam();
|
||||
EXPECT_EQ(net::from_address(address), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cover the first and last usable addresses and adjacent addresses for each range.
|
||||
*/
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
NetworkAddressTests,
|
||||
NetworkAddressTest,
|
||||
testing::Values(
|
||||
std::make_tuple("127.0.0.1", net::PC),
|
||||
std::make_tuple("127.255.255.254", net::PC),
|
||||
std::make_tuple("126.255.255.254", net::WAN),
|
||||
std::make_tuple("128.0.0.1", net::WAN),
|
||||
std::make_tuple("192.168.0.1", net::LAN),
|
||||
std::make_tuple("192.168.255.254", net::LAN),
|
||||
std::make_tuple("192.167.255.254", net::WAN),
|
||||
std::make_tuple("192.169.0.1", net::WAN),
|
||||
std::make_tuple("172.16.0.1", net::LAN),
|
||||
std::make_tuple("172.31.255.254", net::LAN),
|
||||
std::make_tuple("172.15.255.254", net::WAN),
|
||||
std::make_tuple("172.32.0.1", net::WAN),
|
||||
std::make_tuple("10.0.0.1", net::LAN),
|
||||
std::make_tuple("10.255.255.254", net::LAN),
|
||||
std::make_tuple("9.255.255.254", net::WAN),
|
||||
std::make_tuple("11.0.0.1", net::WAN),
|
||||
std::make_tuple("100.64.0.1", net::LAN),
|
||||
std::make_tuple("100.127.255.254", net::LAN),
|
||||
std::make_tuple("100.63.255.254", net::WAN),
|
||||
std::make_tuple("100.128.0.1", net::WAN),
|
||||
std::make_tuple("169.254.0.1", net::LAN),
|
||||
std::make_tuple("169.254.255.254", net::LAN),
|
||||
std::make_tuple("169.253.255.254", net::WAN),
|
||||
std::make_tuple("169.255.0.1", net::WAN),
|
||||
std::make_tuple("::1", net::PC),
|
||||
std::make_tuple("::2", net::WAN),
|
||||
std::make_tuple("fc00::1", net::LAN),
|
||||
std::make_tuple("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", net::LAN),
|
||||
std::make_tuple("fbff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", net::WAN),
|
||||
std::make_tuple("fe00::1", net::WAN),
|
||||
std::make_tuple("fe80::1", net::LAN),
|
||||
std::make_tuple("fe80::ffff:ffff:ffff:ffff", net::LAN),
|
||||
std::make_tuple("fe7f:ffff:ffff:ffff:ffff:ffff:ffff:ffff", net::WAN),
|
||||
std::make_tuple("fe81::1", net::WAN),
|
||||
std::make_tuple("::ffff:127.0.0.1", net::PC),
|
||||
std::make_tuple("::ffff:192.168.1.1", net::LAN),
|
||||
std::make_tuple("::ffff:198.51.100.1", net::WAN)
|
||||
)
|
||||
);
|
||||
|
||||
struct MdnsInstanceNameTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(MdnsInstanceNameTest, Run) {
|
||||
|
||||
Reference in new issue
Block a user