WebRTC和Websockets。有区别吗? [英] WebRTC and Websockets. Is there a difference

查看:160
本文介绍了WebRTC和Websockets。有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设WebRTC是一个解码/编码音频和视频的API,尽管服务器和客户端之间的通信是通过Web套接字或其他网络协议完成的?我有点困惑。 WebRTC是否有自己的通信协议?

I'm assuming that WebRTC is an API that decodes/encodes audio and video, although the communication between the server and the clients is done via web sockets, or some other network protocol? I'm a bit confused. Does WebRTC have its own communications protocol?

推荐答案

WebRTC有两个方面。

There's two sides to WebRTC.


  1. JavaScript API( getUserMedia ),允许应用访问摄像头和麦克风硬件。您可以使用此访问权限在本地显示流(可能是应用效果),或者将流发送到网络。您可以将数据发送到您的服务器,或者您可以使用...

  2. PeerConnection ,一个允许浏览器建立的API strong>直接对等套接字连接。您可以直接与其他人的浏览器建立连接并直接交换数据。这对于视频等高带宽数据非常有用,您不希望服务器必须处理中继大量数据。

  1. JavaScript APIs (getUserMedia) that allow an app to access camera and microphone hardware. You can use this access to simply display the stream locally (perhaps applying effects), or send the stream over the network. You could send the data to your server, or you could use...
  2. PeerConnection, an API that allows browsers to establish direct peer-to-peer socket connections. You can establish a connection directly to someone else's browser and exchange data directly. This is very useful for high-bandwidth data like video, where you don't want your server to have to deal with relaying large amounts of data.

查看演示,了解WebRTC的两个部分。

Take a look at the demos to see both parts of WebRTC in action.

简而言之:


  • WebSockets允许浏览器和网络之间进行全双工通信服务器。

  • WebRTC的 PeerConnection 允许两个浏览器之间进行全双工通信。

  • WebSockets allow full-duplex communication between a browser and a web server.
  • WebRTC's PeerConnection allows full-duplex communication between two browsers.

这篇关于WebRTC和Websockets。有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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