Thursday 8 July 2021

Remote video doesn't load when onAddStream() is called

I am implementing a webRTC android application, and the servers that i am communicating with are a signaling server(via websockets) and a kurento media server.

Time sequence is:

  • clients subscribe to the server
  • every client sent sdpOffer
  • every client sent all the iceCandidate that will be created
  • signaling server send the iceCandidate to every client
  • signaling server send to the clients the sdpAnswers which originate from kurento media server

My mobile clients subscribe to the server and they send theirs sdpOffers. After ice trickle the signaling server sending back the sdpAnswers from kurento media server.

So, i am getting the startCommunication messages and the remote description is set successfully with the sdpAnswers from kurento media server. I have check all my sdp and ice packages, they are all as expected, and all webRTC related callbacks are successful.

After setting the remoteDescription in peerConnection,

the onAddStream() is invoked and i am getting the videoTrack.But the video is not rendering..

my onAddStream:

 override fun onAddStream(p0: MediaStream?) {

            super.onAddStream(p0)
            p0?.videoTracks?.get(0)?.addSink(remote_view)

            Log.d(TAG, "on add stream" + p0?.videoTracks?.size )
            Log.d(TAG,App.rtcClient.peerConnection?.iceConnectionState().toString())
            Log.d(TAG,App.rtcClient.peerConnection?.iceGatheringState().toString())
        }

init of the remote view:

   fun initSurfaceView(view: SurfaceViewRenderer) = view.run {
      setMirror(true)
      setEnableHardwareScaler(true)
      init(rootEglBase.eglBaseContext, null)
   }

  ....

  App.rtcClient.initSurfaceView(remote_view)

xml of the remote view:

 <org.webrtc.SurfaceViewRenderer
    android:id="@+id/remote_view"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/local_view" />

I am not getting any errors and my local stream is rendering perfectly.

So, i am debugging the app without knowing where to go next, because is not clear where this problem comes from.

This exact question exists here but there is no answers and it is 5 y.o

if you need any additional info please comment.

Update: Exact the same behavior exists in the iOS version too - no video rendering.



from Remote video doesn't load when onAddStream() is called

No comments:

Post a Comment