![](https://i-blog.csdnimg.cn/blog_migrate/1db453e3198cda55238ab1650f793ff8.png)
webrtc 框架
Now you can develop applications that take advantage of Unity’s rapidly advancing graphics capabilities without being constrained by device performance. Our new open-source WebRTC library for Unity and easy-to-use drop-in framework demonstrates how you can stream your projects through your browser.
现在,您可以开发利用Unity快速发展的图形功能的应用程序,而不受设备性能的限制。 我们针对Unity和易于使用的嵌入式框架的新开放源WebRTC库演示了如何通过浏览器流式传输项目。
The power of WebRTC technologies lets you run Unity projects with high-quality rendering through your browser. The framework can be used in runtime or in the Editor, so it is useful for a variety of purposes, like running a car configurator made with HDRP or viewing an architectural model – projects that use high-end graphics.
WebRTC技术的强大功能使您可以通过浏览器运行具有高质量渲染的Unity项目。 该框架可以在运行时或在编辑器中使用,因此对于多种用途很有用,例如运行使用HDRP制成的汽车配置器或查看建筑模型-使用高端图形的项目。
WebRTC弥合了浏览器和实时渲染之间的鸿沟 (WebRTC bridges the gap between browsers and real-time rendering)
Developed by Google in 2011, WebRTC is open-source software that enables real-time peer-to-peer communication between browsers and mobile platforms. Any device can use Unity’s open-source framework for render streaming, so long as it’s equipped with the latest version of a browser that supports WebRTC. This includes all major browsers for iPad, iPhone, and Android.
WebRTC由Google在2011年开发,是一种开源软件,可实现浏览器与移动平台之间的实时对等通信。 任何设备都可以使用Unity的开源框架进行渲染流,只要它配备了支持WebRTC的最新版本的浏览器即可。 这包括适用于iPad,iPhone和Android的所有主要浏览器。
WebRTC can be paired with Unity thanks to our app based on the Apache 2.0 license, which is publicly available through Github. This library is also available as a Preview release through Package Manager, to make it even easier to add it to your project.
WebRTC可以与Unity配对,这要归功于我们基于Apache 2.0许可的应用程序,该应用程序可通过Github公开获得。 该库还可以通过Package Manager作为预览版使用,以使其更轻松地添加到项目中。
使用WebRTC + Unity嵌入式框架进行渲染流 (Render Streaming with the WebRTC + Unity drop-in framework )
We’ve used the library to develop a render streaming framework that allows you to run Unity applications through your browser.
我们已经使用该库开发了一个渲染流框架,该框架允许您通过浏览器运行Unity应用程序。
After adding the Render Streaming package to your project, you can control your project in real-time from everyday browsers like Google Chrome and Safari, both on desktop and mobile devices.
将Render Streaming程序包添加到项目后,您可以通过台式机和移动设备上的日常浏览器(例如Google Chrome和Safari)实时控制项目。
The package is available to add to your project through the Package Manager today. The source code is available through this Github repository.
该软件包可立即通过“软件包管理器”添加到您的项目中。 可通过此Github存储库获得源代码。
![](https://i-blog.csdnimg.cn/blog_migrate/2b2064124fc226ce6f33ac141457174f.png)
来自浏览器的用户输入 (User input from the browser)
The Render Streaming package instantly sends inputs from the browser to the Unity application. This includes keyboard input, mouse and touchpad input, and HTML button events. All you have to do is set up the input processing, just as you would for a regular Unity project, and the framework will pass the input to the new Input System using WebRTC’s DataChannel API. The result from browser inputs is the same quality of developer experience that you would get from working directly in Unity.
Render Streaming包立即将输入从浏览器发送到Unity应用程序。 这包括键盘输入,鼠标和触摸板输入以及HTML按钮事件。 您要做的就是像常规的Unity项目一样设置输入处理,并且框架将使用WebRTC的DataChannel API将输入传递给新的输入系统 。 浏览器输入的结果与直接在Unity中工作所获得的开发人员体验质量相同。
![](https://img-blog.csdnimg.cn/img_convert/cccab0daa178bc44506c053c96a8c62b.png)
同时广播到多个设备 (Simulcasting to multiple devices)
With the Render Streaming package, you can broadcast video to multiple devices simultaneously. The maximum number of devices depends on the specs of the broadcasting machine and video quality – an average machine under normal circumstances can broadcast to about four devices at once.
使用“渲染流”程序包,可以同时将视频广播到多个设备。 设备的最大数量取决于广播机器的规格和视频质量-在正常情况下,一台普通机器可以一次向大约四个设备广播。
One important consideration when using the Render Streaming package is the network environment. WebRTC handles video streaming, so a stable network is essential to maintaining video quality.
使用渲染流包时的一个重要考虑因素是网络环境。 WebRTC处理视频流,因此稳定的网络对于保持视频质量至关重要。
It is also important to remember that each additional device increases the burden on the broadcasting machine. It’s possible to create an intranet system to stream with the Render Streaming package, but setting up an internet-based broadcasting service requires a substantially more complicated system.
同样重要的是要记住,每个附加设备都会增加广播机的负担。 可以创建一个Intranet系统以使用Render Streaming包进行流传输,但是设置基于Internet的广播服务需要实质上更复杂的系统。
In general, if the goal is to broadcast to more than ten devices, we recommend incorporating an SFU decentralized server into the system structure along with a separate STUN/TURN server for WebRTC.
通常,如果目标是广播到十个以上的设备,则建议将SFU分散服务器与单独的用于WebRTC的STUN / TURN服务器合并到系统结构中。
视频硬件编码 (Video hardware encoding)
To provide high-fidelity graphics and a solid streaming frame rate for high-quality user experience, we had to tackle two problems: performance and latency.
为了提供高质量的图形和稳定的流帧速率以提供高质量的用户体验,我们必须解决两个问题:性能和延迟。
To reduce latency, the Render Streaming framework broadcasts applications to the browser using the NVIDIA Video Codec SDK to perform GPU hardware encoding on the frame buffer.
为了减少延迟,Render Streaming框架使用NVIDIA Video Codec SDK将应用程序广播到浏览器,以在帧缓冲区上执行GPU硬件编码。
This means that to use the framework you currently need a computer with an NVIDIA GPU. Support for other GPUs is planned for future updates.
这意味着要使用该框架,当前需要一台装有NVIDIA GPU的计算机。 计划在将来的更新中支持其他GPU。
什么样的支持以及如何开始? (What’s the support like and how do I get started?)
The WebRTC library is based on the Apache 2.0 license and managed as a community-supported technology. We encourage you to get involved in the continuing development of this technology. Feel free to fork the repository or expand any feature you like.
WebRTC 库基于Apache 2.0许可证,并作为社区支持的技术进行管理。 我们鼓励您参与这项技术的持续发展。 随意派生存储库或扩展您喜欢的任何功能。
To get started, take a look at the tutorial document (English, Japanese) and consult the FAQ in the documentation for any additional questions. There is also a forum for WebRTC and Render Streaming, and we would love to get your feedback.
首先,请查看教程文档( 英语 , 日语 ),并咨询文档中的FAQ ,以获取其他任何问题。 还有一个用于WebRTC和渲染流的论坛 ,我们很乐意获得您的反馈。
We’re excited to see what kind of amazing projects you’ll put together with the power of WebRTC and Unity.
我们很高兴看到您将结合WebRTC和Unity的强大功能来完成什么样的惊人项目。
webrtc 框架