0

I am implementing webrtc in android using libjingle (version-9127), the issue is that in one application life cycle when I try to make calls, then the first call is successfully established and then ended. But when second call is made then when the call gets pickup then , the video is displayed , but audio stream is not transferred and then after 3-7 sec the app crashes giving this error. The complete logcat error is below:

08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: BuiltInAECIsAvailable@[tid=23918]
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/AudioManager: SetCommunicationMode(1)@[tid=23918]
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioManager: setCommunicationMode(true)@[name=Thread-1692 - 23918, id=1699]
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: InitRecording@[tid=23918]
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: InitRecording(sampleRate=48000, channels=1)
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: byteBuffer.capacity: 960
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: OnCacheDirectBufferAddress
08-25 13:47:12.099 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: direct buffer capacity: 960
08-25 13:47:12.109 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: AudioRecord.getMinBufferSize: 4096
08-25 13:47:12.109 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: bufferSizeInBytes: 4096
08-25 13:47:12.109 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: AudioRecord session ID: 299, audio format: 2, channels: 1, sample rate: 48000
08-25 13:47:12.109 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: AcousticEchoCanceler.isAvailable: false
08-25 13:47:12.129 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: frames_per_buffer: 480
08-25 13:47:12.129 20887-23918/com.justtotaltech.tagove.app D/AudioRecordJni: StartRecording@[tid=23918]
08-25 13:47:12.129 20887-23918/com.justtotaltech.tagove.app D/WebRtcAudioRecord: StartRecording
08-25 13:47:12.159 20887-24120/com.justtotaltech.tagove.app D/WebRtcAudioRecord: AudioRecordThread@[name=AudioRecordJavaThread, id=1707]
08-25 13:47:12.159 20887-24120/com.justtotaltech.tagove.app E/AudioRecord: start() status -38
08-25 13:47:12.159 20887-24120/com.justtotaltech.tagove.app W/dalvikvm: threadid=41: thread exiting with uncaught exception (group=0x41687d58)
08-25 13:47:15.232 20887-24120/com.justtotaltech.tagove.app E/AndroidRuntime: FATAL EXCEPTION: AudioRecordJavaThread

                 Process: com.justtotaltech.tagove.app, PID: 20887
                          java.lang.AssertionError: Expected condition to be true
                          at org.webrtc.voiceengine.WebRtcAudioRecord.assertTrue(WebRtcAudioRecord.java:259)
                          at org.webrtc.voiceengine.WebRtcAudioRecord.access$300(WebRtcAudioRecord.java:29)
                          at org.webrtc.voiceengine.WebRtcAudioRecord$AudioRecordThread.run(WebRtcAudioRecord.java:79)

Edit: To disconnect the call I have made this code. Hope you can figur out what the error is. After this I am releasing peerConnections

if(mediaStream != null  && isLocal) {

        mediaStream.removeTrack(audioTrack);
        audioTrack.setState(MediaStreamTrack.State.ENDED);
        audioTrack = null;
        audioSource = null;

        if(videoTrack != null && ActivityCall.callTypeGlobal.equals(CallManager.CallType.VIDEO)){
            Log.d("TestCallType",String.valueOf(ActivityCall.callTypeGlobal));
            mediaStream.removeTrack(videoTrack);
            videoTrack = null;

            source.stop();

            videoCapturer.dispose();
            videoCapturer = null;
            activeCamera = null;
            Log.d("TestCallType","Video Track"+String.valueOf(videoTrack));
            Log.d("TestCallType","Video Capturer"+String.valueOf(videoCapturer));
        }

        mediaStream = null;
    }
Akshay Bissa
  • 109
  • 1
  • 10

1 Answers1

0

Looking at the source code (if that's not the repository i'm sure that's the class that you're using based on the error lines numbers) the line that causes the exception is this: assertTrue(audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING)

Make sure to release everything you use after a call finishes. When a new call starts every resource needs to be fresh. And initialize all back again.

Samuel Méndez
  • 601
  • 10
  • 18
  • @AkshayBissa I have basically the same code so I don't know any other steps – Samuel Méndez Aug 25 '16 at 09:40
  • @SamuelMéndez I am using MediaPlayer to play the ringtone can that also be issue for dis – abissa Aug 25 '16 at 09:47
  • Seeing the log the first error is `AudioRecord start() status -38`. There are some questions about that topic (like this http://stackoverflow.com/questions/20460892/audiorecord-start-status-38). Maybe the solution comes from that – Samuel Méndez Aug 25 '16 at 10:15
  • @SamuelMéndez No, this was not useful. Can you provide me what is the complete process to disconnect the call in webrtc – abissa Aug 26 '16 at 12:02
  • @abissa I am working with the same problem. Could you please assist me that how did you solve your problem? Thanks. – Muhammad Usman Bashir May 05 '20 at 09:42