static bool CefRintimePrepare(string[] args, string temporaryDirectoryPath) { try { string path = Directory.GetCurrentDirectory(); var runtimepath = path; var clientpath = Path.Combine(runtimepath, "cefclient.exe"); Log.InfoFormat("using client path {0}", clientpath); var resourcepath = runtimepath; var localepath = Path.Combine(resourcepath, "locales"); Log.Info("===============START================"); CefRuntime.Load(runtimepath); //using native render helper Log.Info("appending disable cache keys"); CefMainArgs cefMainArgs = new CefMainArgs(args) { }; if (parametres._enableWebRTC) { Log.Info("starting with webrtc"); } var cefApp = new WorkerCefApp(parametres._enableWebRTC, parametres._enableGPU); int exit_code = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero); if (exit_code >= 0) { Log.ErrorFormat("CefRuntime return " + exit_code); return(false); } var cefSettings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true, WindowlessRenderingEnabled = true, // BrowserSubprocessPath = clientpath, FrameworkDirPath = runtimepath, ResourcesDirPath = resourcepath, LocalesDirPath = localepath, LogFile = Path.Combine(Path.GetTempPath(), "cefruntime-" + Guid.NewGuid() + ".log"), Locale = "en-US", LogSeverity = CefLogSeverity.Error, //RemoteDebuggingPort = 8088, NoSandbox = true, //CachePath = temporaryDirectoryPath }; CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); ///////////// } catch (Exception ex) { Log.Info("EXCEPTION ON CEF INITIALIZATION:" + ex.Message + "\n" + ex.StackTrace); return(false); } return(true); }
static int Main(string[] args) { log.Info("===============START================"); //////// CEF RUNTIME try { CefRuntime.Load(); } catch (DllNotFoundException ex) { log.ErrorFormat("{0} error", ex.Message); } catch (CefRuntimeException ex) { log.ErrorFormat("{0} error", ex.Message); } catch (Exception ex) { log.ErrorFormat("{0} error", ex.Message); } int defWidth = 1280; int defHeight = 720; string defUrl = "http://test.webrtc.org"; string defFileName = "MainSharedMem"; string defInFileName = "InSharedMem"; string defOutFileName = "OutSharedMem"; bool useWebRTC = false; bool EnableGPU = false; if (args.Length > 0 && args[0] != "--type=renderer") { if (args.Length > 1) { defWidth = Int32.Parse(args[0]); defHeight = Int32.Parse(args[1]); } if (args.Length > 2) { defUrl = args[2]; } if (args.Length > 3) { defFileName = args[3]; } if (args.Length > 4) { defInFileName = args[4]; } if (args.Length > 5) { defOutFileName = args[5]; } if (args.Length > 6) { if (args[6] == "1") { useWebRTC = true; } } if (args.Length > 7) { if (args[7] == "1") { EnableGPU = true; } } } 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); try { CefMainArgs cefMainArgs; cefMainArgs = new CefMainArgs(args); var cefApp = new WorkerCefApp(useWebRTC, EnableGPU); int exit_code = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero); if (exit_code >= 0) { log.ErrorFormat("CefRuntime return " + exit_code); return(exit_code); } var cefSettings = new CefSettings { SingleProcess = false, MultiThreadedMessageLoop = true, WindowlessRenderingEnabled = true, LogSeverity = CefLogSeverity.Info, }; try { CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); } catch (CefRuntimeException ex) { log.ErrorFormat("{0} error", ex.Message); } ///////////// } catch (Exception ex) { log.Info("EXCEPTION ON CEF INITIALIZATION:" + ex.Message + "\n" + ex.StackTrace); throw; } CefWorker worker = new CefWorker(); worker.Init(defWidth, defHeight, defUrl); SharedMemServer server = new SharedMemServer(); server.Init(defWidth * defHeight * 4, defFileName); SharedCommServer inSrv = new SharedCommServer(false); //TODO: the sizes may vary, but 10k should be enough? inSrv.InitComm(10000, defInFileName); SharedCommServer outSrv = new SharedCommServer(true); outSrv.InitComm(10000, defOutFileName); var app = new App(worker, server, inSrv, outSrv, false); while (app.IsRunning) { Application.DoEvents(); //check incoming messages and push outcoming app.CheckMessage(); } CefRuntime.Shutdown(); return(0); }