Skip to main content
Skip table of contents

Broadpeak SmartLib support

To test this feature and view the example code, please see the  Apple (FPS) SDK 5 Example Code Quick Start guide.

The smartbeam example code shows how an application can playback streams in conjunction with Broadpeak SmartBeam set-top box. This example depends on the SmartLib library, which detects and controls SmartBeam set-top boxes connected to the same LAN as the Android device.

Building and running the Smart-Lib example code

To build Smart lib example code:

  1.  Install Cocoapods. The easiest way to do this is $ sudo gem install cocoapods; see the Cocoapods installation guide at https://cocoapods.org.

  2. Change the username and password inside the podfile to the values associated with your smart lib account. Source https://username:[email protected]/ios/broadpeak/specs.git.

  3. Run the pod install command from the working directory. This will fetch the smart lib dependency and make an .xcworkspace which you will use to build and install the example code.

  4. Build and install the application from the .xcworkspace.

You must have your own Smart Lib account to fetch the dependency from Cocoapods. 
You may need to update the streams inside the example code by changing the URLs in the ViewController.m. The variables to change are stream1 and stream2.

To run OTVAVPlayer with a smartbeam gateway box, you must use an external library that creates a SmartLib client for the current streaming session and attaches it to the player. The following values are required to initiate the SmartLib client:

  • analyticsAddress: The URL for analytics

  • nanCDNHost: The address inside the device's home network where the nanoCDN is embedded, or discover if the discovery is enabled on the nanoCDN.

  • broadpeakDomainNames: The domain name list used to identify URL(s) using the Broadpeak product

A specific value "*" is used to declare that all the given URLs are using the broadpeak product.
An empty value "" is used to declare that no given URLs are using the Broadpeak value.
Discovery will take place if the Android device is in the same sub-network as the SmartBeam box.

Prerequisites

A SmartBeam box and the library mentioned in the example code.

Example code

The following example code is used to configure SmartLib.

Click here to see the example code.
Smart lib client example code
CODE
 /**
  * Init core, async nanoCDN resolution, register to app and system events
  *
  * Note: To be called once when the app starts
   
  * @param analyticsAddress Address of the analytics server (i.e. "http://server-host:8080")
  * @param nanoCDNHost A nanoCDN host configuration. null/empty string "" or
  *                    "discover" to enable auto-discovery or
  *                    a nanoCDN host list (i.e "192.168.1.1,192.168.1.10")
  * @param broadpeakDomainNames The domain name list used to identify Broadpeak sessions (i.e "cdn.broadpeak.com,cdn2.broadpeak.com")
  *                             "*" specific value is used to declare that all sessions are using a Broadpeak CDN
  *                             null/empty string "" is used to declare that all given url are not hosted on a Broadpeak CDN
- (instancetype)initWith:(NSString *)analyticsAddress
     nanoCDNHost:(NSString *)nanoCDNHost
broadpeakDomainNames:(NSString *)broadpeakDomainNames
{
  self = [super init];
  if (self) {
    [SmartLib registerNanoCDNReceiver:self];
    [SmartLib initSmartLib:analyticsAddress nanoCDNHost:nanoCDNHost broadpeakDomainNames:broadpeakDomainNames];
  }
  return self;
}

 // getURL (session start, default method)
- (NSString *)getURL:(NSString *)requestedURL {
  if (playerAttached) {
     return [SmartLib getURL:requestedURL];
  }
  return @"";
}

//Attach a player to SmartLib to handle analytics

- (void)attachPlayer:(NSObject *)player {
  [SmartLib attachPlayer:player];
  playerAttached = true;
}

Once the nanoCDN is registered, the SmartLib and the OTVAVPlayer have been created, pass the stream URI to the client:

Click here to see the example code.
Smart lib client example code
CODE
 
smartLibClient = [[SmartLibClient alloc]initWith:@"" nanoCDNHost:@"discover" broadpeakDomainNames:@""];
  
  otvLicenseDelegate = [[OTVDefaultLicenseDelegate alloc]initWithCertificateURL:certificateURL licenseURL:licenseURL];
  drmManager = [OTVDRMManager shared];
  [drmManager setLicenseDelegate:otvLicenseDelegate];
  [otvLicenseDelegate setHTTPHeaderWithParameters:@{
      @"nv-authorizations" : sspToken
  }];
  
  otvPlayer = [[OTVAVPlayer alloc]initWithPlayerItem:nil];
  
  //Attach a player to SmartLib to handle analytics
  [smartLibClient attachPlayer:otvPlayer];
  
 // getURL (session start, default method)
  NSURL* url = [NSURL URLWithString:[smartLibClient getURL:assetURL.absoluteString]];
  if (url != nil) {
    otvPlayerItem = [[OTVAVPlayerItem alloc]initWithURL:url];
     [otvPlayer replaceCurrentItemWithPlayerItem:otvPlayerItem];
     [_playerView setPlayer:otvPlayer];
    
     [otvPlayer play];
  } else
  {
    NSLog(@"Smart lib returned a nil URL, please check configuration options and or stream variables");
  }


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.