Reputation: 2066
I am working on an Android video-audio call application, so far I have made the main functionality, it's working fine no problem I can make: voice call, video call. my problem is that when I press the home button (video gets interrupted for any reason) I can't get it back again, the strange thing is that I can do what ever I need with the voice; continue while app is in the background and stop voice, but unfortunately I can't control the video at all. I think that there is a problem in the creation of the video related webRTC stuff so here is the code responsible for that:
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
.builder(this)
.setEnableVideoHwAcceleration(true)
.createInitializationOptions());
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(rootEglBase.getEglBaseContext(), true, true);
DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(rootEglBase.getEglBaseContext());
peerConnectionFactory = new PeerConnectionFactory(options, defaultVideoEncoderFactory,defaultVideoDecoderFactory);
videoCapturerAndroid = createCameraCapturer(new Camera1Enumerator(false));
audioConstraints = new MediaConstraints();
videoConstraints = new MediaConstraints();
//Create a VideoSource instance
videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid);
localVideoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);
//create an AudioSource instance
audioSource = peerConnectionFactory.createAudioSource(audioConstraints);
localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);
videoCapturerAndroid.startCapture(1024, 720, 30);
localVideoView.setVisibility(View.VISIBLE);
//create a videoRenderer based on SurfaceViewRenderer instance
localRenderer = new VideoRenderer(localVideoView);
localVideoTrack.addRenderer(localRenderer);
gotUserMedia = true;
I will be updating the question when needed(i.e. some other code snippet is needed). Please help, I have been trying to solve this problem for about a week and the only progress I achieved is learning how to control the voice :) Thank u in advance
Upvotes: 0
Views: 1161
Reputation: 2066
I have spent more time trying to do it, and finally it worked, here is what I did:
I tried to check if the stream is null in the onResume() after I open the app again from the sleep (sleep means the home button was clicked) but it wasn't null. after that I decided to see what will happen if I display the stream again in the onResume() (but I needed to check before I display it if it is null cuz it will be null in the first time I open the app). That's all what I had to do to reuse the video stream again, actually that allowed me to flip the camera(front and back) cuz before that I couldn't do that.
Upvotes: 1