static int Main(string[] args)
        {
            Log.InfoFormat("start at current directory {0}", Directory.GetCurrentDirectory());
            Log.Info("parsing command args");

            if (!ParseCommandLine(args))
            {
                Log.Error("command line parse error");
                return(0);
            }
            Log.InfoFormat("Starting plugin, settings:width:{0},height:{1},url:{2},memfile:{3},inMem:{4},outMem:{5}, WebRtc:{6},Enable GPU:{7}",
                           defWidth, defHeight, defUrl, defFileName, defInFileName, defOutFileName, useWebRTC, EnableGPU);

            Log.InfoFormat("Statring cef runtime");

            if (!CefRintimePrepare(args, temporaryDirectoryPath))
            {
                Log.Error("cef runtime initialisation failed");
                return(0); //immediate exit
            }


            try {
                Log.Info("starting cef worker");
                CefWorker worker = new CefWorker();
                worker.Init(defWidth, defHeight, defUrl);
                Log.Info("Binding shared memory");
                SharedTextureWriter server = new SharedTextureWriter(defFileName, defWidth * defHeight * 4);
                MessageReader       inSrv  = MessageReader.Create(defInFileName, 10000);
                MessageWriter       outSrv = MessageWriter.Create(defOutFileName, 10000);
                Log.Info("complete to bind shared memory, ready and wait");
                var app = new App(worker, server, inSrv, outSrv, false);
                Log.Info("Enter main loop");
                try {
                    while (app.IsRunning)
                    {
                        Application.DoEvents();
                        app.CheckMessage();     //check incoming messages
                    }
                }
                catch (Exception e) {
                    Log.ErrorFormat("abnormal exit main loop{0}", e.Message);
                }

                Log.Info("Exit main loop END DISPOSING ALL");
                worker.Dispose();
                server.Dispose();
                inSrv.Dispose();
                outSrv.Dispose();
            }
            catch (Exception e) {
                Log.ErrorFormat("Unclean exit error {0}", e.Message);
            }
            GC.Collect();
            GC.WaitForFullGCComplete(-1);
            Log.Info("CefRuntime.Shutdown");
            CefRuntime.Shutdown();
            Log.Info("Final exit");
            return(0);
        }
示例#2
0
        static int Main(string[] args)
        {
            var version = Environment.Version;

            Log.InfoFormat("start at current directory {0}", Directory.GetCurrentDirectory());
            Log.Info("parsing command args");

            if (!ParseCommandLine(args))
            {
                Log.Error("command line parse error");
                return(0);
            }
            Log.InfoFormat("Starting plugin, settings:{0}", parametres);

            Log.InfoFormat("Statring cef runtime");

            if (!CefRintimePrepare(args, temporaryDirectoryPath))
            {
                Log.Error("cef runtime initialisation failed");
                return(0); //immediate exit
            }


            try {
                Log.Info("starting cef worker");
                var worker = new CefWorker(parametres.SharedFileName);
                worker.Init(parametres);
                Log.Info("Binding shared memory");
                SharedTextureWriter server = new SharedTextureWriter(parametres.SharedFileName, parametres.TextureSize);
                MessageReader       inSrv  = MessageReader.Create(parametres.inCommFile, 10000);
                MessageWriter       outSrv = MessageWriter.Create(parametres.outCommFile, 10000);
                Log.Info("complete to bind shared memory, ready and wait");
                var app = new App(worker, server, inSrv, outSrv, false);
                Log.Info("Enter main loop");
                try {
                    while (app.IsRunning)
                    {
                        Application.DoEvents();
                        app.CheckMessage();     //check incoming messages
                    }
                }
                catch (Exception e) {
                    Log.ErrorFormat("abnormal exit main loop{0}", e.Message);
                }

                Log.Info("Exit main loop END DISPOSING ALL");
                worker.Dispose();
                server.Dispose();
                inSrv.Dispose();
                outSrv.Dispose();
            }
            catch (Exception e) {
                Log.ErrorFormat("Unclean exit error {0}", e.Message);
            }
            GC.Collect();
            GC.WaitForFullGCComplete(-1);
            Log.Info("CefRuntime.Shutdown");
            CefRuntime.Shutdown();
            Log.Info("Final exit");
            return(0);
        }