Added a command-line option to tune SAT>IP servers without actually processing the stream.
This commit is contained in:
parent
fe672a54f9
commit
8de4b56c6f
@ -120,6 +120,11 @@ namespace skyscraper8.GS.GSE_BFBS
|
|||||||
if (!startIndicator && endIndicator)
|
if (!startIndicator && endIndicator)
|
||||||
gseLength -= 4;
|
gseLength -= 4;
|
||||||
|
|
||||||
|
if (span.GetAvailableBytes() < gseLength)
|
||||||
|
{
|
||||||
|
//broken gse packet, invalid length
|
||||||
|
return;
|
||||||
|
}
|
||||||
gsePacket.GseDataBytes = span.ReadBytes(gseLength);
|
gsePacket.GseDataBytes = span.ReadBytes(gseLength);
|
||||||
|
|
||||||
if (!startIndicator && endIndicator)
|
if (!startIndicator && endIndicator)
|
||||||
|
|||||||
@ -290,6 +290,15 @@ namespace skyscraper5
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args[0].ToLowerInvariant().Equals("satip-playout"))
|
||||||
|
{
|
||||||
|
QuickAndDirtySatIpClient qadsipc = new QuickAndDirtySatIpClient(args);
|
||||||
|
qadsipc.SetPlayoutMode(args);
|
||||||
|
qadsipc.Run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (args[0].ToLowerInvariant().Equals("shannon"))
|
if (args[0].ToLowerInvariant().Equals("shannon"))
|
||||||
{
|
{
|
||||||
if (args.Length != 2)
|
if (args.Length != 2)
|
||||||
@ -392,6 +401,7 @@ namespace skyscraper5
|
|||||||
Console.WriteLine(" or: .\\skyscraper8.exe \"C:\\path\\to\\file.ts\\");
|
Console.WriteLine(" or: .\\skyscraper8.exe \"C:\\path\\to\\file.ts\\");
|
||||||
Console.WriteLine(" or: .\\skyscraper8.exe \"C:\\path\\to\\my\\folder\\with\\ts\\files\\\" (for batch extraction)");
|
Console.WriteLine(" or: .\\skyscraper8.exe \"C:\\path\\to\\my\\folder\\with\\ts\\files\\\" (for batch extraction)");
|
||||||
Console.WriteLine(" or: .\\skyscraper8.exe satip IP_ADDRESS DISEQC POLARITY FREQUENCY SYSTEM SYMBOL_RATE (see README file)");
|
Console.WriteLine(" or: .\\skyscraper8.exe satip IP_ADDRESS DISEQC POLARITY FREQUENCY SYSTEM SYMBOL_RATE (see README file)");
|
||||||
|
Console.WriteLine(" or: .\\skyscraper8.exe satip-playout IP_ADDRESS DISEQC POLARITY FREQUENCY SYSTEM SYMBOL_RATE DESTINATION_PORT");
|
||||||
Console.WriteLine(" or: .\\skyscraper8.exe pcap-on - to write a configuration file that allows PCAP writing during scraping.");
|
Console.WriteLine(" or: .\\skyscraper8.exe pcap-on - to write a configuration file that allows PCAP writing during scraping.");
|
||||||
Console.WriteLine(" or: .\\skyscraper8.exe pcap-off - to write a configuration file that turns off PCAP writing during scraping.");
|
Console.WriteLine(" or: .\\skyscraper8.exe pcap-off - to write a configuration file that turns off PCAP writing during scraping.");
|
||||||
Console.WriteLine(" or: .\\skyscraper8.exe subts-on - to write a configuration file that allows extraction of nested TS.");
|
Console.WriteLine(" or: .\\skyscraper8.exe subts-on - to write a configuration file that allows extraction of nested TS.");
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"skyscraper8": {
|
"skyscraper8": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "satip-playout auto 1 V 12597 S2 45000 6970",
|
||||||
"remoteDebugEnabled": false
|
"remoteDebugEnabled": false
|
||||||
},
|
},
|
||||||
"Container (Dockerfile)": {
|
"Container (Dockerfile)": {
|
||||||
|
|||||||
@ -74,6 +74,17 @@ namespace skyscraper8
|
|||||||
symbolRate = Int32.Parse(args[6]);
|
symbolRate = Int32.Parse(args[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetPlayoutMode(string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length == 7)
|
||||||
|
{
|
||||||
|
logger.Fatal("What's the target port?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
destinationPort = int.Parse(args[7]);
|
||||||
|
playoutMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
private IPAddress AutodetectIPAddress()
|
private IPAddress AutodetectIPAddress()
|
||||||
{
|
{
|
||||||
SsdpDevice firstSatIpServer = SsdpClient.GetFirstSatIpServer(1000, null);
|
SsdpDevice firstSatIpServer = SsdpClient.GetFirstSatIpServer(1000, null);
|
||||||
@ -105,7 +116,7 @@ namespace skyscraper8
|
|||||||
SessionDescriptionProtocol sessionDescriptionProtocol = describe.GetSessionDescriptionProtocol();
|
SessionDescriptionProtocol sessionDescriptionProtocol = describe.GetSessionDescriptionProtocol();
|
||||||
|
|
||||||
packetQueue = new Queue<byte[]>();
|
packetQueue = new Queue<byte[]>();
|
||||||
RtspSetupResponse setup = rtspClient.GetSetup(url);
|
RtspSetupResponse setup = rtspClient.GetSetup(url, destinationPort);
|
||||||
if (setup.RtspStatusCode == 404)
|
if (setup.RtspStatusCode == 404)
|
||||||
{
|
{
|
||||||
logger.Fatal("Your SAT>IP server doesn't have a tuner available that can talk to the requested frequency.");
|
logger.Fatal("Your SAT>IP server doesn't have a tuner available that can talk to the requested frequency.");
|
||||||
@ -118,37 +129,59 @@ namespace skyscraper8
|
|||||||
dataStorage = new InMemoryScraperStorage();
|
dataStorage = new InMemoryScraperStorage();
|
||||||
if (objectStorage == null)
|
if (objectStorage == null)
|
||||||
objectStorage = new FilesystemStorage(new DirectoryInfo("."));
|
objectStorage = new FilesystemStorage(new DirectoryInfo("."));
|
||||||
context = new SkyscraperContext(new TsContext(), dataStorage, objectStorage);
|
if (!playoutMode)
|
||||||
context.EnableTimeout = true;
|
{
|
||||||
context.TimeoutSeconds = 60;
|
context = new SkyscraperContext(new TsContext(), dataStorage, objectStorage);
|
||||||
context.InitalizeFilterChain();
|
context.EnableTimeout = true;
|
||||||
|
context.TimeoutSeconds = 60;
|
||||||
|
context.InitalizeFilterChain();
|
||||||
|
}
|
||||||
|
|
||||||
RtspPlayResponse play = rtspClient.GetPlay(setup);
|
RtspPlayResponse play = rtspClient.GetPlay(setup);
|
||||||
DateTime lastTimestamp = DateTime.Now;
|
DateTime lastTimestamp = DateTime.Now;
|
||||||
|
bool initMessagePrinted = false;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (packetQueue.Count >= 1)
|
if (playoutMode)
|
||||||
{
|
{
|
||||||
byte[] buffer;
|
Thread.Sleep(1000);
|
||||||
lock (packetQueue)
|
Keepalive(url);
|
||||||
|
if (!initMessagePrinted)
|
||||||
{
|
{
|
||||||
buffer = packetQueue.Dequeue();
|
logger.InfoFormat("Began SAT>IP playout to port {0}", destinationPort);
|
||||||
|
initMessagePrinted = true;
|
||||||
}
|
}
|
||||||
context.IngestSinglePacket(buffer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Thread.Sleep(1);
|
if (packetQueue.Count >= 1)
|
||||||
}
|
{
|
||||||
|
byte[] buffer;
|
||||||
|
lock (packetQueue)
|
||||||
|
{
|
||||||
|
buffer = packetQueue.Dequeue();
|
||||||
|
}
|
||||||
|
context.IngestSinglePacket(buffer);
|
||||||
|
if (!initMessagePrinted)
|
||||||
|
{
|
||||||
|
logger.InfoFormat("Began SAT>IP stream.");
|
||||||
|
initMessagePrinted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (context.IsAbortConditionMet())
|
if (context.IsAbortConditionMet())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (DateTime.Now.Second != lastTimestamp.Second)
|
if (DateTime.Now.Second != lastTimestamp.Second)
|
||||||
{
|
{
|
||||||
Keepalive(url);
|
Keepalive(url);
|
||||||
lastTimestamp = DateTime.Now;
|
lastTimestamp = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +233,11 @@ namespace skyscraper8
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int rtcps;
|
private int rtcps;
|
||||||
private void Setup_OnRtcpPacket(byte[] data, int length)
|
private IPAddress destinationIp;
|
||||||
|
private int destinationPort;
|
||||||
|
private bool playoutMode;
|
||||||
|
|
||||||
|
private void Setup_OnRtcpPacket(byte[] data, int length)
|
||||||
{
|
{
|
||||||
//rtcps++;
|
//rtcps++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,16 +99,25 @@ namespace skyscraper8.SatIp
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RtspSetupResponse GetSetup(string url)
|
public RtspSetupResponse GetSetup(string url, int destinationPort = 0)
|
||||||
{
|
{
|
||||||
RtspSetupRequest request = new RtspSetupRequest();
|
RtspSetupRequest request = new RtspSetupRequest();
|
||||||
request.RequestPath = url;
|
request.RequestPath = url;
|
||||||
request.CSeq = cseqCounter++;
|
request.CSeq = cseqCounter++;
|
||||||
request.UserAgent = USER_AGENT;
|
request.UserAgent = USER_AGENT;
|
||||||
|
|
||||||
Socket rtpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
int rtpPort = 0;
|
||||||
rtpSocket.Bind(new IPEndPoint(ListenIp, 0));
|
Socket rtpSocket = null;
|
||||||
int rtpPort = GetPortFromEndPoint(rtpSocket.LocalEndPoint);
|
if (destinationPort == 0)
|
||||||
|
{
|
||||||
|
rtpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
|
rtpSocket.Bind(new IPEndPoint(ListenIp, 0));
|
||||||
|
rtpPort = GetPortFromEndPoint(rtpSocket.LocalEndPoint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rtpPort = destinationPort;
|
||||||
|
}
|
||||||
|
|
||||||
Socket rtcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
Socket rtcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
rtcpSocket.Bind(new IPEndPoint(ListenIp, 0));
|
rtcpSocket.Bind(new IPEndPoint(ListenIp, 0));
|
||||||
|
|||||||
@ -53,23 +53,29 @@ namespace skyscraper8.SatIp.RtspResponses
|
|||||||
if (listenersStarted)
|
if (listenersStarted)
|
||||||
throw new RtspException("Listener already started.");
|
throw new RtspException("Listener already started.");
|
||||||
|
|
||||||
rtpCancellation = new CancellationTokenSource();
|
if (RtpSocket != null)
|
||||||
|
{
|
||||||
|
rtpCancellation = new CancellationTokenSource();
|
||||||
|
}
|
||||||
rtcpCancellation = new CancellationTokenSource();
|
rtcpCancellation = new CancellationTokenSource();
|
||||||
|
|
||||||
Task.Run(async () =>
|
if (RtpSocket != null)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[2048];
|
Task.Run(async () =>
|
||||||
|
|
||||||
while (!rtpCancellation.IsCancellationRequested)
|
|
||||||
{
|
{
|
||||||
Array.Clear(buffer);
|
byte[] buffer = new byte[2048];
|
||||||
int result = await RtpSocket.ReceiveAsync(buffer, rtpCancellation.Token);
|
|
||||||
OnRtpPacket?.Invoke(buffer, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
exitedThread++;
|
while (!rtpCancellation.IsCancellationRequested)
|
||||||
}
|
{
|
||||||
);
|
Array.Clear(buffer);
|
||||||
|
int result = await RtpSocket.ReceiveAsync(buffer, rtpCancellation.Token);
|
||||||
|
OnRtpPacket?.Invoke(buffer, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
exitedThread++;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@ -92,8 +98,8 @@ namespace skyscraper8.SatIp.RtspResponses
|
|||||||
|
|
||||||
internal void InvokeCancellationTokens()
|
internal void InvokeCancellationTokens()
|
||||||
{
|
{
|
||||||
rtpCancellation.Cancel();
|
rtpCancellation?.Cancel();
|
||||||
rtcpCancellation.Cancel();
|
rtcpCancellation?.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event OnRtpPacket OnRtpPacket;
|
public event OnRtpPacket OnRtpPacket;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user