简体   繁体   English

通过 Websocket 发送 WebRTC MediaStream(RTP over HTTP/Websocket)

[英]Sending WebRTC MediaStream over Websocket (RTP over HTTP/Websocket)

WebRTC is, among other things, meant for real-time browser to browser media communication, but in my case it will be used for browser to server audio communication.除其他外,WebRTC 用于浏览器到浏览器的实时媒体通信,但就我而言,它将用于浏览器到服务器的音频通信。

From the information I've gathered, the MediaStream is transferred using RTP over UDP.根据我收集的信息,MediaStream 是使用 RTP over UDP 传输的。

This will require at least two additional ports apart from the protocol used for signalling, something I would like to avoid.除了用于信令的协议之外,这将需要至少两个额外的端口,这是我想避免的。

Within WebRTC, is there any possibility to use RTP over Websocket instead of RTP over UDP so that I only need to use port 80 or 443?在 WebRTC 中,是否有可能使用 RTP over Websocket 而不是 RTP over UDP 以便我只需要使用端口 80 或 443?

No, that will not be possible using WebRTC.不,使用 WebRTC 是不可能的。

WebRTC was built to give browsers three main features: WebRTC 旨在为浏览器提供三个主要功能:

  1. Capability to access the device's cameras and microphones;能够访问设备的摄像头和麦克风;
  2. Capability to establish SRTP sessions to send/receive audio and video;能够建立 SRTP 会话以发送/接收音频和视频;
  3. Capability to establish peer-to-peer data channels between browsers;能够在浏览器之间建立对等数据通道;

These features are accessible to web applications via a Javascript API defined here . Web 应用程序可以通过此处定义的 Javascript API 访问这些功能。 To access media devices, you can use getUserMedia() and you will get a MediaStream to attach to HTML5 audio and video tags.要访问媒体设备,您可以使用getUserMedia()并且您将获得一个 MediaStream 以附加到 HTML5 音频和视频标签。 To create an SRTP session, you need to create a peer connection and manage the streams to use.要创建 SRTP 会话,您需要创建对等连接并管理要使用的流。

You have to request the browser a media SDP offer and send it to the other party using any protocol (eg websockets).您必须向浏览器请求媒体 SDP 报价,并使用任何协议(例如 websockets)将其发送给另一方。 When the other party receives your SDP offer, it can inject it into the browser, request an SDP answer, and send it back.当另一方收到您的 SDP 报价时,它可以将其注入浏览器,请求 SDP 答复,然后将其发回。 Once both browsers have the offers, they start the SRTP negotiation, using ICE.一旦两个浏览器都有报价,它们就会使用 ICE 开始 SRTP 协商。

So, you will not have access to RTP packets to send them over websockets.因此,您将无法访问 RTP 数据包以通过 websockets 发送它们。

Actually, the plan is to support RTCP-mux RFC 5761 and some form of BUNDLE (still under debate) to merge all streams onto a single port.实际上,该计划是支持 RTCP-mux RFC 5761和某种形式的 BUNDLE(仍在争论中)以将所有流合并到一个端口上。 However, the port will be chosen by ICE/STUN.但是,端口将由 ICE/STUN 选择。 When needed, it would also use TURN, and eventually support TURN-TCP, which could run over port 80 I believe.需要时,它还将使用 TURN,并最终支持 TURN-TCP,我相信它可以在端口 80 上运行。 Quality will suffer, however.然而,质量会受到影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM