From 5f9f7ce4077d8ab45e17992669f12a3fe159cc15 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 30 Nov 2020 20:38:13 -0600 Subject: [PATCH] Code cleanup: use stdbool.h --- src/AudioStream.c | 18 +++---- src/ByteBuffer.c | 54 +++++++++---------- src/ByteBuffer.h | 18 +++---- src/Connection.c | 18 +++---- src/ConnectionTester.c | 4 +- src/ControlStream.c | 84 +++++++++++++++--------------- src/InputStream.c | 16 +++--- src/Limelight-internal.h | 8 +-- src/Limelight.h | 1 + src/LinkedBlockingQueue.c | 2 +- src/LinkedBlockingQueue.h | 2 +- src/Misc.c | 2 +- src/Platform.c | 24 ++++----- src/PlatformSockets.c | 39 +++++++------- src/PlatformSockets.h | 8 +-- src/PlatformThreads.h | 12 ++--- src/RtpFecQueue.c | 10 ++-- src/RtpFecQueue.h | 2 +- src/RtpReorderQueue.c | 20 +++---- src/Rtsp.h | 1 + src/RtspConnection.c | 90 ++++++++++++++++---------------- src/RtspParser.c | 15 ++---- src/SdpGenerator.c | 6 +-- src/SimpleStun.c | 4 +- src/Video.h | 2 +- src/VideoDepacketizer.c | 107 +++++++++++++++++--------------------- src/VideoStream.c | 18 +++---- 27 files changed, 286 insertions(+), 299 deletions(-) diff --git a/src/AudioStream.c b/src/AudioStream.c index 761535b..404372e 100644 --- a/src/AudioStream.c +++ b/src/AudioStream.c @@ -15,7 +15,7 @@ static PLT_THREAD decoderThread; static unsigned short lastSeq; -static int receivedDataFromPeer; +static bool receivedDataFromPeer; #define RTP_PORT 48000 @@ -42,7 +42,7 @@ void initializeAudioStream(void) { LbqInitializeLinkedBlockingQueue(&packetQueue, 30); RtpqInitializeQueue(&rtpReorderQueue, RTPQ_DEFAULT_MAX_SIZE, RTPQ_DEFAULT_QUEUE_TIME); lastSeq = 0; - receivedDataFromPeer = 0; + receivedDataFromPeer = false; } static void freePacketList(PLINKED_BLOCKING_QUEUE_ENTRY entry) { @@ -86,7 +86,7 @@ static void UdpPingThreadProc(void* context) { } } -static int queuePacketToLbq(PQUEUED_AUDIO_PACKET* packet) { +static bool queuePacketToLbq(PQUEUED_AUDIO_PACKET* packet) { int err; err = LbqOfferQueueItem(&packetQueue, *packet, &(*packet)->q.lentry); @@ -99,10 +99,10 @@ static int queuePacketToLbq(PQUEUED_AUDIO_PACKET* packet) { freePacketList(LbqFlushQueueItems(&packetQueue)); } else if (err == LBQ_INTERRUPTED) { - return 0; + return false; } - return 1; + return true; } static void decodeInputData(PQUEUED_AUDIO_PACKET packet) { @@ -124,7 +124,7 @@ static void ReceiveThreadProc(void* context) { PRTP_PACKET rtp; PQUEUED_AUDIO_PACKET packet; int queueStatus; - int useSelect; + bool useSelect; int packetsToDrop = 500 / AudioPacketDuration; int waitingForAudioMs; @@ -132,11 +132,11 @@ static void ReceiveThreadProc(void* context) { if (setNonFatalRecvTimeoutMs(rtpSocket, UDP_RECV_POLL_TIMEOUT_MS) < 0) { // SO_RCVTIMEO failed, so use select() to wait - useSelect = 1; + useSelect = true; } else { // SO_RCVTIMEO timeout set for recv() - useSelect = 0; + useSelect = false; } waitingForAudioMs = 0; @@ -181,7 +181,7 @@ static void ReceiveThreadProc(void* context) { } if (!receivedDataFromPeer) { - receivedDataFromPeer = 1; + receivedDataFromPeer = true; Limelog("Received first audio packet after %d ms\n", waitingForAudioMs); } diff --git a/src/ByteBuffer.c b/src/ByteBuffer.c index 94be4d4..e3dc6a9 100644 --- a/src/ByteBuffer.c +++ b/src/ByteBuffer.c @@ -37,32 +37,32 @@ static int byteSwapShort(PBYTE_BUFFER buff, short s) { } } -int BbAdvanceBuffer(PBYTE_BUFFER buff, int offset) { +bool BbAdvanceBuffer(PBYTE_BUFFER buff, int offset) { if (buff->position + offset > buff->length) { - return 0; + return false; } buff->position += offset; - return 1; + return true; } // Get a byte from the byte buffer -int BbGet(PBYTE_BUFFER buff, char* c) { +bool BbGet(PBYTE_BUFFER buff, char* c) { if (buff->position + sizeof(*c) > buff->length) { - return 0; + return false; } memcpy(c, &buff->buffer[buff->position], sizeof(*c)); buff->position += sizeof(*c); - return 1; + return true; } // Get a short from the byte buffer -int BbGetShort(PBYTE_BUFFER buff, short* s) { +bool BbGetShort(PBYTE_BUFFER buff, short* s) { if (buff->position + sizeof(*s) > buff->length) { - return 0; + return false; } memcpy(s, &buff->buffer[buff->position], sizeof(*s)); @@ -70,13 +70,13 @@ int BbGetShort(PBYTE_BUFFER buff, short* s) { *s = byteSwapShort(buff, *s); - return 1; + return true; } // Get an int from the byte buffer -int BbGetInt(PBYTE_BUFFER buff, int* i) { +bool BbGetInt(PBYTE_BUFFER buff, int* i) { if (buff->position + sizeof(*i) > buff->length) { - return 0; + return false; } memcpy(i, &buff->buffer[buff->position], sizeof(*i)); @@ -84,13 +84,13 @@ int BbGetInt(PBYTE_BUFFER buff, int* i) { *i = byteSwapInt(buff, *i); - return 1; + return true; } // Get a long from the byte buffer -int BbGetLong(PBYTE_BUFFER buff, long long* l) { +bool BbGetLong(PBYTE_BUFFER buff, long long* l) { if (buff->position + sizeof(*l) > buff->length) { - return 0; + return false; } memcpy(l, &buff->buffer[buff->position], sizeof(*l)); @@ -98,13 +98,13 @@ int BbGetLong(PBYTE_BUFFER buff, long long* l) { *l = byteSwapLongLong(buff, *l); - return 1; + return true; } // Put an int into the byte buffer -int BbPutInt(PBYTE_BUFFER buff, int i) { +bool BbPutInt(PBYTE_BUFFER buff, int i) { if (buff->position + sizeof(i) > buff->length) { - return 0; + return false; } i = byteSwapInt(buff, i); @@ -112,13 +112,13 @@ int BbPutInt(PBYTE_BUFFER buff, int i) { memcpy(&buff->buffer[buff->position], &i, sizeof(i)); buff->position += sizeof(i); - return 1; + return true; } // Put a long into the byte buffer -int BbPutLong(PBYTE_BUFFER buff, long long l) { +bool BbPutLong(PBYTE_BUFFER buff, long long l) { if (buff->position + sizeof(l) > buff->length) { - return 0; + return false; } l = byteSwapLongLong(buff, l); @@ -126,13 +126,13 @@ int BbPutLong(PBYTE_BUFFER buff, long long l) { memcpy(&buff->buffer[buff->position], &l, sizeof(l)); buff->position += sizeof(l); - return 1; + return true; } // Put a short into the byte buffer -int BbPutShort(PBYTE_BUFFER buff, short s) { +bool BbPutShort(PBYTE_BUFFER buff, short s) { if (buff->position + sizeof(s) > buff->length) { - return 0; + return false; } s = byteSwapShort(buff, s); @@ -140,17 +140,17 @@ int BbPutShort(PBYTE_BUFFER buff, short s) { memcpy(&buff->buffer[buff->position], &s, sizeof(s)); buff->position += sizeof(s); - return 1; + return true; } // Put a byte into the buffer -int BbPut(PBYTE_BUFFER buff, char c) { +bool BbPut(PBYTE_BUFFER buff, char c) { if (buff->position + sizeof(c) > buff->length) { - return 0; + return false; } memcpy(&buff->buffer[buff->position], &c, sizeof(c)); buff->position += sizeof(c); - return 1; + return true; } diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index fbf8f59..1d874af 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -25,14 +25,14 @@ typedef struct _BYTE_BUFFER { } BYTE_BUFFER, *PBYTE_BUFFER; void BbInitializeWrappedBuffer(PBYTE_BUFFER buff, char* data, int offset, int length, int byteOrder); -int BbAdvanceBuffer(PBYTE_BUFFER buff, int offset); +bool BbAdvanceBuffer(PBYTE_BUFFER buff, int offset); -int BbGet(PBYTE_BUFFER buff, char* c); -int BbGetShort(PBYTE_BUFFER buff, short* s); -int BbGetInt(PBYTE_BUFFER buff, int* i); -int BbGetLong(PBYTE_BUFFER buff, long long* l); +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); -int BbPutInt(PBYTE_BUFFER buff, int i); -int BbPutShort(PBYTE_BUFFER buff, short s); -int BbPut(PBYTE_BUFFER buff, char c); -int BbPutLong(PBYTE_BUFFER buff, long long 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); diff --git a/src/Connection.c b/src/Connection.c index 18c49dd..f1d87f6 100644 --- a/src/Connection.c +++ b/src/Connection.c @@ -3,7 +3,7 @@ static int stage = STAGE_NONE; static ConnListenerConnectionTerminated originalTerminationCallback; -static int alreadyTerminated; +static bool alreadyTerminated; static PLT_THREAD terminationCallbackThread; static int terminationCallbackErrorCode; @@ -17,9 +17,9 @@ CONNECTION_LISTENER_CALLBACKS ListenerCallbacks; DECODER_RENDERER_CALLBACKS VideoCallbacks; AUDIO_RENDERER_CALLBACKS AudioCallbacks; int NegotiatedVideoFormat; -volatile int ConnectionInterrupted; -int HighQualitySurroundSupported; -int HighQualitySurroundEnabled; +volatile bool ConnectionInterrupted; +bool HighQualitySurroundSupported; +bool HighQualitySurroundEnabled; OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig; OPUS_MULTISTREAM_CONFIGURATION HighQualityOpusConfig; int OriginalVideoBitrate; @@ -50,13 +50,13 @@ const char* LiGetStageName(int stage) { // so it is not safe to start another connection before LiStartConnection() returns. void LiInterruptConnection(void) { // Signal anyone waiting on the global interrupted flag - ConnectionInterrupted = 1; + ConnectionInterrupted = true; } // Stop the connection by undoing the step at the current stage and those before it void LiStopConnection(void) { // Disable termination callbacks now - alreadyTerminated = 1; + alreadyTerminated = true; // Set the interrupted flag LiInterruptConnection(); @@ -153,7 +153,7 @@ static void ClInternalConnectionTerminated(int errorCode) } terminationCallbackErrorCode = errorCode; - alreadyTerminated = 1; + alreadyTerminated = true; // Invoke the termination callback on a separate thread err = PltCreateThread("AsyncTerm", terminationCallbackThreadFunc, NULL, &terminationCallbackThread); @@ -235,8 +235,8 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre goto Cleanup; } - alreadyTerminated = 0; - ConnectionInterrupted = 0; + alreadyTerminated = false; + ConnectionInterrupted = false; Limelog("Initializing platform..."); ListenerCallbacks.stageStarting(STAGE_PLATFORM_INIT); diff --git a/src/ConnectionTester.c b/src/ConnectionTester.c index 6d1364e..a7b08be 100644 --- a/src/ConnectionTester.c +++ b/src/ConnectionTester.c @@ -72,7 +72,7 @@ unsigned short LiGetPortFromPortFlagIndex(int portFlagIndex) return 48010; default: - LC_ASSERT(0); + LC_ASSERT(false); return 0; } } @@ -115,7 +115,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref sockets[i] = createSocket(address.ss_family, LiGetProtocolFromPortFlagIndex(i) == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM, LiGetProtocolFromPortFlagIndex(i), - 1); + true); if (sockets[i] == INVALID_SOCKET) { err = LastSocketFail(); Limelog("Failed to create socket: %d\n", err); diff --git a/src/ControlStream.c b/src/ControlStream.c index 16be37a..142b863 100644 --- a/src/ControlStream.c +++ b/src/ControlStream.c @@ -26,7 +26,7 @@ static SOCKET ctlSock = INVALID_SOCKET; static ENetHost* client; static ENetPeer* peer; static PLT_MUTEX enetMutex; -static int usePeriodicPing; +static bool usePeriodicPing; static PLT_THREAD lossStatsThread; static PLT_THREAD invalidateRefFramesThread; @@ -35,8 +35,8 @@ static PLT_EVENT invalidateRefFramesEvent; static int lossCountSinceLastReport; static long lastGoodFrame; static long lastSeenFrame; -static int stopping; -static int disconnectPending; +static bool stopping; +static bool disconnectPending; static int intervalGoodFrameCount; static int intervalTotalFrameCount; @@ -44,7 +44,7 @@ static uint64_t intervalStartTimeMs; static int lastIntervalLossPercentage; static int lastConnectionStatusUpdate; -static int idrFrameRequired; +static bool idrFrameRequired; static LINKED_BLOCKING_QUEUE invalidReferenceFrameTuples; #define CONN_IMMEDIATE_POOR_LOSS_RATE 30 @@ -172,7 +172,7 @@ static char**preconstructedPayloads; // Initializes the control stream int initializeControlStream(void) { - stopping = 0; + stopping = false; PltCreateEvent(&invalidateRefFramesEvent); LbqInitializeLinkedBlockingQueue(&invalidReferenceFrameTuples, 20); PltCreateMutex(&enetMutex); @@ -198,11 +198,11 @@ int initializeControlStream(void) { preconstructedPayloads = (char**)preconstructedPayloadsGen7; } - idrFrameRequired = 0; + idrFrameRequired = false; lastGoodFrame = 0; lastSeenFrame = 0; lossCountSinceLastReport = 0; - disconnectPending = 0; + disconnectPending = false; intervalGoodFrameCount = 0; intervalTotalFrameCount = 0; intervalStartTimeMs = 0; @@ -250,15 +250,15 @@ void queueFrameInvalidationTuple(int startFrame, int endFrame) { if (LbqOfferQueueItem(&invalidReferenceFrameTuples, qfit, &qfit->entry) == LBQ_BOUND_EXCEEDED) { // Too many invalidation tuples, so we need an IDR frame now free(qfit); - idrFrameRequired = 1; + idrFrameRequired = true; } } else { - idrFrameRequired = 1; + idrFrameRequired = true; } } else { - idrFrameRequired = 1; + idrFrameRequired = true; } PltSetEvent(&invalidateRefFramesEvent); @@ -266,7 +266,7 @@ void queueFrameInvalidationTuple(int startFrame, int endFrame) { // Request an IDR frame on demand by the decoder void requestIdrOnDemand(void) { - idrFrameRequired = 1; + idrFrameRequired = true; PltSetEvent(&invalidateRefFramesEvent); } @@ -345,7 +345,7 @@ static PNVCTL_TCP_PACKET_HEADER readNvctlPacketTcp(void) { return fullPacket; } -static int sendMessageEnet(short ptype, short paylen, const void* payload) { +static bool sendMessageEnet(short ptype, short paylen, const void* payload) { PNVCTL_ENET_PACKET_HEADER packet; ENetPacket* enetPacket; int err; @@ -354,7 +354,7 @@ static int sendMessageEnet(short ptype, short paylen, const void* payload) { enetPacket = enet_packet_create(NULL, sizeof(*packet) + paylen, ENET_PACKET_FLAG_RELIABLE); if (enetPacket == NULL) { - return 0; + return false; } packet = (PNVCTL_ENET_PACKET_HEADER)enetPacket->data; @@ -367,17 +367,17 @@ static int sendMessageEnet(short ptype, short paylen, const void* payload) { if (err < 0) { Limelog("Failed to send ENet control packet\n"); enet_packet_destroy(enetPacket); - return 0; + return false; } PltLockMutex(&enetMutex); enet_host_flush(client); PltUnlockMutex(&enetMutex); - return 1; + return true; } -static int sendMessageTcp(short ptype, short paylen, const void* payload) { +static bool sendMessageTcp(short ptype, short paylen, const void* payload) { PNVCTL_TCP_PACKET_HEADER packet; SOCK_RET err; @@ -385,7 +385,7 @@ static int sendMessageTcp(short ptype, short paylen, const void* payload) { packet = malloc(sizeof(*packet) + paylen); if (packet == NULL) { - return 0; + return false; } packet->type = ptype; @@ -396,14 +396,14 @@ static int sendMessageTcp(short ptype, short paylen, const void* payload) { free(packet); if (err != sizeof(*packet) + paylen) { - return 0; + return false; } - return 1; + return true; } -static int sendMessageAndForget(short ptype, short paylen, const void* payload) { - int ret; +static bool sendMessageAndForget(short ptype, short paylen, const void* payload) { + bool ret; // Unlike regular sockets, ENet sockets aren't safe to invoke from multiple // threads at once. We have to synchronize them with a lock. @@ -417,29 +417,29 @@ static int sendMessageAndForget(short ptype, short paylen, const void* payload) return ret; } -static int sendMessageAndDiscardReply(short ptype, short paylen, const void* payload) { +static bool sendMessageAndDiscardReply(short ptype, short paylen, const void* payload) { if (AppVersionQuad[0] >= 5) { if (!sendMessageEnet(ptype, paylen, payload)) { - return 0; + return false; } } else { PNVCTL_TCP_PACKET_HEADER reply; if (!sendMessageTcp(ptype, paylen, payload)) { - return 0; + return false; } // Discard the response reply = readNvctlPacketTcp(); if (reply == NULL) { - return 0; + return false; } free(reply); } - return 1; + return true; } // This intercept function drops disconnect events to allow us to process @@ -452,7 +452,7 @@ static int ignoreDisconnectIntercept(ENetHost* host, ENetEvent* event) { if ((disconnect->header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_DISCONNECT) { Limelog("ENet disconnect event pending\n"); - disconnectPending = 1; + disconnectPending = true; if (event) { event->type = ENET_EVENT_TYPE_NONE; } @@ -750,7 +750,7 @@ static void invalidateRefFramesFunc(void* context) { } // Send an IDR frame request - idrFrameRequired = 0; + idrFrameRequired = false; requestIdrFrame(); } else { @@ -762,7 +762,7 @@ static void invalidateRefFramesFunc(void* context) { // Stops the control stream int stopControlStream(void) { - stopping = 1; + stopping = true; LbqSignalQueueShutdown(&invalidReferenceFrameTuples); PltSetEvent(&invalidateRefFramesEvent); @@ -830,7 +830,7 @@ int startControlStream(void) { // Create a client that can use 1 outgoing connection and 1 channel client = enet_host_create(address.address.ss_family, NULL, 1, 1, 0, 0); if (client == NULL) { - stopping = 1; + stopping = true; return -1; } @@ -839,7 +839,7 @@ int startControlStream(void) { // Connect to the host peer = enet_host_connect(client, &address, 1, 0); if (peer == NULL) { - stopping = 1; + stopping = true; enet_host_destroy(client); client = NULL; return -1; @@ -849,7 +849,7 @@ int startControlStream(void) { if (serviceEnetHost(client, &event, CONTROL_STREAM_TIMEOUT_SEC * 1000) <= 0 || event.type != ENET_EVENT_TYPE_CONNECT) { Limelog("Failed to connect to UDP port 47999\n"); - stopping = 1; + stopping = true; enet_peer_reset(peer); peer = NULL; enet_host_destroy(client); @@ -867,7 +867,7 @@ int startControlStream(void) { ctlSock = connectTcpSocket(&RemoteAddr, RemoteAddrLen, 47995, CONTROL_STREAM_TIMEOUT_SEC); if (ctlSock == INVALID_SOCKET) { - stopping = 1; + stopping = true; return LastSocketFail(); } @@ -876,7 +876,7 @@ int startControlStream(void) { err = PltCreateThread("ControlRecv", controlReceiveThreadFunc, NULL, &controlReceiveThread); if (err != 0) { - stopping = 1; + stopping = true; if (ctlSock != INVALID_SOCKET) { closeSocket(ctlSock); ctlSock = INVALID_SOCKET; @@ -896,13 +896,13 @@ int startControlStream(void) { preconstructedPayloads[IDX_START_A])) { Limelog("Start A failed: %d\n", (int)LastSocketError()); err = LastSocketFail(); - stopping = 1; + stopping = true; if (ctlSock != INVALID_SOCKET) { shutdownTcpSocket(ctlSock); } else { - ConnectionInterrupted = 1; + ConnectionInterrupted = true; } PltInterruptThread(&controlReceiveThread); @@ -928,13 +928,13 @@ int startControlStream(void) { preconstructedPayloads[IDX_START_B])) { Limelog("Start B failed: %d\n", (int)LastSocketError()); err = LastSocketFail(); - stopping = 1; + stopping = true; if (ctlSock != INVALID_SOCKET) { shutdownTcpSocket(ctlSock); } else { - ConnectionInterrupted = 1; + ConnectionInterrupted = true; } PltInterruptThread(&controlReceiveThread); @@ -956,13 +956,13 @@ int startControlStream(void) { err = PltCreateThread("LossStats", lossStatsThreadFunc, NULL, &lossStatsThread); if (err != 0) { - stopping = 1; + stopping = true; if (ctlSock != INVALID_SOCKET) { shutdownTcpSocket(ctlSock); } else { - ConnectionInterrupted = 1; + ConnectionInterrupted = true; } PltInterruptThread(&controlReceiveThread); @@ -984,13 +984,13 @@ int startControlStream(void) { err = PltCreateThread("InvRefFrames", invalidateRefFramesFunc, NULL, &invalidateRefFramesThread); if (err != 0) { - stopping = 1; + stopping = true; if (ctlSock != INVALID_SOCKET) { shutdownTcpSocket(ctlSock); } else { - ConnectionInterrupted = 1; + ConnectionInterrupted = true; } PltInterruptThread(&lossStatsThread); diff --git a/src/InputStream.c b/src/InputStream.c index 47549a0..224a3c6 100644 --- a/src/InputStream.c +++ b/src/InputStream.c @@ -8,9 +8,9 @@ static SOCKET inputSock = INVALID_SOCKET; static unsigned char currentAesIv[16]; -static int initialized; +static bool initialized; static EVP_CIPHER_CTX* cipherContext; -static int cipherInitialized; +static bool cipherInitialized; static LINKED_BLOCKING_QUEUE packetQueue; static PLT_THREAD inputSendThread; @@ -45,7 +45,7 @@ int initializeInputStream(void) { memcpy(currentAesIv, StreamConfig.remoteInputAesIv, sizeof(currentAesIv)); // Initialized on first packet - cipherInitialized = 0; + cipherInitialized = false; LbqInitializeLinkedBlockingQueue(&packetQueue, 30); @@ -58,7 +58,7 @@ void destroyInputStream(void) { if (cipherInitialized) { EVP_CIPHER_CTX_free(cipherContext); - cipherInitialized = 0; + cipherInitialized = false; } entry = LbqDestroyLinkedBlockingQueue(&packetQueue); @@ -95,7 +95,7 @@ static int encryptData(const unsigned char* plaintext, int plaintextLen, if ((cipherContext = EVP_CIPHER_CTX_new()) == NULL) { return -1; } - cipherInitialized = 1; + cipherInitialized = true; } // Gen 7 servers use 128-bit AES GCM @@ -153,7 +153,7 @@ static int encryptData(const unsigned char* plaintext, int plaintextLen, ret = -1; goto cbc_cleanup; } - cipherInitialized = 1; + cipherInitialized = true; // Prior to Gen 7, 128-bit AES CBC is used for encryption if (EVP_EncryptInit_ex(cipherContext, EVP_aes_128_cbc(), NULL, @@ -421,7 +421,7 @@ int startInputStream(void) { } // Allow input packets to be queued now - initialized = 1; + initialized = true; // GFE will not send haptics events without this magic packet first sendEnableHaptics(); @@ -432,7 +432,7 @@ int startInputStream(void) { // Stops the input stream int stopInputStream(void) { // No more packets should be queued now - initialized = 0; + initialized = false; // Signal the input send thread LbqSignalQueueShutdown(&packetQueue); diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index dc43cd1..e76012f 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -19,9 +19,9 @@ extern CONNECTION_LISTENER_CALLBACKS ListenerCallbacks; extern DECODER_RENDERER_CALLBACKS VideoCallbacks; extern AUDIO_RENDERER_CALLBACKS AudioCallbacks; extern int NegotiatedVideoFormat; -extern volatile int ConnectionInterrupted; -extern int HighQualitySurroundSupported; -extern int HighQualitySurroundEnabled; +extern volatile bool ConnectionInterrupted; +extern bool HighQualitySurroundSupported; +extern bool HighQualitySurroundEnabled; extern OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig; extern OPUS_MULTISTREAM_CONFIGURATION HighQualityOpusConfig; extern int OriginalVideoBitrate; @@ -54,7 +54,7 @@ extern int AudioPacketDuration; int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs); int extractVersionQuadFromString(const char* string, int* quad); -int isReferenceFrameInvalidationEnabled(void); +bool isReferenceFrameInvalidationEnabled(void); void* extendBuffer(void* ptr, size_t newSize); void fixupMissingCallbacks(PDECODER_RENDERER_CALLBACKS* drCallbacks, PAUDIO_RENDERER_CALLBACKS* arCallbacks, diff --git a/src/Limelight.h b/src/Limelight.h index 1fad525..744d57d 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -5,6 +5,7 @@ #pragma once #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/LinkedBlockingQueue.c b/src/LinkedBlockingQueue.c index b9be0c9..20be12a 100644 --- a/src/LinkedBlockingQueue.c +++ b/src/LinkedBlockingQueue.c @@ -52,7 +52,7 @@ int LbqInitializeLinkedBlockingQueue(PLINKED_BLOCKING_QUEUE queueHead, int sizeB } void LbqSignalQueueShutdown(PLINKED_BLOCKING_QUEUE queueHead) { - queueHead->shutdown = 1; + queueHead->shutdown = true; PltSetEvent(&queueHead->containsDataEvent); } diff --git a/src/LinkedBlockingQueue.h b/src/LinkedBlockingQueue.h index 9e6a546..7df7ff3 100644 --- a/src/LinkedBlockingQueue.h +++ b/src/LinkedBlockingQueue.h @@ -19,7 +19,7 @@ typedef struct _LINKED_BLOCKING_QUEUE { PLT_EVENT containsDataEvent; int sizeBound; int currentSize; - int shutdown; + bool shutdown; int lifetimeSize; PLINKED_BLOCKING_QUEUE_ENTRY head; PLINKED_BLOCKING_QUEUE_ENTRY tail; diff --git a/src/Misc.c b/src/Misc.c index b931a33..80b4a83 100644 --- a/src/Misc.c +++ b/src/Misc.c @@ -71,7 +71,7 @@ void* extendBuffer(void* ptr, size_t newSize) { return newBuf; } -int isReferenceFrameInvalidationEnabled(void) { +bool isReferenceFrameInvalidationEnabled(void) { LC_ASSERT(NegotiatedVideoFormat != 0); return ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H264) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) || ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC)); diff --git a/src/Platform.c b/src/Platform.c index f1d1d94..6fd7fab 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -91,7 +91,7 @@ void* ThreadProc(void* context) { ctx->entry(ctx->context); #if defined(__vita__) - ctx->thread->alive = 0; + ctx->thread->alive = false; #else free(ctx); #endif @@ -159,7 +159,7 @@ void PltLockMutex(PLT_MUTEX* mutex) { int err; err = WaitForSingleObjectEx(*mutex, INFINITE, FALSE); if (err != WAIT_OBJECT_0) { - LC_ASSERT(FALSE); + LC_ASSERT(false); } #elif defined(__vita__) sceKernelLockMutex(*mutex, 1, NULL); @@ -202,12 +202,12 @@ void PltCloseThread(PLT_THREAD* thread) { #endif } -int PltIsThreadInterrupted(PLT_THREAD* thread) { +bool PltIsThreadInterrupted(PLT_THREAD* thread) { return thread->cancelled; } void PltInterruptThread(PLT_THREAD* thread) { - thread->cancelled = 1; + thread->cancelled = true; } int PltCreateThread(const char* name, ThreadEntry entry, void* context, PLT_THREAD* thread) { @@ -222,7 +222,7 @@ int PltCreateThread(const char* name, ThreadEntry entry, void* context, PLT_THRE ctx->context = context; ctx->name = name; - thread->cancelled = 0; + thread->cancelled = false; #if defined(LC_WINDOWS) { @@ -234,7 +234,7 @@ int PltCreateThread(const char* name, ThreadEntry entry, void* context, PLT_THRE } #elif defined(__vita__) { - thread->alive = 1; + thread->alive = true; thread->context = ctx; ctx->thread = thread; thread->handle = sceKernelCreateThread(name, ThreadProc, 0, 0x40000, 0, 0, NULL); @@ -275,11 +275,11 @@ int PltCreateEvent(PLT_EVENT* event) { sceKernelDeleteMutex(event->mutex); return -1; } - event->signalled = 0; + event->signalled = false; #else pthread_mutex_init(&event->mutex, NULL); pthread_cond_init(&event->cond, NULL); - event->signalled = 0; + event->signalled = false; #endif activeEvents++; return 0; @@ -303,12 +303,12 @@ void PltSetEvent(PLT_EVENT* event) { SetEvent(*event); #elif defined(__vita__) sceKernelLockMutex(event->mutex, 1, NULL); - event->signalled = 1; + event->signalled = true; sceKernelUnlockMutex(event->mutex, 1); sceKernelSignalCondAll(event->cond); #else pthread_mutex_lock(&event->mutex); - event->signalled = 1; + event->signalled = true; pthread_mutex_unlock(&event->mutex); pthread_cond_broadcast(&event->cond); #endif @@ -318,7 +318,7 @@ void PltClearEvent(PLT_EVENT* event) { #if defined(LC_WINDOWS) ResetEvent(*event); #else - event->signalled = 0; + event->signalled = false; #endif } @@ -331,7 +331,7 @@ int PltWaitForEvent(PLT_EVENT* event) { return PLT_WAIT_SUCCESS; } else { - LC_ASSERT(0); + LC_ASSERT(false); return -1; } #elif defined(__vita__) diff --git a/src/PlatformSockets.c b/src/PlatformSockets.c index 4399719..f0ebef0 100644 --- a/src/PlatformSockets.c +++ b/src/PlatformSockets.c @@ -147,7 +147,7 @@ int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs) { #endif } -int recvUdpSocket(SOCKET s, char* buffer, int size, int useSelect) { +int recvUdpSocket(SOCKET s, char* buffer, int size, bool useSelect) { int err; do { @@ -207,7 +207,7 @@ SOCKET bindUdpSocket(int addrfamily, int bufferSize) { LC_ASSERT(addrfamily == AF_INET || addrfamily == AF_INET6); - s = createSocket(addrfamily, SOCK_DGRAM, IPPROTO_UDP, 0); + s = createSocket(addrfamily, SOCK_DGRAM, IPPROTO_UDP, false); if (s == INVALID_SOCKET) { return INVALID_SOCKET; } @@ -267,7 +267,8 @@ SOCKET bindUdpSocket(int addrfamily, int bufferSize) { return s; } -int setSocketNonBlocking(SOCKET s, int val) { +int setSocketNonBlocking(SOCKET s, bool enabled) { + int val = enabled ? 1 : 0; #if defined(__vita__) return setsockopt(s, SOL_SOCKET, SO_NONBLOCK, (char*)&val, sizeof(val)); #elif defined(FIONBIO) @@ -277,7 +278,7 @@ int setSocketNonBlocking(SOCKET s, int val) { #endif } -SOCKET createSocket(int addressFamily, int socketType, int protocol, int nonBlocking) { +SOCKET createSocket(int addressFamily, int socketType, int protocol, bool nonBlocking) { SOCKET s; s = socket(addressFamily, socketType, protocol); @@ -295,7 +296,7 @@ SOCKET createSocket(int addressFamily, int socketType, int protocol, int nonBloc #endif if (nonBlocking) { - setSocketNonBlocking(s, 1); + setSocketNonBlocking(s, true); } return s; @@ -309,7 +310,7 @@ SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen, int val; // Create a non-blocking TCP socket - s = createSocket(dstaddr->ss_family, SOCK_STREAM, IPPROTO_TCP, 1); + s = createSocket(dstaddr->ss_family, SOCK_STREAM, IPPROTO_TCP, true); if (s == INVALID_SOCKET) { return INVALID_SOCKET; } @@ -397,7 +398,7 @@ SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen, } // Disable non-blocking I/O now that the connection is established - setSocketNonBlocking(s, 0); + setSocketNonBlocking(s, false); Exit: if (err != 0) { @@ -492,20 +493,20 @@ int resolveHostName(const char* host, int family, int tcpTestPort, struct sockad return -1; } -int isInSubnetV6(struct sockaddr_in6* sin6, unsigned char* subnet, int prefixLength) { +bool isInSubnetV6(struct sockaddr_in6* sin6, unsigned char* subnet, int prefixLength) { int i; for (i = 0; i < prefixLength; i++) { unsigned char mask = 1 << (i % 8); if ((sin6->sin6_addr.s6_addr[i / 8] & mask) != (subnet[i / 8] & mask)) { - return 0; + return false; } } - return 1; + return true; } -int isPrivateNetworkAddress(struct sockaddr_storage* address) { +bool isPrivateNetworkAddress(struct sockaddr_storage* address) { // We only count IPv4 addresses as possibly private for now if (address->ss_family == AF_INET) { @@ -516,19 +517,19 @@ int isPrivateNetworkAddress(struct sockaddr_storage* address) { // 10.0.0.0/8 if ((addr & 0xFF000000) == 0x0A000000) { - return 1; + return true; } // 172.16.0.0/12 else if ((addr & 0xFFF00000) == 0xAC100000) { - return 1; + return true; } // 192.168.0.0/16 else if ((addr & 0xFFFF0000) == 0xC0A80000) { - return 1; + return true; } // 169.254.0.0/16 else if ((addr & 0xFFFF0000) == 0xA9FE0000) { - return 1; + return true; } } else if (address->ss_family == AF_INET6) { @@ -539,19 +540,19 @@ int isPrivateNetworkAddress(struct sockaddr_storage* address) { // fe80::/10 if (isInSubnetV6(sin6, linkLocalPrefix, 10)) { - return 1; + return true; } // fec0::/10 else if (isInSubnetV6(sin6, siteLocalPrefix, 10)) { - return 1; + return true; } // fc00::/7 else if (isInSubnetV6(sin6, uniqueLocalPrefix, 7)) { - return 1; + return true; } } - return 0; + return false; } // Enable platform-specific low latency options (best-effort) diff --git a/src/PlatformSockets.h b/src/PlatformSockets.h index 25d37ab..3f5b613 100644 --- a/src/PlatformSockets.h +++ b/src/PlatformSockets.h @@ -68,18 +68,18 @@ typedef socklen_t SOCKADDR_LEN; #define URLSAFESTRING_LEN (INET6_ADDRSTRLEN+2) void addrToUrlSafeString(struct sockaddr_storage* addr, char* string); -SOCKET createSocket(int addressFamily, int socketType, int protocol, int nonBlocking); +SOCKET createSocket(int addressFamily, int socketType, int protocol, bool nonBlocking); SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen, unsigned short port, int timeoutSec); int sendMtuSafe(SOCKET s, char* buffer, int size); SOCKET bindUdpSocket(int addrfamily, int bufferSize); int enableNoDelay(SOCKET s); -int setSocketNonBlocking(SOCKET s, int val); -int recvUdpSocket(SOCKET s, char* buffer, int size, int useSelect); +int setSocketNonBlocking(SOCKET s, bool enabled); +int recvUdpSocket(SOCKET s, char* buffer, int size, bool useSelect); void shutdownTcpSocket(SOCKET s); int setNonFatalRecvTimeoutMs(SOCKET s, int timeoutMs); void setRecvTimeout(SOCKET s, int timeoutSec); void closeSocket(SOCKET s); -int isPrivateNetworkAddress(struct sockaddr_storage* address); +bool isPrivateNetworkAddress(struct sockaddr_storage* address); int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs); #define TCP_PORT_MASK 0xFFFF diff --git a/src/PlatformThreads.h b/src/PlatformThreads.h index 78d11b4..a72420f 100644 --- a/src/PlatformThreads.h +++ b/src/PlatformThreads.h @@ -10,31 +10,31 @@ typedef HANDLE PLT_MUTEX; typedef HANDLE PLT_EVENT; typedef struct _PLT_THREAD { HANDLE handle; - int cancelled; + bool cancelled; } PLT_THREAD; #elif defined(__vita__) typedef int PLT_MUTEX; typedef struct _PLT_EVENT { int mutex; int cond; - int signalled; + bool signalled; } PLT_EVENT; typedef struct _PLT_THREAD { int handle; int cancelled; void *context; - int alive; + bool alive; } PLT_THREAD; #elif defined (LC_POSIX) typedef pthread_mutex_t PLT_MUTEX; typedef struct _PLT_EVENT { pthread_mutex_t mutex; pthread_cond_t cond; - int signalled; + bool signalled; } PLT_EVENT; typedef struct _PLT_THREAD { pthread_t thread; - int cancelled; + bool cancelled; } PLT_THREAD; #else #error Unsupported platform @@ -48,7 +48,7 @@ void PltUnlockMutex(PLT_MUTEX* mutex); int PltCreateThread(const char* name, ThreadEntry entry, void* context, PLT_THREAD* thread); void PltCloseThread(PLT_THREAD* thread); void PltInterruptThread(PLT_THREAD* thread); -int PltIsThreadInterrupted(PLT_THREAD* thread); +bool PltIsThreadInterrupted(PLT_THREAD* thread); void PltJoinThread(PLT_THREAD* thread); int PltCreateEvent(PLT_EVENT* event); diff --git a/src/RtpFecQueue.c b/src/RtpFecQueue.c index cc23eef..203be7e 100644 --- a/src/RtpFecQueue.c +++ b/src/RtpFecQueue.c @@ -25,7 +25,7 @@ void RtpfCleanupQueue(PRTP_FEC_QUEUE queue) { } // newEntry is contained within the packet buffer so we free the whole entry by freeing entry->packet -static int queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, int head, PRTP_PACKET packet, int length, int isParity) { +static bool queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, bool head, PRTP_PACKET packet, int length, bool isParity) { PRTPFEC_QUEUE_ENTRY entry; LC_ASSERT(!isBefore16(packet->sequenceNumber, queue->nextContiguousSequenceNumber)); @@ -41,7 +41,7 @@ static int queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, int h entry = queue->bufferHead; while (entry != NULL) { if (entry->packet->sequenceNumber == packet->sequenceNumber) { - return 0; + return false; } entry = entry->next; @@ -79,7 +79,7 @@ static int queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, int h } queue->bufferSize++; - return 1; + return true; } #define PACKET_RECOVERY_FAILURE() \ @@ -295,7 +295,7 @@ cleanup_packets: // it may be a legitimate part of the H.264 bytestream. LC_ASSERT(isBefore16(rtpPacket->sequenceNumber, queue->bufferFirstParitySequenceNumber)); - queuePacket(queue, queueEntry, 0, rtpPacket, StreamConfig.packetSize + dataOffset, 0); + queuePacket(queue, queueEntry, false, rtpPacket, StreamConfig.packetSize + dataOffset, false); } else if (packets[i] != NULL) { free(packets[i]); } @@ -464,7 +464,7 @@ int RtpfAddPacket(PRTP_FEC_QUEUE queue, PRTP_PACKET packet, int length, PRTPFEC_ LC_ASSERT((nvPacket->fecInfo & 0xFFC00000) >> 22 == queue->bufferDataPackets); LC_ASSERT((nvPacket->flags & FLAG_EOF) || length - dataOffset == StreamConfig.packetSize); - if (!queuePacket(queue, packetEntry, 0, packet, length, !isBefore16(packet->sequenceNumber, queue->bufferFirstParitySequenceNumber))) { + if (!queuePacket(queue, packetEntry, false, packet, length, !isBefore16(packet->sequenceNumber, queue->bufferFirstParitySequenceNumber))) { return RTPF_RET_REJECTED; } else { diff --git a/src/RtpFecQueue.h b/src/RtpFecQueue.h index 473d384..f01ea83 100644 --- a/src/RtpFecQueue.h +++ b/src/RtpFecQueue.h @@ -5,7 +5,7 @@ typedef struct _RTPFEC_QUEUE_ENTRY { PRTP_PACKET packet; int length; - int isParity; + bool isParity; unsigned long long receiveTimeMs; unsigned int presentationTimeMs; diff --git a/src/RtpReorderQueue.c b/src/RtpReorderQueue.c index d0267ec..78a504b 100644 --- a/src/RtpReorderQueue.c +++ b/src/RtpReorderQueue.c @@ -18,7 +18,7 @@ void RtpqCleanupQueue(PRTP_REORDER_QUEUE queue) { } // newEntry is contained within the packet buffer so we free the whole entry by freeing entry->packet -static int queuePacket(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY newEntry, int head, PRTP_PACKET packet) { +static bool queuePacket(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY newEntry, bool head, PRTP_PACKET packet) { PRTP_QUEUE_ENTRY entry; LC_ASSERT(!isBefore16(packet->sequenceNumber, queue->nextRtpSequenceNumber)); @@ -27,7 +27,7 @@ static int queuePacket(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY newEntry, int entry = queue->queueHead; while (entry != NULL) { if (entry->packet->sequenceNumber == packet->sequenceNumber) { - return 0; + return false; } entry = entry->next; @@ -64,7 +64,7 @@ static int queuePacket(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY newEntry, int } queue->queueSize++; - return 1; + return true; } static void updateOldestQueued(PRTP_REORDER_QUEUE queue) { @@ -126,7 +126,7 @@ static void removeEntry(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY entry) { } static PRTP_QUEUE_ENTRY enforceQueueConstraints(PRTP_REORDER_QUEUE queue) { - int dequeuePacket = 0; + bool dequeuePacket = false; // Empty queue is fine if (queue->queueHead == NULL) { @@ -136,7 +136,7 @@ static PRTP_QUEUE_ENTRY enforceQueueConstraints(PRTP_REORDER_QUEUE queue) { // Check that the queue's time constraint is satisfied if (PltGetMillis() - queue->oldestQueuedTimeMs > queue->maxQueueTimeMs) { Limelog("Returning RTP packet queued for too long\n"); - dequeuePacket = 1; + dequeuePacket = true; } // Check that the queue's size constraint is satisfied. We subtract one @@ -144,7 +144,7 @@ static PRTP_QUEUE_ENTRY enforceQueueConstraints(PRTP_REORDER_QUEUE queue) { // the current packet is enqueued. if (!dequeuePacket && queue->queueSize == queue->maxSize - 1) { Limelog("Returning RTP packet after queue overgrowth\n"); - dequeuePacket = 1; + dequeuePacket = true; } if (dequeuePacket) { @@ -172,7 +172,7 @@ int RtpqAddPacket(PRTP_REORDER_QUEUE queue, PRTP_PACKET packet, PRTP_QUEUE_ENTRY } else { // Queue is empty currently so we'll put this packet on there - if (!queuePacket(queue, packetEntry, 0, packet)) { + if (!queuePacket(queue, packetEntry, false, packet)) { return 0; } else { @@ -204,7 +204,7 @@ int RtpqAddPacket(PRTP_REORDER_QUEUE queue, PRTP_PACKET packet, PRTP_QUEUE_ENTRY // Queue has data inside, so we need to see where this packet fits if (packet->sequenceNumber == queue->nextRtpSequenceNumber) { // It fits in a hole where we need a packet, now we have some ready - if (!queuePacket(queue, packetEntry, 0, packet)) { + if (!queuePacket(queue, packetEntry, false, packet)) { return 0; } else { @@ -212,7 +212,7 @@ int RtpqAddPacket(PRTP_REORDER_QUEUE queue, PRTP_PACKET packet, PRTP_QUEUE_ENTRY } } else { - if (!queuePacket(queue, packetEntry, 0, packet)) { + if (!queuePacket(queue, packetEntry, false, packet)) { return 0; } else { @@ -253,4 +253,4 @@ PRTP_PACKET RtpqGetQueuedPacket(PRTP_REORDER_QUEUE queue) { // the caller will call again until it receives null return queuedEntry->packet; -} \ No newline at end of file +} diff --git a/src/Rtsp.h b/src/Rtsp.h index 76bed79..062b1c1 100644 --- a/src/Rtsp.h +++ b/src/Rtsp.h @@ -1,6 +1,7 @@ #include #include #include +#include #define TYPE_REQUEST 0 #define TYPE_RESPONSE 1 diff --git a/src/RtspConnection.c b/src/RtspConnection.c index ed71d21..faef8ce 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -8,10 +8,10 @@ static int currentSeqNumber; static char rtspTargetUrl[256]; static char* sessionIdString; -static int hasSessionId; +static bool hasSessionId; static int rtspClientVersion; static char urlAddr[URLSAFESTRING_LEN]; -static int useEnet; +static bool useEnet; static SOCKET sock = INVALID_SOCKET; static ENetHost* client; @@ -48,21 +48,21 @@ static POPTION_ITEM createOptionItem(char* option, char* content) } // Add an option to the RTSP Message -static int addOption(PRTSP_MESSAGE msg, char* option, char* content) +static bool addOption(PRTSP_MESSAGE msg, char* option, char* content) { POPTION_ITEM item = createOptionItem(option, content); if (item == NULL) { - return 0; + return false; } insertOption(&msg->options, item); msg->flags |= FLAG_ALLOCATED_OPTION_ITEMS; - return 1; + return true; } // Create an RTSP Request -static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target) +static bool initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target) { char sequenceNumberStr[16]; char clientVersionStr[16]; @@ -77,14 +77,14 @@ static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target) !addOption(msg, "X-GS-ClientVersion", clientVersionStr) || (!useEnet && !addOption(msg, "Host", urlAddr))) { freeMessage(msg); - return 0; + return false; } - return 1; + return true; } // Send RTSP message and get response over ENet -static int transactRtspMessageEnet(PRTSP_MESSAGE request, PRTSP_MESSAGE response, int expectingPayload, int* error) { +static bool transactRtspMessageEnet(PRTSP_MESSAGE request, PRTSP_MESSAGE response, bool expectingPayload, int* error) { ENetEvent event; char* serializedMessage; int messageLen; @@ -92,11 +92,11 @@ static int transactRtspMessageEnet(PRTSP_MESSAGE request, PRTSP_MESSAGE response ENetPacket* packet; char* payload; int payloadLength; - int ret; + bool ret; char* responseBuffer; *error = -1; - ret = 0; + ret = false; responseBuffer = NULL; // We're going to handle the payload separately, so temporarily set the payload to NULL @@ -183,7 +183,7 @@ static int transactRtspMessageEnet(PRTSP_MESSAGE request, PRTSP_MESSAGE response if (parseRtspMessage(response, responseBuffer, offset) == RTSP_ERROR_SUCCESS) { // Successfully parsed response - ret = 1; + ret = true; } else { Limelog("Failed to parse RTSP response\n"); @@ -208,9 +208,9 @@ Exit: } // Send RTSP message and get response over TCP -static int transactRtspMessageTcp(PRTSP_MESSAGE request, PRTSP_MESSAGE response, int expectingPayload, int* error) { +static bool transactRtspMessageTcp(PRTSP_MESSAGE request, PRTSP_MESSAGE response, bool expectingPayload, int* error) { SOCK_RET err; - int ret; + bool ret; int offset; char* serializedMessage = NULL; int messageLen; @@ -218,7 +218,7 @@ static int transactRtspMessageTcp(PRTSP_MESSAGE request, PRTSP_MESSAGE response, int responseBufferSize; *error = -1; - ret = 0; + ret = false; responseBuffer = NULL; sock = connectTcpSocket(&RemoteAddr, RemoteAddrLen, 48010, RTSP_TIMEOUT_SEC); @@ -276,7 +276,7 @@ static int transactRtspMessageTcp(PRTSP_MESSAGE request, PRTSP_MESSAGE response, if (parseRtspMessage(response, responseBuffer, offset) == RTSP_ERROR_SUCCESS) { // Successfully parsed response - ret = 1; + ret = true; } else { Limelog("Failed to parse RTSP response\n"); @@ -296,7 +296,7 @@ Exit: return ret; } -static int transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response, int expectingPayload, int* error) { +static bool transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response, bool expectingPayload, int* error) { if (useEnet) { return transactRtspMessageEnet(request, response, expectingPayload, error); } @@ -306,15 +306,15 @@ static int transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response, in } // Send RTSP OPTIONS request -static int requestOptions(PRTSP_MESSAGE response, int* error) { +static bool requestOptions(PRTSP_MESSAGE response, int* error) { RTSP_MESSAGE request; - int ret; + bool ret; *error = -1; ret = initializeRtspRequest(&request, "OPTIONS", rtspTargetUrl); - if (ret != 0) { - ret = transactRtspMessage(&request, response, 0, error); + if (ret) { + ret = transactRtspMessage(&request, response, false, error); freeMessage(&request); } @@ -322,22 +322,22 @@ static int requestOptions(PRTSP_MESSAGE response, int* error) { } // Send RTSP DESCRIBE request -static int requestDescribe(PRTSP_MESSAGE response, int* error) { +static bool requestDescribe(PRTSP_MESSAGE response, int* error) { RTSP_MESSAGE request; - int ret; + bool ret; *error = -1; ret = initializeRtspRequest(&request, "DESCRIBE", rtspTargetUrl); - if (ret != 0) { + if (ret) { if (addOption(&request, "Accept", "application/sdp") && addOption(&request, "If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT")) { - ret = transactRtspMessage(&request, response, 1, error); + ret = transactRtspMessage(&request, response, true, error); } else { - ret = 0; + ret = false; } freeMessage(&request); } @@ -346,18 +346,18 @@ static int requestDescribe(PRTSP_MESSAGE response, int* error) { } // Send RTSP SETUP request -static int setupStream(PRTSP_MESSAGE response, char* target, int* error) { +static bool setupStream(PRTSP_MESSAGE response, char* target, int* error) { RTSP_MESSAGE request; - int ret; + bool ret; char* transportValue; *error = -1; ret = initializeRtspRequest(&request, "SETUP", target); - if (ret != 0) { + if (ret) { if (hasSessionId) { if (!addOption(&request, "Session", sessionIdString)) { - ret = 0; + ret = false; goto FreeMessage; } } @@ -375,10 +375,10 @@ static int setupStream(PRTSP_MESSAGE response, char* target, int* error) { if (addOption(&request, "Transport", transportValue) && addOption(&request, "If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT")) { - ret = transactRtspMessage(&request, response, 0, error); + ret = transactRtspMessage(&request, response, false, error); } else { - ret = 0; + ret = false; } FreeMessage: @@ -389,19 +389,19 @@ static int setupStream(PRTSP_MESSAGE response, char* target, int* error) { } // Send RTSP PLAY request -static int playStream(PRTSP_MESSAGE response, char* target, int* error) { +static bool playStream(PRTSP_MESSAGE response, char* target, int* error) { RTSP_MESSAGE request; - int ret; + bool ret; *error = -1; ret = initializeRtspRequest(&request, "PLAY", target); if (ret != 0) { if (addOption(&request, "Session", sessionIdString)) { - ret = transactRtspMessage(&request, response, 0, error); + ret = transactRtspMessage(&request, response, false, error); } else { - ret = 0; + ret = false; } freeMessage(&request); } @@ -410,17 +410,17 @@ static int playStream(PRTSP_MESSAGE response, char* target, int* error) { } // Send RTSP ANNOUNCE message -static int sendVideoAnnounce(PRTSP_MESSAGE response, int* error) { +static bool sendVideoAnnounce(PRTSP_MESSAGE response, int* error) { RTSP_MESSAGE request; - int ret; + bool ret; int payloadLength; char payloadLengthStr[16]; *error = -1; ret = initializeRtspRequest(&request, "ANNOUNCE", "streamid=video"); - if (ret != 0) { - ret = 0; + if (ret) { + ret = false; if (!addOption(&request, "Session", sessionIdString) || !addOption(&request, "Content-type", "application/sdp")) { @@ -439,7 +439,7 @@ static int sendVideoAnnounce(PRTSP_MESSAGE response, int* error) { goto FreeMessage; } - ret = transactRtspMessage(&request, response, 0, error); + ret = transactRtspMessage(&request, response, false, error); FreeMessage: freeMessage(&request); @@ -484,7 +484,7 @@ static int parseOpusConfigFromParamString(char* paramStr, int channelCount, POPU // Parses the Opus configuration from an RTSP DESCRIBE response static int parseOpusConfigurations(PRTSP_MESSAGE response) { - HighQualitySurroundSupported = 0; + HighQualitySurroundSupported = false; memset(&NormalQualityOpusConfig, 0, sizeof(NormalQualityOpusConfig)); memset(&HighQualityOpusConfig, 0, sizeof(HighQualityOpusConfig)); @@ -549,7 +549,7 @@ static int parseOpusConfigurations(PRTSP_MESSAGE response) { } // We can request high quality audio - HighQualitySurroundSupported = 1; + HighQualitySurroundSupported = true; } } else { @@ -603,7 +603,7 @@ int performRtspHandshake(void) { useEnet = (AppVersionQuad[0] >= 5) && (AppVersionQuad[0] <= 7) && (AppVersionQuad[2] < 404); sprintf(rtspTargetUrl, "rtsp%s://%s:48010", useEnet ? "ru" : "", urlAddr); currentSeqNumber = 1; - hasSessionId = 0; + hasSessionId = false; switch (AppVersionQuad[0]) { case 3: @@ -777,7 +777,7 @@ int performRtspHandshake(void) { goto Exit; } - hasSessionId = 1; + hasSessionId = true; freeMessage(&response); } diff --git a/src/RtspParser.c b/src/RtspParser.c index 2aff40a..bb4cd46 100644 --- a/src/RtspParser.c +++ b/src/RtspParser.c @@ -1,13 +1,8 @@ #include "Rtsp.h" // Check if String s begins with the given prefix -static int startsWith(const char* s, const char* prefix) { - if (strncmp(s, prefix, strlen(prefix)) == 0) { - return 1; - } - else { - return 0; - } +static bool startsWith(const char* s, const char* prefix) { + return strncmp(s, prefix, strlen(prefix)) == 0; } // Gets the length of the message @@ -65,7 +60,7 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) { char* command; char* sequence; char flag; - char messageEnded = 0; + bool messageEnded = false; char* payload = NULL; char* opt = NULL; @@ -175,13 +170,13 @@ int parseRtspMessage(PRTSP_MESSAGE msg, char* rtspMessage, int length) { // See if we've hit the end of the message. The first \r is missing because it's been tokenized if (startsWith(endCheck, "\n") && endCheck[1] == '\0') { // RTSP over ENet doesn't always have the second CRLF for some reason - messageEnded = 1; + messageEnded = true; break; } else if (startsWith(endCheck, "\n\r\n")) { // We've encountered the end of the message - mark it thus - messageEnded = 1; + messageEnded = true; // The payload is the remainder of messageBuffer. If none, then payload = null if (endCheck[3] != '\0') diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index 074f823..3719845 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -365,14 +365,14 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { // Let the audio stream code know that it needs to disable coupled streams when // decoding this audio stream. - HighQualitySurroundEnabled = 1; + HighQualitySurroundEnabled = true; // Use 5 ms frames since we don't have a slow decoder AudioPacketDuration = 5; } else { err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "0"); - HighQualitySurroundEnabled = 0; + HighQualitySurroundEnabled = false; if ((AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) != 0) { // Use 20 ms packets for slow decoders to save CPU time @@ -397,7 +397,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { AudioPacketDuration = 5; // High quality audio mode not supported on legacy servers - HighQualitySurroundEnabled = 0; + HighQualitySurroundEnabled = false; } if (AppVersionQuad[0] >= 7) { diff --git a/src/SimpleStun.c b/src/SimpleStun.c index ea3fa38..f85708e 100644 --- a/src/SimpleStun.c +++ b/src/SimpleStun.c @@ -104,12 +104,12 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un // Wait UDP_RECV_POLL_TIMEOUT_MS before moving on to the next server to // avoid having to spam the other STUN servers if we find a working one. - bytesRead = recvUdpSocket(sock, resp.buf, sizeof(resp.buf), 1); + bytesRead = recvUdpSocket(sock, resp.buf, sizeof(resp.buf), true); } } else { // This waits in UDP_RECV_POLL_TIMEOUT_MS increments - bytesRead = recvUdpSocket(sock, resp.buf, sizeof(resp.buf), 1); + bytesRead = recvUdpSocket(sock, resp.buf, sizeof(resp.buf), true); } } diff --git a/src/Video.h b/src/Video.h index e596ac1..e861de9 100644 --- a/src/Video.h +++ b/src/Video.h @@ -8,7 +8,7 @@ typedef struct _QUEUED_DECODE_UNIT { } QUEUED_DECODE_UNIT, *PQUEUED_DECODE_UNIT; void completeQueuedDecodeUnit(PQUEUED_DECODE_UNIT qdu, int drStatus); -int getNextQueuedDecodeUnit(PQUEUED_DECODE_UNIT* qdu); +bool getNextQueuedDecodeUnit(PQUEUED_DECODE_UNIT* qdu); #pragma pack(push, 1) diff --git a/src/VideoDepacketizer.c b/src/VideoDepacketizer.c index 26fb8e3..5591c86 100644 --- a/src/VideoDepacketizer.c +++ b/src/VideoDepacketizer.c @@ -9,15 +9,15 @@ static int nalChainDataLength; static unsigned int nextFrameNumber; static unsigned int startFrameNumber; -static int waitingForNextSuccessfulFrame; -static int waitingForIdrFrame; +static bool waitingForNextSuccessfulFrame; +static bool waitingForIdrFrame; static unsigned int lastPacketInStream; -static int decodingFrame; -static int strictIdrFrameWait; +static bool decodingFrame; +static bool strictIdrFrameWait; static unsigned long long firstPacketReceiveTime; static unsigned int firstPacketPresentationTime; -static int dropStatePending; -static int idrFrameProcessed; +static bool dropStatePending; +static bool idrFrameProcessed; #define DR_CLEANUP -1000 @@ -43,14 +43,14 @@ void initializeVideoDepacketizer(int pktSize) { nextFrameNumber = 1; startFrameNumber = 0; - waitingForNextSuccessfulFrame = 0; - waitingForIdrFrame = 1; + waitingForNextSuccessfulFrame = false; + waitingForIdrFrame = true; lastPacketInStream = UINT32_MAX; - decodingFrame = 0; + decodingFrame = false; firstPacketReceiveTime = 0; firstPacketPresentationTime = 0; - dropStatePending = 0; - idrFrameProcessed = 0; + dropStatePending = false; + idrFrameProcessed = false; strictIdrFrameWait = !isReferenceFrameInvalidationEnabled(); } @@ -75,12 +75,12 @@ static void dropFrameState(void) { LC_ASSERT(!decodingFrame); // We're dropping frame state now - dropStatePending = 0; + dropStatePending = false; // We'll need an IDR frame now if we're in strict mode // or if we've never seen one before if (strictIdrFrameWait || !idrFrameProcessed) { - waitingForIdrFrame = 1; + waitingForIdrFrame = true; } // Count the number of consecutive frames dropped @@ -94,7 +94,7 @@ static void dropFrameState(void) { consecutiveFrameDrops = 0; // Request an IDR frame - waitingForIdrFrame = 1; + waitingForIdrFrame = true; requestIdrOnDemand(); } @@ -125,25 +125,21 @@ void destroyVideoDepacketizer(void) { cleanupFrameState(); } -// Returns 1 if candidate is a frame start and 0 otherwise -static int isSeqFrameStart(PBUFFER_DESC candidate) { +static bool isSeqFrameStart(PBUFFER_DESC candidate) { return (candidate->length == 4 && candidate->data[candidate->offset + candidate->length - 1] == 1); } -// Returns 1 if candidate is an Annex B start and 0 otherwise -static int isSeqAnnexBStart(PBUFFER_DESC candidate) { +static bool isSeqAnnexBStart(PBUFFER_DESC candidate) { return (candidate->data[candidate->offset + candidate->length - 1] == 1); } -// Returns 1 if candidate is padding and 0 otherwise -static int isSeqPadding(PBUFFER_DESC candidate) { +static bool isSeqPadding(PBUFFER_DESC candidate) { return (candidate->data[candidate->offset + candidate->length - 1] == 0); } -// Returns 1 on success, 0 otherwise -static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) { +static bool getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) { if (current->length < 3) { - return 0; + return false; } if (current->data[current->offset] == 0 && @@ -155,14 +151,14 @@ static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) { candidate->data = current->data; candidate->offset = current->offset; candidate->length = 4; - return 1; + return true; } else { // Padding candidate->data = current->data; candidate->offset = current->offset; candidate->length = 3; - return 1; + return true; } } else if (current->data[current->offset + 2] == 1) { @@ -170,22 +166,17 @@ static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) { candidate->data = current->data; candidate->offset = current->offset; candidate->length = 3; - return 1; + return true; } } - return 0; + return false; } // Get the first decode unit available -int getNextQueuedDecodeUnit(PQUEUED_DECODE_UNIT* qdu) { +bool getNextQueuedDecodeUnit(PQUEUED_DECODE_UNIT* qdu) { int err = LbqWaitForQueueElement(&decodeUnitQueue, (void**)qdu); - if (err == LBQ_SUCCESS) { - return 1; - } - else { - return 0; - } + return (err == LBQ_SUCCESS); } // Cleanup a decode unit by freeing the buffer chain and the holder @@ -199,7 +190,7 @@ void completeQueuedDecodeUnit(PQUEUED_DECODE_UNIT qdu, int drStatus) { else if (drStatus == DR_OK && qdu->decodeUnit.frameType == FRAME_TYPE_IDR) { // Remember that the IDR frame was processed. We can now use // reference frame invalidation. - idrFrameProcessed = 1; + idrFrameProcessed = true; } while (qdu->decodeUnit.bufferList != NULL) { @@ -214,8 +205,7 @@ void completeQueuedDecodeUnit(PQUEUED_DECODE_UNIT qdu, int drStatus) { } } -// Returns 1 if the special sequence describes an I-frame -static int isSeqReferenceFrameStart(PBUFFER_DESC specialSeq) { +static bool isSeqReferenceFrameStart(PBUFFER_DESC specialSeq) { switch (specialSeq->data[specialSeq->offset + specialSeq->length]) { case 0x20: case 0x22: @@ -224,19 +214,18 @@ static int isSeqReferenceFrameStart(PBUFFER_DESC specialSeq) { case 0x28: case 0x2A: // H265 - return 1; + return true; case 0x65: // H264 - return 1; + return true; default: - return 0; + return false; } } -// Returns 1 if this buffer describes an IDR frame -static int isIdrFrameStart(PBUFFER_DESC buffer) { +static bool isIdrFrameStart(PBUFFER_DESC buffer) { BUFFER_DESC specialSeq; return getSpecialSeq(buffer, &specialSeq) && isSeqFrameStart(&specialSeq) && @@ -399,7 +388,7 @@ static void queueFragment(PLENTRY_INTERNAL* existingEntry, char* data, int offse // Process an RTP Payload using the slow path that handles multiple NALUs per packet static void processRtpPayloadSlow(PBUFFER_DESC currentPos, PLENTRY_INTERNAL* existingEntry) { BUFFER_DESC specialSeq; - int decodingVideo = 0; + bool decodingVideo = false; // We should not have any NALUs when processing the first packet in an IDR frame LC_ASSERT(nalChainHead == NULL); @@ -407,27 +396,27 @@ static void processRtpPayloadSlow(PBUFFER_DESC currentPos, PLENTRY_INTERNAL* exi while (currentPos->length != 0) { int start = currentPos->offset; - int containsPicData = 0; + bool containsPicData = false; if (getSpecialSeq(currentPos, &specialSeq)) { if (isSeqAnnexBStart(&specialSeq)) { // Now we're decoding video - decodingVideo = 1; + decodingVideo = true; if (isSeqFrameStart(&specialSeq)) { // Now we're working on a frame - decodingFrame = 1; + decodingFrame = true; if (isSeqReferenceFrameStart(&specialSeq)) { // No longer waiting for an IDR frame - waitingForIdrFrame = 0; + waitingForIdrFrame = false; // Cancel any pending IDR frame request - waitingForNextSuccessfulFrame = 0; + waitingForNextSuccessfulFrame = false; // Use the cached LENTRY for this NALU since it will be // the bulk of the data in this packet. - containsPicData = 1; + containsPicData = true; } } @@ -437,7 +426,7 @@ static void processRtpPayloadSlow(PBUFFER_DESC currentPos, PLENTRY_INTERNAL* exi } else { // Not decoding video - decodingVideo = 0; + decodingVideo = false; // Just skip this byte currentPos->length--; @@ -472,7 +461,7 @@ static void processRtpPayloadSlow(PBUFFER_DESC currentPos, PLENTRY_INTERNAL* exi // an IDR frame void requestDecoderRefresh(void) { // Wait for the next IDR frame - waitingForIdrFrame = 1; + waitingForIdrFrame = true; // Flush the decode unit queue freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue)); @@ -481,7 +470,7 @@ void requestDecoderRefresh(void) { // on the next call. We can't do it here because // it may be trying to queue DUs and we'll nuke // the state out from under it. - dropStatePending = 1; + dropStatePending = true; // Request the IDR frame requestIdrOnDemand(); @@ -535,9 +524,9 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, if (isBefore24(streamPacketIndex, U24(lastPacketInStream + 1)) || (!firstPacket && streamPacketIndex != U24(lastPacketInStream + 1))) { Limelog("Depacketizer detected corrupt frame: %d", frameIndex); - decodingFrame = 0; + decodingFrame = false; nextFrameNumber = frameIndex + 1; - waitingForNextSuccessfulFrame = 1; + waitingForNextSuccessfulFrame = true; dropFrameState(); return; } @@ -557,7 +546,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, nextFrameNumber = frameIndex; // Wait until next complete frame - waitingForNextSuccessfulFrame = 1; + waitingForNextSuccessfulFrame = true; dropFrameState(); } else { @@ -565,7 +554,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, } // We're now decoding a frame - decodingFrame = 1; + decodingFrame = true; firstPacketReceiveTime = receiveTimeMs; firstPacketPresentationTime = presentationTimeMs; } @@ -631,7 +620,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, if (flags & FLAG_EOF) { // Move on to the next frame - decodingFrame = 0; + decodingFrame = false; nextFrameNumber = frameIndex + 1; // If waiting for next successful frame and we got here @@ -639,7 +628,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, if (waitingForNextSuccessfulFrame) { // This is the next successful frame after a loss event connectionDetectedFrameLoss(startFrameNumber, frameIndex - 1); - waitingForNextSuccessfulFrame = 0; + waitingForNextSuccessfulFrame = false; } // If we need an IDR frame first, then drop this frame @@ -662,7 +651,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, // otherwise we'll lose this IDR frame without another in flight // and have to wait until we hit our consecutive drop limit to // request a new one (potentially several seconds). - dropStatePending = 0; + dropStatePending = false; } else { dropFrameState(); diff --git a/src/VideoStream.c b/src/VideoStream.c index cd3262e..ecdad94 100644 --- a/src/VideoStream.c +++ b/src/VideoStream.c @@ -20,9 +20,9 @@ static PLT_THREAD udpPingThread; static PLT_THREAD receiveThread; static PLT_THREAD decoderThread; -static int receivedDataFromPeer; +static bool receivedDataFromPeer; static uint64_t firstDataTimeMs; -static int receivedFullFrame; +static bool receivedFullFrame; // We can't request an IDR frame until the depacketizer knows // that a packet was lost. This timeout bounds the time that @@ -34,9 +34,9 @@ static int receivedFullFrame; void initializeVideoStream(void) { initializeVideoDepacketizer(StreamConfig.packetSize); RtpfInitializeQueue(&rtpQueue); //TODO RTP_QUEUE_DELAY - receivedDataFromPeer = 0; + receivedDataFromPeer = false; firstDataTimeMs = 0; - receivedFullFrame = 0; + receivedFullFrame = false; } // Clean up the video stream @@ -72,7 +72,7 @@ static void ReceiveThreadProc(void* context) { int bufferSize, receiveSize; char* buffer; int queueStatus; - int useSelect; + bool useSelect; int waitingForVideoMs; receiveSize = StreamConfig.packetSize + MAX_RTP_HEADER_SIZE; @@ -81,11 +81,11 @@ static void ReceiveThreadProc(void* context) { if (setNonFatalRecvTimeoutMs(rtpSocket, UDP_RECV_POLL_TIMEOUT_MS) < 0) { // SO_RCVTIMEO failed, so use select() to wait - useSelect = 1; + useSelect = true; } else { // SO_RCVTIMEO timeout set for recv() - useSelect = 0; + useSelect = false; } waitingForVideoMs = 0; @@ -124,7 +124,7 @@ static void ReceiveThreadProc(void* context) { } if (!receivedDataFromPeer) { - receivedDataFromPeer = 1; + receivedDataFromPeer = true; Limelog("Received first video packet after %d ms\n", waitingForVideoMs); firstDataTimeMs = PltGetMillis(); @@ -165,7 +165,7 @@ void submitFrame(PQUEUED_DECODE_UNIT qdu) { completeQueuedDecodeUnit(qdu, ret); // Remember that we got a full frame successfully - receivedFullFrame = 1; + receivedFullFrame = true; } // Decoder thread proc