Minor improvements to the SAT>IP client.
This commit is contained in:
parent
f0b07ab676
commit
a1ce51519c
@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"skyscraper8": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "satip autodetect 1 V 11347 S2 22000",
|
||||
"commandLineArgs": "satip autodetect 1 V 12363 S 27500",
|
||||
"remoteDebugEnabled": false
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
|
||||
@ -76,6 +76,11 @@ namespace skyscraper8
|
||||
private IPAddress AutodetectIPAddress()
|
||||
{
|
||||
SsdpDevice firstSatIpServer = SsdpClient.GetFirstSatIpServer(1000, null);
|
||||
if (firstSatIpServer == null)
|
||||
{
|
||||
logger.WarnFormat("Didn't find any SAT>IP servers.");
|
||||
return null;
|
||||
}
|
||||
IPAddress ipAddress = firstSatIpServer.GetIpAddress();
|
||||
logger.InfoFormat("Found SAT>IP Server at {0}", ipAddress);
|
||||
return ipAddress;
|
||||
@ -98,6 +103,7 @@ namespace skyscraper8
|
||||
RtspDescribeResponse describe = rtspClient.GetDescribe(url);
|
||||
SessionDescriptionProtocol sessionDescriptionProtocol = describe.GetSessionDescriptionProtocol();
|
||||
|
||||
packetQueue = new Queue<byte[]>();
|
||||
RtspSetupResponse setup = rtspClient.GetSetup(url);
|
||||
setup.OnRtcpPacket += Setup_OnRtcpPacket;
|
||||
setup.OnRtpPacket += Setup_OnRtpPacket;
|
||||
@ -113,30 +119,44 @@ namespace skyscraper8
|
||||
|
||||
RtspPlayResponse play = rtspClient.GetPlay(setup);
|
||||
|
||||
while (!context.IsAbortConditionMet())
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
Keepalive(url);
|
||||
if (packetQueue.Count >= 1)
|
||||
{
|
||||
byte[] buffer;
|
||||
lock (packetQueue)
|
||||
{
|
||||
buffer = packetQueue.Dequeue();
|
||||
}
|
||||
context.IngestSinglePacket(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
if (context.IsAbortConditionMet())
|
||||
break;
|
||||
}
|
||||
|
||||
rtspClient.GetTeardown(setup);
|
||||
rtspClient.Dispose();
|
||||
}
|
||||
|
||||
private byte[] buffer;
|
||||
private Queue<byte[]> packetQueue;
|
||||
private ObjectStorage objectStorage;
|
||||
private DataStorage dataStorage;
|
||||
private SkyscraperContext context;
|
||||
private void Setup_OnRtpPacket(byte[] data, int length)
|
||||
{
|
||||
if (buffer == null)
|
||||
buffer = new byte[188];
|
||||
|
||||
for (int i = 12; i < length; i += 188)
|
||||
{
|
||||
Array.Clear(buffer);
|
||||
byte[] buffer = new byte[188];
|
||||
Array.Copy(data, i, buffer, 0, 188);
|
||||
context.IngestSinglePacket(buffer);
|
||||
lock (packetQueue)
|
||||
{
|
||||
packetQueue.Enqueue(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -118,16 +118,18 @@ namespace skyscraper8.SatIp
|
||||
|
||||
RtspResponseHeader response = GetResponse(request.ListHeaders(RootPath));
|
||||
RtspSetupResponse setupResponse = new RtspSetupResponse(response);
|
||||
if (response.statusCode == 200)
|
||||
switch (response.statusCode)
|
||||
{
|
||||
case 200:
|
||||
setupResponse.RtpSocket = rtpSocket;
|
||||
setupResponse.RtcpSocket = rtcpSocket;
|
||||
setupResponse.SetupListeners();
|
||||
setupResponse.Valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setupResponse.Valid = false;
|
||||
break;
|
||||
case 404:
|
||||
setupResponse.Valid = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException(setupResponse.RtspStatusCode.ToString());
|
||||
}
|
||||
return setupResponse;
|
||||
|
||||
@ -171,6 +171,8 @@ namespace skyscraper8.SimpleServiceDiscoveryProtocol
|
||||
public static SsdpDevice GetFirstSatIpServer(int timeout = 1000, IRtspCache cache = null)
|
||||
{
|
||||
List<SsdpDevice> ssdpDevices = GetSsdpDevices(1000, "urn:ses-com:device:SatIPServer:1", cache);
|
||||
if (ssdpDevices.Count == 0)
|
||||
return null;
|
||||
return ssdpDevices.First();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user