diff --git a/limelight-common/ControlStream.cpp b/limelight-common/ControlStream.cpp index c1d1862..fd4e0ce 100644 --- a/limelight-common/ControlStream.cpp +++ b/limelight-common/ControlStream.cpp @@ -39,6 +39,8 @@ int initializeControlStream(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfigP memcpy(&streamConfig, streamConfigPtr, sizeof(*streamConfigPtr)); + PltCreateEvent(&resyncEvent); + return 0; } @@ -62,11 +64,13 @@ static PNVCTL_PACKET_HEADER readNvctlPacket(void) { } memcpy(fullPacket, &staticHeader, sizeof(staticHeader)); + if (staticHeader.payloadLength != 0) { err = recv(ctlSock, (char*) (fullPacket + 1), staticHeader.payloadLength, 0); if (err != staticHeader.payloadLength) { free(fullPacket); return NULL; } + } return fullPacket; } @@ -150,6 +154,7 @@ static void resyncThreadFunc(void* context) { payload[0] = 0; payload[1] = 0xFFFFF; + printf("Sending resync packet\n"); err = send(ctlSock, (char*) payload, sizeof(payload), 0); if (err != sizeof(payload)) { Limelog("Resync thread terminating #2\n"); @@ -183,27 +188,27 @@ int startControlStream(void) { configSize = getConfigDataSize(&streamConfig); config = allocateConfigDataForStreamConfig(&streamConfig); if (config == NULL) { - return NULL; + return -1; } // Send config err = send(ctlSock, config, configSize, 0); free(config); if (err != configSize) { - return NULL; + return LastSocketError(); } // Ping pong - response = sendNoPayloadAndReceive(PTYPE_HEARTBEAT, PPAYLEN_HEARTBEAT); + response = sendNoPayloadAndReceive(PTYPE_KEEPALIVE, PPAYLEN_KEEPALIVE); if (response == NULL) { - return NULL; + return LastSocketError(); } free(response); // 1405 response = sendNoPayloadAndReceive(PTYPE_1405, PPAYLEN_1405); if (response == NULL) { - return NULL; + return LastSocketError(); } free(response); diff --git a/limelight-common/Handshake.cpp b/limelight-common/Handshake.cpp index 78c028f..f41075c 100644 --- a/limelight-common/Handshake.cpp +++ b/limelight-common/Handshake.cpp @@ -1,5 +1,6 @@ #include "PlatformSockets.h" +#include "PlatformThreads.h" const char HELLO [] = { 0x07, 0x00, 0x00, 0x00, @@ -36,6 +37,8 @@ int performHandshake(IP_ADDRESS host) { return LastSocketError(); } + enableNoDelay(s); + err = send(s, HELLO, sizeof(HELLO), 0); if (err == SOCKET_ERROR) { goto CleanupError; diff --git a/limelight-common/VideoDepacketizer.cpp b/limelight-common/VideoDepacketizer.cpp index 6afd96f..a544d3a 100644 --- a/limelight-common/VideoDepacketizer.cpp +++ b/limelight-common/VideoDepacketizer.cpp @@ -178,6 +178,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) { if (decodingAvc) { PLENTRY entry = (PLENTRY) malloc(sizeof(*entry)); if (entry != NULL) { + entry->next = NULL; entry->length = currentPos.offset - start; entry->data = (char*) malloc(entry->length); if (entry->data == NULL) {