public static void Main(string[] args) { var keyHandler = new KeyHandler(); // todo: IOC var environmentService = SwimbaitModule.GetEnvironmentService(); _multicastServer = new MulticastServer(environmentService); _multicastService = new MulticastService(environmentService); var _musicCastHost = new MusicCastHost(environmentService); //Add command line configuration source to read command line parameters. var builder = new ConfigurationBuilder(); var portsToListen = new [] { 80, EnvironmentService.SwimbaitDlnaPort, 51100 }; var urisToListen = portsToListen .ToList() .Select(p => $"http://{environmentService.IpAddress}:{p}"); var uriToListenString = string.Join(";", urisToListen); var config = builder .AddCommandLine(new[] { $"server.urls={uriToListenString}" }) .AddEnvironmentVariables() .Build(); _musicCastHost.RelayHost = IPAddress.Parse(config["Swimbait:RelayHost"]); // Dirty DI Startup._environmentService = environmentService; Startup._musicCastHost = _musicCastHost; var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .UseStartup <Startup>() .Build(); Console.WriteLine($"Starting the server. Listening on {uriToListenString}. Udp broadcasting to {environmentService.SubnetBroadcastIp}"); host.Start(); Console.WriteLine("Press 'Q' to stop the server"); Console.WriteLine("Press 'M' to send SSDP Multicast discovery"); Console.WriteLine("Press 'C' when ready to connect to the MusicCast app"); _multicastServer.Start(); keyHandler.KeyEvent += KeyHandler_KeyEvent; keyHandler.WaitForExit(); host.Dispose(); _multicastServer.Dispose(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { string localAddress = e.Parameter as string; var taskId = MulticastServerBackgroundTask.Register(); server = new MulticastServer(taskId); await server.Bind(localAddress, "224.1.0.0", "9000"); Application.Current.Suspending += OnSuspending; Application.Current.Resuming += OnResuming; }
public frmUNIcastStreamer() { InitializeComponent(); // Clear sample texts lblSubject.Text = String.Empty; lblLecturer.Text = String.Empty; lblDate.Text = String.Empty; // Fix screen position bug this.StartPosition = FormStartPosition.CenterScreen; // Load settings IniFile ini = new IniFile(Path.Combine(Environment.CurrentDirectory, IniFile)); string str = ini.IniReadValue(Section, KeyStream); if (!Address.TryParse(str, out streamAddress)) { streamAddress = DefaultStreamAddress; ini.IniWriteValue(Section, KeyStream, streamAddress.ToString()); } str = ini.IniReadValue(Section, KeyMessage); if (!Address.TryParse(str, out messageAddress)) { messageAddress = DefaultMessageAddress; ini.IniWriteValue(Section, KeyMessage, messageAddress.ToString()); } // Load DeckLink API Thread deckLinkStreamerThread = new Thread(() => { deckLinkStreamer = new DeckLinkStreamer(); // Set callback deckLinkStreamer.SetCallback(this); // Initialise API if (!deckLinkStreamer.TryInitializeAPI()) { deckLinkStreamer.SetCallback(null); MessageBox.Show(strings.errorDeckLinkDriver, strings.error); Environment.Exit(1); } deckLinkAPIVersion = deckLinkStreamer.DeckLinkAPIVersion; lblDeckLinkVersion.InvokeIfRequired(c => c.Text = deckLinkAPIVersion); }); deckLinkStreamerThread.SetApartmentState(ApartmentState.MTA); deckLinkStreamerThread.IsBackground = true; deckLinkStreamerThread.Start(); // Initialise variables, load settings duration = new TimeSpan(1, 30, 00); timeMode = 0; timer = new System.Windows.Forms.Timer(); timer.Tick += timer_Tick; tabControl.SelectedIndex = 0; progressRing.ProgressPercentage = 0; isStreaming = false; streamServer = new MulticastServer(streamAddress.IP, streamAddress.Port, TTL); messageServer = new MulticastServer(messageAddress.IP, messageAddress.Port, TTL); Thread inputMonitorThread = new Thread(() => { inputMonitor = new InputMonitor(); inputMonitor.InputPositionReceived += inputMonitor_InputPositionReceived; inputMonitor.Start(); }); inputMonitorThread.IsBackground = true; inputMonitorThread.Start(); ffmpeg = new FFmpeg(); if (ffmpeg.isAvailable) { //ffmpeg.OnLogDataReceived += ffmpeg_LogDataReceived; ffmpegVersion = ffmpeg.GetVersion(); lblFFmpegVersion.Text = ffmpegVersion; } pipeHandler = new PipeHandler(); pipeHandler.ClientConnected += pipeHandler_ClientConnected; pipeHandler.ClientDisconnected += pipeHandler_ClientDisconnected; //else //{ // MessageBox.Show(strings.errorFFmpeg, strings.error); // Environment.Exit(1); //} //performanceMonitor = new PerformanceMonitor(new string[] { "ffmpeg", "BMDStreamingServer", Process.GetCurrentProcess().ProcessName }); //performanceMonitor.PerfValuesReceived += performanceMonitor_PerfValuesReceived; //performanceMonitor.StartMonitoring(); lblVersion.Text += Application.ProductVersion; progressRing.Enabled = true; messenger = new frmMessenger(); }