mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Fix RTSP handshake on Gen 7 servers
This commit is contained in:
parent
faa0cba39d
commit
34ef95926e
@ -38,6 +38,24 @@ public class RtspConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getRtspVideoStreamName() {
|
||||||
|
if (context.serverGeneration >= ConnectionContext.SERVER_GENERATION_5) {
|
||||||
|
return "video/0/0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "video";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRtspAudioStreamName() {
|
||||||
|
if (context.serverGeneration >= ConnectionContext.SERVER_GENERATION_5) {
|
||||||
|
return "audio/0/0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "video";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int getRtspVersionFromContext(ConnectionContext context) {
|
public static int getRtspVersionFromContext(ConnectionContext context) {
|
||||||
switch (context.serverGeneration)
|
switch (context.serverGeneration)
|
||||||
{
|
{
|
||||||
@ -46,8 +64,13 @@ public class RtspConnection {
|
|||||||
case ConnectionContext.SERVER_GENERATION_4:
|
case ConnectionContext.SERVER_GENERATION_4:
|
||||||
return 11;
|
return 11;
|
||||||
case ConnectionContext.SERVER_GENERATION_5:
|
case ConnectionContext.SERVER_GENERATION_5:
|
||||||
default:
|
|
||||||
return 12;
|
return 12;
|
||||||
|
case ConnectionContext.SERVER_GENERATION_6:
|
||||||
|
// Gen 6 has never been seen in the wild
|
||||||
|
return 13;
|
||||||
|
case ConnectionContext.SERVER_GENERATION_7:
|
||||||
|
default:
|
||||||
|
return 14;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +164,15 @@ public class RtspConnection {
|
|||||||
if (sessionId != 0) {
|
if (sessionId != 0) {
|
||||||
m.setOption("Session", ""+sessionId);
|
m.setOption("Session", ""+sessionId);
|
||||||
}
|
}
|
||||||
m.setOption("Transport", " ");
|
if (context.serverGeneration >= ConnectionContext.SERVER_GENERATION_6) {
|
||||||
|
// It looks like GFE doesn't care what we say our port is but
|
||||||
|
// we need to give it some port to successfully complete the
|
||||||
|
// handshake process.
|
||||||
|
m.setOption("Transport", "unicast;X-GS-ClientPort=50000-50001");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m.setOption("Transport", " ");
|
||||||
|
}
|
||||||
m.setOption("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
|
m.setOption("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
|
||||||
return transactRtspMessage(m);
|
return transactRtspMessage(m);
|
||||||
}
|
}
|
||||||
@ -208,7 +239,7 @@ public class RtspConnection {
|
|||||||
// Process the RTSP DESCRIBE response
|
// Process the RTSP DESCRIBE response
|
||||||
processDescribeResponse(r);
|
processDescribeResponse(r);
|
||||||
|
|
||||||
r = setupStream("audio");
|
r = setupStream(getRtspAudioStreamName());
|
||||||
if (r.getStatusCode() != 200) {
|
if (r.getStatusCode() != 200) {
|
||||||
throw new IOException("RTSP SETUP request failed: "+r.getStatusCode());
|
throw new IOException("RTSP SETUP request failed: "+r.getStatusCode());
|
||||||
}
|
}
|
||||||
@ -216,11 +247,18 @@ public class RtspConnection {
|
|||||||
// Process the RTSP SETUP streamid=audio response
|
// Process the RTSP SETUP streamid=audio response
|
||||||
processRtspSetupAudio(r);
|
processRtspSetupAudio(r);
|
||||||
|
|
||||||
r = setupStream("video");
|
r = setupStream(getRtspVideoStreamName());
|
||||||
if (r.getStatusCode() != 200) {
|
if (r.getStatusCode() != 200) {
|
||||||
throw new IOException("RTSP SETUP request failed: "+r.getStatusCode());
|
throw new IOException("RTSP SETUP request failed: "+r.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.serverGeneration >= ConnectionContext.SERVER_GENERATION_5) {
|
||||||
|
r = setupStream("control/1/0");
|
||||||
|
if (r.getStatusCode() != 200) {
|
||||||
|
throw new IOException("RTSP SETUP request failed: "+r.getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r = sendVideoAnnounce();
|
r = sendVideoAnnounce();
|
||||||
if (r.getStatusCode() != 200) {
|
if (r.getStatusCode() != 200) {
|
||||||
throw new IOException("RTSP ANNOUNCE request failed: "+r.getStatusCode());
|
throw new IOException("RTSP ANNOUNCE request failed: "+r.getStatusCode());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user