mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +00:00
Start RTSP handshake work (pending RTSPLib integration)
This commit is contained in:
parent
50733f6d7a
commit
caa6a203ed
@ -7,7 +7,7 @@ static CONNECTION_LISTENER_CALLBACKS ListenerCallbacks;
|
|||||||
static const char* stageNames[STAGE_MAX] = {
|
static const char* stageNames[STAGE_MAX] = {
|
||||||
"none",
|
"none",
|
||||||
"platform initialization",
|
"platform initialization",
|
||||||
"handshake",
|
"RTSP handshake",
|
||||||
"control stream initialization",
|
"control stream initialization",
|
||||||
"video stream initialization",
|
"video stream initialization",
|
||||||
"audio stream initialization",
|
"audio stream initialization",
|
||||||
@ -71,9 +71,9 @@ void LiStopConnection(void) {
|
|||||||
stage--;
|
stage--;
|
||||||
Limelog("done\n");
|
Limelog("done\n");
|
||||||
}
|
}
|
||||||
if (stage == STAGE_HANDSHAKE) {
|
if (stage == STAGE_RTSP_HANDSHAKE) {
|
||||||
Limelog("Terminating handshake...");
|
Limelog("Terminating RTSP handshake...");
|
||||||
terminateHandshake();
|
terminateRtspHandshake();
|
||||||
stage--;
|
stage--;
|
||||||
Limelog("done\n");
|
Limelog("done\n");
|
||||||
}
|
}
|
||||||
@ -112,17 +112,17 @@ int LiStartConnection(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, PCONN
|
|||||||
ListenerCallbacks.stageComplete(STAGE_PLATFORM_INIT);
|
ListenerCallbacks.stageComplete(STAGE_PLATFORM_INIT);
|
||||||
Limelog("done\n");
|
Limelog("done\n");
|
||||||
|
|
||||||
Limelog("Starting handshake...");
|
Limelog("Starting RTSP handshake...");
|
||||||
ListenerCallbacks.stageStarting(STAGE_HANDSHAKE);
|
ListenerCallbacks.stageStarting(STAGE_RTSP_HANDSHAKE);
|
||||||
err = performHandshake(host);
|
err = performRtspHandshake(host, streamConfig);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Limelog("failed: %d\n", err);
|
Limelog("failed: %d\n", err);
|
||||||
ListenerCallbacks.stageFailed(STAGE_HANDSHAKE, err);
|
ListenerCallbacks.stageFailed(STAGE_RTSP_HANDSHAKE, err);
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
stage++;
|
stage++;
|
||||||
LC_ASSERT(stage == STAGE_HANDSHAKE);
|
LC_ASSERT(stage == STAGE_RTSP_HANDSHAKE);
|
||||||
ListenerCallbacks.stageComplete(STAGE_HANDSHAKE);
|
ListenerCallbacks.stageComplete(STAGE_RTSP_HANDSHAKE);
|
||||||
Limelog("done\n");
|
Limelog("done\n");
|
||||||
|
|
||||||
Limelog("Initializing control stream...");
|
Limelog("Initializing control stream...");
|
||||||
|
@ -17,6 +17,9 @@ void connectionDetectedFrameLoss(int startFrame, int endFrame);
|
|||||||
void connectionReceivedFrame(int frameIndex);
|
void connectionReceivedFrame(int frameIndex);
|
||||||
void connectionLostPackets(int lastReceivedPacket, int nextReceivedPacket);
|
void connectionLostPackets(int lastReceivedPacket, int nextReceivedPacket);
|
||||||
|
|
||||||
|
int performRtspHandshake(IP_ADDRESS addr, PSTREAM_CONFIGURATION streamConfigPtr);
|
||||||
|
void terminateRtspHandshake(void);
|
||||||
|
|
||||||
void initializeVideoDepacketizer(int pktSize);
|
void initializeVideoDepacketizer(int pktSize);
|
||||||
void destroyVideoDepacketizer(void);
|
void destroyVideoDepacketizer(void);
|
||||||
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length);
|
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length);
|
||||||
|
@ -55,7 +55,7 @@ typedef struct _AUDIO_RENDERER_CALLBACKS {
|
|||||||
// Use LiGetStageName() for stable stage names
|
// Use LiGetStageName() for stable stage names
|
||||||
#define STAGE_NONE 0
|
#define STAGE_NONE 0
|
||||||
#define STAGE_PLATFORM_INIT 1
|
#define STAGE_PLATFORM_INIT 1
|
||||||
#define STAGE_HANDSHAKE 2
|
#define STAGE_RTSP_HANDSHAKE 2
|
||||||
#define STAGE_CONTROL_STREAM_INIT 3
|
#define STAGE_CONTROL_STREAM_INIT 3
|
||||||
#define STAGE_VIDEO_STREAM_INIT 4
|
#define STAGE_VIDEO_STREAM_INIT 4
|
||||||
#define STAGE_AUDIO_STREAM_INIT 5
|
#define STAGE_AUDIO_STREAM_INIT 5
|
||||||
|
63
limelight-common/RtspConnection.c
Normal file
63
limelight-common/RtspConnection.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "Limelight-internal.h"
|
||||||
|
|
||||||
|
static SOCKET sock = INVALID_SOCKET;
|
||||||
|
|
||||||
|
#define RTSP_MAX_RESP_SIZE 1024
|
||||||
|
|
||||||
|
// FIXME defs
|
||||||
|
static void* transactRtspMessage(IP_ADDRESS addr, void* message) {
|
||||||
|
int err;
|
||||||
|
char responseBuffer[RTSP_MAX_RESP_SIZE];
|
||||||
|
int offset;
|
||||||
|
void* responseMsg = NULL;
|
||||||
|
|
||||||
|
sock = connectTcpSocket(addr, 48010);
|
||||||
|
if (sock == INVALID_SOCKET) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
enableNoDelay(sock);
|
||||||
|
|
||||||
|
char* serializedMessage = NULL; // FIXME
|
||||||
|
int messageLen = 0; // FIXME
|
||||||
|
|
||||||
|
// Send our message
|
||||||
|
err = send(sock, serializedMessage, messageLen, 0);
|
||||||
|
if (err == SOCKET_ERROR) {
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the response until the server closes the connection
|
||||||
|
offset = 0;
|
||||||
|
for (;;) {
|
||||||
|
err = recv(sock, &responseBuffer[offset], RTSP_MAX_RESP_SIZE - offset, 0);
|
||||||
|
if (err <= 0) {
|
||||||
|
// Done reading
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset += err;
|
||||||
|
|
||||||
|
// Warn if the RTSP message is too big
|
||||||
|
if (offset == RTSP_MAX_RESP_SIZE) {
|
||||||
|
Limelog("RTSP message too long");
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseMsg = NULL; // FIXME
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
closesocket(sock);
|
||||||
|
sock = INVALID_SOCKET;
|
||||||
|
return responseMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void terminateRtspHandshake(void) {
|
||||||
|
if (sock != INVALID_SOCKET) {
|
||||||
|
closesocket(sock);
|
||||||
|
sock = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int performRtspHandshake(IP_ADDRESS addr, PSTREAM_CONFIGURATION streamConfigPtr) {
|
||||||
|
return 0;
|
||||||
|
}
|
@ -135,6 +135,7 @@
|
|||||||
<ClCompile Include="LinkedBlockingQueue.c" />
|
<ClCompile Include="LinkedBlockingQueue.c" />
|
||||||
<ClCompile Include="PlatformSockets.c" />
|
<ClCompile Include="PlatformSockets.c" />
|
||||||
<ClCompile Include="PlatformThreads.c" />
|
<ClCompile Include="PlatformThreads.c" />
|
||||||
|
<ClCompile Include="RtspConnection.c" />
|
||||||
<ClCompile Include="SdpGenerator.c" />
|
<ClCompile Include="SdpGenerator.c" />
|
||||||
<ClCompile Include="VideoDepacketizer.c" />
|
<ClCompile Include="VideoDepacketizer.c" />
|
||||||
<ClCompile Include="VideoStream.c" />
|
<ClCompile Include="VideoStream.c" />
|
||||||
|
@ -48,6 +48,9 @@
|
|||||||
<ClCompile Include="SdpGenerator.c">
|
<ClCompile Include="SdpGenerator.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="RtspConnection.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="PlatformSockets.h">
|
<ClInclude Include="PlatformSockets.h">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user