PeerObjectiveC is WebRTC client library for iOS, that communicate to peerjs-server.
This library is modified from the AppRTCDemo (that Google has been published) for peerjs-server signaling process and PeerJS like API interface.
-
Clone this repository.
$ git clone https://github.com/hiroeorz/PeerObjectiveC.git
-
And build it on Xcode.
-
Clone this repository.
$ git clone https://github.com/hiroeorz/PeerObjectiveC.git
-
Copy
Peer
directory to your project, and add to your app on Xcode.$ cp -r PeerObjectiveC/Peer /path/to/yourapp/
-
You will need to add a few frameworks to your project in order for it to build correctly.
- libc++.dylib
- libicucore.dylib
- Security.framework
- CFNetwork.framework
- GLKit.framework
- libstdc++.6.dylib
- AudioToolbox.framework
- AVFoundation.framework
- CoreAudio.framework
- CoreMedia.framework
- CoreVideo.framework
- CoreGraphics.framework
- OpenGLES.framework
- QuartzCore.framework
- libsqlite3.dylib
-
Initialize
RTCPeerConnectionFactory
in your AppDelegate.mAppDelegate.m
#import "RTCPeerConnectionFactory.h" - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [RTCPeerConnectionFactory initializeSSL]; return YES; }
-
And create instance of
Peer
class in ViewController.ViewController.m
#import <AVFoundation/AVFoundation.h> #import "Peer.h" @interface ViewController () <RTCEAGLVideoViewDelegate> @property(nonatomic, strong) Peer *peer; @end @implementation ViewController { @synthesize peer = _peer; - (void)viewDidAppear:(BOOL)animate { __block typeof(self) __self = self; // Create Configuration object. NSDictionary *config = @{@"key": @"your_api_key", @"port": @(9000)}; // Create Instance of Peer. _peer = [[Peer alloc] initWithConfig:config]; // Set Callbacks. _peer.onOpen = ^(NSString *id) { NSLog(@"onOpen"); }; _peer.onCall = ^(RTCSessionDescription *sdp) { NSLog(@"onCall"); }; _peer.onReceiveLocalVideoTrack = ^(RTCVideoTrack *videoTrack) { NSLog(@"onReceiveLocalVideoTrack"); }; _peer.onReceiveRemoteVideoTrack = ^(RTCVideoTrack *videoTrack) { NSLog(@"onReceiveRemoteVideoTrack"); }; _peer.onError = ^(NSError *error) { NSLog(@"onError: %@", error); }; _peer.onClose = ^() { NSLog(@"onClose"); }; // Start signaling to peerjs-server. [_peer start:^(NSError *error){ if (error) { NSLog(@"Error while openning websocket: %@", error); } }]; }
All default configuration is here.
NSDictionary *config = @{@"host": @"0.peerjs.com", @"port": @(80), @"key": @"peerjs", @"path": @"/", @"secure": @(NO), @"config": @{ @"iceServers": @[ @{@"url": @"stun:stun.l.google.com:19302", @"user": @"", @"password": @""} ] }};
-
See example app, for more details.
MIT