WebsiteBeaver / CordovaCall

Cordova CallKit & ConnectionService plugin for iOS/Android that displays the native call UI for VOIP apps
MIT License
196 stars 92 forks source link

Sender audio stream not work when accept call on answer for android #93

Open hatinfotech opened 4 years ago

hatinfotech commented 4 years ago

Hi team ! I had a problem on android

I try this code then audio stream was stoped (caller not receive audio)

// Show call receive notification
cordova.plugins.CordovaCall.receiveCall("David Marcus");

// Listen answer event then accept call
cordova.plugins.CordovaCall.on("answer", function() {
     // Accept call
      session.accept();
});

But try code below audio working normal, call endCall function before accept call

// Show call receive notification
cordova.plugins.CordovaCall.receiveCall("David Marcus");

// Listen answer event then end call screen and then accept call
cordova.plugins.CordovaCall.on("answer", function() {
     // End call screen after answer
      cordova.plugins.CordovaCall.endCall();

     // Accept call
      session.accept();
});

I think plugin CordovaCall occupied audio stream so app can not send audio.

Please help me !

mattkhaw commented 4 years ago

Please post more details on this. It is pretty vague from what you have described. Are you making an app with VOIP functionality?

Qvadis commented 4 years ago

Hi,

did you find a solution for this already? We have the same issue. When we call receiveCall, the microphone doesn't work (or at least, the caller does not receive any sound from the called.

It only happens in some androids, not all.

Cheers.

mattkhaw commented 4 years ago

I think it's best to list down the devices that you've tested with this issue. There's tons of Android devices out there and the creator might not have the device that has issues like this. I also wish to know more before I encounter this issue. Are you sure the problem is from this plugin?

Qvadis commented 4 years ago

Hi, you are totally right. The devices I tested and ain't worked:

This is the scenario:

User A calls User B (OnePlus 6T or Xiaomi MI A2).

User B receives an incoming call through JSSIP and I call the cordova call receiveCall method. It starts ringing.

The user b can either pick up in the app and in the plugin notification. There's no diference. When it picks the call up, it triggers the method that calls "connectCall". The call is established but I hear nothing on the user A end.

If I hang up from the plugin but I don't call the methods to finish the call in jssip, then the UI of the plugin disappears but I'm able to speak normally! User A can finally hear User B.

It is like if the plugin takes over the audio input channel and if we get ride of it, we can use it again.

Any thoughts?

mattkhaw commented 4 years ago

Just one small question, where is the connectCall function being called? Caller or callee?

Qvadis commented 4 years ago

The callee. So it receives the incoming call -> CordovaCall executes receive call -> Answers -> Cordova call - Connect Call

mattkhaw commented 4 years ago

Forgot to include this question, when did you call connectCall? Before you invoke answer in JsSIP or after? If it is before, then it should be incorrect. I think the correct way is to call the answer function in JsSIP first then only connectCall. Without looking your code, it's pretty difficult to guess. But the main idea is, only use CordovaCall to handle all the native UI and use JsSIP to handle everything else. I think it is just the function call order is incorrect here.

Qvadis commented 4 years ago

Yes, it triggers the connect call only when the JSSIP session is established.

I'll look further in the code, because this may be caused on my end. I'll try to downgrade and see if it worked some versions ago.

I'll keep you updated with my findings :) Thank you for your time!

mattkhaw commented 4 years ago

Sure. Keep us posted. I apologise in the lack of knowledge in JsSIP but the underlying concept should be similar.

Qvadis commented 4 years ago

Hi!

I solved it. I don't know what the problem was, but sending the audio output to the earpiece with the AudioToggle plugin solved it.

mattkhaw commented 4 years ago

@Qvadis I see. I think it might be the default output is not specified. I've seen WebRTC has a function to toggle the audio stream, either to speaker or to earpiece. Maybe it is a good idea to explicitly specify the default output. I'm glad you solved this.