0

Hi I am working on a Video Call Solution by using WebRTC directly. I have achieved 1-1 video call using firebase as Signaling service and using default google ICE Servers.

Core Req: Multiple users with in a Room using WebRTC at least 4 users using the default ice/stun servers available. I'm using pod 'GoogleWebRTC'

Issue comes when multiple users joins the same room ID.

So, I am maintaining Peerconnection reference as this

var peerConnection: RTCPeerConnection! = nil

When a new user i.e., remote user joins I set its description as below

self.peerConnection.setRemoteDescription(offer, completionHandler: {(error: Error?) in
            if error == nil {
                LOG("setRemoteDescription(offer) succsess")
                self.makeAnswer() // Create Answer if setRemoteDescription succeeds
            } else {
                LOG("setRemoteDescription(offer) ERROR: " + error.debugDescription)
            }
        })

What I feel ? Issue is when third user joins again I set the remote Description with above mentioned code which makes my previous video stops to render sometimes or most of the times.

I looked for solutions and found need to maintain multiple peer connection references, but how? Any help with my requirement will be appreciated.

Just give me clue or sample code will be really great.

Jatin Garg
  • 306
  • 1
  • 2
  • 16

1 Answers1

0

In case of multiple user call you should have multiple peerconnections, because it's isn't possible to set different sdps to one pc. So you can use something like this

var peerConnectionMap = [String: RTCPeerConnection]()

Where String here is some constant user id. When new user is joined to the room, then you create new pc and store it in this dictionary. Then you exchange with sdps as usual. Don't forget that you should reuse local audio-video track created when first peerconnection is created.