PeerConnection(iOS): make ARC-clean talk/.../objc* and talk/examples/ios

- Removes a strong-reference cycle between RTCPeerConnection and
  RTCPeerConnectionObserver
- Gives RTCPeerConnectionObserver a virtual dtor
- Ensures RTCPeerConnectionTest tears down correctly
- Ensures AppRTCDemo tears down correctly

This is the talk/ half; the webrtc/ half is in https://webrtc-codereview.appspot.com/10539005

BUG=3054,3055,3100
R=noahric@google.com

Review URL: https://webrtc-codereview.appspot.com/10499005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5771 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h
index 517cade..3e6d600 100644
--- a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h
@@ -30,7 +30,7 @@
 #import "GAEChannelClient.h"
 #import "APPRTCAppClient.h"
 #import "RTCSessionDescriptonDelegate.h"
-
+#import "RTCVideoSource.h"
 // Used to send a message to an apprtc.appspot.com "room".
 @protocol APPRTCSendMessage<NSObject>
 
@@ -43,7 +43,7 @@
 @class RTCVideoTrack;
 
 // The main application class of the AppRTCDemo iOS app demonstrating
-// interoperability between the Objcective C implementation of PeerConnection
+// interoperability between the Objective C implementation of PeerConnection
 // and the apprtc.appspot.com demo webapp.
 @interface APPRTCAppDelegate : UIResponder<ICEServerDelegate,
                                            GAEMessageHandler,
@@ -53,6 +53,7 @@
 
 @property(strong, nonatomic) UIWindow* window;
 @property(strong, nonatomic) APPRTCViewController* viewController;
+@property (strong, nonatomic) RTCVideoSource* videoSource;
 
 - (void)closeVideoUI;
 
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
index ee36604..8610477 100644
--- a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
@@ -246,12 +246,12 @@
 
   RTCVideoCapturer* capturer =
       [RTCVideoCapturer capturerWithDeviceName:cameraID];
-  RTCVideoSource* videoSource = [self.peerConnectionFactory
+  self.videoSource = [self.peerConnectionFactory
       videoSourceWithCapturer:capturer
                   constraints:self.client.videoConstraints];
   RTCVideoTrack* localVideoTrack =
       [self.peerConnectionFactory videoTrackWithID:@"ARDAMSv0"
-                                            source:videoSource];
+                                            source:self.videoSource];
   if (localVideoTrack) {
     [lms addVideoTrack:localVideoTrack];
   }
@@ -485,9 +485,10 @@
       sendData:[@"{\"type\": \"bye\"}" dataUsingEncoding:NSUTF8StringEncoding]];
   [self.peerConnection close];
   self.peerConnection = nil;
-  self.peerConnectionFactory = nil;
   self.pcObserver = nil;
   self.client = nil;
+  self.videoSource = nil;
+  self.peerConnectionFactory = nil;
   [RTCPeerConnectionFactory deinitializeSSL];
 }
 
@@ -523,8 +524,8 @@
 #pragma mark - public methods
 
 - (void)closeVideoUI {
-  [self disconnect];
   [self.viewController resetUI];
+  [self disconnect];
 }
 
 @end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCViewController.m b/talk/examples/ios/AppRTCDemo/APPRTCViewController.m
index 8c5ccde..3cebb72 100644
--- a/talk/examples/ios/AppRTCDemo/APPRTCViewController.m
+++ b/talk/examples/ios/AppRTCDemo/APPRTCViewController.m
@@ -77,7 +77,7 @@
   [_remoteVideoView removeFromSuperview];
   self.remoteVideoView = nil;
 
-  [_remoteVideoView renderVideoTrackInterface:nil];
+  [_localVideoView renderVideoTrackInterface:nil];
   [_localVideoView removeFromSuperview];
   self.localVideoView = nil;
 }