PeerConnection shutdown-time fixes
- TCPPort::~TCPPort() was leaking incoming_ sockets; now they are deleted. - PeerConnection::RemoveStream() now removes streams even if the PeerConnection::IsClosed(). Previously such streams would never get removed. - Gave MediaStreamTrackInterface a virtual destructor to ensure deletes on base pointers are dispatched virtually. - VideoTrack.dispose() delegates to super.dispose() (instead of leaking) - PeerConnection.dispose() now removes streams before disposing of them. - MediaStream.dispose() now removes tracks before disposing of them. - VideoCapturer.dispose() only unowned VideoCapturers (mirroring C++ API) - AppRTCDemo.disconnectAndExit() now correctly .dispose()s its VideoSource and PeerConnectionFactory. - CHECK that Release()d objects are deleted when expected to (i.e. no ref-cycles or missing .dispose() calls) in the Java API. - Create & Return webrtc::Traces at factory birth/death to be able to assert that _all_ threads started during the test are collected by the end. - Name threads attached to the JVM more informatively for debugging. - Removed a bunch of unnecessary scoped_refptr instances in peerconnection_jni.cc whose only job was messing with refcounts. RISK=P2 TESTED=AppRTCDemo can be ended and restarted just fine instead of crashing on camera unavailability. No more post-app-exit logcat lines. PCTest.java now asserts that all threads are collected before exit. BUG=2183 R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2005004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4534 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		| @@ -71,6 +71,8 @@ import java.util.List; | ||||
| public class AppRTCDemoActivity extends Activity | ||||
|     implements AppRTCClient.IceServersObserver { | ||||
|   private static final String TAG = "AppRTCDemoActivity"; | ||||
|   private PeerConnectionFactory factory; | ||||
|   private VideoSource videoSource; | ||||
|   private PeerConnection pc; | ||||
|   private final PCObserver pcObserver = new PCObserver(); | ||||
|   private final SDPObserver sdpObserver = new SDPObserver(); | ||||
| @@ -183,8 +185,7 @@ public class AppRTCDemoActivity extends Activity | ||||
|  | ||||
|   @Override | ||||
|   public void onIceServers(List<PeerConnection.IceServer> iceServers) { | ||||
|     PeerConnectionFactory factory = new PeerConnectionFactory(); | ||||
|  | ||||
|     factory = new PeerConnectionFactory(); | ||||
|     pc = factory.createPeerConnection( | ||||
|         iceServers, appRtcClient.pcConstraints(), pcObserver); | ||||
|  | ||||
| @@ -217,7 +218,7 @@ public class AppRTCDemoActivity extends Activity | ||||
|     { | ||||
|       logAndToast("Creating local video source..."); | ||||
|       VideoCapturer capturer = getVideoCapturer(); | ||||
|       VideoSource videoSource = factory.createVideoSource( | ||||
|       videoSource = factory.createVideoSource( | ||||
|           capturer, appRtcClient.videoConstraints()); | ||||
|       MediaStream lMS = factory.createLocalMediaStream("ARDAMS"); | ||||
|       VideoTrack videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource); | ||||
| @@ -485,6 +486,14 @@ public class AppRTCDemoActivity extends Activity | ||||
|         appRtcClient.disconnect(); | ||||
|         appRtcClient = null; | ||||
|       } | ||||
|       if (videoSource != null) { | ||||
|         videoSource.dispose(); | ||||
|         videoSource = null; | ||||
|       } | ||||
|       if (factory != null) { | ||||
|         factory.dispose(); | ||||
|         factory = null; | ||||
|       } | ||||
|       finish(); | ||||
|     } | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 fischman@webrtc.org
					fischman@webrtc.org