Latest 1.1.8
Homepage https://github.com/opentok/accelerator-core-ios
License MIT
Platforms ios 9.0, requires ARC
Dependencies OTKAnalytics, OpenTok, SVProgressHUD
Authors

logo

Build Status
Version Status
license MIT
Platform
PRs Welcome

Accelerator Core iOS

The Accelerator Core is an easy manner to integrate audio/video communication to any iOS applications via OpenTok platform. Things you can easily do:

  • one to one audio/video call
  • multiparty audio/video call
  • one to one screen sharing
  • multiparty screen sharing
  • UI components for handling audio/video enable&disable

Configure, build and run the sample app

  1. Get values for API Key, Session ID, and Token. See Obtaining OpenTok Credentials for important information.

  2. Install CocoaPods as described in CocoaPods Getting Started.

  3. In Terminal, cd to your project directory and type pod install.

  4. Reopen your project in Xcode using the new *.xcworkspace file.

  5. Replace the following empty strings with the corresponding API Key, Session ID, and Token values:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        sharedSession = [[OTAcceleratorSession alloc] initWithOpenTokApiKey:@"apikey" sessionId:@"sessionid" token:@"token"];
        return YES;
    }
  6. Use Xcode to build and run the app on an iOS simulator or device.

  7. For testing audio/video communication, we include a simple web app to make it easier: Browser-Demo. Simply open it and replace the corresponding API Key, Session ID, and Token values. Then save and load it to the browser. For multiparty, you can achieve by opening up multiple tabs.

  8. You might want to run on other platforms:

Accelerator Core Javascript
Accelerator Core Android

Sample Codes

Each communicator instance will take the OpenTok session from OTOneToOneCommunicatorDataSource, so this applies to each communicator instance:

  • Passing the session

    - (OTAcceleratorSession *)sessionOfOTOneToOneCommunicator:(OTOneToOneCommunicator *)oneToOneCommunicator {
        return <#OTAcceleratorSession#>;
    }
  • One-to-One

    self.communicator = [[OTOneToOneCommunicator alloc] init];
    self.communicator.dataSource = self;
    [self.communicator connectWithHandler:^(OTCommunicationSignal signal, NSError *error) {
        if (signal == OTPublisherCreated && !error) {
            weakSelf.communicator.publisherView.frame = CGRectMake(0, 0, 100, 100);
            [self.publisherView addSubview:weakSelf.communicator.publisherView];
        }
        else if (signal == OTSubscriberReady && !error) {
            weakSelf.communicator.subscriberView.frame = CGRectMake(0, 0, 100, 100);
            [self.subscriberView addSubview:weakSelf.communicator.subscriberView];
        }
    }];
  • Multiparty

    self.communicator = [[OTMultiPartyCommunicator alloc] init];
    self.communicator.dataSource = self;
    [self.communicator connectWithHandler:^(OTCommunicationSignal signal, OTMultiPartyRemote *subscriber, NSError *error) {
        if (signal == OTPublisherCreated && !error) {
            weakSelf.communicator.publisherView.frame = CGRectMake(0, 0, 100, 100);
            [self.publisherView addSubview:weakSelf.communicator.publisherView];
        }
        else if (signal == OTSubscriberReady && !error) {
            subscriber.subscriberView.frame = <#your desired frame for this remote subscriberview#>;
            // your logic to handle multiple remote subscriberview(s)
        }
    }];
  • Screen Sharing

    Use - (instancetype)initWithView: or - (instancetype)initWithView:name: like so

    self.screenSharer = [[OTOneToOneCommunicator alloc] initWithView:[UIApplication sharedApplication].keyWindow.rootViewController.view];

    or

    self.screenSharer = [[OTMultiPartyCommunicator alloc] initWithView:[UIApplication sharedApplication].keyWindow.rootViewController.view];
  • Pre-defined UI

    Enable audio&video control

    self.communicator.publisherView.controlView.isVerticalAlignment = YES;
    self.communicator.publisherView.controlView.frame = CGRectMake(10, 10, CGRectGetWidth(self.publisherView.frame) * 0.1, CGRectGetHeight(self.publisherView.frame) * 0.3);

    Handle video enable/disable control

    // default
    // enable handleAudioVideo property, the publisherView will be covered by a silhouette automatically.
    self.communicator.publisherView.handleAudioVideo = YES; 
    
    // disable handleAudioVideo property, the publisherView will do nothing for enabling/disabling publishVideo.
    self.communicator.publisherView.handleAudioVideo = NO; 

Ready-in-Use components

  • One-to-One communication

ready-in-use-2
ready-in-use-3

OTOneToOneCommunicationController *vc = [OTOneToOneCommunicationController oneToOneCommunicationControllerWithSession:<#OTAcceleratorSession#>];
[self.navigationController pushViewController:vc animated:YES];

Sample Apps that uses the Core

The following sample apps use Accelerator Core:

Obtaining OpenTok Credentials

To use OpenTok’s framework you need a Session ID, Token, and API Key you can get these values at the OpenTok Developer Dashboard . For production deployment, you must generate the Session ID and Token values using one of the OpenTok Server SDKs.

Accelerator Core as a dependency

The Accelerator Core is required whenever you use any of the OpenTok accelerators. The Accelerator Core is a common layer that includes the audio-video communication logic contained in all OpenTok One-to-One Communication Sample Apps, and permits all accelerators and samples to share the same OpenTok session. The accelerator packs and sample app access the OpenTok session through the Common Accelerator Session Pack layer, which allows them to share a single OpenTok session:

architecture

On the Android and iOS mobile platforms, when you try to set a listener (Android) or delegate (iOS), it is not normally possible to set multiple listeners or delegates for the same event. For example, on these mobile platforms you can only set one OpenTok signal listener. The Common Accelerator Session Pack, however, allows you to set up several listeners for the same event.

Latest podspec

{
    "name": "OTAcceleratorCore",
    "version": "1.1.8",
    "summary": "A painless way to integrate WebRTC audio/video(screen sharing) to any iOS applications via OpenTok.",
    "description": "The OpenTok Accelerator Core is required whenever you use any of the OpenTok accelerators. The OpenTok Accelerator Core is a common layer that permits all accelerators and samples to share the same OpenTok session. The accelerator packs and sample app access the OpenTok session through the Accelerator Core Pack layer, which allows them to share a single OpenTok session.nnOn the Android and iOS mobile platforms, when you try to set a listener (Android) or delegate (iOS), it is not normally possible to set multiple listeners or delegates for the same event. For example, on these mobile platforms you can only set one OpenTok signal listener. The Common Accelerator Session Pack, however, allows you to set up several listeners for the same event.",
    "homepage": "https://github.com/opentok/accelerator-core-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Lucas Huang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/opentok/accelerator-core-ios.git",
        "tag": "1.1.8"
    },
    "social_media_url": "https://twitter.com/tokbox",
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "OTAcceleratorCore/**/*.{h,m}",
    "resource_bundles": {
        "OTAcceleratorCoreBundle": [
            "OTAcceleratorCoreBundle/**/*"
        ]
    },
    "public_header_files": "OTAcceleratorCore/**/*.{h}",
    "dependencies": {
        "OTKAnalytics": [
            "= 2.1.0"
        ],
        "OpenTok": [
            "~> 2.13.0"
        ],
        "SVProgressHUD": [
            "= 2.2.1"
        ]
    }
}

Pin It on Pinterest

Share This