AndroidRTC icon indicating copy to clipboard operation
AndroidRTC copied to clipboard

No sound

Open qbonnard opened this issue 9 years ago • 9 comments

Hello,

irst of all, thnaks a lot for your work, it helps a lot !

I adapted this demo for our own videochat needs, but I can't get the sound to work.

Logcat does show that something happens with the sounds :

09-28 17:47:51.148  17972-20776/com.relinkdevice.manager D/AudioManager﹕ ctor@[tid=20776]
09-28 17:47:51.148  17972-20776/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioManager)
09-28 17:47:51.148  17972-20776/com.relinkdevice.manager D/WebRtcAudioManager﹕ ctor@[name=Thread-1292, id=1292]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager V/AudioTrack﹕ getMinFrameCount=5644: afFrameCount=1024, minBufCount=6, afSampleRate=48000, afLatency=138
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ OnCacheAudioParameters@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ hardware_aec: 1
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ low_latency_output: 0
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ sample_rate: 44100
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ channels: 1
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ output_buffer_size: 5644
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ input_buffer_size: 3840
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ JavaAudioManager::ctor@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ IsLowLatencyPlayoutSupported()
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioTrackJni﹕ ctor@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioTrack)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioTrack﹕ ctor@[name=Thread-1292, id=1292]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioTrack﹕ Android SDK: 16, Release: 4.1.2, Brand: lge, Device: d1lsk, Id: JZO54K, Hardware: d1lsk, Manufacturer: lge, Model: LG-F160S, Product: d1lsk_SKT_KR
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ ctor@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioRecord)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioRecord﹕ ctor@[name=Thread-1292, id=1292]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ SetActiveAudioLayer(5)@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ delay_estimate_in_milliseconds: 150
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioTrackJni﹕ AttachAudioBuffer@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioTrackJni﹕ SetPlayoutSampleRate(44100)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioTrackJni﹕ SetPlayoutChannels(1)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ AttachAudioBuffer
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ SetRecordingSampleRate(44100)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ SetRecordingChannels(1)
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ total_delay_in_milliseconds: 150
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioManager﹕ Init@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioManager﹕ init@[name=Thread-1292, id=1292]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioManager﹕ audio mode is: MODE_NORMAL
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ EnableBuiltInAEC@[tid=20776]
09-28 17:47:51.158  17972-20776/com.relinkdevice.manager D/WebRtcAudioRecord﹕ EnableBuiltInAEC(true)
09-28 17:47:51.168  17972-20776/com.relinkdevice.manager D/AudioRecordJni﹕ EnableBuiltInAEC@[tid=20776]
09-28 17:47:51.168  17972-20776/com.relinkdevice.manager D/WebRtcAudioRecord﹕ EnableBuiltInAEC(true)
09-28 17:47:51.208  17972-20782/com.relinkdevice.manager D/AudioManager﹕ ctor@[tid=20782]
09-28 17:47:51.208  17972-20782/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioManager)
09-28 17:47:51.208  17972-20782/com.relinkdevice.manager D/WebRtcAudioManager﹕ ctor@[name=Thread-1295, id=1295]
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ getMinFrameCount=5644: afFrameCount=1024, minBufCount=6, afSampleRate=48000, afLatency=138
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ OnCacheAudioParameters@[tid=20782]
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ hardware_aec: 1
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ low_latency_output: 0
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ sample_rate: 44100
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ channels: 1
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ output_buffer_size: 5644
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ input_buffer_size: 3840
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ JavaAudioManager::ctor@[tid=20782]
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioManager﹕ IsLowLatencyPlayoutSupported()
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ ctor@[tid=20782]
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioTrack)
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ ctor@[name=Thread-1295, id=1295]
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ Android SDK: 16, Release: 4.1.2, Brand: lge, Device: d1lsk, Id: JZO54K, Hardware: d1lsk, Manufacturer: lge, Model: LG-F160S, Product: d1lsk_SKT_KR
09-28 17:47:51.218  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ ctor@[tid=20782]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/JVM﹕ JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioRecord)
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/WebRtcAudioRecord﹕ ctor@[name=Thread-1295, id=1295]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioManager﹕ SetActiveAudioLayer(5)@[tid=20782]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioManager﹕ delay_estimate_in_milliseconds: 150
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ AttachAudioBuffer@[tid=20782]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ SetPlayoutSampleRate(44100)
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ SetPlayoutChannels(1)
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ AttachAudioBuffer
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ SetRecordingSampleRate(44100)
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ SetRecordingChannels(1)
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ total_delay_in_milliseconds: 150
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioManager﹕ Init@[tid=20782]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/WebRtcAudioManager﹕ init@[name=Thread-1295, id=1295]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/WebRtcAudioManager﹕ audio mode is: MODE_NORMAL
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ EnableBuiltInAEC@[tid=20782]
09-28 17:47:51.228  17972-20782/com.relinkdevice.manager D/WebRtcAudioRecord﹕ EnableBuiltInAEC(true)
09-28 17:47:51.238  17972-20782/com.relinkdevice.manager D/AudioRecordJni﹕ EnableBuiltInAEC@[tid=20782]
09-28 17:47:51.238  17972-20782/com.relinkdevice.manager D/WebRtcAudioRecord﹕ EnableBuiltInAEC(true)
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ InitPlayout@[tid=20782]
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ InitPlayout(sampleRate=44100, channels=1)
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ byteBuffer.capacity: 882
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ OnCacheDirectBufferAddress
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ direct buffer capacity: 882
09-28 17:47:53.190  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ frames_per_buffer: 441
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ getMinFrameCount=5644: afFrameCount=1024, minBufCount=6, afSampleRate=48000, afLatency=138
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ AudioTrack.getMinBufferSize: 11288
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ set() streamType 0 frameCount 5644 flags 0000
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ AudioTrack getOutput streamType 0, sampleRate 44100, format 1, channelMask 1, flags 0
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ createTrack_l() output 2 afLatency 138
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ minFrameCount: 5644, afFrameCount=1024, minBufCount=6, sampleRate=44100, afSampleRate=48000, afLatency=138
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager D/AudioManager﹕ IsCommunicationModeEnabled()
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager W/AudioDeviceTemplate﹕ The application should use MODE_IN_COMMUNICATION audio mode!
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ StartPlayout@[tid=20782]
09-28 17:47:53.200  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ StartPlayout
09-28 17:47:53.200  17972-20832/com.relinkdevice.manager D/WebRtcAudioTrack﹕ AudioTrackThread@[name=AudioTrackJavaThread, id=1303]
09-28 17:47:53.200  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ start 0x5e53a980
09-28 17:47:53.200  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ start 0x5e53a980 before lock cblk 0x66906000
09-28 17:47:53.200  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ mAudioTrack->start()
09-28 17:47:53.210  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ write 0x5e53a980: 882 bytes, mActive=1
[many more like that]
09-28 17:47:55.933  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ write 0x5e53a980: 882 bytes, mActive=1
09-28 17:47:55.943  17972-20782/com.relinkdevice.manager D/AudioTrackJni﹕ StopPlayout@[tid=20782]
09-28 17:47:55.943  17972-20782/com.relinkdevice.manager D/WebRtcAudioTrack﹕ StopPlayout
09-28 17:47:55.973  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ stop 0x5e53a980
09-28 17:47:55.973  17972-20832/com.relinkdevice.manager V/AudioTrack﹕ flush
09-28 17:47:55.983  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ stop 0x5e53a980
09-28 17:47:55.983  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ stop 0x5e53a980
09-28 17:47:55.983  17972-20782/com.relinkdevice.manager V/AudioTrack﹕ stop 0x5e53a980

