public Connection(Action destructorAction) { queue = new MediaQueue(); this.destructorAction = destructorAction; IsAlive = true; }
public static void Main(string[] args) { var logger = new Logger <Program>(); System.Net.ServicePointManager.DefaultConnectionLimit = 50; System.Net.ServicePointManager.MaxServicePoints = 50; var cmdArgs = new CmdArgs { SinkM2TcpPort = 13999, UdpPort = 1236, M2TcpConnections = 30 }; var optionSet = new OptionSet() { { "http", v => cmdArgs.IsSourceHttp = v != null }, { "port=", (int v) => cmdArgs.UdpPort = v }, { "url=", v => cmdArgs.HttpUri = v }, { "sinkhttp", v => cmdArgs.IsSinkHttp = v != null }, { "sinkhttpport=", (int v) => cmdArgs.SinkHttpPort = v }, { "sinkbuffer=", (int v) => cmdArgs.SinkBufferSize = v }, { "sinkconsole", v => cmdArgs.IsSinkConsole = v != null }, { "sinkm2tcp", v => cmdArgs.IsSinkM2Tcp = v != null }, { "sinkm2tcpport=", (int v) => cmdArgs.SinkM2TcpPort = v }, { "m2tcp", v => cmdArgs.IsSourceM2Tcp = v != null }, { "m2tcphost=", v => cmdArgs.M2TcpHost = v }, { "m2tcpport=", (int v) => cmdArgs.M2TcpPort = v }, { "m2tcpconn=", (int v) => cmdArgs.M2TcpConnections = v }, { "m2tcpreset", v => cmdArgs.M2TcpResetPackets = v != null } }; try { optionSet.Parse(args); } catch (OptionException e) { logger.Error(e.Message); return; } if (!cmdArgs.IsSinkConsole) { DisplayHelp(cmdArgs); } Thread.CurrentThread.Priority = ThreadPriority.Highest; var mediaQueue = new MediaQueue(); var connectionManager = new ConnectionManager(); var source = SourceFactory.CreateSource(cmdArgs); var sink = SinkFactory.CreateSink(cmdArgs); var buffer = new Buffer(cmdArgs.SinkBufferSize); new Thread(() => source.SourceLoop(mediaQueue)).Start(); new Thread(() => sink.SinkLoop(connectionManager)).Start(); new Distributor.Distributor().DistributionLoop(mediaQueue, connectionManager, buffer); }