1

I have an app that implements the video calling feature using WebRTC in android.

From the App, I am creating an Offer for calls and receiving from another App/ Web.

So, when I am working on app to app, everything is working fine, I can see the remote peer, and the remote peer can also see me.

But when I am working on app (creating offer) to web (receiver). In the app, I can see both local and remote Stream, but from the web, I can't see the remote stream only seeing the remote stream.

This is my android code while creating an offer

val pcConstraints = object : MediaConstraints() {
        init {
            optional.add(KeyValuePair("DtlsSrtpKeyAgreement", "true"))
            optional.add(KeyValuePair("OfferToReceiveAudio", "true"))
            optional.add(KeyValuePair("OfferToReceiveVideo", "true"))
        }
    }
 val peerConnection = getOrCreatePeerConnection(mRemoteSocketId, "A")
        peerConnection.createOffer(object : CustomSdpObserver() {
            override fun onCreateSuccess(sessionDescription: SessionDescription?) {
                Timber.d("onCreateSuccess: ")
                peerConnection.setLocalDescription(CustomSdpObserver(), sessionDescription)
                if (sessionDescription != null) {
                    // sending sessionDescription from here
                }


                // starting the call from here
            }
        }, pcConstraints)

Here Creating the peerConnection

    private fun getOrCreatePeerConnection(socketId: String, role: String): PeerConnection {

        Timber.tag("live").d("getOrCreatePeerConnection socketId $socketId role $role")

        var peerConnection = peerConnectionMap[socketId]


        if (peerConnection != null) {
            return peerConnection
        }

        val rtcConfig = PeerConnection.RTCConfiguration(iceServers)
        rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE
        rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE
        rtcConfig.keyType = PeerConnection.KeyType.ECDSA
        rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.ALL
        rtcConfig.enableCpuOveruseDetection = true


        peerConnection =
            peerConnectionFactory?.createPeerConnection(
                rtcConfig,
                pcConstraints,
                object : CustomPCObserver() {

                    override fun onIceCandidate(p0: IceCandidate?) {
                        super.onIceCandidate(p0)

                        Timber.tag("live").d("getOrCreatePeerConnection onIceCandidate${p0} ")
                        if (p0 != null) {
                            SignalingServer.get()?.sendIceCandidate(p0)
                        }

                    }

                    override fun onAddStream(p0: MediaStream?) {
                        super.onAddStream(p0)

                        Timber.tag("live")
                            .d("onAddStream  Remote MediaStream ${p0?.videoTracks?.size} ")

                        gotRemoteStream(p0!!)

                    }

                    override fun onRenegotiationNeeded() {
                        super.onRenegotiationNeeded()

                        Timber.tag("live").d("onRenegotiationNeeded")
                    }
                })


        peerConnection!!.addStream(localMediaStream)
        peerConnectionMap[socketId] = peerConnection
        Timber.tag("live")
            .d("getOrCreatePeerConnection size $socketId ${peerConnectionMap.size} ,  ${peerConnectionMap.values} ")

        return peerConnection
    }

So, what am I missing, I believe in Web end somehow my local Stream is not received. Your help would be highly appreciated.

0 Answers0