I don't really have a clue where to begin debugging... So I would be grateful for any tip or advice !

Best,

Quentin

qbonnard avatar Sep 28 '15 15:09 qbonnard

Just wanting to acknowledge that I saw this, I'll take a closer look at this later today.

I am seeing The application should use MODE_IN_COMMUNICATION audio mode! but I doubt that will fix things.

I have a getting started tutorial, specifically I would point you to the Gathering Video and Audio Resources section. If everything there looks good, I would suggest you run AndroidRTC without modifications to make sure that the audio works for you. Just tested it and it still works for me, but perhaps it is an issue that varies by the phone.

Let me know!

GleasonK avatar Sep 28 '15 17:09 GleasonK

Thank you for your prompt reply !

Regarding the MODE_IN_COMMUNICATION, do you know how to set it ?

I did read the tutorial and used the AndroidRTC example as a starting point for my application, but I'll try with the unmodified version of it. I'll have to tweak the SDK versions a bit, as I'm testing with older androids (4.1 and 4.3). Maybe that's one source of issue ?

I'll let you know !

qbonnard avatar Sep 28 '15 21:09 qbonnard

Hello,

Unconclusive report here : I tried AndroidRTC with two 4.3 devices. The only modification I did was to add an if (this.localVideoSource != null) to avoid an NPE in VideoChat::onResume. The call are stuck in the "connecting" phase (even though the other device does display the green and red buttons when the first device calls). The messages don't go through...

