mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
79 lines
2.8 KiB
C++
79 lines
2.8 KiB
C++
#include "prx/libc/include/general/VabiMacros.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <stdexcept>
|
|
#include <span>
|
|
|
|
struct GameLiveStreamingStatus2 {
|
|
std::int32_t userId;
|
|
bool isOnAir;
|
|
std::uint8_t align[3];
|
|
std::uint32_t spectatorCounts;
|
|
std::uint32_t textMessageCounts;
|
|
std::uint32_t commandMessageCounts;
|
|
std::uint32_t broadcastVideoResolution;
|
|
std::uint8_t reserved[48];
|
|
};
|
|
static_assert(sizeof(GameLiveStreamingStatus2) == 72);
|
|
|
|
extern "C" {
|
|
int APS5_VABI sceGameLiveStreamingInitialize(std::size_t heap_size);
|
|
int APS5_VABI sceGameLiveStreamingTerminate(void);
|
|
int APS5_VABI sceGameLiveStreamingGetCurrentStatus2(GameLiveStreamingStatus2* status);
|
|
struct GameLiveStreamingProgramInfo;
|
|
int APS5_VABI sceGameLiveStreamingGetProgramInfo(GameLiveStreamingProgramInfo*);
|
|
}
|
|
|
|
namespace {
|
|
|
|
void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
constexpr std::int32_t kInvalidUserId = -1;
|
|
|
|
}
|
|
|
|
int main() {
|
|
constexpr int invalidArgument = static_cast<int>(0x80A00002);
|
|
constexpr int alreadyInitialized = static_cast<int>(0x80A00003);
|
|
constexpr int notInitialized = static_cast<int>(0x80A00004);
|
|
Require(sceGameLiveStreamingTerminate() == notInitialized);
|
|
Require(sceGameLiveStreamingGetCurrentStatus2(nullptr) == notInitialized);
|
|
for (const std::size_t size : {0u, 1u, 0x3fffu, 0x4001u, 0x100000u}) Require(sceGameLiveStreamingInitialize(size) == invalidArgument);
|
|
Require(sceGameLiveStreamingInitialize(0x4000) == 0);
|
|
Require(sceGameLiveStreamingInitialize(0) == invalidArgument);
|
|
Require(sceGameLiveStreamingInitialize(0x4000) == alreadyInitialized);
|
|
Require(sceGameLiveStreamingGetCurrentStatus2(nullptr) == invalidArgument);
|
|
|
|
GameLiveStreamingStatus2 status{};
|
|
std::memset(&status, 0x7f, sizeof(status));
|
|
Require(sceGameLiveStreamingGetCurrentStatus2(&status) == 0);
|
|
Require(status.userId == kInvalidUserId);
|
|
Require(!status.isOnAir);
|
|
Require(status.spectatorCounts == 0);
|
|
Require(status.textMessageCounts == 0);
|
|
Require(status.commandMessageCounts == 0);
|
|
Require(status.broadcastVideoResolution == 0);
|
|
for (std::uint8_t byte : status.align) {
|
|
Require(byte == 0);
|
|
}
|
|
for (std::uint8_t byte : status.reserved) {
|
|
Require(byte == 0);
|
|
}
|
|
|
|
bool threwProgramInfo = false;
|
|
try {
|
|
sceGameLiveStreamingGetProgramInfo(nullptr);
|
|
} catch (const std::runtime_error&) {
|
|
threwProgramInfo = true;
|
|
}
|
|
Require(threwProgramInfo);
|
|
|
|
Require(sceGameLiveStreamingTerminate() == 0);
|
|
std::memset(&status, 0x7f, sizeof(status));
|
|
Require(sceGameLiveStreamingGetCurrentStatus2(&status) == notInitialized);
|
|
for (const auto value : std::as_bytes(std::span(&status, 1))) Require(value == std::byte{0x7f});
|
|
Require(sceGameLiveStreamingTerminate() == notInitialized);
|
|
}
|