2

I have never tried webrtc before. I have an application made using Firebase. Now I'm trying to add voice call feature in it.

So tried searching for some tutorials, Most are using PubNub or most tutorials are based on web app.

I saw this stackoverflow thread and knew that it's possible to use webrtc using Firebase.

Voice calls over a Chat app 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);

But then I'm confused how to share the stream with other devices using Firebase. Need Help :(

Bucky
  • 1,116
  • 2
  • 18
  • 34

1 Answers1

0

AFAIK I don't think Firebase has any support for voice calls for now .

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).

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.

  1. Get started
  2. Step wise Sample for android

SignallingServer implementation also provided in the sample. You will going to need NODE.JS to run it . WebRTC is pretty amazing.

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 .

ADM
  • 20,406
  • 11
  • 52
  • 83
  • Can I somehow use Google Cloud Functions for WebRTC? – Bucky Feb 18 '18 at 08:52
  • I mean on an article https://websitebeaver.com/insanely-simple-webrtc-video-chat-using-firebase-with-codepen-demo . He used only Firebase and webrtc to create a video chat app. But that was in javascript. – Bucky Feb 18 '18 at 08:54
  • I have gone through the article It's using firebase for signalling purpose only as it's a real time database . I suggest you to use the solution I provide above. It's quite simple and less complicated . It uses socket.io for socket which is used for signalling . – ADM Feb 18 '18 at 09:09
  • I think using Firebase for signaling will be overhead while you can directly use a Socket . – ADM Feb 18 '18 at 09:15