P2P Streaming Engine

vuePress-theme-reco    2018 - 2021
P2P Streaming Engine P2P Streaming Engine

Choose mode

  • dark
  • auto
  • light
Documents
  • Introduction
  • Web SDK

    • Hls.js
    • Dash.js
    • Shaka-Player
    • MP4
    • Downloader
  • Android SDK
  • iOS SDK
  • Flutter SDK
Pricing
Contact Us
Partnership
Console
GitHub
语言
  • English
  • 简体中文

Documents
  • Introduction
  • Web SDK

    • Hls.js
    • Dash.js
    • Shaka-Player
    • MP4
    • Downloader
  • Android SDK
  • iOS SDK
  • Flutter SDK
Pricing
Contact Us
Partnership
Console
GitHub
语言
  • English
  • 简体中文
  • Introduction
  • FAQ
  • Tracking Service
  • Signaling Service
  • P2P Optimization
  • Console

    • Domain/AppId Binding
    • Data Analysis
    • P2P Control
    • Restful API
  • Hls.js SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • CDN
    • Change Log
  • Android SDK

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • iOS SDK

    • Introduction
    • Usage
      • Installation with CocoaPods
      • Integration
    • API & Config
    • Change Log
  • Flutter SDK

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • Shaka-Player SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Web MP4 SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Dash.js SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Web Downloader

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • Android SDK 1.x

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • More

    • Design

Usage

vuePress-theme-reco    2018 - 2021

Usage


# Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. You can install it with the following command:

$ gem install cocoapods

# Podfile

To integrate CDNByeSDK into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target 'TargetName' do
# Uncomment the next line if you're using Swift
# use_frameworks!   
pod 'CDNByeSDK'
end

Then, run the following command:

$ pod install

If can not find CDNByeSDK in repo, run command:

$ pod repo update

Update SDK if needed:

pod update CDNByeSDK --verbose --no-repo-update

# Integration

In order to allow the loading of distributed content via the local proxy, enable loading data from HTTP in your app by opening your info.plist file as source code and adding the following values below the tag:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

# Include

Import CDNByeSDK in AppDelegate.m:

#import <CDNByeKit/CBP2pEngine.h>

If you want to use CDNByeSDK in your Swift app, then you need to create a bridging header that allows your Swift code to work with it.

# Initialize CBP2pEngine

Initialize CBP2pEngine in AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[CBP2pEngine sharedInstance] startWithToken:YOUR_TOKEN andP2pConfig:nil];
    return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    CBP2pEngine.sharedInstance().start(token: YOUR_TOKEN, p2pConfig: nil)
    return true
}

Where YOUR_TOKEN is your Customer ID. Please replace it by your own token obtained from console, click here for more information.

# Usage

When initializing an AVPlayer (or any other video player) instance, before passing it a URL, pass that URL through CDNBye P2P Engine:

NSURL *originalUrl = [NSURL URLWithString:@"https://your_stream.m3u8"];
NSURL *parsedUrl = [[CBP2pEngine sharedInstance] parseStreamURL:originalUrl];
_player = [[AVPlayer alloc] initWithURL:parsedUrl];
let orginalUrl = URL.init(string: "https://your_stream.m3u8")
let parsedUrl = CBP2pEngine.sharedInstance().parse(streamURL: orginalUrl!)
_player = AVPlayer.init(url: parsedUrl)

That’s it! CDNBye should now be integrated into your app.

# Demo

A completed example can be found here

# Troubleshooting Steps when P2P doesn't work

Click here