mercredi 17 juillet 2019

Why WebRTC call has audio only on mobile?

I'm developing a WebRTC app.

When I make a video call from browser to a mobile video displays fine on both devices. About audio, I can listen from mobile what the browser says but I can't listen from browser what the mobile says.

Funny thing is that locally everything(video & audio) works good. But when I uploaded my app online I've had the audio issue mentioned above.

Is this an Android or a Web issue?

How I retrieve remote stream on Web:

function handleRemoteStreamAdded(event) {
  remoteStream = event.stream;
  remoteVideo.srcObject = remoteStream;
}

How I set local stream in Android:

...
audioSource = peerConnectionFactory.createAudioSource(audioConstraints);
localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);
...

private void addStreamToLocalPeer() {
    MediaStream stream = peerConnectionFactory.createLocalMediaStream("102");
    stream.addTrack(localAudioTrack);
    stream.addTrack(localVideoTrack);
    localPeer.addStream(stream);
}

My code is mainly based on WebRTC codelab for Web client(https://codelabs.developers.google.com/codelabs/webrtc-web/#2) and for Android client on an open source repo(https://github.com/vivek1794/webrtc-android-codelab).

Have I missed something on the code above or do I need some extra code to make it work online?

Aucun commentaire:

Enregistrer un commentaire