WebRTC 与 Websockets:如果 WebRTC 可以处理视频、音频和数据,为什么我需要 Websockets? [英] WebRTC vs Websockets: If WebRTC can do Video, Audio, and Data, why do I need Websockets?

查看:20
本文介绍了WebRTC 与 Websockets:如果 WebRTC 可以处理视频、音频和数据,为什么我需要 Websockets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我希望构建一个允许视频、音频和文本的聊天应用程序.我花了一些时间研究 Websockets 和 WebRTC 来决定使用哪个.由于有大量带有 WebRTC 的视频和音频应用程序,这听起来是一个合理的选择,但我还应该考虑其他事项吗?随时分享您的想法.

So I'm looking to build a chat app that will allow video, audio, and text. I spent some time researching into Websockets and WebRTC to decide which to use. Since there are plenty of video and audio apps with WebRTC, this sounds like a reasonable choice, but are there other things I should consider? Feel free to share your thoughts.

例如:

  • 由于新的 WebRTC 仅在某些浏览器上可用,而 WebSockets 似乎在更多浏览器中可用.

  • Due to being new WebRTC is available only on some browsers, while WebSockets seems to be in more browsers.

可扩展性 - Websockets 使用服务器进行会话,而 WebRTC 似乎是 p2p.

Scalability - Websockets uses a server for session and WebRTC seems to be p2p.

多路复用/多聊天室 - 在 Google+ 环聊中使用,我仍在查看有关如何实施的演示应用.

Multiplexing/multiple chatrooms - Used in Google+ Hangouts, and I'm still viewing demo apps on how to implement.

服务器 - Websockets 需要 RedisSessionStore 或 RabbitMQ 才能跨多台机器扩展.

Server - Websockets needs RedisSessionStore or RabbitMQ to scale across multiple machines.

推荐答案

WebRTC 旨在实现视频、音频和任意数据的高性能、高质量通信.换句话说,对于与您所描述的完全一样的应用程序.

WebRTC is designed for high-performance, high quality communication of video, audio and arbitrary data. In other words, for apps exactly like what you describe.

WebRTC 应用需要一种服务,通过该服务它们可以交换网络和媒体元数据,这一过程称为信号传输.但是,一旦发生信令,视频/音频/数据将直接在客户端之间进行流式传输,从而避免了通过中间服务器进行流式传输的性能成本.

WebRTC apps need a service via which they can exchange network and media metadata, a process known as signaling. However, once signaling has taken place, video/audio/data is streamed directly between clients, avoiding the performance cost of streaming via an intermediary server.

另一方面,WebSocket 是为客户端和服务器之间的双向通信而设计的.可以通过 WebSocket 流式传输音频和视频(例如,请参见 此处),但这些技术和 API 的本质并不是像 WebRTC 那样为高效、稳健的流式传输而设计的.

WebSocket on the other hand is designed for bi-directional communication between client and server. It is possible to stream audio and video over WebSocket (see here for example), but the technology and APIs are not inherently designed for efficient, robust streaming in the way that WebRTC is.

正如其他回复所说,WebSocket 可用于发信号.

As other replies have said, WebSocket can be used for signaling.

我维护了一个 WebRTC 资源的列表:强烈建议您从查找开始在 2013 年 Google I/O 上关于 WebRTC 的演示.

I maintain a list of WebRTC resources: strongly recommend you start by looking at the 2013 Google I/O presentation about WebRTC.

这篇关于WebRTC 与 Websockets:如果 WebRTC 可以处理视频、音频和数据,为什么我需要 Websockets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