Adds trunk/talk folder of revision 359 from libjingles google code to
trunk/talk


git-svn-id: http://webrtc.googlecode.com/svn/trunk@4318 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppClient.h b/talk/examples/ios/AppRTCDemo/APPRTCAppClient.h
new file mode 100644
index 0000000..cac2f17
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppClient.h
@@ -0,0 +1,54 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "GAEChannelClient.h"
+
+// Called when there are RTCIceServers.
+@protocol IceServerDelegate <NSObject>
+
+- (void)onIceServers:(NSArray *)servers;
+
+@end
+
+// Negotiates signaling for chatting with apprtc.appspot.com "rooms".
+// Uses the client<->server specifics of the apprtc AppEngine webapp.
+//
+// To use: create an instance of this object (registering a message handler) and
+// call connectToRoom().  apprtc.appspot.com will signal that is successful via
+// onOpen through the browser channel.  Then you should call sendData() and wait
+// for the registered handler to be called with received messages.
+@interface APPRTCAppClient : NSObject<NSURLConnectionDataDelegate>
+
+@property(nonatomic, assign) id<IceServerDelegate>iceServerDelegate;
+@property(nonatomic, assign) id<GAEMessageHandler>messageHandler;
+
+- (void)connectToRoom:(NSURL *)room;
+- (void)sendData:(NSData *)data;
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppClient.m b/talk/examples/ios/AppRTCDemo/APPRTCAppClient.m
new file mode 100644
index 0000000..bcc2329
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppClient.m
@@ -0,0 +1,333 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "APPRTCAppClient.h"
+
+#import <dispatch/dispatch.h>
+
+#import "GAEChannelClient.h"
+#import "RTCIceServer.h"
+
+@interface APPRTCAppClient ()
+
+@property(nonatomic, strong) dispatch_queue_t backgroundQueue;
+@property(nonatomic, copy) NSString *baseURL;
+@property(nonatomic, strong) GAEChannelClient *gaeChannel;
+@property(nonatomic, copy) NSString *postMessageUrl;
+@property(nonatomic, copy) NSString *pcConfig;
+@property(nonatomic, strong) NSMutableString *receivedData;
+@property(atomic, strong) NSMutableArray *sendQueue;
+@property(nonatomic, copy) NSString *token;
+
+@property(nonatomic, assign) BOOL verboseLogging;
+
+@end
+
+@implementation APPRTCAppClient
+
+- (id)init {
+  if (self = [super init]) {
+    _backgroundQueue = dispatch_queue_create("RTCBackgroundQueue", NULL);
+    _sendQueue = [NSMutableArray array];
+    // Uncomment to see Request/Response logging.
+    //_verboseLogging = YES;
+  }
+  return self;
+}
+
+#pragma mark - Public methods
+
+- (void)connectToRoom:(NSURL *)url {
+  NSURLRequest *request = [self getRequestFromUrl:url];
+  [NSURLConnection connectionWithRequest:request delegate:self];
+}
+
+- (void)sendData:(NSData *)data {
+  @synchronized(self) {
+    [self maybeLogMessage:@"Send message"];
+    [self.sendQueue addObject:[data copy]];
+  }
+  [self requestQueueDrainInBackground];
+}
+
+#pragma mark - Internal methods
+
+- (NSTextCheckingResult *)findMatch:(NSString *)regexpPattern
+                         withString:(NSString *)string
+                       errorMessage:(NSString *)errorMessage {
+  NSError *error;
+  NSRegularExpression *regexp =
+      [NSRegularExpression regularExpressionWithPattern:regexpPattern
+                                                options:0
+                                                  error:&error];
+  if (error) {
+    [self maybeLogMessage:
+            [NSString stringWithFormat:@"Failed to create regexp - %@",
+                [error description]]];
+    return nil;
+  }
+  NSRange fullRange = NSMakeRange(0, [string length]);
+  NSArray *matches = [regexp matchesInString:string options:0 range:fullRange];
+  if ([matches count] == 0) {
+    if ([errorMessage length] > 0) {
+      [self maybeLogMessage:string];
+      [self showMessage:
+              [NSString stringWithFormat:@"Missing %@ in HTML.", errorMessage]];
+    }
+    return nil;
+  } else if ([matches count] > 1) {
+    if ([errorMessage length] > 0) {
+      [self maybeLogMessage:string];
+      [self showMessage:[NSString stringWithFormat:@"Too many %@s in HTML.",
+                         errorMessage]];
+    }
+    return nil;
+  }
+  return matches[0];
+}
+
+- (NSURLRequest *)getRequestFromUrl:(NSURL *)url {
+  self.receivedData = [NSMutableString stringWithCapacity:20000];
+  NSString *path =
+      [NSString stringWithFormat:@"https:%@", [url resourceSpecifier]];
+  NSURLRequest *request =
+      [NSURLRequest requestWithURL:[NSURL URLWithString:path]];
+  return request;
+}
+
+- (void)maybeLogMessage:(NSString *)message {
+  if (self.verboseLogging) {
+    NSLog(@"%@", message);
+  }
+}
+
+- (void)requestQueueDrainInBackground {
+  dispatch_async(self.backgroundQueue, ^(void) {
+    // TODO(hughv): This can block the UI thread.  Fix.
+    @synchronized(self) {
+      if ([self.postMessageUrl length] < 1) {
+        return;
+      }
+      for (NSData *data in self.sendQueue) {
+        NSString *url = [NSString stringWithFormat:@"%@/%@",
+                         self.baseURL,
+                         self.postMessageUrl];
+        [self sendData:data withUrl:url];
+      }
+      [self.sendQueue removeAllObjects];
+    }
+  });
+}
+
+- (void)sendData:(NSData *)data withUrl:(NSString *)url {
+  NSMutableURLRequest *request =
+      [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
+  request.HTTPMethod = @"POST";
+  [request setHTTPBody:data];
+  NSURLResponse *response;
+  NSError *error;
+  NSData *responseData = [NSURLConnection sendSynchronousRequest:request
+                                               returningResponse:&response
+                                                           error:&error];
+  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
+  int status = [httpResponse statusCode];
+  NSAssert(status == 200,
+           @"Bad response [%d] to message: %@\n\n%@",
+           status,
+           [NSString stringWithUTF8String:[data bytes]],
+           [NSString stringWithUTF8String:[responseData bytes]]);
+}
+
+- (void)showMessage:(NSString *)message {
+  NSLog(@"%@", message);
+  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Unable to join"
+                                                      message:message
+                                                     delegate:nil
+                                            cancelButtonTitle:@"OK"
+                                            otherButtonTitles:nil];
+  [alertView show];
+}
+
+- (void)updateIceServers:(NSMutableArray *)iceServers
+          withTurnServer:(NSString *)turnServerUrl {
+  if ([turnServerUrl length] < 1) {
+    [self.iceServerDelegate onIceServers:iceServers];
+    return;
+  }
+  dispatch_async(self.backgroundQueue, ^(void) {
+    NSMutableURLRequest *request = [NSMutableURLRequest
+        requestWithURL:[NSURL URLWithString:turnServerUrl]];
+    [request addValue:@"Mozilla/5.0" forHTTPHeaderField:@"user-agent"];
+    [request addValue:@"https://apprtc.appspot.com"
+        forHTTPHeaderField:@"origin"];
+    NSURLResponse *response;
+    NSError *error;
+    NSData *responseData = [NSURLConnection sendSynchronousRequest:request
+                                                 returningResponse:&response
+                                                             error:&error];
+    if (!error) {
+      NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData
+                                                           options:0
+                                                             error:&error];
+      NSAssert(!error, @"Unable to parse.  %@", error.localizedDescription);
+      NSString *username = json[@"username"];
+      NSString *turnServer = json[@"turn"];
+      NSString *password = json[@"password"];
+      NSString *fullUrl =
+          [NSString stringWithFormat:@"turn:%@@%@", username, turnServer];
+      RTCIceServer *iceServer =
+          [[RTCIceServer alloc] initWithUri:[NSURL URLWithString:fullUrl]
+                                   password:password];
+      [iceServers addObject:iceServer];
+    } else {
+      NSLog(@"Unable to get TURN server.  Error: %@", error.description);
+    }
+
+    dispatch_async(dispatch_get_main_queue(), ^(void) {
+      [self.iceServerDelegate onIceServers:iceServers];
+    });
+  });
+}
+
+#pragma mark - NSURLConnectionDataDelegate methods
+
+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+  NSString *roomHtml = [NSString stringWithUTF8String:[data bytes]];
+  [self maybeLogMessage:
+          [NSString stringWithFormat:@"Received %d chars", [roomHtml length]]];
+  [self.receivedData appendString:roomHtml];
+}
+
+- (void)connection:(NSURLConnection *)connection
+    didReceiveResponse:(NSURLResponse *)response {
+  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
+  int statusCode = [httpResponse statusCode];
+  [self maybeLogMessage:
+          [NSString stringWithFormat:
+                  @"Response received\nURL\n%@\nStatus [%d]\nHeaders\n%@",
+              [httpResponse URL],
+              statusCode,
+              [httpResponse allHeaderFields]]];
+  NSAssert(statusCode == 200, @"Invalid response  of %d received.", statusCode);
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
+  [self maybeLogMessage:[NSString stringWithFormat:@"finished loading %d chars",
+                         [self.receivedData length]]];
+  NSTextCheckingResult *result =
+      [self findMatch:@".*\n *Sorry, this room is full\\..*"
+            withString:self.receivedData
+          errorMessage:nil];
+  if (result) {
+    [self showMessage:@"Room full"];
+    return;
+  }
+
+  NSString *fullUrl = [[[connection originalRequest] URL] absoluteString];
+  NSRange queryRange = [fullUrl rangeOfString:@"?"];
+  self.baseURL = [fullUrl substringToIndex:queryRange.location];
+  [self maybeLogMessage:[NSString stringWithFormat:@"URL\n%@", self.baseURL]];
+
+  result = [self findMatch:@".*\n *openChannel\\('([^']*)'\\);\n.*"
+                withString:self.receivedData
+              errorMessage:@"channel token"];
+  if (!result) {
+    return;
+  }
+  self.token = [self.receivedData substringWithRange:[result rangeAtIndex:1]];
+  [self maybeLogMessage:[NSString stringWithFormat:@"Token\n%@", self.token]];
+
+  result =
+      [self findMatch:@".*\n *path = '/(message\\?r=.+)' \\+ '(&u=[0-9]+)';\n.*"
+            withString:self.receivedData
+          errorMessage:@"postMessage URL"];
+  if (!result) {
+    return;
+  }
+  self.postMessageUrl =
+      [NSString stringWithFormat:@"%@%@",
+          [self.receivedData substringWithRange:[result rangeAtIndex:1]],
+          [self.receivedData substringWithRange:[result rangeAtIndex:2]]];
+  [self maybeLogMessage:[NSString stringWithFormat:@"POST message URL\n%@",
+                         self.postMessageUrl]];
+
+  result = [self findMatch:@".*\n *var pc_config = (\\{[^\n]*\\});\n.*"
+                withString:self.receivedData
+              errorMessage:@"pc_config"];
+  if (!result) {
+    return;
+  }
+  NSString *pcConfig =
+      [self.receivedData substringWithRange:[result rangeAtIndex:1]];
+  [self maybeLogMessage:
+          [NSString stringWithFormat:@"PC Config JSON\n%@", pcConfig]];
+
+  result = [self findMatch:@".*\n *requestTurn\\('([^\n]*)'\\);\n.*"
+                withString:self.receivedData
+              errorMessage:@"channel token"];
+  NSString *turnServerUrl;
+  if (result) {
+    turnServerUrl =
+        [self.receivedData substringWithRange:[result rangeAtIndex:1]];
+    [self maybeLogMessage:
+            [NSString stringWithFormat:@"TURN server request URL\n%@",
+                turnServerUrl]];
+  }
+
+  NSError *error;
+  NSData *pcData = [pcConfig dataUsingEncoding:NSUTF8StringEncoding];
+  NSDictionary *json =
+      [NSJSONSerialization JSONObjectWithData:pcData options:0 error:&error];
+  NSAssert(!error, @"Unable to parse.  %@", error.localizedDescription);
+  NSArray *servers = [json objectForKey:@"iceServers"];
+  NSMutableArray *iceServers = [NSMutableArray array];
+  for (NSDictionary *server in servers) {
+    NSString *url = [server objectForKey:@"url"];
+    NSString *credential = [server objectForKey:@"credential"];
+    if (!credential) {
+      credential = @"";
+    }
+    [self maybeLogMessage:
+            [NSString stringWithFormat:@"url [%@] - credential [%@]",
+                url,
+                credential]];
+    RTCIceServer *iceServer =
+        [[RTCIceServer alloc] initWithUri:[NSURL URLWithString:url]
+                                 password:credential];
+    [iceServers addObject:iceServer];
+  }
+  [self updateIceServers:iceServers withTurnServer:turnServerUrl];
+
+  [self maybeLogMessage:
+          [NSString stringWithFormat:@"About to open GAE with token:  %@",
+              self.token]];
+  self.gaeChannel =
+      [[GAEChannelClient alloc] initWithToken:self.token
+                                     delegate:self.messageHandler];
+}
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h
new file mode 100644
index 0000000..82b07f0
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.h
@@ -0,0 +1,53 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <UIKit/UIKit.h>
+
+#import "GAEChannelClient.h"
+#import "APPRTCAppClient.h"
+#import "RTCSessionDescriptonDelegate.h"
+
+// Used to send a message to an apprtc.appspot.com "room".
+@protocol APPRTCSendMessage<NSObject>
+
+- (void)sendData:(NSData *)data;
+
+@end
+
+@class APPRTCViewController;
+
+// The main application class of the AppRTCDemo iOS app demonstrating
+// interoperability between the Objcective C implementation of PeerConnection
+// and the apprtc.appspot.com demo webapp.
+@interface APPRTCAppDelegate : UIResponder<IceServerDelegate,
+    GAEMessageHandler, APPRTCSendMessage, RTCSessionDescriptonDelegate,
+    UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+@property (strong, nonatomic) APPRTCViewController *viewController;
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
new file mode 100644
index 0000000..0c429a0
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
@@ -0,0 +1,370 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "APPRTCAppDelegate.h"
+
+#import "APPRTCViewController.h"
+#import "RTCIceCandidate.h"
+#import "RTCIceServer.h"
+#import "RTCMediaConstraints.h"
+#import "RTCMediaStream.h"
+#import "RTCPair.h"
+#import "RTCPeerConnection.h"
+#import "RTCPeerConnectionDelegate.h"
+#import "RTCPeerConnectionFactory.h"
+#import "RTCSessionDescription.h"
+
+@interface PCObserver : NSObject<RTCPeerConnectionDelegate>
+
+- (id)initWithDelegate:(id<APPRTCSendMessage>)delegate;
+
+@end
+
+@implementation PCObserver {
+  id<APPRTCSendMessage> _delegate;
+}
+
+- (id)initWithDelegate:(id<APPRTCSendMessage>)delegate {
+  if (self = [super init]) {
+    _delegate = delegate;
+  }
+  return self;
+}
+
+- (void)peerConnectionOnError:(RTCPeerConnection *)peerConnection {
+  NSLog(@"PCO onError.");
+  NSAssert(NO, @"PeerConnection failed.");
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+    onSignalingStateChange:(RTCSignalingState)stateChanged {
+  NSLog(@"PCO onSignalingStateChange.");
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+           onAddStream:(RTCMediaStream *)stream {
+  NSLog(@"PCO onAddStream.");
+  dispatch_async(dispatch_get_main_queue(), ^(void) {
+    NSAssert([stream.audioTracks count] >= 1,
+             @"Expected at least 1 audio stream");
+    //NSAssert([stream.videoTracks count] >= 1,
+    //         @"Expected at least 1 video stream");
+    // TODO(hughv): Add video support
+  });
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+        onRemoveStream:(RTCMediaStream *)stream {
+  NSLog(@"PCO onRemoveStream.");
+  // TODO(hughv): Remove video track.
+}
+
+- (void)
+    peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)peerConnection {
+  NSLog(@"PCO onRenegotiationNeeded.");
+  // TODO(hughv): Handle this.
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+        onIceCandidate:(RTCIceCandidate *)candidate {
+  NSLog(@"PCO onIceCandidate.\n  Mid[%@] Index[%d] Sdp[%@]",
+        candidate.sdpMid,
+        candidate.sdpMLineIndex,
+        candidate.sdp);
+  NSDictionary *json =
+      @{ @"type" : @"candidate",
+         @"label" : [NSNumber numberWithInt:candidate.sdpMLineIndex],
+         @"id" : candidate.sdpMid,
+         @"candidate" : candidate.sdp };
+  NSError *error;
+  NSData *data =
+      [NSJSONSerialization dataWithJSONObject:json options:0 error:&error];
+  if (!error) {
+    [_delegate sendData:data];
+  } else {
+    NSAssert(NO, @"Unable to serialize JSON object with error: %@",
+             error.localizedDescription);
+  }
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+    onIceGatheringChange:(RTCIceGatheringState)newState {
+  NSLog(@"PCO onIceGatheringChange. %d", newState);
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+    onIceConnectionChange:(RTCIceConnectionState)newState {
+  NSLog(@"PCO onIceConnectionChange. %d", newState);
+}
+
+@end
+
+@interface APPRTCAppDelegate ()
+
+@property(nonatomic, strong) APPRTCAppClient *client;
+@property(nonatomic, strong) PCObserver *pcObserver;
+@property(nonatomic, strong) RTCPeerConnection *peerConnection;
+@property(nonatomic, strong) RTCPeerConnectionFactory *peerConnectionFactory;
+@property(nonatomic, strong) NSMutableArray *queuedRemoteCandidates;
+
+@end
+
+@implementation APPRTCAppDelegate
+
+#pragma mark - UIApplicationDelegate methods
+
+- (BOOL)application:(UIApplication *)application
+    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+  self.viewController =
+      [[APPRTCViewController alloc] initWithNibName:@"RTCViewController"
+                                             bundle:nil];
+  self.window.rootViewController = self.viewController;
+  [self.window makeKeyAndVisible];
+  return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+  [self displayLogMessage:@"Application lost focus, connection broken."];
+  [self disconnect];
+  [self.viewController resetUI];
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+}
+
+- (BOOL)application:(UIApplication *)application
+              openURL:(NSURL *)url
+    sourceApplication:(NSString *)sourceApplication
+           annotation:(id)annotation {
+  if (self.client) {
+    return NO;
+  }
+  self.client = [[APPRTCAppClient alloc] init];
+  self.client.iceServerDelegate = self;
+  self.client.messageHandler = self;
+  [self.client connectToRoom:url];
+  return YES;
+}
+
+- (void)displayLogMessage:(NSString *)message {
+  NSLog(@"%@", message);
+  [self.viewController displayText:message];
+}
+
+#pragma mark - RTCSendMessage method
+
+- (void)sendData:(NSData *)data {
+  [self.client sendData:data];
+}
+
+#pragma mark - IceServerDelegate method
+
+- (void)onIceServers:(NSArray *)servers {
+  self.queuedRemoteCandidates = [NSMutableArray array];
+  self.peerConnectionFactory = [[RTCPeerConnectionFactory alloc] init];
+  RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] init];
+  self.pcObserver = [[PCObserver alloc] initWithDelegate:self];
+  self.peerConnection =
+      [self.peerConnectionFactory peerConnectionWithIceServers:servers
+                                                   constraints:constraints
+                                                      delegate:self.pcObserver];
+  RTCMediaStream *lms =
+      [self.peerConnectionFactory mediaStreamWithLabel:@"ARDAMS"];
+  // TODO(hughv): Add video.
+  [lms addAudioTrack:[self.peerConnectionFactory audioTrackWithId:@"ARDAMSa0"]];
+  [self.peerConnection addStream:lms withConstraints:constraints];
+  [self displayLogMessage:@"onIceServers - add local stream."];
+}
+
+#pragma mark - GAEMessageHandler methods
+
+- (void)onOpen {
+  [self displayLogMessage:@"GAE onOpen - create offer."];
+  RTCPair *audio =
+      [[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"];
+  // TODO(hughv): Add video.
+  //  RTCPair *video = [[RTCPair alloc] initWithKey:@"OfferToReceiveVideo"
+  //                                          value:@"true"];
+  NSArray *mandatory = @[ audio /*, video*/ ];
+  RTCMediaConstraints *constraints =
+      [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatory
+                                            optionalConstraints:nil];
+  [self.peerConnection createOfferWithDelegate:self constraints:constraints];
+  [self displayLogMessage:@"PC - createOffer."];
+}
+
+- (void)onMessage:(NSString *)data {
+  NSString *message = [self unHTMLifyString:data];
+  NSError *error;
+  NSDictionary *objects = [NSJSONSerialization
+      JSONObjectWithData:[message dataUsingEncoding:NSUTF8StringEncoding]
+                 options:0
+                   error:&error];
+  NSAssert(!error,
+           @"%@",
+           [NSString stringWithFormat:@"Error: %@", error.description]);
+  NSAssert([objects count] > 0, @"Invalid JSON object");
+  NSString *value = [objects objectForKey:@"type"];
+  [self displayLogMessage:
+          [NSString stringWithFormat:@"GAE onMessage type - %@", value]];
+  if ([value compare:@"candidate"] == NSOrderedSame) {
+    NSString *mid = [objects objectForKey:@"id"];
+    NSNumber *sdpLineIndex = [objects objectForKey:@"label"];
+    NSString *sdp = [objects objectForKey:@"candidate"];
+    RTCIceCandidate *candidate =
+        [[RTCIceCandidate alloc] initWithMid:mid
+                                       index:sdpLineIndex.intValue
+                                         sdp:sdp];
+    if (self.queuedRemoteCandidates) {
+      [self.queuedRemoteCandidates addObject:candidate];
+    } else {
+      [self.peerConnection addIceCandidate:candidate];
+    }
+  } else if (([value compare:@"offer"] == NSOrderedSame) ||
+             ([value compare:@"answer"] == NSOrderedSame)) {
+    NSString *sdpString = [objects objectForKey:@"sdp"];
+    RTCSessionDescription *sdp =
+        [[RTCSessionDescription alloc] initWithType:value sdp:sdpString];
+    [self.peerConnection setRemoteDescriptionWithDelegate:self
+                                       sessionDescription:sdp];
+    [self displayLogMessage:@"PC - setRemoteDescription."];
+  } else if ([value compare:@"bye"] == NSOrderedSame) {
+    [self disconnect];
+  } else {
+    NSAssert(NO, @"Invalid message: %@", data);
+  }
+}
+
+- (void)onClose {
+  [self displayLogMessage:@"GAE onClose."];
+  [self disconnect];
+}
+
+- (void)onError:(int)code withDescription:(NSString *)description {
+  [self displayLogMessage:
+          [NSString stringWithFormat:@"GAE onError:  %@", description]];
+  [self disconnect];
+}
+
+#pragma mark - RTCSessionDescriptonDelegate methods
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+    createSessionDescriptionCompleted:(RTCSessionDescription *)sdp
+                            withError:(NSError *)error {
+  if (error) {
+    [self displayLogMessage:@"SDP onFailure."];
+    NSAssert(NO, error.description);
+    return;
+  }
+
+  [self displayLogMessage:@"SDP onSuccess(SDP) - set local description."];
+  [self.peerConnection setLocalDescriptionWithDelegate:self
+                                    sessionDescription:sdp];
+  [self displayLogMessage:@"PC setLocalDescription."];
+  dispatch_async(dispatch_get_main_queue(), ^(void) {
+    NSDictionary *json = @{ @"type" : sdp.type, @"sdp" : sdp.description };
+    NSError *error;
+    NSData *data =
+        [NSJSONSerialization dataWithJSONObject:json options:0 error:&error];
+    NSAssert(!error,
+             @"%@",
+             [NSString stringWithFormat:@"Error: %@", error.description]);
+    [self sendData:data];
+  });
+}
+
+- (void)peerConnection:(RTCPeerConnection *)peerConnection
+    setSessionDescriptionCompletedWithError:(NSError *)error {
+  if (error) {
+    [self displayLogMessage:@"SDP onFailure."];
+    NSAssert(NO, error.description);
+    return;
+  }
+
+  [self displayLogMessage:@"SDP onSuccess() - possibly drain candidates"];
+  dispatch_async(dispatch_get_main_queue(), ^(void) {
+    // TODO(hughv): Handle non-initiator case.  http://s10/46622051
+    if (self.peerConnection.remoteDescription) {
+      [self displayLogMessage:@"SDP onSuccess - drain candidates"];
+      [self drainRemoteCandidates];
+    }
+  });
+}
+
+#pragma mark - internal methods
+
+- (void)disconnect {
+  [self.client
+      sendData:[@"{\"type\": \"bye\"}" dataUsingEncoding:NSUTF8StringEncoding]];
+  self.peerConnection = nil;
+  self.peerConnectionFactory = nil;
+  self.pcObserver = nil;
+  self.client.iceServerDelegate = nil;
+  self.client.messageHandler = nil;
+  self.client = nil;
+}
+
+- (void)drainRemoteCandidates {
+  for (RTCIceCandidate *candidate in self.queuedRemoteCandidates) {
+    [self.peerConnection addIceCandidate:candidate];
+  }
+  self.queuedRemoteCandidates = nil;
+}
+
+- (NSString *)unHTMLifyString:(NSString *)base {
+  // TODO(hughv): Investigate why percent escapes are being added.  Removing
+  // them isn't necessary on Android.
+  // convert HTML escaped characters to UTF8.
+  NSString *removePercent =
+      [base stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+  // remove leading and trailing ".
+  NSRange range;
+  range.length = [removePercent length] - 2;
+  range.location = 1;
+  NSString *removeQuotes = [removePercent substringWithRange:range];
+  // convert \" to ".
+  NSString *removeEscapedQuotes =
+      [removeQuotes stringByReplacingOccurrencesOfString:@"\\\""
+                                              withString:@"\""];
+  // convert \\ to \.
+  NSString *removeBackslash =
+      [removeEscapedQuotes stringByReplacingOccurrencesOfString:@"\\\\"
+                                                     withString:@"\\"];
+  return removeBackslash;
+}
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCViewController.h b/talk/examples/ios/AppRTCDemo/APPRTCViewController.h
new file mode 100644
index 0000000..6b107a5
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCViewController.h
@@ -0,0 +1,40 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <UIKit/UIKit.h>
+
+// The view controller that is displayed when AppRTCDemo is loaded.
+@interface APPRTCViewController : UIViewController<UITextFieldDelegate>
+
+@property (weak, nonatomic) IBOutlet UITextField *textField;
+@property (weak, nonatomic) IBOutlet UITextView *textInstructions;
+@property (weak, nonatomic) IBOutlet UITextView *textOutput;
+
+- (void)displayText:(NSString *)text;
+- (void)resetUI;
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCViewController.m b/talk/examples/ios/AppRTCDemo/APPRTCViewController.m
new file mode 100644
index 0000000..928686b
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/APPRTCViewController.m
@@ -0,0 +1,83 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "APPRTCViewController.h"
+
+@interface APPRTCViewController ()
+
+@end
+
+@implementation APPRTCViewController
+
+- (void)viewDidLoad {
+  [super viewDidLoad];
+  self.textField.delegate = self;
+}
+
+- (void)displayText:(NSString *)text {
+  dispatch_async(dispatch_get_main_queue(), ^(void) {
+    NSString *output =
+        [NSString stringWithFormat:@"%@\n%@", self.textOutput.text, text];
+    self.textOutput.text = output;
+  });
+}
+
+- (void)resetUI {
+  self.textField.text = nil;
+  self.textField.hidden = NO;
+  self.textInstructions.hidden = NO;
+  self.textOutput.hidden = YES;
+  self.textOutput.text = nil;
+}
+
+#pragma mark - UITextFieldDelegate
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+  NSString *room = textField.text;
+  if ([room length] == 0) {
+    return;
+  }
+  textField.hidden = YES;
+  self.textInstructions.hidden = YES;
+  self.textOutput.hidden = NO;
+  // TODO(hughv): Instead of launching a URL with apprtc scheme, change to
+  // prepopulating the textField with a valid URL missing the room.  This allows
+  // the user to have the simplicity of just entering the room or the ability to
+  // override to a custom appspot instance.  Remove apprtc:// when this is done.
+  NSString *url =
+      [NSString stringWithFormat:@"apprtc://apprtc.appspot.com/?r=%@", room];
+  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
+}
+
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+  // There is no other control that can take focus, so manually resign focus
+  // when return (Join) is pressed to trigger |textFieldDidEndEditing|.
+  [textField resignFirstResponder];
+  return YES;
+}
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/AppRTCDemo-Info.plist b/talk/examples/ios/AppRTCDemo/AppRTCDemo-Info.plist
new file mode 100644
index 0000000..3ab57ed
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/AppRTCDemo-Info.plist
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleDisplayName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIcons</key>
+	<dict>
+		<key>CFBundlePrimaryIcon</key>
+		<dict>
+			<key>CFBundleIconFiles</key>
+			<array>
+				<string>Icon.png</string>
+			</array>
+		</dict>
+	</dict>
+	<key>CFBundleIdentifier</key>
+	<string>com.Google.${PRODUCT_NAME:rfc1034identifier}</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLName</key>
+			<string>com.google.apprtcdemo</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>apprtc</string>
+			</array>
+		</dict>
+	</array>
+	<key>CFBundleVersion</key>
+	<string>1.0</string>
+	<key>LSRequiresIPhoneOS</key>
+	<true/>
+	<key>UIRequiredDeviceCapabilities</key>
+	<array>
+		<string>armv7</string>
+	</array>
+	<key>UIStatusBarTintParameters</key>
+	<dict>
+		<key>UINavigationBar</key>
+		<dict>
+			<key>Style</key>
+			<string>UIBarStyleDefault</string>
+			<key>Translucent</key>
+			<false/>
+		</dict>
+	</dict>
+	<key>UISupportedInterfaceOrientations</key>
+	<array>
+		<string>UIInterfaceOrientationPortrait</string>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+</dict>
+</plist>
diff --git a/talk/examples/ios/AppRTCDemo/AppRTCDemo-Prefix.pch b/talk/examples/ios/AppRTCDemo/AppRTCDemo-Prefix.pch
new file mode 100644
index 0000000..3ac2c3b
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/AppRTCDemo-Prefix.pch
@@ -0,0 +1,40 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//
+// Prefix header for all source files of the 'AppRTCDemo' target in the
+// 'AppRTCDemo' project
+//
+
+#import <Availability.h>
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
+#warning "This project uses features only available in iOS SDK 6.0 and later."
+#endif
+
+#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
diff --git a/talk/examples/ios/AppRTCDemo/Default.png b/talk/examples/ios/AppRTCDemo/Default.png
new file mode 100644
index 0000000..4c8ca6f6
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/Default.png
Binary files differ
diff --git a/talk/examples/ios/AppRTCDemo/GAEChannelClient.h b/talk/examples/ios/AppRTCDemo/GAEChannelClient.h
new file mode 100644
index 0000000..49a928d
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/GAEChannelClient.h
@@ -0,0 +1,49 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <UIKit/UIKit.h>
+
+// These methods will be called by the AppEngine chanel.  The documentation
+// for these methods is found here.  (Yes, it is a JS API.)
+// https://developers.google.com/appengine/docs/java/channel/javascript
+@protocol GAEMessageHandler<NSObject>
+
+- (void)onOpen;
+- (void)onMessage:(NSString *)data;
+- (void)onClose;
+- (void)onError:(int)code withDescription:(NSString *)description;
+
+@end
+
+// Initialize with a token for an AppRTC data channel.  This will load
+// ios_channel.html and use the token to establish a data channel between the
+// application and AppEngine.
+@interface GAEChannelClient : NSObject<UIWebViewDelegate>
+
+- (id)initWithToken:(NSString *)token delegate:(id<GAEMessageHandler>)delegate;
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/GAEChannelClient.m b/talk/examples/ios/AppRTCDemo/GAEChannelClient.m
new file mode 100644
index 0000000..9126f67
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/GAEChannelClient.m
@@ -0,0 +1,104 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "GAEChannelClient.h"
+
+#import "RTCPeerConnectionFactory.h"
+
+@interface GAEChannelClient ()
+
+@property(nonatomic, assign) id<GAEMessageHandler> delegate;
+@property(nonatomic, strong) UIWebView *webView;
+
+@end
+
+@implementation GAEChannelClient
+
+- (id)initWithToken:(NSString *)token delegate:(id<GAEMessageHandler>)delegate {
+  self = [super init];
+  if (self) {
+    _webView = [[UIWebView alloc] init];
+    _webView.delegate = self;
+    _delegate = delegate;
+    NSString *htmlPath =
+        [[NSBundle mainBundle] pathForResource:@"ios_channel" ofType:@"html"];
+    NSURL *htmlUrl = [NSURL fileURLWithPath:htmlPath];
+    NSString *path = [NSString stringWithFormat:@"%@?token=%@",
+                      [htmlUrl absoluteString],
+                      token];
+
+    [_webView
+        loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:path]]];
+  }
+  return self;
+}
+
+- (void)dealloc {
+  _webView.delegate = nil;
+  [_webView stopLoading];
+}
+
+#pragma mark - UIWebViewDelegate method
+
+- (BOOL)webView:(UIWebView *)webView
+    shouldStartLoadWithRequest:(NSURLRequest *)request
+                navigationType:(UIWebViewNavigationType)navigationType {
+  NSString *scheme = [request.URL scheme];
+  if ([scheme compare:@"js-frame"] != NSOrderedSame) {
+    return YES;
+  }
+  NSString *resourceSpecifier = [request.URL resourceSpecifier];
+  NSRange range = [resourceSpecifier rangeOfString:@":"];
+  NSString *method;
+  NSString *message;
+  if (range.length == 0 && range.location == NSNotFound) {
+    method = resourceSpecifier;
+  } else {
+    method = [resourceSpecifier substringToIndex:range.location];
+    message = [resourceSpecifier substringFromIndex:range.location + 1];
+  }
+  dispatch_async(dispatch_get_main_queue(), ^(void) {
+    if ([method compare:@"onopen"] == NSOrderedSame) {
+      [self.delegate onOpen];
+    } else if ([method compare:@"onmessage"] == NSOrderedSame) {
+      [self.delegate onMessage:message];
+    } else if ([method compare:@"onclose"] == NSOrderedSame) {
+      [self.delegate onClose];
+    } else if ([method compare:@"onerror"] == NSOrderedSame) {
+      // TODO(hughv): Get error.
+      int code = -1;
+      NSString *description = message;
+      [self.delegate onError:code withDescription:description];
+    } else {
+      NSAssert(NO, @"Invalid message sent from UIWebView: %@",
+               resourceSpecifier);
+    }
+  });
+  return YES;
+}
+
+@end
diff --git a/talk/examples/ios/AppRTCDemo/en.lproj/APPRTCViewController.xib b/talk/examples/ios/AppRTCDemo/en.lproj/APPRTCViewController.xib
new file mode 100644
index 0000000..cd73ea6
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/en.lproj/APPRTCViewController.xib
@@ -0,0 +1,529 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+	<data>
+		<int key="IBDocument.SystemTarget">1552</int>
+		<string key="IBDocument.SystemVersion">12D78</string>
+		<string key="IBDocument.InterfaceBuilderVersion">3084</string>
+		<string key="IBDocument.AppKitVersion">1187.37</string>
+		<string key="IBDocument.HIToolboxVersion">626.00</string>
+		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			<string key="NS.object.0">2083</string>
+		</object>
+		<array key="IBDocument.IntegratedClassDependencies">
+			<string>IBNSLayoutConstraint</string>
+			<string>IBProxyObject</string>
+			<string>IBUITextField</string>
+			<string>IBUITextView</string>
+			<string>IBUIView</string>
+		</array>
+		<array key="IBDocument.PluginDependencies">
+			<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+		</array>
+		<object class="NSMutableDictionary" key="IBDocument.Metadata">
+			<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+			<integer value="1" key="NS.object.0"/>
+		</object>
+		<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+			<object class="IBProxyObject" id="372490531">
+				<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBProxyObject" id="843779117">
+				<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBUIView" id="774585933">
+				<nil key="NSNextResponder"/>
+				<int key="NSvFlags">274</int>
+				<array class="NSMutableArray" key="NSSubviews">
+					<object class="IBUITextView" id="176994284">
+						<reference key="NSNextResponder" ref="774585933"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{20, 20}, {280, 141}}</string>
+						<reference key="NSSuperview" ref="774585933"/>
+						<reference key="NSNextKeyView" ref="546385578"/>
+						<string key="NSReuseIdentifierKey">_NS:9</string>
+						<object class="NSColor" key="IBUIBackgroundColor" id="621995359">
+							<int key="NSColorSpace">1</int>
+							<bytes key="NSRGB">MSAxIDEAA</bytes>
+						</object>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<bool key="IBUIUserInteractionEnabled">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<string key="IBUIText">Use Safari and open a URL with a scheme of apprtc to load the test app and connect.  i.e.  apprtc://apprtc.appspot.com/?r=12345678  Or just enter the room below to connect to apprtc.</string>
+						<object class="IBUITextInputTraits" key="IBUITextInputTraits">
+							<int key="IBUIAutocapitalizationType">2</int>
+							<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						</object>
+						<object class="IBUIFontDescription" key="IBUIFontDescription" id="166497611">
+							<int key="type">1</int>
+							<double key="pointSize">14</double>
+						</object>
+						<object class="NSFont" key="IBUIFont" id="371333696">
+							<string key="NSName">Helvetica</string>
+							<double key="NSSize">14</double>
+							<int key="NSfFlags">16</int>
+						</object>
+					</object>
+					<object class="IBUITextField" id="546385578">
+						<reference key="NSNextResponder" ref="774585933"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{20, 180}, {280, 30}}</string>
+						<reference key="NSSuperview" ref="774585933"/>
+						<reference key="NSNextKeyView" ref="634862110"/>
+						<string key="NSReuseIdentifierKey">_NS:9</string>
+						<bool key="IBUIOpaque">NO</bool>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBUIContentVerticalAlignment">0</int>
+						<string key="IBUIText"/>
+						<int key="IBUIBorderStyle">3</int>
+						<string key="IBUIPlaceholder">apprtc room</string>
+						<object class="NSColor" key="IBUITextColor">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MAA</bytes>
+							<object class="NSColorSpace" key="NSCustomColorSpace" id="14071810">
+								<int key="NSID">2</int>
+							</object>
+						</object>
+						<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+						<float key="IBUIMinimumFontSize">17</float>
+						<object class="IBUITextInputTraits" key="IBUITextInputTraits">
+							<int key="IBUIKeyboardType">2</int>
+							<int key="IBUIReturnKeyType">3</int>
+							<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						</object>
+						<reference key="IBUIFontDescription" ref="166497611"/>
+						<reference key="IBUIFont" ref="371333696"/>
+					</object>
+					<object class="IBUITextView" id="634862110">
+						<reference key="NSNextResponder" ref="774585933"/>
+						<int key="NSvFlags">-2147483356</int>
+						<string key="NSFrame">{{20, 20}, {280, 508}}</string>
+						<reference key="NSSuperview" ref="774585933"/>
+						<string key="NSReuseIdentifierKey">_NS:9</string>
+						<reference key="IBUIBackgroundColor" ref="621995359"/>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<bool key="IBUIMultipleTouchEnabled">YES</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<bool key="IBUIEditable">NO</bool>
+						<string key="IBUIText"/>
+						<object class="IBUITextInputTraits" key="IBUITextInputTraits">
+							<int key="IBUIAutocapitalizationType">2</int>
+							<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						</object>
+						<reference key="IBUIFontDescription" ref="166497611"/>
+						<reference key="IBUIFont" ref="371333696"/>
+					</object>
+				</array>
+				<string key="NSFrame">{{0, 20}, {320, 548}}</string>
+				<reference key="NSNextKeyView" ref="176994284"/>
+				<object class="NSColor" key="IBUIBackgroundColor">
+					<int key="NSColorSpace">3</int>
+					<bytes key="NSWhite">MC43NQA</bytes>
+					<reference key="NSCustomColorSpace" ref="14071810"/>
+				</object>
+				<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+				<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+				<object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics">
+					<string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string>
+					<object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<array key="dict.sortedKeys">
+							<integer value="1"/>
+							<integer value="3"/>
+						</array>
+						<array key="dict.values">
+							<string>{320, 568}</string>
+							<string>{568, 320}</string>
+						</array>
+					</object>
+					<string key="IBUITargetRuntime">IBCocoaTouchFramework</string>
+					<string key="IBUIDisplayName">Retina 4 Full Screen</string>
+					<int key="IBUIType">2</int>
+				</object>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+		</array>
+		<object class="IBObjectContainer" key="IBDocument.Objects">
+			<array class="NSMutableArray" key="connectionRecords">
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">view</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="774585933"/>
+					</object>
+					<int key="connectionID">7</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">textField</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="546385578"/>
+					</object>
+					<int key="connectionID">108</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">textInstructions</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="176994284"/>
+					</object>
+					<int key="connectionID">127</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">textOutput</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="634862110"/>
+					</object>
+					<int key="connectionID">138</int>
+				</object>
+			</array>
+			<object class="IBMutableOrderedSet" key="objectRecords">
+				<array key="orderedObjects">
+					<object class="IBObjectRecord">
+						<int key="objectID">0</int>
+						<array key="object" id="0"/>
+						<reference key="children" ref="1000"/>
+						<nil key="parent"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-1</int>
+						<reference key="object" ref="372490531"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">File's Owner</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-2</int>
+						<reference key="object" ref="843779117"/>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">6</int>
+						<reference key="object" ref="774585933"/>
+						<array class="NSMutableArray" key="children">
+							<object class="IBNSLayoutConstraint" id="117610664">
+								<reference key="firstItem" ref="774585933"/>
+								<int key="firstAttribute">6</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="546385578"/>
+								<int key="secondAttribute">6</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="555801739">
+								<reference key="firstItem" ref="546385578"/>
+								<int key="firstAttribute">3</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">3</int>
+								<float key="multiplier">1</float>
+								<object class="IBLayoutConstant" key="constant">
+									<double key="value">180</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">3</int>
+								<float key="scoringTypeFloat">9</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="860801955">
+								<reference key="firstItem" ref="546385578"/>
+								<int key="firstAttribute">5</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">5</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="19985792">
+								<reference key="firstItem" ref="634862110"/>
+								<int key="firstAttribute">3</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">3</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="1001701893">
+								<reference key="firstItem" ref="774585933"/>
+								<int key="firstAttribute">6</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="634862110"/>
+								<int key="secondAttribute">6</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="914503793">
+								<reference key="firstItem" ref="774585933"/>
+								<int key="firstAttribute">4</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="634862110"/>
+								<int key="secondAttribute">4</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="858545289">
+								<reference key="firstItem" ref="634862110"/>
+								<int key="firstAttribute">5</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">5</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="1039342825">
+								<reference key="firstItem" ref="774585933"/>
+								<int key="firstAttribute">6</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="176994284"/>
+								<int key="secondAttribute">6</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="663764352">
+								<reference key="firstItem" ref="176994284"/>
+								<int key="firstAttribute">3</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">3</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<object class="IBNSLayoutConstraint" id="46028745">
+								<reference key="firstItem" ref="176994284"/>
+								<int key="firstAttribute">5</int>
+								<int key="relation">0</int>
+								<reference key="secondItem" ref="774585933"/>
+								<int key="secondAttribute">5</int>
+								<float key="multiplier">1</float>
+								<object class="IBNSLayoutSymbolicConstant" key="constant">
+									<double key="value">20</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="774585933"/>
+								<int key="scoringType">8</int>
+								<float key="scoringTypeFloat">29</float>
+								<int key="contentType">3</int>
+							</object>
+							<reference ref="176994284"/>
+							<reference ref="546385578"/>
+							<reference ref="634862110"/>
+						</array>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">57</int>
+						<reference key="object" ref="176994284"/>
+						<array class="NSMutableArray" key="children">
+							<object class="IBNSLayoutConstraint" id="234302232">
+								<reference key="firstItem" ref="176994284"/>
+								<int key="firstAttribute">8</int>
+								<int key="relation">0</int>
+								<nil key="secondItem"/>
+								<int key="secondAttribute">0</int>
+								<float key="multiplier">1</float>
+								<object class="IBLayoutConstant" key="constant">
+									<double key="value">141</double>
+								</object>
+								<float key="priority">1000</float>
+								<reference key="containingView" ref="176994284"/>
+								<int key="scoringType">3</int>
+								<float key="scoringTypeFloat">9</float>
+								<int key="contentType">1</int>
+							</object>
+						</array>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">62</int>
+						<reference key="object" ref="46028745"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">63</int>
+						<reference key="object" ref="663764352"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">66</int>
+						<reference key="object" ref="1039342825"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">104</int>
+						<reference key="object" ref="546385578"/>
+						<array class="NSMutableArray" key="children"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">107</int>
+						<reference key="object" ref="860801955"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">123</int>
+						<reference key="object" ref="234302232"/>
+						<reference key="parent" ref="176994284"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">124</int>
+						<reference key="object" ref="555801739"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">126</int>
+						<reference key="object" ref="117610664"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">128</int>
+						<reference key="object" ref="634862110"/>
+						<array class="NSMutableArray" key="children"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">133</int>
+						<reference key="object" ref="858545289"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">136</int>
+						<reference key="object" ref="914503793"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">137</int>
+						<reference key="object" ref="1001701893"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">139</int>
+						<reference key="object" ref="19985792"/>
+						<reference key="parent" ref="774585933"/>
+					</object>
+				</array>
+			</object>
+			<dictionary class="NSMutableDictionary" key="flattenedProperties">
+				<string key="-1.CustomClassName">APPRTCViewController</string>
+				<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="-2.CustomClassName">UIResponder</string>
+				<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="104.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<boolean value="NO" key="104.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
+				<string key="107.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="123.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="126.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="128.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<boolean value="NO" key="128.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
+				<string key="133.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="136.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="137.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="139.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<array class="NSMutableArray" key="57.IBViewMetadataConstraints">
+					<reference ref="234302232"/>
+				</array>
+				<boolean value="NO" key="57.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
+				<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<array key="6.IBViewMetadataConstraints">
+					<reference ref="46028745"/>
+					<reference ref="663764352"/>
+					<reference ref="1039342825"/>
+					<reference ref="858545289"/>
+					<reference ref="914503793"/>
+					<reference ref="1001701893"/>
+					<reference ref="19985792"/>
+					<reference ref="860801955"/>
+					<reference ref="555801739"/>
+					<reference ref="117610664"/>
+				</array>
+				<string key="62.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="63.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="66.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			</dictionary>
+			<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+			<nil key="activeLocalization"/>
+			<dictionary class="NSMutableDictionary" key="localizations"/>
+			<nil key="sourceID"/>
+			<int key="maxID">139</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<object class="IBPartialClassDescription">
+					<string key="className">NSLayoutConstraint</string>
+					<string key="superclassName">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
+					</object>
+				</object>
+			</array>
+		</object>
+		<int key="IBDocument.localizationMode">0</int>
+		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+		<int key="IBDocument.defaultPropertyAccessControl">3</int>
+		<bool key="IBDocument.UseAutolayout">YES</bool>
+		<string key="IBCocoaTouchPluginVersion">2083</string>
+	</data>
+</archive>
diff --git a/talk/examples/ios/AppRTCDemo/ios_channel.html b/talk/examples/ios/AppRTCDemo/ios_channel.html
new file mode 100644
index 0000000..a55b8f4
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/ios_channel.html
@@ -0,0 +1,88 @@
+<html>
+  <head>
+    <script src="http://apprtc.appspot.com/_ah/channel/jsapi"></script>
+  </head>
+  <!--
+  Helper HTML that redirects Google AppEngine's Channel API to Objective C.
+  This is done by hosting this page in an iOS application.  The hosting
+  class creates a UIWebView control and implements the UIWebViewDelegate
+  protocol.  Then when there is a channel message, it is encoded in an IFRAME.
+  That IFRAME is added to the DOM which triggers a navigation event
+  |shouldStartLoadWithRequest| in Objective C which can then be routed in the
+  application as desired.
+  -->
+  <body onbeforeunload="closeSocket()" onload="openSocket()">
+    <script type="text/javascript">
+      // QueryString is copy/pasta from
+      // chromium's chrome/test/data/media/html/utils.js.
+      var QueryString = function () {
+        // Allows access to query parameters on the URL; e.g., given a URL like:
+        //    http://<url>/my.html?test=123&bob=123
+        // parameters can now be accessed via QueryString.test or
+        // QueryString.bob.
+        var params = {};
+
+        // RegEx to split out values by &.
+        var r = /([^&=]+)=?([^&]*)/g;
+
+        // Lambda function for decoding extracted match values. Replaces '+'
+        // with space so decodeURIComponent functions properly.
+        function d(s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }
+
+        var match;
+        while (match = r.exec(window.location.search.substring(1)))
+          params[d(match[1])] = d(match[2]);
+
+        return params;
+      } ();
+
+      var channel = null;
+      var socket = null;
+
+      function openSocket() {
+        if (!QueryString.token || !QueryString.token.match(/^[A-z0-9_-]+$/)) {
+          // Send error back to ObjC.  This will assert in GAEChannelClient.m.
+          sendMessageToObjC("JSError:Missing/malformed token parameter " +
+                            QueryString.token);
+          throw "Missing/malformed token parameter: " + QueryString.token;
+        }
+        channel = new goog.appengine.Channel(QueryString.token);
+        socket = channel.open({
+          'onopen': function() {
+            sendMessageToObjC("onopen");
+          },
+          'onmessage': function(msg) {
+            sendMessageToObjC("onmessage:" +
+                              encodeURIComponent(JSON.stringify(msg.data)));
+          },
+          'onclose': function() {
+            sendMessageToObjC("onclose");
+          },
+          'onerror': function(err) {
+            sendMessageToObjC("onerror:" +
+                              encodeURIComponent(JSON.stringify(err.code)) +
+                              ":message:" +
+                              encodeURIComponent(JSON.stringify(err.description)));
+          }
+        });
+      }
+
+      function closeSocket() {
+        socket.close();
+      }
+
+      // Add an IFRAME to the DOM to trigger a navigation event.  Then remove
+      // it as it is no longer needed.  Only one event is generated.
+      function sendMessageToObjC(message) {
+        var iframe = document.createElement("IFRAME");
+        iframe.setAttribute("src", "js-frame:" + message);
+        // For some reason we need to set a non-empty size for the iOS6
+        // simulator...
+        iframe.setAttribute("height", "1px");
+        iframe.setAttribute("width", "1px");
+        document.documentElement.appendChild(iframe);
+        iframe.parentNode.removeChild(iframe);
+      }
+    </script>
+  </body>
+</html>
diff --git a/talk/examples/ios/AppRTCDemo/main.m b/talk/examples/ios/AppRTCDemo/main.m
new file mode 100644
index 0000000..bf35f4c
--- /dev/null
+++ b/talk/examples/ios/AppRTCDemo/main.m
@@ -0,0 +1,37 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <UIKit/UIKit.h>
+
+#import "APPRTCAppDelegate.h"
+
+int main(int argc, char *argv[]) {
+  @autoreleasepool {
+    return UIApplicationMain(
+        argc, argv, nil, NSStringFromClass([APPRTCAppDelegate class]));
+  }
+}