Node.js WebRTC 客户端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18872712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Node.js WebRTC client
提问by jantimon
I am looking for a webrtcimplementation for node.js
to transmit data from a nodeJS clientto another webRTC peer.
我正在寻找node.js的webrtc实现,
以将数据从nodeJS 客户端传输到另一个 webRTC 对等点。
So in my case the nodejs application is notthe server but a client.
Does such a node module exist?
所以在我的情况下,nodejs 应用程序不是服务器而是客户端。
是否存在这样的节点模块?
采纳答案by Raoul
I came along the same problem and stumbled upon these two gems:
我遇到了同样的问题并偶然发现了这两个宝石:
https://github.com/helloIAmPau/node-rtcSadly it is lacking any documentation.
https://github.com/helloIAmPau/node-rtc遗憾的是它缺少任何文档。
However https://github.com/js-platform/node-webrtcseems more reliable to me.
但是 https://github.com/js-platform/node-webrtc对我来说似乎更可靠。
回答by Vlad Ankudinov
How about simple-peerand rtc-everywhere?
simple-peer和rtc-everywhere怎么样?
https://github.com/feross/simple-peer
https://github.com/feross/simple-peer
回答by Aki
You should check out licode. Their open source webrtc multi-point video conferencing bridge that runs on top of node.js. Their server acts as a webrtc client, which then bridges audio/video to other webrtc clients. You might be able to reuse some of their c++ code that uses libnice(for ICE protocol) and libsrtp(for SRTP stack), and then wrap it inside of your own node.js module to create a successful webrtc client.
你应该检查一下licode。他们的开源 webrtc 多点视频会议桥运行在 node.js 之上。他们的服务器充当 webrtc 客户端,然后将音频/视频桥接到其他 webrtc 客户端。您也许可以重用他们的一些使用 libnice(用于 ICE 协议)和 libsrtp(用于 SRTP 堆栈)的 c++ 代码,然后将其包装在您自己的 node.js 模块中以创建一个成功的 webrtc 客户端。
Obviously most of their code you don't need, but I think their server gives a good example of a working SDP that you need to send back to the browser in order to establish a successful webrtc connection.
显然,您不需要他们的大部分代码,但我认为他们的服务器提供了一个很好的示例,说明您需要将其发送回浏览器以建立成功的 webrtc 连接。
回答by boggy b
There is one more WebRTC wrapper for node https://github.com/vmolsa/webrtc-native.
节点https://github.com/vmolsa/webrtc-native还有一个 WebRTC 包装器 。
Supports data channel as well as media streams.
支持数据通道和媒体流。
Has support for linux, mac and windows.
支持 linux、mac 和 windows。
WebRTC codebase is synced frequently.
WebRTC 代码库经常同步。
Update: There's a light datachannel only implementation, supports linux/mac/windows http://www.meshcommander.com/webrtc
更新:有一个光数据通道唯一的实现,支持 linux/mac/windows http://www.meshcommander.com/webrtc
回答by M.Hefny
This solutionprovides video streaming from native to web. i.e. no need for browser to capture video, and it broadcast video to client browser. There is a websocket examplethat works just fine.
此解决方案提供从本机到 Web 的视频流。即不需要浏览器捕获视频,它会将视频广播到客户端浏览器。有一个websocket 示例可以正常工作。
Your challenge actually is to build and link webrtc.node, and it is all explained in the above link.
您的挑战实际上是构建和链接 webrtc.node,这在上面的链接中都有说明。
回答by Omkar Dusane
You might want to use this implementation : https://github.com/andyet/SimpleWebRTC
你可能想使用这个实现:https: //github.com/andyet/SimpleWebRTC
I have used it for my projects and it was very easy to integrate.
我已经将它用于我的项目,并且非常容易集成。
回答by sandover
Update: the solution below doesn't actually supply video to the server. I'm not sure what the best (Node) solution for that is. In C++, try libJingle.
更新:下面的解决方案实际上并不向服务器提供视频。我不确定最好的(节点)解决方案是什么。在 C++ 中,试试 libJingle。
It sounds like webrtc.io will allow you to create a node application that is a peer. See the github project here: https://github.com/webRTC/webRTC.io.
听起来 webrtc.io 将允许您创建一个节点应用程序作为对等节点。在此处查看 github 项目:https: //github.com/webRTC/webRTC.io。
There doesn't appear to be super-active development on the project at the moment, but there are 100 forks of it, and the node module is being downloaded 500 times a month right now, so it seems like people care.
该项目目前似乎没有超级活跃的开发,但它有 100 个 fork,并且节点模块现在每月下载 500 次,所以看起来人们很关心。
Example code from the project -- client side
来自项目的示例代码——客户端
<video id="local" autoplay="autoplay"></video>
<video id="remote" autoplay="autoplay"></video>
<script src="/webrtc.io.js"></script>
<script>
// note: make sure hostname available to all connecting clients
// (ie. probably not `localhost`)
rtc.connect('ws://yourserveraddress:8001');
rtc.createStream({"video": true, "audio":false}, function(stream){
// get local stream for manipulation
rtc.attachStream(stream, 'local');
});
rtc.on('add remote stream', function(stream){
// show the remote video
rtc.attachStream(stream, 'remote');
});
// more rtc callbacks are available
</script>
Server side
服务器端
var webRTC = require('webrtc.io').listen(8001);
回答by Adynathos
It is possible to establish a WebRTC data connection from node.js to browser with the serverless-webrtc packagewhich uses the wrtc packageas WebRTC implementation.
可以使用serverless -webrtc 包建立从 node.js 到浏览器的 WebRTC 数据连接,该包使用wrtc 包作为 WebRTC 实现。
Unfortunately, when I try using wrtc module with signalling libraries like PeerJS or EasyRTC, the connection is not establish (the error message is "ICE failed"). If anyone has had any success with using any high-level libraries on top of wrtc, I would be grateful for the information.
不幸的是,当我尝试将 wrtc 模块与 PeerJS 或 EasyRTC 等信号库一起使用时,连接未建立(错误消息是“ICE 失败”)。如果有人在 wrtc 之上使用任何高级库取得了任何成功,我将不胜感激。

