Compare commits
9 Commits
safestring
...
atomics
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cbd555b14 | |||
| ce546b12b0 | |||
| 6dd3f9e7bc | |||
| 941ffef2ca | |||
| 8dc304bcd3 | |||
| 3fddfc5557 | |||
| ac6630ef59 | |||
| 0ead0df2a1 | |||
| 333382ae74 |
@@ -0,0 +1,37 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(moonlight-common-c LANGUAGES C)
|
||||
|
||||
SET(CMAKE_C_STANDARD 11)
|
||||
|
||||
find_package(OpenSSL 1.0.2 REQUIRED)
|
||||
|
||||
aux_source_directory(src SRC_LIST)
|
||||
aux_source_directory(enet SRC_LIST)
|
||||
aux_source_directory(reedsolomon SRC_LIST)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/W4 /wd4100 /wd4232)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1 -D_CRT_NONSTDC_NO_DEPRECATE=1)
|
||||
link_libraries(ws2_32.lib qwave.lib winmm.lib)
|
||||
else()
|
||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror)
|
||||
endif()
|
||||
|
||||
string(TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||
if("${BUILD_TYPE}" STREQUAL "XDEBUG")
|
||||
add_definitions(-DLC_DEBUG)
|
||||
else()
|
||||
add_definitions(-DNDEBUG)
|
||||
endif()
|
||||
|
||||
add_definitions(-DHAS_SOCKLEN_T)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enet/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/reedsolomon
|
||||
${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
link_libraries(${OPENSSL_CRYPTO_LIBRARY})
|
||||
|
||||
add_library(moonlight-common-c SHARED ${SRC_LIST})
|
||||
@@ -0,0 +1,37 @@
|
||||
clone_depth: 1
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_ARGS: -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -A Win32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_ARGS: -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -A x64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: macOS
|
||||
BUILD_TARGET: macos
|
||||
CMAKE_ARGS: -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
|
||||
before_build:
|
||||
- 'git submodule update --init --recursive'
|
||||
|
||||
build_script:
|
||||
- 'mkdir build_debug'
|
||||
- 'cd build_debug'
|
||||
- sh: 'cmake $CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug ..'
|
||||
- cmd: 'cmake %CMAKE_ARGS% -DCMAKE_BUILD_TYPE=Debug ..'
|
||||
- sh: 'cmake --build .'
|
||||
- cmd: 'cmake --build . --config Debug'
|
||||
- 'cd ..'
|
||||
- 'mkdir build_release'
|
||||
- 'cd build_release'
|
||||
- sh: 'cmake $CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release ..'
|
||||
- cmd: 'cmake %CMAKE_ARGS% -DCMAKE_BUILD_TYPE=Release ..'
|
||||
- sh: 'cmake --build .'
|
||||
- cmd: 'cmake --build . --config Release'
|
||||
|
||||
deploy: off
|
||||
+2
-4
@@ -499,7 +499,7 @@ static int reed_solomon_decode(reed_solomon* rs, unsigned char **data_blocks, in
|
||||
unsigned char* subShards[DATA_SHARDS_MAX];
|
||||
unsigned char* outputs[DATA_SHARDS_MAX];
|
||||
gf* m = rs->m;
|
||||
int i, j, c, swap, subMatrixRow, dataShards, nos, nshards;
|
||||
int i, j, c, swap, subMatrixRow, dataShards;
|
||||
|
||||
/* the erased_blocks should always sorted
|
||||
* if sorted, nr_fec_blocks times to check it
|
||||
@@ -523,11 +523,9 @@ static int reed_solomon_decode(reed_solomon* rs, unsigned char **data_blocks, in
|
||||
|
||||
j = 0;
|
||||
subMatrixRow = 0;
|
||||
nos = 0;
|
||||
nshards = 0;
|
||||
dataShards = rs->data_shards;
|
||||
for (i = 0; i < dataShards; i++) {
|
||||
if (j < nr_fec_blocks && i == erased_blocks[j])
|
||||
if (j < nr_fec_blocks && i == (int)erased_blocks[j])
|
||||
j++;
|
||||
else {
|
||||
/* this row is ok */
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ static void ReceiveThreadProc(void* context) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (packet->size < sizeof(RTP_PACKET)) {
|
||||
if (packet->size < (int)sizeof(RTP_PACKET)) {
|
||||
// Runt packet
|
||||
continue;
|
||||
}
|
||||
|
||||
+17
-17
@@ -8,7 +8,7 @@ void BbInitializeWrappedBuffer(PBYTE_BUFFER buff, char* data, int offset, int le
|
||||
}
|
||||
|
||||
// Get the long long in the correct byte order
|
||||
static long long byteSwapLongLong(PBYTE_BUFFER buff, long long l) {
|
||||
static uint64_t byteSwap64(PBYTE_BUFFER buff, uint64_t l) {
|
||||
if (buff->byteOrder == BYTE_ORDER_BIG) {
|
||||
return HTONLL(l);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ static long long byteSwapLongLong(PBYTE_BUFFER buff, long long l) {
|
||||
}
|
||||
|
||||
// Get the int in the correct byte order
|
||||
static int byteSwapInt(PBYTE_BUFFER buff, int i) {
|
||||
static uint32_t byteSwap32(PBYTE_BUFFER buff, uint32_t i) {
|
||||
if (buff->byteOrder == BYTE_ORDER_BIG) {
|
||||
return htonl(i);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ static int byteSwapInt(PBYTE_BUFFER buff, int i) {
|
||||
}
|
||||
|
||||
// Get the short in the correct byte order
|
||||
static int byteSwapShort(PBYTE_BUFFER buff, short s) {
|
||||
static uint16_t byteSwap16(PBYTE_BUFFER buff, uint16_t s) {
|
||||
if (buff->byteOrder == BYTE_ORDER_BIG) {
|
||||
return htons(s);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ bool BbAdvanceBuffer(PBYTE_BUFFER buff, int offset) {
|
||||
}
|
||||
|
||||
// Get a byte from the byte buffer
|
||||
bool BbGet(PBYTE_BUFFER buff, char* c) {
|
||||
bool BbGet8(PBYTE_BUFFER buff, uint8_t* c) {
|
||||
if (buff->position + sizeof(*c) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ bool BbGet(PBYTE_BUFFER buff, char* c) {
|
||||
}
|
||||
|
||||
// Get a short from the byte buffer
|
||||
bool BbGetShort(PBYTE_BUFFER buff, short* s) {
|
||||
bool BbGet16(PBYTE_BUFFER buff, uint16_t* s) {
|
||||
if (buff->position + sizeof(*s) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -68,13 +68,13 @@ bool BbGetShort(PBYTE_BUFFER buff, short* s) {
|
||||
memcpy(s, &buff->buffer[buff->position], sizeof(*s));
|
||||
buff->position += sizeof(*s);
|
||||
|
||||
*s = byteSwapShort(buff, *s);
|
||||
*s = byteSwap16(buff, *s);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get an int from the byte buffer
|
||||
bool BbGetInt(PBYTE_BUFFER buff, int* i) {
|
||||
bool BbGet32(PBYTE_BUFFER buff, uint32_t* i) {
|
||||
if (buff->position + sizeof(*i) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -82,13 +82,13 @@ bool BbGetInt(PBYTE_BUFFER buff, int* i) {
|
||||
memcpy(i, &buff->buffer[buff->position], sizeof(*i));
|
||||
buff->position += sizeof(*i);
|
||||
|
||||
*i = byteSwapInt(buff, *i);
|
||||
*i = byteSwap32(buff, *i);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get a long from the byte buffer
|
||||
bool BbGetLong(PBYTE_BUFFER buff, long long* l) {
|
||||
bool BbGet64(PBYTE_BUFFER buff, uint64_t* l) {
|
||||
if (buff->position + sizeof(*l) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -96,18 +96,18 @@ bool BbGetLong(PBYTE_BUFFER buff, long long* l) {
|
||||
memcpy(l, &buff->buffer[buff->position], sizeof(*l));
|
||||
buff->position += sizeof(*l);
|
||||
|
||||
*l = byteSwapLongLong(buff, *l);
|
||||
*l = byteSwap64(buff, *l);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Put an int into the byte buffer
|
||||
bool BbPutInt(PBYTE_BUFFER buff, int i) {
|
||||
bool BbPut32(PBYTE_BUFFER buff, uint32_t i) {
|
||||
if (buff->position + sizeof(i) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
i = byteSwapInt(buff, i);
|
||||
i = byteSwap32(buff, i);
|
||||
|
||||
memcpy(&buff->buffer[buff->position], &i, sizeof(i));
|
||||
buff->position += sizeof(i);
|
||||
@@ -116,12 +116,12 @@ bool BbPutInt(PBYTE_BUFFER buff, int i) {
|
||||
}
|
||||
|
||||
// Put a long into the byte buffer
|
||||
bool BbPutLong(PBYTE_BUFFER buff, long long l) {
|
||||
bool BbPut64(PBYTE_BUFFER buff, uint64_t l) {
|
||||
if (buff->position + sizeof(l) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
l = byteSwapLongLong(buff, l);
|
||||
l = byteSwap64(buff, l);
|
||||
|
||||
memcpy(&buff->buffer[buff->position], &l, sizeof(l));
|
||||
buff->position += sizeof(l);
|
||||
@@ -130,12 +130,12 @@ bool BbPutLong(PBYTE_BUFFER buff, long long l) {
|
||||
}
|
||||
|
||||
// Put a short into the byte buffer
|
||||
bool BbPutShort(PBYTE_BUFFER buff, short s) {
|
||||
bool BbPut16(PBYTE_BUFFER buff, uint16_t s) {
|
||||
if (buff->position + sizeof(s) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
s = byteSwapShort(buff, s);
|
||||
s = byteSwap16(buff, s);
|
||||
|
||||
memcpy(&buff->buffer[buff->position], &s, sizeof(s));
|
||||
buff->position += sizeof(s);
|
||||
@@ -144,7 +144,7 @@ bool BbPutShort(PBYTE_BUFFER buff, short s) {
|
||||
}
|
||||
|
||||
// Put a byte into the buffer
|
||||
bool BbPut(PBYTE_BUFFER buff, char c) {
|
||||
bool BbPut8(PBYTE_BUFFER buff, uint8_t c) {
|
||||
if (buff->position + sizeof(c) > buff->length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+8
-8
@@ -27,12 +27,12 @@ typedef struct _BYTE_BUFFER {
|
||||
void BbInitializeWrappedBuffer(PBYTE_BUFFER buff, char* data, int offset, int length, int byteOrder);
|
||||
bool BbAdvanceBuffer(PBYTE_BUFFER buff, int offset);
|
||||
|
||||
bool BbGet(PBYTE_BUFFER buff, char* c);
|
||||
bool BbGetShort(PBYTE_BUFFER buff, short* s);
|
||||
bool BbGetInt(PBYTE_BUFFER buff, int* i);
|
||||
bool BbGetLong(PBYTE_BUFFER buff, long long* l);
|
||||
bool BbGet8(PBYTE_BUFFER buff, uint8_t* c);
|
||||
bool BbGet16(PBYTE_BUFFER buff, uint16_t* s);
|
||||
bool BbGet32(PBYTE_BUFFER buff, uint32_t* i);
|
||||
bool BbGet64(PBYTE_BUFFER buff, uint64_t* l);
|
||||
|
||||
bool BbPutInt(PBYTE_BUFFER buff, int i);
|
||||
bool BbPutShort(PBYTE_BUFFER buff, short s);
|
||||
bool BbPut(PBYTE_BUFFER buff, char c);
|
||||
bool BbPutLong(PBYTE_BUFFER buff, long long l);
|
||||
bool BbPut8(PBYTE_BUFFER buff, uint8_t c);
|
||||
bool BbPut16(PBYTE_BUFFER buff, uint16_t s);
|
||||
bool BbPut32(PBYTE_BUFFER buff, uint32_t i);
|
||||
bool BbPut64(PBYTE_BUFFER buff, uint64_t l);
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
static int stage = STAGE_NONE;
|
||||
static ConnListenerConnectionTerminated originalTerminationCallback;
|
||||
static bool alreadyTerminated;
|
||||
static atomic_bool alreadyTerminated;
|
||||
static PLT_THREAD terminationCallbackThread;
|
||||
static int terminationCallbackErrorCode;
|
||||
|
||||
@@ -17,7 +17,7 @@ CONNECTION_LISTENER_CALLBACKS ListenerCallbacks;
|
||||
DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
||||
AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||
int NegotiatedVideoFormat;
|
||||
volatile bool ConnectionInterrupted;
|
||||
atomic_bool ConnectionInterrupted;
|
||||
bool HighQualitySurroundSupported;
|
||||
bool HighQualitySurroundEnabled;
|
||||
OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig;
|
||||
|
||||
@@ -111,7 +111,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
}
|
||||
|
||||
for (i = 0; i < PORT_FLAGS_MAX_COUNT; i++) {
|
||||
if (testPortFlags & (1 << i)) {
|
||||
if (testPortFlags & (1U << i)) {
|
||||
sockets[i] = createSocket(address.ss_family,
|
||||
LiGetProtocolFromPortFlagIndex(i) == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM,
|
||||
LiGetProtocolFromPortFlagIndex(i),
|
||||
@@ -133,7 +133,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
Limelog("Failed to start async connect to TCP %u: %d\n", LiGetPortFromPortFlagIndex(i), err);
|
||||
|
||||
// Mask off this bit so we don't try to include it in pollSockets() below
|
||||
testPortFlags &= ~(1 << i);
|
||||
testPortFlags &= ~(1U << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
Limelog("Failed to send test packet to UDP %u: %d\n", LiGetPortFromPortFlagIndex(i), err);
|
||||
|
||||
// Mask off this bit so we don't try to include it in pollSockets() below
|
||||
testPortFlags &= ~(1 << i);
|
||||
testPortFlags &= ~(1U << i);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
|
||||
// Fill out our FD sets
|
||||
for (i = 0; i < PORT_FLAGS_MAX_COUNT; i++) {
|
||||
if (testPortFlags & (1 << i)) {
|
||||
if (testPortFlags & (1U << i)) {
|
||||
pfds[nfds].fd = sockets[i];
|
||||
|
||||
if (LiGetProtocolFromPortFlagIndex(i) == IPPROTO_UDP) {
|
||||
@@ -211,7 +211,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
// This socket was signalled. Figure out what port it was.
|
||||
for (portIndex = 0; portIndex < PORT_FLAGS_MAX_COUNT; portIndex++) {
|
||||
if (sockets[portIndex] == pfds[i].fd) {
|
||||
LC_ASSERT(testPortFlags & (1 << portIndex));
|
||||
LC_ASSERT(testPortFlags & (1U << portIndex));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,13 +225,13 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
// a packet from the test server, or it could be because we
|
||||
// received an ICMP error which will be given to us from
|
||||
// recvfrom().
|
||||
testPortFlags &= ~(1 << portIndex);
|
||||
testPortFlags &= ~(1U << portIndex);
|
||||
|
||||
// Check if the socket can be successfully read now
|
||||
err = recvfrom(sockets[portIndex], buf, sizeof(buf), 0, NULL, NULL);
|
||||
if (err >= 0) {
|
||||
// The UDP test was a success.
|
||||
failingPortFlags &= ~(1 << portIndex);
|
||||
failingPortFlags &= ~(1U << portIndex);
|
||||
|
||||
Limelog("UDP port %u test successful\n", LiGetPortFromPortFlagIndex(portIndex));
|
||||
}
|
||||
@@ -250,10 +250,10 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
}
|
||||
|
||||
// The TCP test has completed for this port
|
||||
testPortFlags &= ~(1 << portIndex);
|
||||
testPortFlags &= ~(1U << portIndex);
|
||||
if (err == 0) {
|
||||
// The TCP test was a success
|
||||
failingPortFlags &= ~(1 << portIndex);
|
||||
failingPortFlags &= ~(1U << portIndex);
|
||||
|
||||
Limelog("TCP port %u test successful\n", LiGetPortFromPortFlagIndex(portIndex));
|
||||
}
|
||||
|
||||
+24
-24
@@ -33,9 +33,9 @@ static PLT_THREAD invalidateRefFramesThread;
|
||||
static PLT_THREAD controlReceiveThread;
|
||||
static PLT_EVENT invalidateRefFramesEvent;
|
||||
static int lossCountSinceLastReport;
|
||||
static long lastGoodFrame;
|
||||
static long lastSeenFrame;
|
||||
static bool stopping;
|
||||
static atomic_int lastGoodFrame;
|
||||
static atomic_int lastSeenFrame;
|
||||
static atomic_bool stopping;
|
||||
static bool disconnectPending;
|
||||
|
||||
static int intervalGoodFrameCount;
|
||||
@@ -44,7 +44,7 @@ static uint64_t intervalStartTimeMs;
|
||||
static int lastIntervalLossPercentage;
|
||||
static int lastConnectionStatusUpdate;
|
||||
|
||||
static bool idrFrameRequired;
|
||||
static atomic_bool idrFrameRequired;
|
||||
static LINKED_BLOCKING_QUEUE invalidReferenceFrameTuples;
|
||||
|
||||
#define CONN_IMMEDIATE_POOR_LOSS_RATE 30
|
||||
@@ -395,7 +395,7 @@ static bool sendMessageTcp(short ptype, short paylen, const void* payload) {
|
||||
err = send(ctlSock, (char*) packet, sizeof(*packet) + paylen, 0);
|
||||
free(packet);
|
||||
|
||||
if (err != sizeof(*packet) + paylen) {
|
||||
if (err != (SOCK_RET)(sizeof(*packet) + paylen)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -544,13 +544,13 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
BbInitializeWrappedBuffer(&bb, (char*)event.packet->data, sizeof(*ctlHdr), event.packet->dataLength - sizeof(*ctlHdr), BYTE_ORDER_LITTLE);
|
||||
BbAdvanceBuffer(&bb, 4);
|
||||
|
||||
unsigned short controllerNumber;
|
||||
unsigned short lowFreqRumble;
|
||||
unsigned short highFreqRumble;
|
||||
uint16_t controllerNumber;
|
||||
uint16_t lowFreqRumble;
|
||||
uint16_t highFreqRumble;
|
||||
|
||||
BbGetShort(&bb, (short*)&controllerNumber);
|
||||
BbGetShort(&bb, (short*)&lowFreqRumble);
|
||||
BbGetShort(&bb, (short*)&highFreqRumble);
|
||||
BbGet16(&bb, &controllerNumber);
|
||||
BbGet16(&bb, &lowFreqRumble);
|
||||
BbGet16(&bb, &highFreqRumble);
|
||||
|
||||
ListenerCallbacks.rumble(controllerNumber, lowFreqRumble, highFreqRumble);
|
||||
}
|
||||
@@ -559,10 +559,10 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
|
||||
BbInitializeWrappedBuffer(&bb, (char*)event.packet->data, sizeof(*ctlHdr), event.packet->dataLength - sizeof(*ctlHdr), BYTE_ORDER_LITTLE);
|
||||
|
||||
unsigned short terminationReason;
|
||||
uint16_t terminationReason;
|
||||
int terminationErrorCode;
|
||||
|
||||
BbGetShort(&bb, (short*)&terminationReason);
|
||||
BbGet16(&bb, &terminationReason);
|
||||
|
||||
Limelog("Server notified termination reason: 0x%04x\n", terminationReason);
|
||||
|
||||
@@ -603,8 +603,8 @@ static void lossStatsThreadFunc(void* context) {
|
||||
char periodicPingPayload[8];
|
||||
|
||||
BbInitializeWrappedBuffer(&byteBuffer, periodicPingPayload, 0, sizeof(periodicPingPayload), BYTE_ORDER_LITTLE);
|
||||
BbPutShort(&byteBuffer, 4); // Length of payload
|
||||
BbPutInt(&byteBuffer, 0); // Timestamp?
|
||||
BbPut16(&byteBuffer, 4); // Length of payload
|
||||
BbPut32(&byteBuffer, 0); // Timestamp?
|
||||
|
||||
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
||||
// Send the message (and don't expect a response)
|
||||
@@ -631,13 +631,13 @@ static void lossStatsThreadFunc(void* context) {
|
||||
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
||||
// Construct the payload
|
||||
BbInitializeWrappedBuffer(&byteBuffer, lossStatsPayload, 0, payloadLengths[IDX_LOSS_STATS], BYTE_ORDER_LITTLE);
|
||||
BbPutInt(&byteBuffer, lossCountSinceLastReport);
|
||||
BbPutInt(&byteBuffer, LOSS_REPORT_INTERVAL_MS);
|
||||
BbPutInt(&byteBuffer, 1000);
|
||||
BbPutLong(&byteBuffer, lastGoodFrame);
|
||||
BbPutInt(&byteBuffer, 0);
|
||||
BbPutInt(&byteBuffer, 0);
|
||||
BbPutInt(&byteBuffer, 0x14);
|
||||
BbPut32(&byteBuffer, lossCountSinceLastReport);
|
||||
BbPut32(&byteBuffer, LOSS_REPORT_INTERVAL_MS);
|
||||
BbPut32(&byteBuffer, 1000);
|
||||
BbPut64(&byteBuffer, lastGoodFrame);
|
||||
BbPut32(&byteBuffer, 0);
|
||||
BbPut32(&byteBuffer, 0);
|
||||
BbPut32(&byteBuffer, 0x14);
|
||||
|
||||
// Send the message (and don't expect a response)
|
||||
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
||||
@@ -660,7 +660,7 @@ static void lossStatsThreadFunc(void* context) {
|
||||
}
|
||||
|
||||
static void requestIdrFrame(void) {
|
||||
long long payload[3];
|
||||
int64_t payload[3];
|
||||
|
||||
if (AppVersionQuad[0] >= 5) {
|
||||
// Form the payload
|
||||
@@ -697,7 +697,7 @@ static void requestIdrFrame(void) {
|
||||
}
|
||||
|
||||
static void requestInvalidateReferenceFrames(void) {
|
||||
long long payload[3];
|
||||
int64_t payload[3];
|
||||
PQUEUED_FRAME_INVALIDATION_TUPLE qfit;
|
||||
|
||||
LC_ASSERT(isReferenceFrameInvalidationEnabled());
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct _NV_INPUT_HEADER {
|
||||
int packetType;
|
||||
uint32_t packetType;
|
||||
} NV_INPUT_HEADER, PNV_INPUT_HEADER;
|
||||
|
||||
#define PACKET_TYPE_HAPTICS 0x06
|
||||
|
||||
+4
-4
@@ -8,7 +8,7 @@
|
||||
|
||||
static SOCKET inputSock = INVALID_SOCKET;
|
||||
static unsigned char currentAesIv[16];
|
||||
static bool initialized;
|
||||
static atomic_bool initialized;
|
||||
static EVP_CIPHER_CTX* cipherContext;
|
||||
static bool cipherInitialized;
|
||||
|
||||
@@ -187,7 +187,7 @@ static void inputSendThreadProc(void* context) {
|
||||
SOCK_RET err;
|
||||
PPACKET_HOLDER holder;
|
||||
char encryptedBuffer[MAX_INPUT_PACKET_SIZE];
|
||||
int encryptedSize;
|
||||
uint32_t encryptedSize;
|
||||
|
||||
while (!PltIsThreadInterrupted(&inputSendThread)) {
|
||||
int encryptedLengthPrefix;
|
||||
@@ -323,7 +323,7 @@ static void inputSendThreadProc(void* context) {
|
||||
// Encrypt the message into the output buffer while leaving room for the length
|
||||
encryptedSize = sizeof(encryptedBuffer) - 4;
|
||||
err = encryptData((const unsigned char*)&holder->packet, holder->packetLength,
|
||||
(unsigned char*)&encryptedBuffer[4], &encryptedSize);
|
||||
(unsigned char*)&encryptedBuffer[4], (int*)&encryptedSize);
|
||||
free(holder);
|
||||
if (err != 0) {
|
||||
Limelog("Input: Encryption failed: %d\n", (int)err);
|
||||
@@ -332,7 +332,7 @@ static void inputSendThreadProc(void* context) {
|
||||
}
|
||||
|
||||
// Prepend the length to the message
|
||||
encryptedLengthPrefix = htonl((unsigned long)encryptedSize);
|
||||
encryptedLengthPrefix = htonl(encryptedSize);
|
||||
memcpy(&encryptedBuffer[0], &encryptedLengthPrefix, 4);
|
||||
|
||||
if (AppVersionQuad[0] < 5) {
|
||||
|
||||
@@ -19,7 +19,7 @@ extern CONNECTION_LISTENER_CALLBACKS ListenerCallbacks;
|
||||
extern DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
||||
extern AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||
extern int NegotiatedVideoFormat;
|
||||
extern volatile bool ConnectionInterrupted;
|
||||
extern atomic_bool ConnectionInterrupted;
|
||||
extern bool HighQualitySurroundSupported;
|
||||
extern bool HighQualitySurroundEnabled;
|
||||
extern OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig;
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ typedef struct _DECODE_UNIT {
|
||||
// Receive time of first buffer. This value uses an implementation-defined epoch.
|
||||
// To compute actual latency values, use LiGetMillis() to get a timestamp that
|
||||
// shares the same epoch as this value.
|
||||
unsigned long long receiveTimeMs;
|
||||
uint64_t receiveTimeMs;
|
||||
|
||||
// Presentation time in milliseconds with the epoch at the first captured frame.
|
||||
// This can be used to aid frame pacing or to drop old frames that were queued too
|
||||
|
||||
@@ -106,7 +106,7 @@ int LbqPeekQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
|
||||
return LBQ_INTERRUPTED;
|
||||
}
|
||||
|
||||
if (queueHead->head == NULL) {
|
||||
if (queueHead->currentSize == 0) {
|
||||
return LBQ_NO_ELEMENT;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ int LbqPollQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
|
||||
return LBQ_INTERRUPTED;
|
||||
}
|
||||
|
||||
if (queueHead->head == NULL) {
|
||||
if (queueHead->currentSize == 0) {
|
||||
return LBQ_NO_ELEMENT;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ typedef struct _LINKED_BLOCKING_QUEUE {
|
||||
PLT_MUTEX mutex;
|
||||
PLT_EVENT containsDataEvent;
|
||||
int sizeBound;
|
||||
int currentSize;
|
||||
bool shutdown;
|
||||
atomic_int currentSize;
|
||||
atomic_bool shutdown;
|
||||
int lifetimeSize;
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY head;
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY tail;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -10,18 +10,18 @@ typedef HANDLE PLT_MUTEX;
|
||||
typedef HANDLE PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
HANDLE handle;
|
||||
bool cancelled;
|
||||
atomic_bool cancelled;
|
||||
} PLT_THREAD;
|
||||
#elif defined(__vita__)
|
||||
typedef int PLT_MUTEX;
|
||||
typedef struct _PLT_EVENT {
|
||||
int mutex;
|
||||
int cond;
|
||||
bool signalled;
|
||||
atomic_bool signalled;
|
||||
} PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
int handle;
|
||||
int cancelled;
|
||||
atomic_bool cancelled;
|
||||
void *context;
|
||||
bool alive;
|
||||
} PLT_THREAD;
|
||||
@@ -30,11 +30,11 @@ typedef pthread_mutex_t PLT_MUTEX;
|
||||
typedef struct _PLT_EVENT {
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
bool signalled;
|
||||
atomic_bool signalled;
|
||||
} PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
pthread_t thread;
|
||||
bool cancelled;
|
||||
atomic_bool cancelled;
|
||||
} PLT_THREAD;
|
||||
#else
|
||||
#error Unsupported platform
|
||||
|
||||
+4
-4
@@ -92,7 +92,7 @@ static bool queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, bool
|
||||
|
||||
// Returns 0 if the frame is completely constructed
|
||||
static int reconstructFrame(PRTP_FEC_QUEUE queue) {
|
||||
int totalPackets = U16(queue->bufferHighestSequenceNumber - queue->bufferLowestSequenceNumber) + 1;
|
||||
unsigned int totalPackets = U16(queue->bufferHighestSequenceNumber - queue->bufferLowestSequenceNumber) + 1;
|
||||
int ret;
|
||||
|
||||
#ifdef FEC_VALIDATION_MODE
|
||||
@@ -150,14 +150,14 @@ static int reconstructFrame(PRTP_FEC_QUEUE queue) {
|
||||
|
||||
#ifdef FEC_VALIDATION_MODE
|
||||
// Choose a packet to drop
|
||||
int dropIndex = rand() % queue->bufferDataPackets;
|
||||
unsigned int dropIndex = rand() % queue->bufferDataPackets;
|
||||
PRTP_PACKET droppedRtpPacket = NULL;
|
||||
int droppedRtpPacketLength = 0;
|
||||
#endif
|
||||
|
||||
PRTPFEC_QUEUE_ENTRY entry = queue->bufferHead;
|
||||
while (entry != NULL) {
|
||||
int index = U16(entry->packet->sequenceNumber - queue->bufferLowestSequenceNumber);
|
||||
unsigned int index = U16(entry->packet->sequenceNumber - queue->bufferLowestSequenceNumber);
|
||||
|
||||
#ifdef FEC_VALIDATION_MODE
|
||||
if (index == dropIndex) {
|
||||
@@ -181,7 +181,7 @@ static int reconstructFrame(PRTP_FEC_QUEUE queue) {
|
||||
entry = entry->next;
|
||||
}
|
||||
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < totalPackets; i++) {
|
||||
if (marks[i]) {
|
||||
packets[i] = malloc(packetBufferSize);
|
||||
|
||||
+13
-13
@@ -6,8 +6,8 @@ typedef struct _RTPFEC_QUEUE_ENTRY {
|
||||
PRTP_PACKET packet;
|
||||
int length;
|
||||
bool isParity;
|
||||
unsigned long long receiveTimeMs;
|
||||
unsigned int presentationTimeMs;
|
||||
uint64_t receiveTimeMs;
|
||||
uint32_t presentationTimeMs;
|
||||
|
||||
struct _RTPFEC_QUEUE_ENTRY* next;
|
||||
struct _RTPFEC_QUEUE_ENTRY* prev;
|
||||
@@ -16,18 +16,18 @@ typedef struct _RTPFEC_QUEUE_ENTRY {
|
||||
typedef struct _RTP_FEC_QUEUE {
|
||||
PRTPFEC_QUEUE_ENTRY bufferHead;
|
||||
PRTPFEC_QUEUE_ENTRY bufferTail;
|
||||
unsigned long long bufferFirstRecvTimeMs;
|
||||
int bufferSize;
|
||||
int bufferLowestSequenceNumber;
|
||||
int bufferHighestSequenceNumber;
|
||||
int bufferFirstParitySequenceNumber;
|
||||
int bufferDataPackets;
|
||||
int bufferParityPackets;
|
||||
int receivedBufferDataPackets;
|
||||
int fecPercentage;
|
||||
int nextContiguousSequenceNumber;
|
||||
uint64_t bufferFirstRecvTimeMs;
|
||||
uint32_t bufferSize;
|
||||
uint32_t bufferLowestSequenceNumber;
|
||||
uint32_t bufferHighestSequenceNumber;
|
||||
uint32_t bufferFirstParitySequenceNumber;
|
||||
uint32_t bufferDataPackets;
|
||||
uint32_t bufferParityPackets;
|
||||
uint32_t receivedBufferDataPackets;
|
||||
uint32_t fecPercentage;
|
||||
uint32_t nextContiguousSequenceNumber;
|
||||
|
||||
int currentFrameNumber;
|
||||
uint32_t currentFrameNumber;
|
||||
} RTP_FEC_QUEUE, *PRTP_FEC_QUEUE;
|
||||
|
||||
#define RTPF_RET_QUEUED 0
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef struct _RTP_QUEUE_ENTRY {
|
||||
|
||||
typedef struct _RTP_REORDER_QUEUE {
|
||||
int maxSize;
|
||||
int maxQueueTimeMs;
|
||||
uint32_t maxQueueTimeMs;
|
||||
|
||||
PRTP_QUEUE_ENTRY queueHead;
|
||||
PRTP_QUEUE_ENTRY queueTail;
|
||||
|
||||
+3
-3
@@ -123,7 +123,7 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un
|
||||
Limelog("Failed to read STUN binding response: %d\n", err);
|
||||
goto Exit;
|
||||
}
|
||||
else if (bytesRead < sizeof(resp.hdr)) {
|
||||
else if (bytesRead < (int)sizeof(resp.hdr)) {
|
||||
Limelog("STUN message truncated: %d\n", bytesRead);
|
||||
err = -3;
|
||||
goto Exit;
|
||||
@@ -146,8 +146,8 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un
|
||||
|
||||
attribute = (PSTUN_ATTRIBUTE_HEADER)(&resp.hdr + 1);
|
||||
bytesRead -= sizeof(resp.hdr);
|
||||
while (bytesRead > sizeof(*attribute)) {
|
||||
if (bytesRead < sizeof(*attribute) + htons(attribute->length)) {
|
||||
while (bytesRead > (int)sizeof(*attribute)) {
|
||||
if (bytesRead < (int)(sizeof(*attribute) + htons(attribute->length))) {
|
||||
Limelog("STUN attribute out of bounds: %d\n", htons(attribute->length));
|
||||
err = -5;
|
||||
goto Exit;
|
||||
|
||||
@@ -14,7 +14,7 @@ static bool waitingForIdrFrame;
|
||||
static unsigned int lastPacketInStream;
|
||||
static bool decodingFrame;
|
||||
static bool strictIdrFrameWait;
|
||||
static unsigned long long firstPacketReceiveTime;
|
||||
static uint64_t firstPacketReceiveTime;
|
||||
static unsigned int firstPacketPresentationTime;
|
||||
static bool dropStatePending;
|
||||
static bool idrFrameProcessed;
|
||||
@@ -488,11 +488,11 @@ static int isFirstPacket(char flags) {
|
||||
|
||||
// Process an RTP Payload
|
||||
// The caller will free *existingEntry unless we NULL it
|
||||
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length,
|
||||
unsigned long long receiveTimeMs, unsigned int presentationTimeMs,
|
||||
static void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length,
|
||||
uint64_t receiveTimeMs, unsigned int presentationTimeMs,
|
||||
PLENTRY_INTERNAL* existingEntry) {
|
||||
BUFFER_DESC currentPos;
|
||||
int frameIndex;
|
||||
unsigned int frameIndex;
|
||||
char flags;
|
||||
unsigned int firstPacket;
|
||||
unsigned int streamPacketIndex;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ static PLT_THREAD decoderThread;
|
||||
|
||||
static bool receivedDataFromPeer;
|
||||
static uint64_t firstDataTimeMs;
|
||||
static bool receivedFullFrame;
|
||||
static atomic_bool receivedFullFrame;
|
||||
|
||||
// We can't request an IDR frame until the depacketizer knows
|
||||
// that a packet was lost. This timeout bounds the time that
|
||||
|
||||
Reference in New Issue
Block a user