9 Commits

Author SHA1 Message Date
Cameron Gutman 5cbd555b14 Fix thread sanitizer warnings with C11 atomics 2020-12-06 00:49:10 -06:00
Cameron Gutman ce546b12b0 Fix undefined behavior due to shifting an int by 31 2020-12-06 00:44:33 -06:00
Cameron Gutman 6dd3f9e7bc Treat GCC/Clang warnings as errors 2020-12-05 23:46:10 -06:00
Cameron Gutman 941ffef2ca Fix final GCC sign warnings 2020-12-05 23:45:49 -06:00
Cameron Gutman 8dc304bcd3 Fix more warnings 2020-12-05 23:30:25 -06:00
Cameron Gutman 3fddfc5557 Fix Clang warnings 2020-12-05 23:20:02 -06:00
Cameron Gutman ac6630ef59 Add AppVeyor CI builds 2020-12-05 20:12:14 -06:00
Cameron Gutman 0ead0df2a1 Remove usage of long types for LP64 and LLP64 consistency 2020-12-05 16:51:03 -06:00
Cameron Gutman 333382ae74 Use stdint types for ByteBuffer 2020-11-30 22:03:24 -06:00
28 changed files with 238 additions and 179 deletions
+37
View File
@@ -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})
+37
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
+9 -9
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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) {
+1 -5
View File
@@ -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;
@@ -39,10 +39,6 @@ extern int AudioPacketDuration;
#define isBefore24(x, y) (U24((x) - (y)) > (UINT24_MAX/2))
#define isBefore32(x, y) (U32((x) - (y)) > (UINT32_MAX/2))
#ifndef ARRAYSIZE
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
#endif
#define UDP_RECV_POLL_TIMEOUT_MS 100
// At this value or above, we will request high quality audio unless CAPABILITY_SLOW_OPUS_DECODER
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -37,7 +37,7 @@ int extractVersionQuadFromString(const char* string, int* quad) {
char* nextNumber;
int i;
strcpy_s(versionString, ARRAYSIZE(versionString), string);
strcpy(versionString, string);
nextNumber = versionString;
for (i = 0; i < 4; i++) {
+1 -3
View File
@@ -1,11 +1,9 @@
#pragma once
// Don't warn for POSIX functions like strdup
#define _CRT_NONSTDC_NO_DEPRECATE
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdatomic.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
+2 -2
View File
@@ -30,14 +30,14 @@ void addrToUrlSafeString(struct sockaddr_storage* addr, char* string)
inet_ntop(addr->ss_family, &sin6->sin6_addr, addrstr, sizeof(addrstr));
// IPv6 addresses need to be enclosed in brackets for URLs
sprintf_s(string, URLSAFESTRING_LEN, "[%s]", addrstr);
sprintf(string, "[%s]", addrstr);
}
else {
struct sockaddr_in* sin = (struct sockaddr_in*)addr;
inet_ntop(addr->ss_family, &sin->sin_addr, addrstr, sizeof(addrstr));
// IPv4 addresses are returned without changes
sprintf_s(string, URLSAFESTRING_LEN, "%s", addrstr);
sprintf(string, "%s", addrstr);
}
}
+5 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
+1 -1
View File
@@ -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;
+7 -8
View File
@@ -71,8 +71,8 @@ static bool initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target
createRtspRequest(msg, NULL, 0, command, target, "RTSP/1.0",
0, NULL, NULL, 0);
sprintf_s(sequenceNumberStr, ARRAYSIZE(sequenceNumberStr), "%d", currentSeqNumber++);
sprintf_s(clientVersionStr, ARRAYSIZE(clientVersionStr), "%d", rtspClientVersion);
sprintf(sequenceNumberStr, "%d", currentSeqNumber++);
sprintf(clientVersionStr, "%d", rtspClientVersion);
if (!addOption(msg, "CSeq", sequenceNumberStr) ||
!addOption(msg, "X-GS-ClientVersion", clientVersionStr) ||
(!useEnet && !addOption(msg, "Host", urlAddr))) {
@@ -434,7 +434,7 @@ static bool sendVideoAnnounce(PRTSP_MESSAGE response, int* error) {
request.flags |= FLAG_ALLOCATED_PAYLOAD;
request.payloadLength = payloadLength;
sprintf_s(payloadLengthStr, ARRAYSIZE(payloadLengthStr), "%d", payloadLength);
sprintf(payloadLengthStr, "%d", payloadLength);
if (!addOption(&request, "Content-length", payloadLengthStr)) {
goto FreeMessage;
}
@@ -508,7 +508,7 @@ static int parseOpusConfigurations(PRTSP_MESSAGE response) {
channelCount = CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(StreamConfig.audioConfiguration);
// Find the correct audio parameter value
sprintf_s(paramsPrefix, ARRAYSIZE(paramsPrefix), "a=fmtp:97 surround-params=%d", channelCount);
sprintf(paramsPrefix, "a=fmtp:97 surround-params=%d", channelCount);
paramStart = strstr(response->payload, paramsPrefix);
if (paramStart) {
// Skip the prefix
@@ -596,12 +596,12 @@ int performRtspHandshake(void) {
addrToUrlSafeString(&RemoteAddr, urlAddr);
}
else {
strcpy_s(urlAddr, ARRAYSIZE(urlAddr), "0.0.0.0");
strcpy(urlAddr, "0.0.0.0");
}
// Initialize global state
useEnet = (AppVersionQuad[0] >= 5) && (AppVersionQuad[0] <= 7) && (AppVersionQuad[2] < 404);
sprintf_s(rtspTargetUrl, ARRAYSIZE(rtspTargetUrl), "rtsp%s://%s:48010", useEnet ? "ru" : "", urlAddr);
sprintf(rtspTargetUrl, "rtsp%s://%s:48010", useEnet ? "ru" : "", urlAddr);
currentSeqNumber = 1;
hasSessionId = false;
@@ -740,7 +740,6 @@ int performRtspHandshake(void) {
{
RTSP_MESSAGE response;
char* sessionId;
char* tokenizerContext;
int error = -1;
if (!setupStream(&response,
@@ -771,7 +770,7 @@ int performRtspHandshake(void) {
// resolves any 454 session not found errors on
// standard RTSP server implementations.
// (i.e - sessionId = "DEADBEEFCAFE;timeout = 90")
sessionIdString = strdup(strtok_s(sessionId, ";", &tokenizerContext));
sessionIdString = strdup(strtok(sessionId, ";"));
if (sessionIdString == NULL) {
Limelog("Failed to duplicate session ID string\n");
ret = -1;
+25 -27
View File
@@ -1,4 +1,3 @@
#include "Limelight-internal.h"
#include "Rtsp.h"
// Check if String s begins with the given prefix
@@ -27,7 +26,7 @@ static int getMessageLength(PRTSP_MESSAGE msg) {
// Add length of response-specific strings
else {
char statusCodeStr[16];
sprintf_s(statusCodeStr, ARRAYSIZE(statusCodeStr), "%d", msg->message.response.statusCode);
sprintf(statusCodeStr, "%d", msg->message.response.statusCode);
count += strlen(statusCodeStr);
count += strlen(msg->message.response.statusString);
// two spaces and \r\n
@@ -54,7 +53,6 @@ static int getMessageLength(PRTSP_MESSAGE msg) {
// Given an RTSP message string rtspMessage, parse it into an RTSP_MESSAGE struct msg
int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
char* token;
char* tokenizerContext;
char* protocol;
char* endCheck;
char* target;
@@ -90,7 +88,7 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
messageBuffer[length] = 0;
// Get the first token of the message
token = strtok_s(messageBuffer, delim, &tokenizerContext);
token = strtok(messageBuffer, delim);
if (token == NULL) {
exitCode = RTSP_ERROR_MALFORMED;
goto ExitFailure;
@@ -103,7 +101,7 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
protocol = token;
// Get the status code
token = strtok_s(NULL, delim, &tokenizerContext);
token = strtok(NULL, delim);
statusCode = atoi(token);
if (token == NULL) {
exitCode = RTSP_ERROR_MALFORMED;
@@ -111,7 +109,7 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
}
// Get the status string
statusStr = strtok_s(NULL, end, &tokenizerContext);
statusStr = strtok(NULL, end);
if (statusStr == NULL) {
exitCode = RTSP_ERROR_MALFORMED;
goto ExitFailure;
@@ -126,12 +124,12 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
else {
flag = TYPE_REQUEST;
command = token;
target = strtok_s(NULL, delim, &tokenizerContext);
target = strtok(NULL, delim);
if (target == NULL) {
exitCode = RTSP_ERROR_MALFORMED;
goto ExitFailure;
}
protocol = strtok_s(NULL, delim, &tokenizerContext);
protocol = strtok(NULL, delim);
if (protocol == NULL) {
exitCode = RTSP_ERROR_MALFORMED;
goto ExitFailure;
@@ -146,7 +144,7 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) {
// Parse remaining options
while (token != NULL)
{
token = strtok_s(NULL, typeFlag == TOKEN_OPTION ? optDelim : end, &tokenizerContext);
token = strtok(NULL, typeFlag == TOKEN_OPTION ? optDelim : end);
if (token != NULL) {
if (typeFlag == TOKEN_OPTION) {
opt = token;
@@ -324,37 +322,37 @@ char* serializeRtspMessage(PRTSP_MESSAGE msg, int* serializedLength) {
if (msg->type == TYPE_REQUEST) {
// command [space]
strcpy_s(serializedMessage, size, msg->message.request.command);
strcat_s(serializedMessage, size, " ");
strcpy(serializedMessage, msg->message.request.command);
strcat(serializedMessage, " ");
// target [space]
strcat_s(serializedMessage, size, msg->message.request.target);
strcat_s(serializedMessage, size, " ");
strcat(serializedMessage, msg->message.request.target);
strcat(serializedMessage, " ");
// protocol \r\n
strcat_s(serializedMessage, size, msg->protocol);
strcat_s(serializedMessage, size, "\r\n");
strcat(serializedMessage, msg->protocol);
strcat(serializedMessage, "\r\n");
}
else {
// protocol [space]
strcpy_s(serializedMessage, size, msg->protocol);
strcat_s(serializedMessage, size, " ");
strcpy(serializedMessage, msg->protocol);
strcat(serializedMessage, " ");
// status code [space]
sprintf_s(statusCodeStr, ARRAYSIZE(statusCodeStr), "%d", msg->message.response.statusCode);
strcat_s(serializedMessage, size, statusCodeStr);
strcat_s(serializedMessage, size, " ");
sprintf(statusCodeStr, "%d", msg->message.response.statusCode);
strcat(serializedMessage, statusCodeStr);
strcat(serializedMessage, " ");
// status str\r\n
strcat_s(serializedMessage, size, msg->message.response.statusString);
strcat_s(serializedMessage, size, "\r\n");
strcat(serializedMessage, msg->message.response.statusString);
strcat(serializedMessage, "\r\n");
}
// option content\r\n
while (current != NULL) {
strcat_s(serializedMessage, size, current->option);
strcat_s(serializedMessage, size, ": ");
strcat_s(serializedMessage, size, current->content);
strcat_s(serializedMessage, size, "\r\n");
strcat(serializedMessage, current->option);
strcat(serializedMessage, ": ");
strcat(serializedMessage, current->content);
strcat(serializedMessage, "\r\n");
current = current->next;
}
// Final \r\n
strcat_s(serializedMessage, size, "\r\n");
strcat(serializedMessage, "\r\n");
// payload
if (msg->payload != NULL) {
+22 -26
View File
@@ -39,14 +39,14 @@ static int getSerializedAttributeListSize(PSDP_OPTION head) {
}
// Populate the serialized attribute list into a string
static int fillSerializedAttributeList(char* buffer, int bufferLength, PSDP_OPTION head) {
static int fillSerializedAttributeList(char* buffer, PSDP_OPTION head) {
PSDP_OPTION currentEntry = head;
int offset = 0;
while (currentEntry != NULL) {
offset += sprintf_s(&buffer[offset], bufferLength - offset, "a=%s:", currentEntry->name);
offset += sprintf(&buffer[offset], "a=%s:", currentEntry->name);
memcpy(&buffer[offset], currentEntry->payload, currentEntry->payloadLen);
offset += currentEntry->payloadLen;
offset += sprintf_s(&buffer[offset], bufferLength - offset, " \r\n");
offset += sprintf(&buffer[offset], " \r\n");
currentEntry = currentEntry->next;
}
@@ -64,7 +64,7 @@ static int addAttributeBinary(PSDP_OPTION* head, char* name, const void* payload
option->next = NULL;
option->payloadLen = payloadLen;
strcpy_s(option->name, ARRAYSIZE(option->name), name);
strcpy(option->name, name);
option->payload = (void*)(option + 1);
memcpy(option->payload, payload, payloadLen);
@@ -133,7 +133,7 @@ static int addGen4Options(PSDP_OPTION* head, char* addrStr) {
char payloadStr[92];
int err = 0;
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "rtsp://%s:48010", addrStr);
sprintf(payloadStr, "rtsp://%s:48010", addrStr);
err |= addAttributeString(head, "x-nv-general.serverAddress", payloadStr);
return err;
@@ -175,15 +175,15 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
optionHead = NULL;
err = 0;
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", StreamConfig.width);
sprintf(payloadStr, "%d", StreamConfig.width);
err |= addAttributeString(&optionHead, "x-nv-video[0].clientViewportWd", payloadStr);
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", StreamConfig.height);
sprintf(payloadStr, "%d", StreamConfig.height);
err |= addAttributeString(&optionHead, "x-nv-video[0].clientViewportHt", payloadStr);
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", StreamConfig.fps);
sprintf(payloadStr, "%d", StreamConfig.fps);
err |= addAttributeString(&optionHead, "x-nv-video[0].maxFPS", payloadStr);
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", StreamConfig.packetSize);
sprintf(payloadStr, "%d", StreamConfig.packetSize);
err |= addAttributeString(&optionHead, "x-nv-video[0].packetSize", payloadStr);
err |= addAttributeString(&optionHead, "x-nv-video[0].rateControlMode", "4");
@@ -222,7 +222,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
// settle on the optimal bitrate if it's somewhere in the middle), so we'll just latch the bitrate
// to the requested value.
if (AppVersionQuad[0] >= 5) {
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", bitrate);
sprintf(payloadStr, "%d", bitrate);
err |= addAttributeString(&optionHead, "x-nv-video[0].initialBitrateKbps", payloadStr);
err |= addAttributeString(&optionHead, "x-nv-video[0].initialPeakBitrateKbps", payloadStr);
@@ -236,7 +236,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
err |= addAttributeString(&optionHead, "x-nv-video[0].peakBitrate", "4");
}
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", bitrate);
sprintf(payloadStr, "%d", bitrate);
err |= addAttributeString(&optionHead, "x-nv-vqos[0].bw.minimumBitrate", payloadStr);
err |= addAttributeString(&optionHead, "x-nv-vqos[0].bw.maximumBitrate", payloadStr);
}
@@ -286,7 +286,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
// If not using slicing, we request 1 slice per frame
slicesPerFrame = 1;
}
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", slicesPerFrame);
sprintf(payloadStr, "%d", slicesPerFrame);
err |= addAttributeString(&optionHead, "x-nv-video[0].videoEncoderSlicesPerFrame", payloadStr);
if (NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) {
@@ -340,13 +340,13 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
err |= addAttributeString(&optionHead, "x-nv-video[0].maxNumReferenceFrames", "1");
}
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", StreamConfig.clientRefreshRateX100);
sprintf(payloadStr, "%d", StreamConfig.clientRefreshRateX100);
err |= addAttributeString(&optionHead, "x-nv-video[0].clientRefreshRateX100", payloadStr);
}
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", audioChannelCount);
sprintf(payloadStr, "%d", audioChannelCount);
err |= addAttributeString(&optionHead, "x-nv-audio.surround.numChannels", payloadStr);
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", audioChannelMask);
sprintf(payloadStr, "%d", audioChannelMask);
err |= addAttributeString(&optionHead, "x-nv-audio.surround.channelMask", payloadStr);
if (audioChannelCount > 2) {
err |= addAttributeString(&optionHead, "x-nv-audio.surround.enable", "1");
@@ -389,7 +389,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
}
}
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", AudioPacketDuration);
sprintf(payloadStr, "%d", AudioPacketDuration);
err |= addAttributeString(&optionHead, "x-nv-aqos.packetDuration", payloadStr);
}
else {
@@ -401,7 +401,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
}
if (AppVersionQuad[0] >= 7) {
sprintf_s(payloadStr, ARRAYSIZE(payloadStr), "%d", (StreamConfig.colorSpace << 1) | StreamConfig.colorRange);
sprintf(payloadStr, "%d", (StreamConfig.colorSpace << 1) | StreamConfig.colorRange);
err |= addAttributeString(&optionHead, "x-nv-video[0].encoderCscMode", payloadStr);
}
@@ -415,7 +415,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
// Populate the SDP header with required information
static int fillSdpHeader(char* buffer, int rtspClientVersion, char*urlSafeAddr) {
return sprintf_s(buffer, MAX_SDP_HEADER_LEN,
return sprintf(buffer,
"v=0\r\n"
"o=android 0 %d IN %s %s\r\n"
"s=NVIDIA Streaming Client\r\n",
@@ -426,7 +426,7 @@ static int fillSdpHeader(char* buffer, int rtspClientVersion, char*urlSafeAddr)
// Populate the SDP tail with required information
static int fillSdpTail(char* buffer) {
return sprintf_s(buffer, MAX_SDP_TAIL_LEN,
return sprintf(buffer,
"t=0 0\r\n"
"m=video %d \r\n",
AppVersionQuad[0] < 4 ? 47996 : 47998);
@@ -435,7 +435,6 @@ static int fillSdpTail(char* buffer) {
// Get the SDP attributes for the stream config
char* getSdpPayloadForStreamConfig(int rtspClientVersion, int* length) {
PSDP_OPTION attributeList;
int attributeListSize;
int offset;
char* payload;
char urlSafeAddr[URLSAFESTRING_LEN];
@@ -447,18 +446,15 @@ char* getSdpPayloadForStreamConfig(int rtspClientVersion, int* length) {
return NULL;
}
attributeListSize = getSerializedAttributeListSize(attributeList);
payload = malloc(MAX_SDP_HEADER_LEN + MAX_SDP_TAIL_LEN + attributeListSize);
payload = malloc(MAX_SDP_HEADER_LEN + MAX_SDP_TAIL_LEN +
getSerializedAttributeListSize(attributeList));
if (payload == NULL) {
freeAttributeList(attributeList);
return NULL;
}
offset = fillSdpHeader(payload, rtspClientVersion, urlSafeAddr);
// Add 1 for the null terminator (which will immediately be overwritten by fillSdpTail())
offset += fillSerializedAttributeList(&payload[offset], attributeListSize + 1, attributeList);
offset += fillSerializedAttributeList(&payload[offset], attributeList);
offset += fillSdpTail(&payload[offset]);
freeAttributeList(attributeList);
+4 -4
View File
@@ -67,7 +67,7 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un
hints.ai_protocol = IPPROTO_UDP;
hints.ai_flags = AI_ADDRCONFIG;
sprintf_s(stunPortStr, ARRAYSIZE(stunPortStr), "%u", stunPort);
sprintf(stunPortStr, "%u", stunPort);
err = getaddrinfo(stunServer, stunPortStr, &hints, &stunAddrs);
if (err != 0 || stunAddrs == NULL) {
Limelog("Failed to resolve STUN server: %d\n", err);
@@ -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;
+4 -4
View File
@@ -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
View File
@@ -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