cineio-peer-ios 0.0.10

cineio-peer-ios 0.0.10

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2015

Maintained by Thomas Shafer, Daniel Klein, Norm Brandinger.



 
Depends on:
libjingle_peerconnection~> 10842.2.3
Primus>= 0
SocketRocket~> 0.4.2
 

  • By
  • Cine.io Team

This is the cine.io Peer iOS SDK. This library allows you to integrate real-time live video and audio chat to your iOS application. It is fully compatable with with the cine.io Peer Android SDK and cine.io peer JavaScript SDK.

Table of Contents

Installation

The easiest way to use the SDK is via CocoaPods. Create a new XCode project with a file named Podfile that contains the following:

pod 'cineio-peer-ios', '0.0.10'

Then, install the Pod by running the pod install command:

pod install

Then you can open the project using the <project>.xcworkspace file:

open <project>.xcworkspace

Example Application

Check out the cineio-peer-ios-example-app repository for a working example that use this SDK.

Basic Usage

Start by including the necessary files

#import "CinePeerClient.h"
#import "CinePeerClientConfig.h"
#import "CineCall.h"
#import "CineIdentity.h" // Only necessary if your app requires identifying
#import "RTCMediaStream.h"
#import "RTCEAGLVideoView.h" // For displaying media strems

Initializing

Create a CinePeerClientDelegate

For simplicity sake, let's make our ViewController a CinePeerClientDelegate

In ViewController.m

@interface ViewController () <CinePeerClientDelegate>

Create the CinePeerClient

In ViewController.m, because that's our CinePeerClientDelegate.

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *CINE_IO_PUBLIC_KEY = @"CINE_IO_PUBLIC_KEY";
    NSString *CINE_IO_SECRET_KEY = @"CINE_IO_SECRET_KEY";

    // Initialize the CinePeerClientConfig class
    // Pass in a CinePeerClientDelegate
    CinePeerClientConfig *config = [[CinePeerClientConfig alloc] initWithPublicKey:CINE_IO_PUBLIC_KEY delegate:self];

    // Create the peer client
    CinePeerClient *cinePeerClient  = [[CinePeerClient alloc] initWithConfig:config];
}

CinePeerClientDelegate methods

You'll add the CinePeerClientDelegate methods to your ViewController.

// happens when a new peer joins, or your local camera and microphone starts
- (void) addStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// happens when a peer leaves, or your local camera and microphone stops
- (void) removeStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// when a new call comes in
- (void) handleCall:(CineCall *)call;
// when a call that came to you is cancelled
- (void) onCallCancel:(CineCall *)call;
// when a call that you sent out is rejected
- (void) onCallReject:(CineCall *)call;
// generic error catcher
- (void) handleError:(NSDictionary *)error;

CinePeerClient Methods

Starting the camera and microphone

[cinePeerClient startMediaStream];

Joining a room

NSString *roomName = @"example";
[cinePeerClient joinRoom:roomName];

Identifying

You'll need to set the secretKey on the config to identify.

[config setSecretKey:CINE_IO_SECRET_KEY];

NSString *identityName = @"UNIQUE-IDENTITY";
CineIdentity *identity = [config generateIdentity:identityName];
[self.cinePeerClient identify:identity];

Calling an other identity

NSString *identityName = @"UNIQUE-IDENTITY-TO-CALL";
[self.cinePeerClient call:identity];

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request