(Auto)update libjingle 68275107-> 68379861

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6305 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
buildbot@webrtc.org 2014-06-02 15:48:10 +00:00
parent a28c697d93
commit 34a08b4fb8
20 changed files with 2447 additions and 6 deletions

View File

@ -0,0 +1,66 @@
/*
* 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
@class RTCMediaConstraints;
// 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, weak, readonly) id<ICEServerDelegate> ICEServerDelegate;
@property(nonatomic, weak, readonly) id<GAEMessageHandler> messageHandler;
@property(nonatomic, assign) BOOL initiator;
@property(nonatomic, copy, readonly) RTCMediaConstraints* videoConstraints;
- (id)initWithICEServerDelegate:(id<ICEServerDelegate>)delegate
messageHandler:(id<GAEMessageHandler>)handler;
- (void)connectToRoom:(NSURL*)room;
- (void)sendData:(NSData*)data;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -0,0 +1,348 @@
/*
* 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"
#import "APPRTCAppDelegate.h"
#import "RTCMediaConstraints.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* roomHtml;
@property(atomic, strong) NSMutableArray* sendQueue;
@property(nonatomic, copy) NSString* token;
@property(nonatomic, assign) BOOL verboseLogging;
@end
@implementation APPRTCAppClient
- (id)initWithICEServerDelegate:(id<ICEServerDelegate>)delegate
messageHandler:(id<GAEMessageHandler>)handler {
if (self = [super init]) {
_ICEServerDelegate = delegate;
_messageHandler = handler;
_backgroundQueue = dispatch_queue_create("RTCBackgroundQueue",
DISPATCH_QUEUE_SERIAL);
_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 {
[self maybeLogMessage:@"Send message"];
dispatch_async(self.backgroundQueue, ^{
[self.sendQueue addObject:[data copy]];
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];
});
}
#pragma mark - Internal methods
- (NSString*)findVar:(NSString*)name strippingQuotes:(BOOL)strippingQuotes {
NSError* error;
NSString* pattern =
[NSString stringWithFormat:@".*\n *var %@ = ([^\n]*);\n.*", name];
NSRegularExpression* regexp =
[NSRegularExpression regularExpressionWithPattern:pattern
options:0
error:&error];
NSAssert(!error,
@"Unexpected error compiling regex: ",
error.localizedDescription);
NSRange fullRange = NSMakeRange(0, [self.roomHtml length]);
NSArray* matches =
[regexp matchesInString:self.roomHtml options:0 range:fullRange];
if ([matches count] != 1) {
[self showMessage:[NSString stringWithFormat:@"%d matches for %@ in %@",
[matches count],
name,
self.roomHtml]];
return nil;
}
NSRange matchRange = [matches[0] rangeAtIndex:1];
NSString* value = [self.roomHtml substringWithRange:matchRange];
if (strippingQuotes) {
NSAssert([value length] > 2,
@"Can't strip quotes from short string: [%@]",
value);
NSAssert(([value characterAtIndex:0] == '\'' &&
[value characterAtIndex:[value length] - 1] == '\''),
@"Can't strip quotes from unquoted string: [%@]",
value);
value = [value substringWithRange:NSMakeRange(1, [value length] - 2)];
}
return value;
}
- (NSURLRequest*)getRequestFromUrl:(NSURL*)url {
self.roomHtml = [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)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* 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);
}
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.roomHtml 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.roomHtml length]]];
NSRegularExpression* fullRegex =
[NSRegularExpression regularExpressionWithPattern:@"room is full"
options:0
error:nil];
if ([fullRegex
numberOfMatchesInString:self.roomHtml
options:0
range:NSMakeRange(0, [self.roomHtml length])]) {
[self showMessage:@"Room full"];
APPRTCAppDelegate* ad =
(APPRTCAppDelegate*)[[UIApplication sharedApplication] delegate];
[ad closeVideoUI];
return;
}
NSString* fullUrl = [[[connection originalRequest] URL] absoluteString];
NSRange queryRange = [fullUrl rangeOfString:@"?"];
self.baseURL = [fullUrl substringToIndex:queryRange.location];
[self maybeLogMessage:[NSString
stringWithFormat:@"Base URL: %@", self.baseURL]];
self.initiator = [[self findVar:@"initiator" strippingQuotes:NO] boolValue];
self.token = [self findVar:@"channelToken" strippingQuotes:YES];
if (!self.token)
return;
[self maybeLogMessage:[NSString stringWithFormat:@"Token: %@", self.token]];
NSString* roomKey = [self findVar:@"roomKey" strippingQuotes:YES];
NSString* me = [self findVar:@"me" strippingQuotes:YES];
if (!roomKey || !me)
return;
self.postMessageUrl =
[NSString stringWithFormat:@"/message?r=%@&u=%@", roomKey, me];
[self maybeLogMessage:[NSString stringWithFormat:@"POST message URL: %@",
self.postMessageUrl]];
NSString* pcConfig = [self findVar:@"pcConfig" strippingQuotes:NO];
if (!pcConfig)
return;
[self maybeLogMessage:[NSString
stringWithFormat:@"PC Config JSON: %@", pcConfig]];
NSString* turnServerUrl = [self findVar:@"turnUrl" strippingQuotes:YES];
if (turnServerUrl) {
[self maybeLogMessage:[NSString
stringWithFormat:@"TURN server request URL: %@",
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:@"urls"];
NSString* username = json[@"username"];
NSString* credential = [server objectForKey:@"credential"];
if (!username) {
username = @"";
}
if (!credential) {
credential = @"";
}
[self maybeLogMessage:[NSString
stringWithFormat:@"url [%@] - credential [%@]",
url,
credential]];
RTCICEServer* ICEServer =
[[RTCICEServer alloc] initWithURI:[NSURL URLWithString:url]
username:username
password:credential];
NSLog(@"Added ICE Server: %@", ICEServer);
[ICEServers addObject:ICEServer];
}
[self updateICEServers:ICEServers withTurnServer:turnServerUrl];
NSString* mc = [self findVar:@"mediaConstraints" strippingQuotes:NO];
if (mc) {
error = nil;
NSData* mcData = [mc dataUsingEncoding:NSUTF8StringEncoding];
json =
[NSJSONSerialization JSONObjectWithData:mcData options:0 error:&error];
NSAssert(!error, @"Unable to parse. %@", error.localizedDescription);
if ([[json objectForKey:@"video"] boolValue]) {
_videoConstraints = [[RTCMediaConstraints alloc] init];
}
}
[self
maybeLogMessage:[NSString
stringWithFormat:@"About to open GAE with token: %@",
self.token]];
self.gaeChannel =
[[GAEChannelClient alloc] initWithToken:self.token
delegate:self.messageHandler];
}
@end

View File

@ -0,0 +1,60 @@
/*
* 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 "RTCSessionDescriptionDelegate.h"
#import "RTCVideoSource.h"
// Used to send a message to an apprtc.appspot.com "room".
@protocol APPRTCSendMessage<NSObject>
- (void)sendData:(NSData*)data;
// Logging helper.
- (void)displayLogMessage:(NSString*)message;
@end
@class APPRTCViewController;
@class RTCVideoTrack;
// The main application class of the AppRTCDemo iOS app demonstrating
// interoperability between the Objective C implementation of PeerConnection
// and the apprtc.appspot.com demo webapp.
@interface APPRTCAppDelegate : UIResponder<ICEServerDelegate,
GAEMessageHandler,
APPRTCSendMessage,
RTCSessionDescriptionDelegate,
UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;
@property(strong, nonatomic) APPRTCViewController* viewController;
@property (strong, nonatomic) RTCVideoSource* videoSource;
- (void)closeVideoUI;
@end

View File

@ -0,0 +1,575 @@
/*
* 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 <AVFoundation/AVFoundation.h>
#import "APPRTCAppDelegate.h"
#import "APPRTCViewController.h"
#import "RTCEAGLVideoView.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"
#import "RTCStatsDelegate.h"
#import "RTCVideoRenderer.h"
#import "RTCVideoCapturer.h"
#import "RTCVideoTrack.h"
@interface PCObserver : NSObject<RTCPeerConnectionDelegate>
- (id)initWithDelegate:(id<APPRTCSendMessage>)delegate;
@property(nonatomic, strong) RTCEAGLVideoView* videoView;
@end
@implementation PCObserver {
id<APPRTCSendMessage> _delegate;
}
- (id)initWithDelegate:(id<APPRTCSendMessage>)delegate {
if (self = [super init]) {
_delegate = delegate;
}
return self;
}
#pragma mark - RTCPeerConnectionDelegate
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSLog(@"PCO onError.");
NSAssert(NO, @"PeerConnection failed.");
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSLog(@"PCO onSignalingStateChange: %d", stateChanged);
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
addedStream:(RTCMediaStream*)stream {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSLog(@"PCO onAddStream.");
NSAssert([stream.audioTracks count] <= 1,
@"Expected at most 1 audio stream");
NSAssert([stream.videoTracks count] <= 1,
@"Expected at most 1 video stream");
if ([stream.videoTracks count] != 0) {
self.videoView.videoTrack = stream.videoTracks[0];
}
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
removedStream:(RTCMediaStream*)stream {
dispatch_async(dispatch_get_main_queue(),
^(void) { NSLog(@"PCO onRemoveStream."); });
}
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection*)peerConnection {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSLog(@"PCO onRenegotiationNeeded - ignoring because AppRTC has a "
"predefined negotiation strategy");
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
gotICECandidate:(RTCICECandidate*)candidate {
dispatch_async(dispatch_get_main_queue(), ^(void) {
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
iceGatheringChanged:(RTCICEGatheringState)newState {
dispatch_async(dispatch_get_main_queue(),
^(void) { NSLog(@"PCO onIceGatheringChange. %d", newState); });
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
iceConnectionChanged:(RTCICEConnectionState)newState {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSLog(@"PCO onIceConnectionChange. %d", newState);
if (newState == RTCICEConnectionConnected)
[self displayLogMessage:@"ICE Connection Connected."];
NSAssert(newState != RTCICEConnectionFailed, @"ICE Connection failed!");
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didOpenDataChannel:(RTCDataChannel*)dataChannel {
NSAssert(NO, @"AppRTC doesn't use DataChannels");
}
#pragma mark - Private
- (void)displayLogMessage:(NSString*)message {
[_delegate displayLogMessage:message];
}
@end
@interface APPRTCAppDelegate () <RTCStatsDelegate>
@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 {
NSTimer* _statsTimer;
}
#pragma mark - UIApplicationDelegate methods
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
[RTCPeerConnectionFactory initializeSSL];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController =
[[APPRTCViewController alloc] initWithNibName:@"APPRTCViewController"
bundle:nil];
self.window.rootViewController = self.viewController;
_statsTimer =
[NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(didFireStatsTimer:)
userInfo:nil
repeats:YES];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication*)application {
[self displayLogMessage:@"Application lost focus, connection broken."];
[self closeVideoUI];
}
- (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] initWithICEServerDelegate:self
messageHandler:self];
[self.client connectToRoom:url];
return YES;
}
- (void)displayLogMessage:(NSString*)message {
NSAssert([NSThread isMainThread], @"Called off main thread!");
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]
initWithMandatoryConstraints:
@[
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"],
[[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]
]
optionalConstraints:
@[
[[RTCPair alloc] initWithKey:@"internalSctpDataChannels"
value:@"true"],
[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement"
value:@"true"]
]];
self.pcObserver = [[PCObserver alloc] initWithDelegate:self];
self.peerConnection =
[self.peerConnectionFactory peerConnectionWithICEServers:servers
constraints:constraints
delegate:self.pcObserver];
RTCMediaStream* lms =
[self.peerConnectionFactory mediaStreamWithLabel:@"ARDAMS"];
// The iOS simulator doesn't provide any sort of camera capture
// support or emulation (http://goo.gl/rHAnC1) so don't bother
// trying to open a local stream.
RTCVideoTrack* localVideoTrack;
#if !TARGET_IPHONE_SIMULATOR
NSString* cameraID = nil;
for (AVCaptureDevice* captureDevice in
[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if (captureDevice.position == AVCaptureDevicePositionFront) {
cameraID = [captureDevice localizedName];
break;
}
}
NSAssert(cameraID, @"Unable to get the front camera id");
RTCVideoCapturer* capturer =
[RTCVideoCapturer capturerWithDeviceName:cameraID];
self.videoSource = [self.peerConnectionFactory
videoSourceWithCapturer:capturer
constraints:self.client.videoConstraints];
localVideoTrack =
[self.peerConnectionFactory videoTrackWithID:@"ARDAMSv0"
source:self.videoSource];
if (localVideoTrack) {
[lms addVideoTrack:localVideoTrack];
}
self.viewController.localVideoView.videoTrack = localVideoTrack;
#else
self.viewController.localVideoView.hidden = YES;
#endif
self.pcObserver.videoView = self.viewController.remoteVideoView;
[lms addAudioTrack:[self.peerConnectionFactory audioTrackWithID:@"ARDAMSa0"]];
[self.peerConnection addStream:lms constraints:constraints];
[self displayLogMessage:@"onICEServers - added local stream."];
}
#pragma mark - GAEMessageHandler methods
- (void)onOpen {
if (!self.client.initiator) {
[self displayLogMessage:@"Callee; waiting for remote offer"];
return;
}
[self displayLogMessage:@"GAE onOpen - create offer."];
RTCPair* audio =
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"];
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:(NSDictionary*)messageData {
NSString* type = messageData[@"type"];
NSAssert(type, @"Missing type: %@", messageData);
[self displayLogMessage:[NSString stringWithFormat:@"GAE onMessage type - %@",
type]];
if ([type isEqualToString:@"candidate"]) {
NSString* mid = messageData[@"id"];
NSNumber* sdpLineIndex = messageData[@"label"];
NSString* sdp = messageData[@"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 ([type isEqualToString:@"offer"] ||
[type isEqualToString:@"answer"]) {
NSString* sdpString = messageData[@"sdp"];
RTCSessionDescription* sdp = [[RTCSessionDescription alloc]
initWithType:type
sdp:[APPRTCAppDelegate preferISAC:sdpString]];
[self.peerConnection setRemoteDescriptionWithDelegate:self
sessionDescription:sdp];
[self displayLogMessage:@"PC - setRemoteDescription."];
} else if ([type isEqualToString:@"bye"]) {
[self closeVideoUI];
UIAlertView* alertView =
[[UIAlertView alloc] initWithTitle:@"Remote end hung up"
message:@"dropping PeerConnection"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
} else {
NSAssert(NO, @"Invalid message: %@", messageData);
}
}
- (void)onClose {
[self displayLogMessage:@"GAE onClose."];
[self closeVideoUI];
}
- (void)onError:(int)code withDescription:(NSString*)description {
[self displayLogMessage:[NSString stringWithFormat:@"GAE onError: %d, %@",
code, description]];
[self closeVideoUI];
}
#pragma mark - RTCSessionDescriptionDelegate methods
// Match |pattern| to |string| and return the first group of the first
// match, or nil if no match was found.
+ (NSString*)firstMatch:(NSRegularExpression*)pattern
withString:(NSString*)string {
NSTextCheckingResult* result =
[pattern firstMatchInString:string
options:0
range:NSMakeRange(0, [string length])];
if (!result)
return nil;
return [string substringWithRange:[result rangeAtIndex:1]];
}
// Mangle |origSDP| to prefer the ISAC/16k audio codec.
+ (NSString*)preferISAC:(NSString*)origSDP {
int mLineIndex = -1;
NSString* isac16kRtpMap = nil;
NSArray* lines = [origSDP componentsSeparatedByString:@"\n"];
NSRegularExpression* isac16kRegex = [NSRegularExpression
regularExpressionWithPattern:@"^a=rtpmap:(\\d+) ISAC/16000[\r]?$"
options:0
error:nil];
for (int i = 0;
(i < [lines count]) && (mLineIndex == -1 || isac16kRtpMap == nil);
++i) {
NSString* line = [lines objectAtIndex:i];
if ([line hasPrefix:@"m=audio "]) {
mLineIndex = i;
continue;
}
isac16kRtpMap = [self firstMatch:isac16kRegex withString:line];
}
if (mLineIndex == -1) {
NSLog(@"No m=audio line, so can't prefer iSAC");
return origSDP;
}
if (isac16kRtpMap == nil) {
NSLog(@"No ISAC/16000 line, so can't prefer iSAC");
return origSDP;
}
NSArray* origMLineParts =
[[lines objectAtIndex:mLineIndex] componentsSeparatedByString:@" "];
NSMutableArray* newMLine =
[NSMutableArray arrayWithCapacity:[origMLineParts count]];
int origPartIndex = 0;
// Format is: m=<media> <port> <proto> <fmt> ...
[newMLine addObject:[origMLineParts objectAtIndex:origPartIndex++]];
[newMLine addObject:[origMLineParts objectAtIndex:origPartIndex++]];
[newMLine addObject:[origMLineParts objectAtIndex:origPartIndex++]];
[newMLine addObject:isac16kRtpMap];
for (; origPartIndex < [origMLineParts count]; ++origPartIndex) {
if (![isac16kRtpMap
isEqualToString:[origMLineParts objectAtIndex:origPartIndex]]) {
[newMLine addObject:[origMLineParts objectAtIndex:origPartIndex]];
}
}
NSMutableArray* newLines = [NSMutableArray arrayWithCapacity:[lines count]];
[newLines addObjectsFromArray:lines];
[newLines replaceObjectAtIndex:mLineIndex
withObject:[newMLine componentsJoinedByString:@" "]];
return [newLines componentsJoinedByString:@"\n"];
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didCreateSessionDescription:(RTCSessionDescription*)origSdp
error:(NSError*)error {
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (error) {
[self displayLogMessage:@"SDP onFailure."];
NSAssert(NO, error.description);
return;
}
[self displayLogMessage:@"SDP onSuccess(SDP) - set local description."];
RTCSessionDescription* sdp = [[RTCSessionDescription alloc]
initWithType:origSdp.type
sdp:[APPRTCAppDelegate preferISAC:origSdp.description]];
[self.peerConnection setLocalDescriptionWithDelegate:self
sessionDescription:sdp];
[self displayLogMessage:@"PC setLocalDescription."];
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
didSetSessionDescriptionWithError:(NSError*)error {
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (error) {
[self displayLogMessage:@"SDP onFailure."];
NSAssert(NO, error.description);
return;
}
[self displayLogMessage:@"SDP onSuccess() - possibly drain candidates"];
if (!self.client.initiator) {
if (self.peerConnection.remoteDescription &&
!self.peerConnection.localDescription) {
[self displayLogMessage:@"Callee, setRemoteDescription succeeded"];
RTCPair* audio = [[RTCPair alloc] initWithKey:@"OfferToReceiveAudio"
value:@"true"];
RTCPair* video = [[RTCPair alloc] initWithKey:@"OfferToReceiveVideo"
value:@"true"];
NSArray* mandatory = @[ audio, video ];
RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatory
optionalConstraints:nil];
[self.peerConnection createAnswerWithDelegate:self
constraints:constraints];
[self displayLogMessage:@"PC - createAnswer."];
} else {
[self displayLogMessage:@"SDP onSuccess - drain candidates"];
[self drainRemoteCandidates];
}
} else {
if (self.peerConnection.remoteDescription) {
[self displayLogMessage:@"SDP onSuccess - drain candidates"];
[self drainRemoteCandidates];
}
}
});
}
#pragma mark - RTCStatsDelegate methods
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didGetStats:(NSArray*)stats {
dispatch_async(dispatch_get_main_queue(), ^{
NSString* message = [NSString stringWithFormat:@"Stats:\n %@", stats];
[self displayLogMessage:message];
});
}
#pragma mark - internal methods
- (void)disconnect {
[self.client
sendData:[@"{\"type\": \"bye\"}" dataUsingEncoding:NSUTF8StringEncoding]];
[self.peerConnection close];
self.peerConnection = nil;
self.pcObserver = nil;
self.client = nil;
self.videoSource = nil;
self.peerConnectionFactory = nil;
[RTCPeerConnectionFactory deinitializeSSL];
}
- (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;
}
- (void)didFireStatsTimer:(NSTimer *)timer {
if (self.peerConnection) {
[self.peerConnection getStatsWithDelegate:self
mediaStreamTrack:nil
statsOutputLevel:RTCStatsOutputLevelDebug];
}
}
#pragma mark - public methods
- (void)closeVideoUI {
[self.viewController resetUI];
[self disconnect];
}
@end

View File

@ -0,0 +1,46 @@
/*
* 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>
@class RTCEAGLVideoView;
// The view controller that is displayed when AppRTCDemo is loaded.
@interface APPRTCViewController : UIViewController<UITextFieldDelegate>
@property(weak, nonatomic) IBOutlet UITextField* roomInput;
@property(weak, nonatomic) IBOutlet UITextView* instructionsView;
@property(weak, nonatomic) IBOutlet UITextView* logView;
@property(weak, nonatomic) IBOutlet UIView* blackView;
@property(nonatomic, strong) RTCEAGLVideoView* localVideoView;
@property(nonatomic, strong) RTCEAGLVideoView* remoteVideoView;
- (void)displayText:(NSString*)text;
- (void)resetUI;
@end

View File

@ -0,0 +1,150 @@
/*
* 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"
#import <AVFoundation/AVFoundation.h>
#import "RTCEAGLVideoView.h"
@interface APPRTCViewController ()
@property(nonatomic, assign) UIInterfaceOrientation statusBarOrientation;
@end
@implementation APPRTCViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.statusBarOrientation =
[UIApplication sharedApplication].statusBarOrientation;
self.roomInput.delegate = self;
[self.roomInput becomeFirstResponder];
}
- (void)viewDidLayoutSubviews {
if (self.statusBarOrientation !=
[UIApplication sharedApplication].statusBarOrientation) {
self.statusBarOrientation =
[UIApplication sharedApplication].statusBarOrientation;
[[NSNotificationCenter defaultCenter]
postNotificationName:@"StatusBarOrientationDidChange"
object:nil];
}
}
- (void)displayText:(NSString*)text {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSString* output =
[NSString stringWithFormat:@"%@\n%@", self.logView.text, text];
self.logView.text = output;
[self.logView
scrollRangeToVisible:NSMakeRange([self.logView.text length], 0)];
});
}
- (void)resetUI {
[self.roomInput resignFirstResponder];
self.roomInput.text = nil;
self.roomInput.hidden = NO;
self.instructionsView.hidden = NO;
self.logView.hidden = YES;
self.logView.text = nil;
self.blackView.hidden = YES;
[self.remoteVideoView removeFromSuperview];
self.remoteVideoView = nil;
[self.localVideoView removeFromSuperview];
self.localVideoView = nil;
}
// TODO(fischman): Use video dimensions from the incoming video stream
// and resize the Video View accordingly w.r.t. aspect ratio.
enum {
// Remote video view dimensions.
kRemoteVideoWidth = 640,
kRemoteVideoHeight = 480,
// Padding space for local video view with its parent.
kLocalViewPadding = 20
};
- (void)setupCaptureSession {
self.blackView.hidden = NO;
CGSize videoSize =
CGSizeMake(kRemoteVideoWidth, kRemoteVideoHeight);
CGRect remoteVideoFrame =
AVMakeRectWithAspectRatioInsideRect(videoSize,
self.blackView.bounds);
CGRect localVideoFrame = remoteVideoFrame;
// TODO(tkchin): use video dimensions from incoming video stream
// and handle rotation.
localVideoFrame.size.width = remoteVideoFrame.size.height / 4;
localVideoFrame.size.height = remoteVideoFrame.size.width / 4;
localVideoFrame.origin.x = CGRectGetMaxX(remoteVideoFrame)
- localVideoFrame.size.width - kLocalViewPadding;
localVideoFrame.origin.y = CGRectGetMaxY(remoteVideoFrame)
- localVideoFrame.size.height - kLocalViewPadding;
self.remoteVideoView =
[[RTCEAGLVideoView alloc] initWithFrame:remoteVideoFrame];
[self.blackView addSubview:self.remoteVideoView];
self.remoteVideoView.transform = CGAffineTransformMakeScale(-1, 1);
self.localVideoView =
[[RTCEAGLVideoView alloc] initWithFrame:localVideoFrame];
[self.blackView addSubview:self.localVideoView];
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField*)textField {
NSString* room = textField.text;
if ([room length] == 0) {
return;
}
textField.hidden = YES;
self.instructionsView.hidden = YES;
self.logView.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]];
dispatch_async(dispatch_get_main_queue(), ^{ [self setupCaptureSession]; });
}
- (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

View File

@ -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>

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -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:(NSDictionary*)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

View File

@ -0,0 +1,116 @@
/*
* 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
+ (NSDictionary*)jsonStringToDictionary:(NSString*)str {
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSError* error;
NSDictionary* dict =
[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
NSAssert(!error, @"Invalid JSON? %@", str);
return dict;
}
- (BOOL)webView:(UIWebView*)webView
shouldStartLoadWithRequest:(NSURLRequest*)request
navigationType:(UIWebViewNavigationType)navigationType {
NSString* scheme = [request.URL scheme];
NSAssert(scheme, @"scheme is nil: %@", request);
if (![scheme isEqualToString:@"js-frame"]) {
return YES;
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSString* queuedMessage = [webView
stringByEvaluatingJavaScriptFromString:@"popQueuedMessage();"];
NSAssert([queuedMessage length], @"Empty queued message from JS");
NSDictionary* queuedMessageDict =
[GAEChannelClient jsonStringToDictionary:queuedMessage];
NSString* method = queuedMessageDict[@"type"];
NSAssert(method, @"Missing method: %@", queuedMessageDict);
NSDictionary* payload = queuedMessageDict[@"payload"]; // May be nil.
if ([method isEqualToString:@"onopen"]) {
[self.delegate onOpen];
} else if ([method isEqualToString:@"onmessage"]) {
NSDictionary* payloadData =
[GAEChannelClient jsonStringToDictionary:payload[@"data"]];
[self.delegate onMessage:payloadData];
} else if ([method isEqualToString:@"onclose"]) {
[self.delegate onClose];
} else if ([method isEqualToString:@"onerror"]) {
NSNumber* codeNumber = payload[@"code"];
int code = [codeNumber intValue];
NSAssert([codeNumber isEqualToNumber:[NSNumber numberWithInt:code]],
@"Unexpected non-integral code: %@", payload);
[self.delegate onError:code withDescription:payload[@"description"]];
} else {
NSAssert(NO, @"Invalid message sent from UIWebView: %@", queuedMessage);
}
});
return NO;
}
@end

View File

@ -0,0 +1,75 @@
<?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>BuildMachineOSBuild</key>
<string>12E55</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>AppRTCDemo</string>
<key>CFBundleExecutable</key>
<string>AppRTCDemo</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.AppRTCDemo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>AppRTCDemo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleResourceSpecification</key>
<string>ResourceRules.plist</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<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>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>
</array>
</dict>
</plist>

View File

@ -0,0 +1,25 @@
<?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>rules</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,716 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1536</int>
<string key="IBDocument.SystemVersion">13B42</string>
<string key="IBDocument.InterfaceBuilderVersion">4514</string>
<string key="IBDocument.AppKitVersion">1265</string>
<string key="IBDocument.HIToolboxVersion">696.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">3747</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">
<reference 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="NSWindow"/>
<reference key="NSNextKeyView" ref="634862110"/>
<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="144501234">
<string key="NSName">HelveticaNeue</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="NSWindow"/>
<reference key="NSNextKeyView" ref="261050959"/>
<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="144501234"/>
</object>
<object class="IBUITextView" id="634862110">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">-2147483356</int>
<string key="NSFrame">{{20, 20}, {280, 190}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="546385578"/>
<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="144501234"/>
</object>
<object class="IBUIView" id="261050959">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">-2147483356</int>
<string key="NSFrame">{{20, 228}, {280, 300}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<string key="NSFrame">{{0, 20}, {320, 548}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<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-inch 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">roomInput</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">instructionsView</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">logView</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="634862110"/>
</object>
<int key="connectionID">138</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">blackView</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="261050959"/>
</object>
<int key="connectionID">151</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="933872207">
<reference key="firstItem" ref="774585933"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="261050959"/>
<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">23</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</object>
<object class="IBNSLayoutConstraint" id="863471211">
<reference key="firstItem" ref="261050959"/>
<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">228</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>
<bool key="placeholder">NO</bool>
</object>
<object class="IBNSLayoutConstraint" id="590654550">
<reference key="firstItem" ref="546385578"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="261050959"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="774585933"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
<bool key="placeholder">NO</bool>
</object>
<object class="IBNSLayoutConstraint" id="734153049">
<reference key="firstItem" ref="546385578"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="261050959"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="774585933"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
<bool key="placeholder">NO</bool>
</object>
<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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</object>
<object class="IBNSLayoutConstraint" id="544488581">
<reference key="firstItem" ref="634862110"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="546385578"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">0.0</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="774585933"/>
<int key="scoringType">6</int>
<float key="scoringTypeFloat">24</float>
<int key="contentType">2</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</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">0</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
<bool key="placeholder">NO</bool>
</object>
<reference ref="176994284"/>
<reference ref="546385578"/>
<reference ref="634862110"/>
<reference ref="261050959"/>
</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>
<bool key="placeholder">NO</bool>
</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">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">
<object class="IBNSLayoutConstraint" id="988159807">
<reference key="firstItem" ref="634862110"/>
<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">190</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="634862110"/>
<int key="scoringType">3</int>
<float key="scoringTypeFloat">9</float>
<int key="contentType">1</int>
<bool key="placeholder">NO</bool>
</object>
</array>
<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">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>
<object class="IBObjectRecord">
<int key="objectID">141</int>
<reference key="object" ref="988159807"/>
<reference key="parent" ref="634862110"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">142</int>
<reference key="object" ref="261050959"/>
<reference key="parent" ref="774585933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">148</int>
<reference key="object" ref="734153049"/>
<reference key="parent" ref="774585933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">149</int>
<reference key="object" ref="590654550"/>
<reference key="parent" ref="774585933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">153</int>
<reference key="object" ref="863471211"/>
<reference key="parent" ref="774585933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">154</int>
<reference key="object" ref="933872207"/>
<reference key="parent" ref="774585933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">155</int>
<reference key="object" ref="544488581"/>
<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="126.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="128.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<array key="128.IBViewMetadataConstraints">
<reference ref="988159807"/>
</array>
<boolean value="NO" key="128.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="133.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="141.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="142.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<boolean value="NO" key="142.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="148.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="149.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="153.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="154.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="155.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 class="NSMutableArray" key="6.IBViewMetadataConstraints">
<reference ref="46028745"/>
<reference ref="663764352"/>
<reference ref="1039342825"/>
<reference ref="858545289"/>
<reference ref="1001701893"/>
<reference ref="19985792"/>
<reference ref="544488581"/>
<reference ref="860801955"/>
<reference ref="117610664"/>
<reference ref="734153049"/>
<reference ref="590654550"/>
<reference ref="863471211"/>
<reference ref="933872207"/>
</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">155</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">APPRTCViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="blackView">UIView</string>
<string key="roomInput">UITextField</string>
<string key="instructionsView">UITextView</string>
<string key="logView">UITextView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="blackView">
<string key="name">blackView</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="roomInput">
<string key="name">roomInput</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="instructionsView">
<string key="name">instructionsView</string>
<string key="candidateClassName">UITextView</string>
</object>
<object class="IBToOneOutletInfo" key="logView">
<string key="name">logView</string>
<string key="candidateClassName">UITextView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/APPRTCViewController.h</string>
</object>
</object>
<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.previouslyAttemptedUpgradeToXcode5">YES</bool>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<real value="1536" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="4600" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<bool key="IBDocument.UseAutolayout">YES</bool>
<string key="IBCocoaTouchPluginVersion">3747</string>
</data>
</archive>

View File

@ -0,0 +1,94 @@
<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 queued in JS,
and an IFRAME is added to the DOM, triggering a navigation event
|shouldStartLoadWithRequest| in Objective C which can then fetch the
message using |popQueuedMessage|. This queuing is necessary to avoid URL
length limits in UIWebView (which are undocumented).
-->
<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;
// In-order queue of messages to be delivered to ObjectiveC.
// Each is a JSON.stringify()'d dictionary containing a 'type'
// field and optionally a 'payload'.
var messageQueue = [];
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", msg);
},
'onclose': function() {
sendMessageToObjC("onclose");
},
'onerror': function(err) {
sendMessageToObjC("onerror", err);
}
});
}
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(type, payload) {
messageQueue.push(JSON.stringify({'type': type, 'payload': payload}));
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "js-frame:");
// 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);
}
function popQueuedMessage() {
return messageQueue.shift();
}
</script>
</body>
</html>

View File

@ -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]));
}
}

View File

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

3
talk/examples/ios/README Executable file
View File

@ -0,0 +1,3 @@
This directory contains an example iOS client for http://apprtc.appspot.com
See ../../app/webrtc/objc/README for information on how to use it.

View File

@ -175,6 +175,7 @@ class WebRtcMediaEngine : public cricket::MediaEngineInterface {
#else
#include "talk/media/webrtc/webrtcvideoengine.h"
#include "talk/media/webrtc/webrtcvideoengine2.h"
#include "talk/media/webrtc/webrtcvoiceengine.h"
namespace cricket {
@ -195,6 +196,25 @@ class WebRtcMediaEngine : public WebRtcCompositeMediaEngine {
}
};
#ifdef WEBRTC_CHROMIUM_BUILD
typedef CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine2>
WebRtcCompositeMediaEngine2;
class WebRtcMediaEngine2 : public WebRtcCompositeMediaEngine2 {
public:
WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc,
WebRtcVideoEncoderFactory* encoder_factory,
WebRtcVideoDecoderFactory* decoder_factory) {
voice_.SetAudioDeviceModule(adm, adm_sc);
video_.SetVoiceEngine(&voice_);
video_.EnableTimedRender();
// video_.SetExternalEncoderFactory(encoder_factory);
// video_.SetExternalDecoderFactory(decoder_factory);
}
};
#endif
} // namespace cricket
#endif // !defined(LIBPEERCONNECTION_LIB) &&

View File

@ -62,6 +62,7 @@
#include "talk/media/webrtc/webrtcvoiceengine.h"
#include "webrtc/experiments.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/system_wrappers/interface/field_trial.h"
#if !defined(LIBPEERCONNECTION_LIB)
#include "talk/media/webrtc/webrtcmediaengine.h"
@ -71,13 +72,30 @@ cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
webrtc::AudioDeviceModule* adm, webrtc::AudioDeviceModule* adm_sc,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
return new cricket::WebRtcMediaEngine(adm, adm_sc, encoder_factory,
decoder_factory);
#ifdef WEBRTC_CHROMIUM_BUILD
if (webrtc::field_trial::FindFullName("WebRTC-NewVideoAPI") == "Enabled") {
return new cricket::WebRtcMediaEngine2(
adm, adm_sc, encoder_factory, decoder_factory);
} else {
#endif
return new cricket::WebRtcMediaEngine(
adm, adm_sc, encoder_factory, decoder_factory);
#ifdef WEBRTC_CHROMIUM_BUILD
}
#endif
}
WRME_EXPORT
void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
delete static_cast<cricket::WebRtcMediaEngine*>(media_engine);
#ifdef WEBRTC_CHROMIUM_BUILD
if (webrtc::field_trial::FindFullName("WebRTC-NewVideoAPI") == "Enabled") {
delete static_cast<cricket::WebRtcMediaEngine2*>(media_engine);
} else {
#endif
delete static_cast<cricket::WebRtcMediaEngine*>(media_engine);
#ifdef WEBRTC_CHROMIUM_BUILD
}
#endif
}
#endif
@ -104,7 +122,6 @@ static const char kFecPayloadName[] = "ulpfec";
static const int kDefaultNumberOfTemporalLayers = 1; // 1:1
static const int kMaxExternalVideoCodecs = 8;
static const int kExternalVideoPayloadTypeBase = 120;
static bool BitrateIsSet(int value) {
@ -117,7 +134,10 @@ static int GetBitrate(int value, int deflt) {
// Static allocation of payload type values for external video codec.
static int GetExternalVideoPayloadType(int index) {
#if ENABLE_DEBUG
static const int kMaxExternalVideoCodecs = 8;
ASSERT(index >= 0 && index < kMaxExternalVideoCodecs);
#endif
return kExternalVideoPayloadTypeBase + index;
}

View File

@ -46,8 +46,6 @@ const int MAX_LIFETIME = 15 * 60 * 1000;
// The number of bytes in each of the usernames we use.
const uint32 USERNAME_LENGTH = 16;
static const uint32 kMessageAcceptConnection = 1;
// Calls SendTo on the given socket and logs any bad results.
void Send(talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size,
const talk_base::SocketAddress& addr) {
@ -548,7 +546,10 @@ void RelayServer::RemoveBinding(RelayServerBinding* binding) {
}
void RelayServer::OnMessage(talk_base::Message *pmsg) {
#if ENABLE_DEBUG
static const uint32 kMessageAcceptConnection = 1;
ASSERT(pmsg->message_id == kMessageAcceptConnection);
#endif
talk_base::MessageData* data = pmsg->pdata;
talk_base::AsyncSocket* socket =
static_cast <talk_base::TypedMessageData<talk_base::AsyncSocket*>*>