├── .gitattributes ├── .gitignore ├── CLRBrowserSourcePipe ├── CLRBrowserSourcePipe.cpp ├── CLRBrowserSourcePipe.vcxproj ├── CLRBrowserSourcePipe.vcxproj.filters └── ReadMe.txt ├── CLRBrowserSourcePlugin.sln ├── Client ├── App.config ├── BrowserApp.cs ├── CLRBrowserSourceClient.cs ├── CLRBrowserSourceClient.csproj └── Properties │ └── AssemblyInfo.cs ├── LICENSE ├── Plugin ├── BrowserSettingsPane.cs ├── BrowserSource.cs ├── BrowserSourceFactory.cs ├── CLRBrowserSourcePlugin.cs ├── CLRBrowserSourcePlugin.csproj ├── ConfigDialog.xaml ├── ConfigDialog.xaml.cs ├── Properties │ └── AssemblyInfo.cs ├── References │ └── ICSharpCode.AvalonEdit.dll ├── RemoteBrowser │ ├── AssetSchemeHandler.cs │ ├── BrowserClient.cs │ ├── BrowserDisplayHandler.cs │ ├── BrowserLifeSpanHandler.cs │ ├── BrowserLoadHandler.cs │ ├── BrowserManager.cs │ ├── BrowserPluginManager.cs │ ├── BrowserPluginVisitor.cs │ ├── BrowserRenderHandler.cs │ ├── BrowserTask.cs │ ├── BrowserWrapper.cs │ ├── MimeTypeManager.cs │ ├── RenderProcess.cs │ ├── SharedTexture.cs │ ├── SimpleDispatcher.cs │ └── StreamUtils.cs ├── SettingsPane.xaml ├── SettingsPane.xaml.cs └── Shared │ ├── BrowserApp.cs │ ├── BrowserConfig.cs │ ├── BrowserPlugin.cs │ └── BrowserSettings.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML 109 | -------------------------------------------------------------------------------- /CLRBrowserSourcePipe/CLRBrowserSourcePipe.cpp: -------------------------------------------------------------------------------- 1 | // CLRBrowserSourcePipe.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include 5 | #include 6 | #using 7 | #include 8 | 9 | using namespace System; 10 | using namespace System::Diagnostics; 11 | using namespace System::IO; 12 | 13 | using namespace msclr::interop; 14 | using namespace Xilium::CefGlue; 15 | 16 | std::wstring ToWString(System::String^ string) 17 | { 18 | return marshal_as(string); 19 | } 20 | 21 | 22 | 23 | public ref class BrowserApp : public CefApp 24 | { 25 | public: 26 | virtual void OnRegisterCustomSchemes(CefSchemeRegistrar^ registrar) override 27 | { 28 | registrar->AddCustomScheme("local", true, true, false); 29 | } 30 | }; 31 | 32 | 33 | 34 | int main(array ^args) 35 | { 36 | String^ currentDirectory = AppDomain::CurrentDomain->BaseDirectory; 37 | String^ libraryDirectory = Path::Combine(currentDirectory, L"CLRBrowserSourcePlugin"); 38 | 39 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"d3dcompiler_43.dll")).c_str()); 40 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"d3dcompiler_46.dll")).c_str()); 41 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"libGLESv2.dll")).c_str()); 42 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"libEGL.dll")).c_str()); 43 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"ffmpegsumo.dll")).c_str()); 44 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"icudt.dll")).c_str()); 45 | LoadLibrary(ToWString(Path::Combine(libraryDirectory, L"libcef.dll")).c_str()); 46 | 47 | try 48 | { 49 | try 50 | { 51 | Trace::WriteLine(String::Format("Starting browser proces with event args {0}", args)); 52 | CefMainArgs ^mainArgs = gcnew CefMainArgs(args); 53 | return CefRuntime::ExecuteProcess(mainArgs, gcnew BrowserApp()); 54 | } 55 | catch(const std::exception& stdEx) 56 | { 57 | throw gcnew System::Exception(gcnew System::String(stdEx.what())); 58 | } 59 | } 60 | catch (Exception^ ex) 61 | { 62 | Trace::Fail(String::Format("Error while running browser child event loop: {0}", ex->Message)); 63 | return 0; 64 | } 65 | catch (...) 66 | { 67 | Trace::Fail("Error while running browser child event loop: {0}"); 68 | return 0; 69 | } 70 | 71 | return 0; 72 | } 73 | 74 | int APIENTRY WinMain(HINSTANCE hInstance, 75 | HINSTANCE hPrevInstance, 76 | LPSTR lpCmdLine, 77 | int nCmdShow) 78 | { 79 | int argc; 80 | LPWSTR *argv; 81 | 82 | argv = CommandLineToArgvW(GetCommandLine(), &argc); 83 | 84 | array^ managedArgv = gcnew array(argc); 85 | for(int i = 0; i < argc; i++) { 86 | managedArgv[i] = gcnew String(argv[i]); 87 | } 88 | 89 | LocalFree(argv); 90 | 91 | return main(managedArgv); 92 | } 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /CLRBrowserSourcePipe/CLRBrowserSourcePipe.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {FA150D86-A827-44DE-8EAD-E510E759C7C5} 23 | Win32Proj 24 | CLRBrowserSourcePipe 25 | 26 | 27 | 28 | Application 29 | true 30 | Windows7.1SDK 31 | Unicode 32 | true 33 | 34 | 35 | Application 36 | true 37 | Windows7.1SDK 38 | Unicode 39 | true 40 | 41 | 42 | Application 43 | false 44 | Windows7.1SDK 45 | true 46 | Unicode 47 | true 48 | 49 | 50 | Application 51 | false 52 | Windows7.1SDK 53 | true 54 | Unicode 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | 93 | 94 | Windows 95 | true 96 | 97 | 98 | 99 | 100 | 101 | 102 | Level3 103 | Disabled 104 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 105 | 106 | 107 | Windows 108 | true 109 | 110 | 111 | 112 | 113 | Level3 114 | 115 | 116 | MaxSpeed 117 | true 118 | true 119 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | 127 | 128 | copy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\OBS\rundir\plugins\CLRHostPlugin\CLRBrowserSourcePlugin" 129 | 130 | 131 | 132 | 133 | Level3 134 | 135 | 136 | MaxSpeed 137 | true 138 | true 139 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 140 | 141 | 142 | Windows 143 | true 144 | true 145 | true 146 | 147 | 148 | copy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\OBS\rundir\plugins\CLRHostPlugin\CLRBrowserSourcePlugin" 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | {703ff300-34b9-48d4-a5d6-e741f48d5f95} 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /CLRBrowserSourcePipe/CLRBrowserSourcePipe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /CLRBrowserSourcePipe/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : CLRBrowserSourcePipe Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this CLRBrowserSourcePipe application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your CLRBrowserSourcePipe application. 9 | 10 | 11 | CLRBrowserSourcePipe.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | CLRBrowserSourcePipe.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | CLRBrowserSourcePipe.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named CLRBrowserSourcePipe.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /CLRBrowserSourcePlugin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CLRBrowserSourcePlugin", "Plugin\CLRBrowserSourcePlugin.csproj", "{2C4D3528-0D34-4679-B507-5F7953BB07B0}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CLRBrowserSourceClient", "Client\CLRBrowserSourceClient.csproj", "{A12F6229-68CB-4EC1-A318-17FAA0386CE6}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefGlue", "..\xilium.cefglue\CefGlue\CefGlue.csproj", "{703FF300-34B9-48D4-A5D6-E741F48D5F95}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|x86 = Debug|x86 16 | Release|Any CPU = Release|Any CPU 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Debug|x86.ActiveCfg = Debug|x86 23 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Debug|x86.Build.0 = Debug|x86 24 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Release|x86.ActiveCfg = Release|x86 27 | {2C4D3528-0D34-4679-B507-5F7953BB07B0}.Release|x86.Build.0 = Release|x86 28 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Debug|x86.ActiveCfg = Debug|x86 31 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Debug|x86.Build.0 = Debug|x86 32 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Release|x86.ActiveCfg = Release|x86 35 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6}.Release|x86.Build.0 = Release|x86 36 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Debug|x86.ActiveCfg = Debug|Any CPU 39 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {703FF300-34B9-48D4-A5D6-E741F48D5F95}.Release|x86.ActiveCfg = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /Client/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Client/BrowserApp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xilium.CefGlue; 8 | 9 | namespace CLRBrowserSourcePlugin.Shared 10 | { 11 | internal class BrowserApp : CefApp 12 | { 13 | private BrowserRenderProcessHandler renderProcessHandler; 14 | 15 | public BrowserApp() 16 | { 17 | renderProcessHandler = new BrowserRenderProcessHandler(); 18 | } 19 | 20 | protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar) 21 | { 22 | registrar.AddCustomScheme("http", true, true, false); 23 | registrar.AddCustomScheme("local", true, true, false); 24 | } 25 | 26 | private class BrowserRenderProcessHandler : CefRenderProcessHandler 27 | { 28 | protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message) 29 | { 30 | if (message.Name == "renderProcessIdRequest") 31 | { 32 | CefProcessMessage response = CefProcessMessage.Create("renderProcessIdResponse"); 33 | response.Arguments.SetInt(0, Process.GetCurrentProcess().Id); 34 | browser.SendProcessMessage(CefProcessId.Browser, response); 35 | } 36 | 37 | return false; 38 | } 39 | } 40 | 41 | protected override CefRenderProcessHandler GetRenderProcessHandler() 42 | { 43 | return renderProcessHandler; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Client/CLRBrowserSourceClient.cs: -------------------------------------------------------------------------------- 1 | using CLRBrowserSourcePlugin.Shared; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | using Xilium.CefGlue; 13 | 14 | namespace CLRBrowserSourceClient 15 | { 16 | internal class CLRBrowserSourceClient 17 | { 18 | [DllImport("kernel32")] 19 | public extern static int LoadLibrary(string librayName); 20 | 21 | public static string AssemblyDirectory 22 | { 23 | get 24 | { 25 | string codeBase = Assembly.GetExecutingAssembly().CodeBase; 26 | UriBuilder uri = new UriBuilder(codeBase); 27 | string path = Uri.UnescapeDataString(uri.Path); 28 | return Path.GetDirectoryName(path); 29 | } 30 | } 31 | 32 | static int Main(String[] args) 33 | { 34 | LoadLibrary(Path.Combine(AssemblyDirectory, "d3dcompiler_43.dll")); 35 | LoadLibrary(Path.Combine(AssemblyDirectory, "d3dcompiler_46.dll")); 36 | LoadLibrary(Path.Combine(AssemblyDirectory, "libGLESv2.dll")); 37 | LoadLibrary(Path.Combine(AssemblyDirectory, "libEGL.dll")); 38 | LoadLibrary(Path.Combine(AssemblyDirectory, "ffmpegsumo.dll")); 39 | LoadLibrary(Path.Combine(AssemblyDirectory, "icudt.dll")); 40 | LoadLibrary(Path.Combine(AssemblyDirectory, "libcef.dll")); 41 | 42 | CefMainArgs mainArgs = new CefMainArgs(IntPtr.Zero, args); 43 | return CefRuntime.ExecuteProcess(mainArgs, new BrowserApp(), IntPtr.Zero); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Client/CLRBrowserSourceClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A12F6229-68CB-4EC1-A318-17FAA0386CE6} 8 | WinExe 9 | Properties 10 | CLRBrowserSourceClient 11 | CLRBrowserSourceClient 12 | v4.5 13 | 512 14 | false 15 | 16 | publish\ 17 | true 18 | Disk 19 | false 20 | Foreground 21 | 7 22 | Days 23 | false 24 | false 25 | true 26 | 0 27 | 1.0.0.%2a 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | bin\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | false 41 | 42 | 43 | AnyCPU 44 | pdbonly 45 | true 46 | bin\Release\ 47 | TRACE 48 | prompt 49 | 4 50 | false 51 | 52 | 53 | true 54 | bin\x86\Debug\ 55 | DEBUG;TRACE 56 | full 57 | x86 58 | prompt 59 | ManagedMinimumRules.ruleset 60 | true 61 | 62 | 63 | bin\x86\Release\ 64 | TRACE 65 | true 66 | pdbonly 67 | x86 68 | prompt 69 | ManagedMinimumRules.ruleset 70 | true 71 | 72 | 73 | 74 | 75 | 76 | true 77 | bin\x64\Debug\ 78 | DEBUG;TRACE 79 | full 80 | x64 81 | prompt 82 | ManagedMinimumRules.ruleset 83 | false 84 | 85 | 86 | bin\x64\Release\ 87 | TRACE 88 | true 89 | pdbonly 90 | x64 91 | prompt 92 | ManagedMinimumRules.ruleset 93 | false 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | {703ff300-34b9-48d4-a5d6-e741f48d5f95} 115 | CefGlue 116 | 117 | 118 | 119 | 120 | False 121 | Microsoft .NET Framework 4.5 %28x86 and x64%29 122 | true 123 | 124 | 125 | False 126 | .NET Framework 3.5 SP1 Client Profile 127 | false 128 | 129 | 130 | False 131 | .NET Framework 3.5 SP1 132 | false 133 | 134 | 135 | 136 | 137 | {5477469E-83B1-11D2-8B49-00A0C9B7C9C4} 138 | 2 139 | 4 140 | 0 141 | tlbimp 142 | False 143 | True 144 | 145 | 146 | 147 | 148 | copy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\OBS\rundir\plugins\CLRHostPlugin\CLRBrowserSourcePlugin" 149 | 150 | 157 | -------------------------------------------------------------------------------- /Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CLRBrowserSourceClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CLRBrowserSourceClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5b637353-d488-4fd3-a673-96d2a1c5b14d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 2013 John R. Bradley 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Plugin/BrowserSettingsPane.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | using CLROBS; 9 | using CLRBrowserSourcePlugin.Shared; 10 | 11 | namespace CLRBrowserSourcePlugin 12 | { 13 | class BrowserSettingsPane : AbstractWPFSettingsPane 14 | { 15 | 16 | private SettingsPane settingsPane; 17 | 18 | public BrowserSettingsPane() 19 | { 20 | Category = "Browser"; 21 | } 22 | 23 | public override void ApplySettings() 24 | { 25 | BrowserSettings.Instance.SourceSettings.CSS = settingsPane.CSSEditor.Text; 26 | BrowserSettings.Instance.SourceSettings.Template = settingsPane.TemplateEditor.Text; 27 | BrowserSettings.Instance.SourceSettings.IsShowingAdvancedProperties = settingsPane.AdvancedPropertiesCheckBox.IsChecked.GetValueOrDefault(); 28 | 29 | BrowserSettings.Instance.Save(); 30 | } 31 | 32 | public override void CancelSettings() 33 | { 34 | BrowserSettings.Instance.Reload(); 35 | } 36 | 37 | public override UIElement CreateUIElement() 38 | { 39 | return settingsPane = new SettingsPane(); 40 | } 41 | 42 | public override bool HasDefaults() 43 | { 44 | return true; 45 | } 46 | 47 | public override void SetDefaults() 48 | { 49 | BrowserSettings.Instance.Reset(); 50 | if (settingsPane != null) 51 | { 52 | settingsPane.Reload(); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Plugin/BrowserSource.cs: -------------------------------------------------------------------------------- 1 | using CLRBrowserSourcePlugin.Browser; 2 | using CLRBrowserSourcePlugin.Shared; 3 | using CLROBS; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace CLRBrowserSourcePlugin 11 | { 12 | internal class BrowserSource : AbstractImageSource, IDisposable 13 | { 14 | private XElement configElement; 15 | private BrowserConfig browserConfig; 16 | 17 | private BrowserWrapper browser; 18 | 19 | private Dictionary textureMap; 20 | private Object textureLock = new Object(); 21 | private Texture texture; 22 | private UInt32 outputColor; 23 | 24 | private bool hasBrowser; 25 | 26 | public BrowserSource(XElement configElement) 27 | { 28 | this.configElement = configElement; 29 | this.browserConfig = new BrowserConfig(); 30 | this.textureMap = new Dictionary(); 31 | 32 | UpdateSettings(); 33 | } 34 | 35 | #region Disposable 36 | 37 | ~BrowserSource() 38 | { 39 | Dispose(false); 40 | } 41 | 42 | public void Dispose() 43 | { 44 | Dispose(true); 45 | GC.SuppressFinalize(this); 46 | } 47 | 48 | protected virtual void Dispose(bool disposing) 49 | { 50 | if (disposing) 51 | { 52 | // remove any pending texture requests 53 | lock (pendingTextureLock) 54 | { 55 | if (pendingTexture != null && pendingTexture.Texture != null) 56 | { 57 | pendingTexture.Texture.Dispose(); 58 | } 59 | pendingTexture = null; 60 | } 61 | if (browser != null) 62 | { 63 | browser.CloseBrowser(true); 64 | browser = null; 65 | } 66 | } 67 | } 68 | 69 | #endregion Disposable 70 | 71 | override public void UpdateSettings() 72 | { 73 | browserConfig.Reload(configElement); 74 | 75 | // unscaled w/h 76 | Size.X = (float)browserConfig.BrowserSourceSettings.Width; 77 | Size.Y = (float)browserConfig.BrowserSourceSettings.Height; 78 | 79 | outputColor = 0xFFFFFF | (((uint)(browserConfig.BrowserSourceSettings.Opacity * 255) & 0xFF) << 24); 80 | 81 | if (hasBrowser || browser == null) 82 | { 83 | if (browser != null) 84 | { 85 | browser.CloseBrowser(true); 86 | } 87 | browser = new BrowserWrapper(); 88 | } 89 | 90 | hasBrowser = browser.CreateBrowser(this, browserConfig); 91 | } 92 | 93 | public void RenderTexture(IntPtr textureHandle) 94 | { 95 | lock (textureLock) 96 | { 97 | Texture textureToRender; 98 | if (textureMap.TryGetValue(textureHandle, out textureToRender)) 99 | { 100 | texture = textureToRender; 101 | } 102 | } 103 | } 104 | 105 | public class TextureDesc 106 | { 107 | public UInt32 Width { get; set; } 108 | 109 | public UInt32 Height { get; set; } 110 | 111 | public Texture Texture { get; set; } 112 | } 113 | 114 | private TextureDesc pendingTexture; 115 | private Object pendingTextureLock = new Object(); 116 | 117 | public void CreateTexture(UInt32 width, UInt32 height, out IntPtr textureHandle) 118 | { 119 | // TODO : switch to shared textures when we go multiprocess 120 | //textureHandle = GS.CreateSharedTexture(width, height, GSColorFormat.GS_BGRA); 121 | lock (pendingTextureLock) 122 | { 123 | if (pendingTexture != null && pendingTexture.Width == width && pendingTexture.Height == height) 124 | { 125 | if (pendingTexture.Texture != null) 126 | { 127 | textureMap.Add(pendingTexture.Texture.OBSTexture, pendingTexture.Texture); 128 | textureHandle = pendingTexture.Texture.OBSTexture; 129 | pendingTexture = null; 130 | return; 131 | } 132 | else 133 | { 134 | textureHandle = IntPtr.Zero; 135 | return; 136 | } 137 | } 138 | else 139 | { 140 | if (pendingTexture != null) 141 | { 142 | // if we have a pending texture that was the wrong size, dispose 143 | if (pendingTexture.Texture != null) 144 | { 145 | pendingTexture.Texture.Dispose(); 146 | } 147 | } 148 | 149 | pendingTexture = new TextureDesc 150 | { 151 | Width = width, 152 | Height = height 153 | }; 154 | textureHandle = IntPtr.Zero; 155 | 156 | return; 157 | } 158 | } 159 | } 160 | 161 | public void DestroyTexture(IntPtr textureHandle) 162 | { 163 | lock (textureLock) 164 | { 165 | Texture textureToRemove; 166 | if (textureMap.TryGetValue(textureHandle, out textureToRemove)) 167 | { 168 | if (texture == textureToRemove) 169 | { 170 | texture = null; 171 | } 172 | textureToRemove.Dispose(); 173 | textureMap.Remove(textureHandle); 174 | } 175 | } 176 | } 177 | 178 | public override void Preprocess() 179 | { 180 | // only does something if browser is single threaded event loop 181 | BrowserManager.Instance.Update(); 182 | 183 | if (!hasBrowser) 184 | { 185 | UpdateSettings(); 186 | } 187 | 188 | lock (pendingTextureLock) 189 | { 190 | if (pendingTexture != null && pendingTexture.Texture == null) 191 | { 192 | pendingTexture.Texture = GS.CreateTexture(pendingTexture.Width, pendingTexture.Height, GSColorFormat.GS_BGRA, null, false, false); 193 | } 194 | } 195 | } 196 | 197 | override public void Render(float x, float y, float width, float height) 198 | { 199 | lock (textureLock) 200 | { 201 | if (texture != null) 202 | { 203 | GS.DrawSprite(texture, outputColor, x, y, x + width, y + height); 204 | } 205 | } 206 | } 207 | } 208 | } -------------------------------------------------------------------------------- /Plugin/BrowserSourceFactory.cs: -------------------------------------------------------------------------------- 1 | using CLRBrowserSourcePlugin.Shared; 2 | using CLROBS; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CLRBrowserSourcePlugin 10 | { 11 | internal class BrowserSourceFactory : AbstractImageSourceFactory 12 | { 13 | public BrowserSourceFactory() 14 | { 15 | ClassName = "CLRBrowserSource"; 16 | DisplayName = "CLR Browser"; 17 | } 18 | 19 | public override ImageSource Create(XElement data) 20 | { 21 | return new BrowserSource(data); 22 | } 23 | 24 | public override bool ShowConfiguration(XElement data) 25 | { 26 | ConfigDialog dialog = new ConfigDialog(data); 27 | if (dialog.ShowDialog().GetValueOrDefault(false)) 28 | { 29 | BrowserConfig config = new BrowserConfig(); 30 | config.Reload(data); 31 | 32 | data.Parent.SetFloat("cx", (float)config.BrowserSourceSettings.Width); 33 | data.Parent.SetFloat("cy", (float)config.BrowserSourceSettings.Height); 34 | 35 | return true; 36 | } 37 | else 38 | { 39 | return false; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Plugin/CLRBrowserSourcePlugin.cs: -------------------------------------------------------------------------------- 1 | using CLRBrowserSourcePlugin.Browser; 2 | using CLROBS; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Threading; 12 | 13 | namespace CLRBrowserSourcePlugin 14 | { 15 | public class CLRBrowserSourcePlugin : AbstractPlugin 16 | { 17 | [DllImport("kernel32")] 18 | public extern static int LoadLibrary(string librayName); 19 | 20 | public CLRBrowserSourcePlugin() 21 | { 22 | Name = "CLR Browser Source Plugin"; 23 | Description = "CLR Browser Source Plugin based on CEF"; 24 | } 25 | 26 | public static string AssemblyDirectory 27 | { 28 | get 29 | { 30 | string codeBase = Assembly.GetExecutingAssembly().CodeBase; 31 | UriBuilder uri = new UriBuilder(codeBase); 32 | string path = Uri.UnescapeDataString(uri.Path); 33 | return Path.GetDirectoryName(path); 34 | } 35 | } 36 | 37 | public override bool LoadPlugin() 38 | { 39 | String libraryDirectory = Path.Combine(AssemblyDirectory, "CLRBrowserSourcePlugin"); 40 | 41 | LoadLibrary(Path.Combine(libraryDirectory, "d3dcompiler_43.dll")); 42 | LoadLibrary(Path.Combine(libraryDirectory, "d3dcompiler_46.dll")); 43 | LoadLibrary(Path.Combine(libraryDirectory, "libGLESv2.dll")); 44 | LoadLibrary(Path.Combine(libraryDirectory, "libEGL.dll")); 45 | LoadLibrary(Path.Combine(libraryDirectory, "ffmpegsumo.dll")); 46 | LoadLibrary(Path.Combine(libraryDirectory, "icudt.dll")); 47 | LoadLibrary(Path.Combine(libraryDirectory, "libcef.dll")); 48 | 49 | Browser.BrowserManager.Instance.Start(); 50 | 51 | API.Instance.AddImageSourceFactory(new BrowserSourceFactory()); 52 | API.Instance.AddSettingsPane(new BrowserSettingsPane()); 53 | return true; 54 | } 55 | 56 | public override void UnloadPlugin() 57 | { 58 | BrowserManager.Instance.Stop(); 59 | 60 | // This is required to stop a crash when debugging; 61 | // apparently the WPF thread(?) doesn't shut down 62 | // the appdomain unloading causes an access to now 63 | // invalidated local store data 64 | // This should most likely be done in CLRHost after 65 | // removing all applications, but I'm not sure if it 66 | // can access the thread local dispatcher from there 67 | Dispatcher.CurrentDispatcher.InvokeShutdown(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Plugin/CLRBrowserSourcePlugin.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2C4D3528-0D34-4679-B507-5F7953BB07B0} 8 | Library 9 | Properties 10 | CLRBrowserSourcePlugin 11 | CLRBrowserSourcePlugin 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x86\Debug\ 38 | TRACE;DEBUG;WIN32 39 | full 40 | x86 41 | prompt 42 | ManagedMinimumRules.ruleset 43 | false 44 | false 45 | 46 | 47 | bin\x86\Release\ 48 | TRACE;WIN32 49 | true 50 | pdbonly 51 | x86 52 | prompt 53 | ManagedMinimumRules.ruleset 54 | false 55 | 56 | 57 | true 58 | bin\x64\Debug\ 59 | TRACE;DEBUG;WIN64 60 | full 61 | x64 62 | prompt 63 | ManagedMinimumRules.ruleset 64 | false 65 | 66 | 67 | bin\x64\Release\ 68 | TRACE;WIN64 69 | true 70 | pdbonly 71 | x64 72 | prompt 73 | ManagedMinimumRules.ruleset 74 | false 75 | 76 | 77 | 78 | 79 | False 80 | ..\..\OBS\rundir\plugins\CLRHostPlugin\CLRBrowserSourcePlugin\ICSharpCode.AvalonEdit.dll 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | ConfigDialog.xaml 129 | 130 | 131 | 132 | 133 | SettingsPane.xaml 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | {703ff300-34b9-48d4-a5d6-e741f48d5f95} 143 | CefGlue 144 | 145 | 146 | {18746141-1223-4fdf-bd6e-e7536ccade4f} 147 | CLRHost.Interop %28Visual Studio 2010%29 148 | 149 | 150 | 151 | 152 | MSBuild:Compile 153 | Designer 154 | 155 | 156 | Designer 157 | MSBuild:Compile 158 | 159 | 160 | 161 | 162 | copy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\OBS\rundir\plugins\CLRHostPlugin" 163 | 164 | 171 | -------------------------------------------------------------------------------- /Plugin/ConfigDialog.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |