Questions about releasing WEBRTC resources on the Android layer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.