What's weird is that I do manage to have video call with the AndroidRTC code I merged into my application... So now I'm even more puzzled ;)

Any hint or advice ?

qbonnard avatar Sep 29 '15 22:09 qbonnard

Hi Kevin, I am having the same issue, I tried to run your example code from this repository, and I tried it on three different devices, connecting to the web app, so I receive sound on my laptop but on the devices there is no sound. I tried calling from the device, and from the web. The devices that I am using are, ASUS MeMO Pad 10 (ME103K), Nexus 7 2012 and Nexus 4.

Any help will be appreciated. Thanks!

nakov0301 avatar Nov 16 '15 08:11 nakov0301

Hi Kevin,

I wondered if you had to time to look at this issue ? I also managed to make the sample code work in one way, and I could backport this into my app. So now the application on one device (a tablet) sends sound to the application on another device (a phone), but not in the other direction... Any idea what could cause this ?

Thanks,

qbonnard avatar Nov 25 '15 23:11 qbonnard

Sorry everyone, I've been looking into this and it has been a relatively difficult issue to pinpoint. XirSys, a WebRTC server hosting company posted some of the Common WebRTC problems. Says one issue is "No hardware / driver support. WebRTC in Android isn't enabled for all devices." However some issues can probably be fixed by using XirSys Servers. The updated AndroidRTC has code showing how to use XirSys servers. See here for the server code. Hoping that's not the case with the issues on this page.

Once you have that class, we can create a function that gathers ICE Servers as follows.

 public List<PeerConnection.IceServer> getXirSysIceServers(){
    List<PeerConnection.IceServer> servers = new ArrayList<PeerConnection.IceServer>();
    try {
        servers = new XirSysRequest().execute().get();
    } catch (InterruptedException e){
        e.printStackTrace();
    } catch (ExecutionException e){
       e.printStackTrace();
    }
    return servers;
}

Now when we place our call in VideoChatActivity we can provide servers to our PnSignalingParams as follows:

List<PeerConnection.IceServer> servers = getXirSysIceServers(); 
if (!servers.isEmpty()){ 
    this.pnRTCClient.setSignalParams(new PnSignalingParams(servers)); 
}

I will add this all to the tutorial in the near future. Hope some of this helps.

Also thanks @qbonnard, what did you change to get audio going from tablet to phone?

GleasonK avatar Feb 12 '16 18:02 GleasonK

Hello,

This project and your tutorial was well done, I created my own app using the guide. However I am also having the problem of the Caller cannot hear the Callee's audio but the Callee can hear the Caller. Other than that it works well, I have asked on Stack overflow and will provide the link below. Just posting here incase anyone has solved this problem or has insight as to why this situation would happen

http://stackoverflow.com/questions/36611968/video-chat-with-webrtc-on-android-using-pubnubs-sdk-and-api

tcsdeveloperssc avatar Apr 14 '16 17:04 tcsdeveloperssc

pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));

louqianquan avatar Sep 07 '16 08:09 louqianquan

#14

Should fix the issue. For now you will have to clone the repo and add it to your project. Will rebuild artifacts for the gradle distribution shortly.

GleasonK avatar Sep 07 '16 13:09 GleasonK