2013-07-10 02:45:36 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-05-31 00:26:06 +02:00
|
|
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
|
|
|
#error "This file requires ARC support."
|
|
|
|
#endif
|
|
|
|
|
2013-07-10 02:45:36 +02:00
|
|
|
#import "APPRTCAppClient.h"
|
|
|
|
|
|
|
|
#import <dispatch/dispatch.h>
|
|
|
|
|
|
|
|
#import "GAEChannelClient.h"
|
2013-08-01 20:29:45 +02:00
|
|
|
#import "RTCICEServer.h"
|
2014-03-10 21:41:22 +01:00
|
|
|
#import "RTCMediaConstraints.h"
|
2014-05-31 00:26:06 +02:00
|
|
|
#import "RTCPair.h"
|
2013-07-10 02:45:36 +02:00
|
|
|
|
|
|
|
@interface APPRTCAppClient ()
|
|
|
|
|
2014-05-31 00:26:06 +02:00
|
|
|
@property(nonatomic, weak, readonly) id<GAEMessageHandler> messageHandler;
|
2014-03-25 01:11:56 +01:00
|
|
|
@property(nonatomic, copy) NSString* baseURL;
|
|
|
|
@property(nonatomic, strong) GAEChannelClient* gaeChannel;
|
|
|
|
@property(nonatomic, copy) NSString* postMessageUrl;
|
|
|
|
@property(nonatomic, copy) NSString* pcConfig;
|
|
|
|
@property(nonatomic, strong) NSMutableString* roomHtml;
|
|
|
|
@property(atomic, strong) NSMutableArray* sendQueue;
|
|
|
|
@property(nonatomic, copy) NSString* token;
|
2013-07-10 02:45:36 +02:00
|
|
|
|
|
|
|
@property(nonatomic, assign) BOOL verboseLogging;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2014-05-31 00:26:06 +02:00
|
|
|
@implementation APPRTCAppClient {
|
|
|
|
dispatch_queue_t _backgroundQueue;
|
|
|
|
}
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-05-31 00:26:06 +02:00
|
|
|
- (id)initWithDelegate:(id<APPRTCAppClientDelegate>)delegate
|
|
|
|
messageHandler:(id<GAEMessageHandler>)handler {
|
2013-07-10 02:45:36 +02:00
|
|
|
if (self = [super init]) {
|
2014-05-31 00:26:06 +02:00
|
|
|
_delegate = delegate;
|
2014-03-25 01:11:56 +01:00
|
|
|
_messageHandler = handler;
|
2014-04-30 02:17:47 +02:00
|
|
|
_backgroundQueue = dispatch_queue_create("RTCBackgroundQueue",
|
|
|
|
DISPATCH_QUEUE_SERIAL);
|
2013-07-10 02:45:36 +02:00
|
|
|
_sendQueue = [NSMutableArray array];
|
|
|
|
// Uncomment to see Request/Response logging.
|
2013-08-01 20:29:45 +02:00
|
|
|
// _verboseLogging = YES;
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Public methods
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)connectToRoom:(NSURL*)url {
|
2014-05-31 00:26:06 +02:00
|
|
|
self.roomHtml = [NSMutableString stringWithCapacity:20000];
|
|
|
|
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
2013-07-10 02:45:36 +02:00
|
|
|
[NSURLConnection connectionWithRequest:request delegate:self];
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)sendData:(NSData*)data {
|
2014-04-30 02:17:47 +02:00
|
|
|
[self maybeLogMessage:@"Send message"];
|
|
|
|
|
2014-05-31 00:26:06 +02:00
|
|
|
dispatch_async(_backgroundQueue, ^{
|
2013-07-10 02:45:36 +02:00
|
|
|
[self.sendQueue addObject:[data copy]];
|
2014-04-30 02:17:47 +02:00
|
|
|
|
|
|
|
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];
|
|
|
|
});
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Internal methods
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (NSString*)findVar:(NSString*)name strippingQuotes:(BOOL)strippingQuotes {
|
2013-08-01 20:29:45 +02:00
|
|
|
NSError* error;
|
|
|
|
NSString* pattern =
|
|
|
|
[NSString stringWithFormat:@".*\n *var %@ = ([^\n]*);\n.*", name];
|
2014-03-25 01:11:56 +01:00
|
|
|
NSRegularExpression* regexp =
|
2013-08-01 20:29:45 +02:00
|
|
|
[NSRegularExpression regularExpressionWithPattern:pattern
|
2013-07-10 02:45:36 +02:00
|
|
|
options:0
|
|
|
|
error:&error];
|
2014-03-25 01:11:56 +01:00
|
|
|
NSAssert(!error,
|
|
|
|
@"Unexpected error compiling regex: ",
|
2013-08-01 20:29:45 +02:00
|
|
|
error.localizedDescription);
|
|
|
|
|
|
|
|
NSRange fullRange = NSMakeRange(0, [self.roomHtml length]);
|
2014-03-25 01:11:56 +01:00
|
|
|
NSArray* matches =
|
2013-08-01 20:29:45 +02:00
|
|
|
[regexp matchesInString:self.roomHtml options:0 range:fullRange];
|
|
|
|
if ([matches count] != 1) {
|
2014-05-31 00:26:06 +02:00
|
|
|
NSString* format = @"%lu matches for %@ in %@";
|
|
|
|
NSString* message = [NSString stringWithFormat:format,
|
|
|
|
(unsigned long)[matches count], name, self.roomHtml];
|
|
|
|
[self.delegate appClient:self didErrorWithMessage:message];
|
2013-07-10 02:45:36 +02:00
|
|
|
return nil;
|
|
|
|
}
|
2013-08-01 20:29:45 +02:00
|
|
|
NSRange matchRange = [matches[0] rangeAtIndex:1];
|
|
|
|
NSString* value = [self.roomHtml substringWithRange:matchRange];
|
|
|
|
if (strippingQuotes) {
|
|
|
|
NSAssert([value length] > 2,
|
2014-03-25 01:11:56 +01:00
|
|
|
@"Can't strip quotes from short string: [%@]",
|
|
|
|
value);
|
2013-08-01 20:29:45 +02:00
|
|
|
NSAssert(([value characterAtIndex:0] == '\'' &&
|
|
|
|
[value characterAtIndex:[value length] - 1] == '\''),
|
2014-03-25 01:11:56 +01:00
|
|
|
@"Can't strip quotes from unquoted string: [%@]",
|
|
|
|
value);
|
2013-08-01 20:29:45 +02:00
|
|
|
value = [value substringWithRange:NSMakeRange(1, [value length] - 2)];
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
2013-08-01 20:29:45 +02:00
|
|
|
return value;
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)maybeLogMessage:(NSString*)message {
|
2013-07-10 02:45:36 +02:00
|
|
|
if (self.verboseLogging) {
|
|
|
|
NSLog(@"%@", message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)sendData:(NSData*)data withUrl:(NSString*)url {
|
|
|
|
NSMutableURLRequest* request =
|
2013-07-10 02:45:36 +02:00
|
|
|
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
|
|
|
|
request.HTTPMethod = @"POST";
|
|
|
|
[request setHTTPBody:data];
|
2014-03-25 01:11:56 +01:00
|
|
|
NSURLResponse* response;
|
|
|
|
NSError* error;
|
|
|
|
NSData* responseData = [NSURLConnection sendSynchronousRequest:request
|
2013-07-10 02:45:36 +02:00
|
|
|
returningResponse:&response
|
|
|
|
error:&error];
|
2014-03-25 01:11:56 +01:00
|
|
|
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
|
2013-07-10 02:45:36 +02:00
|
|
|
int status = [httpResponse statusCode];
|
|
|
|
NSAssert(status == 200,
|
|
|
|
@"Bad response [%d] to message: %@\n\n%@",
|
|
|
|
status,
|
|
|
|
[NSString stringWithUTF8String:[data bytes]],
|
|
|
|
[NSString stringWithUTF8String:[responseData bytes]]);
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)updateICEServers:(NSMutableArray*)ICEServers
|
|
|
|
withTurnServer:(NSString*)turnServerUrl {
|
2013-07-10 02:45:36 +02:00
|
|
|
if ([turnServerUrl length] < 1) {
|
2014-05-31 00:26:06 +02:00
|
|
|
[self.delegate appClient:self didReceiveICEServers:ICEServers];
|
2013-07-10 02:45:36 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-31 00:26:06 +02:00
|
|
|
dispatch_async(_backgroundQueue, ^(void) {
|
2014-03-25 01:11:56 +01:00
|
|
|
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* password = json[@"password"];
|
|
|
|
NSArray* uris = json[@"uris"];
|
|
|
|
for (int i = 0; i < [uris count]; ++i) {
|
|
|
|
NSString* turnServer = [uris objectAtIndex:i];
|
|
|
|
RTCICEServer* ICEServer =
|
|
|
|
[[RTCICEServer alloc] initWithURI:[NSURL URLWithString:turnServer]
|
|
|
|
username:username
|
|
|
|
password:password];
|
|
|
|
NSLog(@"Added ICE Server: %@", ICEServer);
|
|
|
|
[ICEServers addObject:ICEServer];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NSLog(@"Unable to get TURN server. Error: %@", error.description);
|
2013-09-05 23:49:58 +02:00
|
|
|
}
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
2014-05-31 00:26:06 +02:00
|
|
|
[self.delegate appClient:self didReceiveICEServers:ICEServers];
|
2014-03-25 01:11:56 +01:00
|
|
|
});
|
2013-07-10 02:45:36 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - NSURLConnectionDataDelegate methods
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
|
|
|
|
NSString* roomHtml = [NSString stringWithUTF8String:[data bytes]];
|
2014-05-31 00:26:06 +02:00
|
|
|
NSString* message =
|
|
|
|
[NSString stringWithFormat:@"Received %lu chars",
|
|
|
|
(unsigned long)[roomHtml length]];
|
|
|
|
[self maybeLogMessage:message];
|
2013-08-01 20:29:45 +02:00
|
|
|
[self.roomHtml appendString:roomHtml];
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)connection:(NSURLConnection*)connection
|
|
|
|
didReceiveResponse:(NSURLResponse*)response {
|
|
|
|
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
|
2013-07-10 02:45:36 +02:00
|
|
|
int statusCode = [httpResponse statusCode];
|
2014-03-25 01:11:56 +01:00
|
|
|
[self
|
|
|
|
maybeLogMessage:
|
2013-07-10 02:45:36 +02:00
|
|
|
[NSString stringWithFormat:
|
2014-03-25 01:11:56 +01:00
|
|
|
@"Response received\nURL\n%@\nStatus [%d]\nHeaders\n%@",
|
|
|
|
[httpResponse URL],
|
|
|
|
statusCode,
|
|
|
|
[httpResponse allHeaderFields]]];
|
2013-07-10 02:45:36 +02:00
|
|
|
NSAssert(statusCode == 200, @"Invalid response of %d received.", statusCode);
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
- (void)connectionDidFinishLoading:(NSURLConnection*)connection {
|
2014-05-31 00:26:06 +02:00
|
|
|
NSString* message =
|
|
|
|
[NSString stringWithFormat:@"finished loading %lu chars",
|
|
|
|
(unsigned long)[self.roomHtml length]];
|
|
|
|
[self maybeLogMessage:message];
|
2013-08-01 20:29:45 +02:00
|
|
|
NSRegularExpression* fullRegex =
|
2014-03-25 01:11:56 +01:00
|
|
|
[NSRegularExpression regularExpressionWithPattern:@"room is full"
|
|
|
|
options:0
|
|
|
|
error:nil];
|
2013-09-05 23:49:58 +02:00
|
|
|
if ([fullRegex
|
|
|
|
numberOfMatchesInString:self.roomHtml
|
|
|
|
options:0
|
|
|
|
range:NSMakeRange(0, [self.roomHtml length])]) {
|
2014-05-31 00:26:06 +02:00
|
|
|
NSString* message = @"Room full, dropping peerconnection.";
|
|
|
|
[self.delegate appClient:self didErrorWithMessage:message];
|
2013-07-10 02:45:36 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
NSString* fullUrl = [[[connection originalRequest] URL] absoluteString];
|
2013-07-10 02:45:36 +02:00
|
|
|
NSRange queryRange = [fullUrl rangeOfString:@"?"];
|
|
|
|
self.baseURL = [fullUrl substringToIndex:queryRange.location];
|
2014-03-25 01:11:56 +01:00
|
|
|
[self maybeLogMessage:[NSString
|
|
|
|
stringWithFormat:@"Base URL: %@", self.baseURL]];
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-02-10 19:47:11 +01:00
|
|
|
self.initiator = [[self findVar:@"initiator" strippingQuotes:NO] boolValue];
|
2013-08-01 20:29:45 +02:00
|
|
|
self.token = [self findVar:@"channelToken" strippingQuotes:YES];
|
|
|
|
if (!self.token)
|
2013-07-10 02:45:36 +02:00
|
|
|
return;
|
2013-08-01 20:29:45 +02:00
|
|
|
[self maybeLogMessage:[NSString stringWithFormat:@"Token: %@", self.token]];
|
|
|
|
|
|
|
|
NSString* roomKey = [self findVar:@"roomKey" strippingQuotes:YES];
|
|
|
|
NSString* me = [self findVar:@"me" strippingQuotes:YES];
|
|
|
|
if (!roomKey || !me)
|
2013-07-10 02:45:36 +02:00
|
|
|
return;
|
|
|
|
self.postMessageUrl =
|
2014-03-25 01:11:56 +01:00
|
|
|
[NSString stringWithFormat:@"/message?r=%@&u=%@", roomKey, me];
|
2013-08-01 20:29:45 +02:00
|
|
|
[self maybeLogMessage:[NSString stringWithFormat:@"POST message URL: %@",
|
2014-03-25 01:11:56 +01:00
|
|
|
self.postMessageUrl]];
|
2013-08-01 20:29:45 +02:00
|
|
|
|
|
|
|
NSString* pcConfig = [self findVar:@"pcConfig" strippingQuotes:NO];
|
|
|
|
if (!pcConfig)
|
2013-07-10 02:45:36 +02:00
|
|
|
return;
|
2014-03-25 01:11:56 +01:00
|
|
|
[self maybeLogMessage:[NSString
|
|
|
|
stringWithFormat:@"PC Config JSON: %@", pcConfig]];
|
2013-08-01 20:29:45 +02:00
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
NSString* turnServerUrl = [self findVar:@"turnUrl" strippingQuotes:YES];
|
2013-08-01 20:29:45 +02:00
|
|
|
if (turnServerUrl) {
|
2014-03-25 01:11:56 +01:00
|
|
|
[self maybeLogMessage:[NSString
|
|
|
|
stringWithFormat:@"TURN server request URL: %@",
|
|
|
|
turnServerUrl]];
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
NSError* error;
|
|
|
|
NSData* pcData = [pcConfig dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
NSDictionary* json =
|
2013-07-10 02:45:36 +02:00
|
|
|
[NSJSONSerialization JSONObjectWithData:pcData options:0 error:&error];
|
|
|
|
NSAssert(!error, @"Unable to parse. %@", error.localizedDescription);
|
2014-03-25 01:11:56 +01:00
|
|
|
NSArray* servers = [json objectForKey:@"iceServers"];
|
|
|
|
NSMutableArray* ICEServers = [NSMutableArray array];
|
|
|
|
for (NSDictionary* server in servers) {
|
|
|
|
NSString* url = [server objectForKey:@"urls"];
|
|
|
|
NSString* username = json[@"username"];
|
|
|
|
NSString* credential = [server objectForKey:@"credential"];
|
2013-09-05 23:49:58 +02:00
|
|
|
if (!username) {
|
|
|
|
username = @"";
|
|
|
|
}
|
2013-07-10 02:45:36 +02:00
|
|
|
if (!credential) {
|
|
|
|
credential = @"";
|
|
|
|
}
|
2014-03-25 01:11:56 +01:00
|
|
|
[self maybeLogMessage:[NSString
|
|
|
|
stringWithFormat:@"url [%@] - credential [%@]",
|
|
|
|
url,
|
|
|
|
credential]];
|
|
|
|
RTCICEServer* ICEServer =
|
2013-08-01 20:29:45 +02:00
|
|
|
[[RTCICEServer alloc] initWithURI:[NSURL URLWithString:url]
|
2013-09-05 23:49:58 +02:00
|
|
|
username:username
|
2013-07-10 02:45:36 +02:00
|
|
|
password:credential];
|
2013-09-05 23:49:58 +02:00
|
|
|
NSLog(@"Added ICE Server: %@", ICEServer);
|
2013-08-01 20:29:45 +02:00
|
|
|
[ICEServers addObject:ICEServer];
|
2013-07-10 02:45:36 +02:00
|
|
|
}
|
2013-08-01 20:29:45 +02:00
|
|
|
[self updateICEServers:ICEServers withTurnServer:turnServerUrl];
|
2013-07-10 02:45:36 +02:00
|
|
|
|
2014-03-10 21:41:22 +01:00
|
|
|
NSString* mc = [self findVar:@"mediaConstraints" strippingQuotes:NO];
|
|
|
|
if (mc) {
|
|
|
|
error = nil;
|
2014-03-25 01:11:56 +01:00
|
|
|
NSData* mcData = [mc dataUsingEncoding:NSUTF8StringEncoding];
|
2014-03-10 21:41:22 +01:00
|
|
|
json =
|
2014-03-25 01:11:56 +01:00
|
|
|
[NSJSONSerialization JSONObjectWithData:mcData options:0 error:&error];
|
2014-03-10 21:41:22 +01:00
|
|
|
NSAssert(!error, @"Unable to parse. %@", error.localizedDescription);
|
2014-05-31 00:26:06 +02:00
|
|
|
id video = json[@"video"];
|
|
|
|
if ([video isKindOfClass:[NSDictionary class]]) {
|
|
|
|
NSDictionary* mandatory = video[@"mandatory"];
|
|
|
|
NSMutableArray* mandatoryContraints =
|
|
|
|
[NSMutableArray arrayWithCapacity:[mandatory count]];
|
|
|
|
[mandatory enumerateKeysAndObjectsUsingBlock:^(
|
|
|
|
id key, id obj, BOOL* stop) {
|
|
|
|
[mandatoryContraints addObject:[[RTCPair alloc] initWithKey:key
|
|
|
|
value:obj]];
|
|
|
|
}];
|
|
|
|
// TODO(tkchin): figure out json formats for optional constraints.
|
|
|
|
_videoConstraints =
|
|
|
|
[[RTCMediaConstraints alloc]
|
|
|
|
initWithMandatoryConstraints:mandatoryContraints
|
|
|
|
optionalConstraints:nil];
|
|
|
|
} else if ([video isKindOfClass:[NSNumber class]] && [video boolValue]) {
|
2014-03-25 01:11:56 +01:00
|
|
|
_videoConstraints = [[RTCMediaConstraints alloc] init];
|
2014-03-10 21:41:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 01:11:56 +01:00
|
|
|
[self
|
|
|
|
maybeLogMessage:[NSString
|
|
|
|
stringWithFormat:@"About to open GAE with token: %@",
|
|
|
|
self.token]];
|
2013-07-10 02:45:36 +02:00
|
|
|
self.gaeChannel =
|
|
|
|
[[GAEChannelClient alloc] initWithToken:self.token
|
|
|
|
delegate:self.messageHandler];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|