Giter Club home page Giter Club logo

peerobjectivec's Introduction

PeerObjectiveC

About

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.

Usage

Build Sample App

  1. Clone this repository.

    $ git clone https://github.com/hiroeorz/PeerObjectiveC.git
    
  2. And build it on Xcode.

Use PeerObjectiveC in your custom app.

  1. Clone this repository.

    $ git clone https://github.com/hiroeorz/PeerObjectiveC.git
    
  2. Copy Peer directory to your project, and add to your app on Xcode.

    $ cp -r PeerObjectiveC/Peer /path/to/yourapp/
    
  3. 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
  4. Initialize RTCPeerConnectionFactory in your AppDelegate.m

    AppDelegate.m

    #import "RTCPeerConnectionFactory.h"
    
    - (BOOL)application:(UIApplication *)application 
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [RTCPeerConnectionFactory initializeSSL];
        return YES;
    }
  5. 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": @""}
                                 ]
                             }};
  6. See example app, for more details.

License

MIT

peerobjectivec's People

Contributors

hiroeorz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

peerobjectivec's Issues

failed to set session description

Hi,
I want to say thanks first. It saved lots of time of mine.

If you can help me to get rid out of this.

I clone your code and it is working fine when I make call on web based(peerjs heroku app) platform but the only problem when I received call from web app which is saying "failed to set session description".

I am getting offer code and that run perfactly but after oncall i am getting this below error:
this is what i am getting on console:
2017-09-09 19:24:06.772481+0530 PeerObjectiveC[665:156448] Failed to set session description. Error: Error Domain=RTCSDPError Code=-1 "(null)" UserInfo={error=SessionDescription is NULL.}
2017-09-09 19:24:06.772661+0530 PeerObjectiveC[665:156448] disconnecting....
2017-09-09 19:24:06.772737+0530 PeerObjectiveC[665:156448] deleteRemoteMediaStream
2017-09-09 19:24:06.772806+0530 PeerObjectiveC[665:156448] deleteLocalMediaStream
2017-09-09 19:24:06.773257+0530 PeerObjectiveC[665:156703] WARNING: Renegotiation needed but unimplemented.
2017-09-09 19:24:06.773618+0530 PeerObjectiveC[665:156448] local video audio track remove from media stream
2017-09-09 19:24:06.774098+0530 PeerObjectiveC[665:156448] onError: Error Domain=PeerJS Code=-4 "Failed to set session description." UserInfo={NSLocalizedDescription=Failed to set session description.}

Not able to compile:Incompatible block pointer types assigning to ....

/PeerObjectiveC/PeerObjectiveC/ViewController.m:122:16: Incompatible block pointer types assigning to 'void (^)(RTCSessionDescription *__strong, NSDictionary *__strong)' from 'void (^)(RTCSessionDescription *__strong)'

If fixed this given another parameter (not used?) to it, can fix the issue. Compile again and got another error:/PeerObjectiveC/PeerObjectiveC/ViewController.m:221:10: No visible @interface for 'Peer' declares the selector 'callWithId:'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.