The most recent time you've been doing WEBRTC-based Android apps has encountered some problems releasing resources, which are now recorded for memos.
The official Apprtcdemo is too simplistic and many questions are not involved.
1. Releasing the peerconnection resource problem.
Scenario: A and B make a call (Video call)
Now stop the call in B.
Error: After B terminates the call, the terminal a program will exit unexpectedly.
Analysis: When A and b make a call with the corresponding Peerconnection class instance, this instance holds a stream reference (Localstream and remote stream, etc.).
b when terminating a call, release an instance of the Peerconnection class that was established when a call was made. This will cause problems, a in the release of Peerconnection instances will be released Localstream, and Localstream himself still in use, this time the program will terminate unexpectedly.
Workaround: Do not release the local localstream only release the remote stream when the Peerconnection instance is placed. Define events individually to trigger the release of Localstream.
2, Release the whole WEBRTC module problem.
Scenario: A and B make a call, B terminate the call, B then make a video call
Error: b Unexpected termination when video call is made again
Analysis: B When the video call again, due to the last time the video call out of the camera resource is not released, but the screen call again when the camera resources are not available.
This seems to be the problem of not acquiring camera resources, in fact, we have not been released in time after the use of WEBRTC resources.
Workaround: To actually release the appropriate resources, my steps are as follows:
1. Hang up all video calls that are being communicated (Hangupall ()) (release peerconnection instances)
2. Release Localstream
3. Release camera resources (Videosource.dispose () method)
4. Releasing Peerconnectionfactory Resources
Even so when I frequently open and close video calls, the program will still have a certain probability of error. I hope you can help correct my mistake.
Questions about releasing WEBRTC resources on the Android layer