Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            HdmiExtenderReceiver receiver = new HdmiExtenderReceiver(1);

            receiver.AddDevice("192.168.168.55");

            server = new VideoWebServer(18080, -1, receiver);
            server.Start();
        }
Esempio n. 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            // create a generic parser for the ApplicationArguments type
            var cmdParser = new FluentCommandLineParser <ApplicationArguments>();

            // Define application arguments
            cmdParser.Setup(arg => arg.cmd)
            .As('c', "cmd")
            .WithDescription("Run as a console application rather than a Windows Service.")
            .SetDefault(false);

            cmdParser.Setup(arg => arg.port)
            .As('p', "port")
            .WithDescription("Port to use for the output streams.")
            .SetDefault(18080);

            cmdParser.Setup(arg => arg.networkInterface)
            .As('n', "interface")
            .WithDescription("Network interface id where the input device is connected to.")
            .SetDefault(1);

            cmdParser.Setup(arg => arg.devices)
            .As('d', "devices")
            .WithDescription("Input device IPs.");

            cmdParser.Setup(arg => arg.verbose)
            .As('v', "verbose")
            .WithDescription("Print 'netdrop1' or 'netdrop2'  in the console when a frame is dropped.")
            .SetDefault(true);

            cmdParser.SetupHelp("h", "help")
            .Callback(text => Console.WriteLine(text));

            //Parse arguments
            var cmdParseResult = cmdParser.Parse(args);

            //If no errors, continue
            if (!cmdParseResult.HasErrors && !cmdParseResult.HelpCalled)
            {
                // Check whether ro run as a service or a console application
                if (cmdParser.Object.cmd)
                {
                    MainService svc = new MainService();

                    HdmiExtenderReceiver receiver = new HdmiExtenderReceiver(cmdParser.Object.networkInterface);

                    foreach (string ip in cmdParser.Object.devices)
                    {
                        receiver.AddDevice(ip);
                    }

                    VideoWebServer server = new VideoWebServer(cmdParser.Object.port, -1, receiver);
                    server.Start();

                    receiver.Start();

                    Console.WriteLine("Jpeg still image:");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("http://localhost:" + cmdParser.Object.port + "/device ip/image.jpg");
                    Console.ResetColor();
                    Console.WriteLine();
                    Console.WriteLine("Motion JPEG:");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("http://localhost:" + cmdParser.Object.port + "/device ip/image.mjpg");
                    Console.ResetColor();
                    Console.WriteLine();
                    Console.WriteLine("PCM 48kHz, Signed 32 bit, Big Endian");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("http://localhost:" + cmdParser.Object.port + "/device ip/audio.wav");
                    Console.ResetColor();
                    Console.WriteLine();
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    Console.WriteLine("Shutting down...");
                    server.Stop();
                }
                else
                {
                    ServiceBase[] ServicesToRun;
                    ServicesToRun = new ServiceBase[]
                    {
                        new MainService()
                    };
                    ServiceBase.Run(ServicesToRun);
                }
            }
        }