使用Firebase进行WebRTC语音聊天 [英] WebRTC Voice Chat Using Firebase
问题描述
我之前从未尝试过webrtc。我有一个使用Firebase的应用程序。现在我正在尝试添加语音通话功能。
I have never tried webrtc before. I have an application made using Firebase. Now I'm trying to add voice call feature in it.
因此尝试搜索一些教程,大多数使用PubNub或大多数教程都基于Web应用程序。
So tried searching for some tutorials, Most are using PubNub or most tutorials are based on web app.
我看到了这个stackoverflow线程并且知道可以使用Firebase来使用webrtc。
I saw this stackoverflow thread and knew that it's possible to use webrtc using Firebase.
在尝试了一些教程之后,我编写了这段代码,
After trying some tutorials, I wrote this code,
PeerConnectionFactory.initializeAndroidGlobals(this,false,true,true);
PeerConnectionFactory peerConnectionFactory = new PeerConnectionFactory();
AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("4444",audioSource);
audioTrack.setEnabled(true);
MediaStream mediaStream = peerConnectionFactory.createLocalMediaStream("4444");
mediaStream.addTrack(audioTrack);
但是我很困惑如何使用Firebase与其他设备共享流。需要帮助:(
But then I'm confused how to share the stream with other devices using Firebase. Need Help :(
推荐答案
AFAIK我不认为 Firebase
有现在支持语音通话。
AFAIK I don't think Firebase
has any support for voice calls for now .
另一方面
WebRTC
((Web Real-Time Communication)是一个免费的开源项目,通过简单的应用程序编程接口(API)为Web浏览器和移动应用程序提供实时通信(RTC)。
On other hand
WebRTC
((Web Real-Time Communication) is a free, open-source project that provides web browsers and mobile applications with real-time communication (RTC) via simple application programming interfaces (APIs).
基本上你需要的是一个 Socket
用于信号与 SignallingServer
和 PeerConnection
用于建立两个客户之间的连接。
以下是一些开头的链接。
Basically what you need is a Socket
for signalling with SignallingServer
and PeerConnection
for establishing the connection between two clients.
Below are some links to start with.
- Get started
- Step wise Sample for android
SignallingServer
implementat样品中也提供了离子。您将需要 NODE.JS
来运行它。 WebRTC
非常棒。
SignallingServer
implementation also provided in the sample. You will going to need NODE.JS
to run it . WebRTC
is pretty amazing.
如果你想使用 Firebase
作为 SignallingServer
你可以用它。但我认为这将是一个开销,而简单的 Socket
可以工作。
If you want to use Firebase
as SignallingServer
you can use it. But i think it will an overhead Whereas a simple Socket
can work .
这篇关于使用Firebase进行WebRTC语音聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!