Unity using WebRTC UWP Libraries
This is a Unity Project with integration Plugins to utilize the UWP WebRTC Library from Nuget.Org. Uses https://github.com/webrtc-uwp/PeerCC as reference for the integration project.
Unity3D Development Workstation
- Install Unity3D 2017.3.0f3
- Install Visual Studio 2017 Update to 15.5.6 with Unity Support
- Clone this Project
- Must have WebCam, Microphone, Audio Output
Visual Studio Workstation
- Install Visual Studio 2017 Update to 15.5.6 with Unity Support
- Clone this Project
- Must have WebCam, Microphone, Audio Output
Compiled plugin DLL’s are included in the Unity Assets Folder \UnityWithWebRTC\Assets\Plugins\WebRtcWrapper
Org.WebRtc.dll+Org.WebRtc.winmd WebRTC libraries wrapped by WebRtcWrapper.dll for use with Unity
Plugin Source Code located in \ExternalProjects.
- Build the XAML Test App (Visual Studio Workstation)
- Open the Visual Studio Solution: \ExternalProjects\WebRtcIntegration\WebRtcIntegration.sln
- Right-Click "XamlTestApp" in the Visual Studio Solution
- Click Build and then Deploy to install the XamlTestApp on the workstation
- Build the Plugin DLL (Unity3D Development Workstation)
- Open the Visual Studio Solution: \ExternalProjects\WebRtcIntegration\WebRtcIntegration.sln
- Build and Deploy the "WebRtcWrapper" Project, the DLL's are automatically copied to the Unity Asset Folder
- Build the Unity Project (Unity3D Development Workstation)
- Start Unity3D, select the clone root folder
- Load the Scene "RenderTexture" located in \Scenes\RenderTexture
- Open the Build Settings Window (Ctrl-Shift-B or File->Build Settings)
- Ensure "RenderTexture" is the in the Build Scenes List and Checked
- Ensure "Universal Windows Platform" is the selected Platform
- Click "Build and Run", this will build, deploy and run the Unity App as a Universal Windows Application
- The system can be executed on a local network without the need for Internet access to Google servers.
- On the (Visual Studio Workstation), open a command window with Administrative access
- Get the IP Address of the workstation
- Make sure the workstation firewall allows port 8888 access
- go to the \ExternalProjects\WebRTCPeerConnectionServerExe Folder
- Run the peerconnection_server.exe (this came from the WebRTC core source code)
- On the (Unity3D Development Workstation), change the IP address to the value (Visual Studio Workstation) address on the running Unity Application
- Click "Connect" on the Unity3D and XAMLTestApp (this defaults to localhost) to connect to server
- Click "Connect Peer" to establish a peer session
- Unity Peer Application only receives video/audio feed from transmitting peer. Webcam/Mic device is required by UWP WebRTC Lib but not used/disabled on Unity App
- The plugin can be optimized further by using shaders to handle the color conversion
- Disconnecting and Reconnecting a session may not work, session objects need to clean-up
- The setup is dependent on the UWP WebRTC package from nuget.org, next major iteration is to transition to webrtc.org native libraries to support cross-platform build
- Plan to support Android, iOS and Windows (Standalone) with Unity
A brief description of the InterOp in the project is at Microsoft Code Stories: Revisiting InterOp with Unity, UWP and DirectX