PallyCon Widevine Android SDK Guide

PallyCon Widevine Android SDK makes it easy to apply Google's Widevine Modular DRM when developing media service apps for Android. This document describes how to use the libraries and sample project included in the SDK.

Details of PallyCon Multi DRM service integration are provided in License Callback API and License Token API guides. For technical questions about using the SDK, please visit our Helpdesk site.

SDK products can be requested when subscribing to PallyCon cloud commercial service. Then SDK can be downloaded from the Download page of PallyCon admin site.


Requirements

  • Android version 4.1 (JellyBean) or later
  • This SDK has been tested on Android Studio 2.2.3 and will not work on the simulator.

OS support environment according to NCG CENC playback support option (Global.enableNcgCenc flag)

  • true: support Android 4.1~4.4 using NCG CENC, 5.0 or later using Widevine CENC (both streaming and download)
  • false: support Android 4.4 or later using Widevine CENC (4.4: streaming only, 5.0 or later: streaming and download)

Note

  • To develop application using the SDK, first sign up for PallyCon Admin Site, and get Site ID and Site Key from the site.

Quick Start

You can apply PallyCon Widevine Android SDK to your development project by following these steps:

  1. Extract downloaded SDK file.

  2. Copy PallyconWVMSDK.jar exoplayer.aarfile to project/module/libs/ folder in your project.

  3. Copy armeabi x86 folder to /src/main/jniLibs/ folder in your project

  4. Apply the below configuration in build.gradle (project).

     allprojects {
         repositories {
             jcenter()
             flatDir {
                 dirs 'libs'
             }
         }
     }
    
  5. Apply the below configuration in build.gradle (module).

     android {
         defaultConfig {
             minSdkVersion 15
             targetSdkVersion 21
             multiDexEnabled true
         }
     }
     dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
             exclude group: 'com.android.support', module: 'support-annotations'
             exclude group: 'com.google.code.findbugs'
         })
         compile 'com.google.android.gms:play-services-safetynet:11.0.1'
         compile ('com.google.http-client:google-http-client-jackson2:1.22.0', {
             exclude group: 'org.apache.httpcomponents'
         })
         compile 'com.google.android.exoplayer2:exoplayer:2.3.1@aar'
     }
    
  6. Implement PallyconDownloadTask.PallyconDownloadEventListener in MainActivity.(refer to sample project)

     private PallyconDownloadTask.PallyconDownloadEventListener eventListener = new PallyconDownloadTask.PallyconDownloadEventListener() {
         @Override
         public void onPreExecute() {
             // called on preparing download
         }
    
         @Override
         public void onPostExecute() {
             // called on download complete
         }
    
         @Override
         public void onProgressUpdate(String fileName, long downloadedSize, long totalSize, int percent, int downloadIndex) {
             // called on progress update : refer to API document
         }
    
         @Override
         public void onCancelled() {
             // called on canceling download : refer to API document
         }
    
         @Override
         public void onNetworkError(NetworkConnectedException e) {
             // called on network error : refer to API document
         }
    
         @Override
         public void onPallyconDownloadError(PallyconDownloadException e) {
             // called on download error : refer to API document
         }
     };
    
  7. Create PallyconDownloadTask object with content information.

     downloadTask = new PallyconDownloadTask(MainActivity.this, content.uri, content.name, enableNcgCenc, listener, eventHandler);
    
  8. Start downloading content if the content is not previously downloaded.

     boolean result = downloadTask.isDownloadCompleted();
     if(result == true) {
         Uri localUri = downloadTask.getLocalUri(content.uri, content.name);
     } else {
         downloadTask.execute();    
     }
    
  9. After the download is complete, you can issue a license using the following APIs before playback

     WVMAgent.downloadLicense(content.drmSchemeUuid, content.drmLicenseUrl, content.uri, content.userId, content.cid, content.oid);
    
  10. Implement player in PlayerActivity.java using ExoPlayer development guide.

    Please refer to the below guide from Google for more information about Exoplayer. https://developer.android.com/guide/topics/media/exoplayer.html

  11. Implement ExoPlayer.EventListener. (refer to sample project)

     private ExoPlayer.EventListener playerEventListener = new ExoPlayer.EventListener() {
         @Override
         public void onTimelineChanged(Timeline timeline, Object manifest){
             //  refer to API document & sample source
         }
    
         @Override
         public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
             //  refer to API document & sample source
         }
    
         @Override
         public void onLoadingChanged(boolean isLoading) {
             //  refer to API document & sample source
         }
    
         @Override
         public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
             //  refer to API document & sample source
         }
    
         @Override
         public void onPlayerError(ExoPlaybackException e) {
             //  refer to API document & sample source
         }
    
         @Override
         public void onPositionDiscontinuity() {
             //  refer to API document & sample source
         }
     };
    
  12. Implement PallyconStreamingDrmSessionManager.PallyconEventListener. (refer to sample project)

    Important : content playback should be prohibited to prevent illegal use of content when DetectedDeviceTimeModifiedException occurs.

     private PallyconStreamingDrmSessionManager.PallyconEventListener eventListener = new PallyconStreamingDrmSessionManager.PallyconEventListener() {
         @Override
         public void onDrmKeysLoaded(Map<String, String> licenseInfo) {
             // refer to API document
         }
    
         @Override
         public void onDrmSessionManagerError(Exception e) {
             // refer to API document
             if (e instanceof NetworkConnectedException) {
    
             } else if (e instanceof PallyconDrmException) {
    
             } else if (e instanceof PallyconEncrypterException) {
    
             } else if (e instanceof PallyconServerResponseException) {
    
             } else if (e instanceof KeysExpiredException) {
    
             } else if (e instanceof DetectedDeviceTimeModifiedException) {
                 // Important : content playback should be prohibited to prevent illegal use of content.
             } else {
    
             }
         }
     };
    
  13. Get PallyconWVMSDK instance.

     PallyconWVMSDK WVMAgent = PallyconWVMSDKFactory.getInstance(this, Global.enableNcgCenc);
    
  14. Set Site ID and Site Key issued by PallyCon Admin Site to PallyconWVMSDK instance.

     WVMAgent.init(this, eventHandler, "SITEID", "SITEKEY");
    
  15. Register a listener to receive events from the object of PallyconWVMSDK.

     WVMAgent.setPallyconEventListener(pallyconEventListener);
    
  16. Create PallyconDrmSessionManager with information for license acquisition.

     drmSessionManager = WVMAgent.createDrmSessionManager(drmSchemeUuid, drmLicenseUrl, uri, userId, cid, oid);
    

    If you use license token type integration, set the token information as below.

     drmSessionManager = WVMAgent.createDrmSessionManagerByToken(drmSchemeUuid, drmLicenseUrl, uri, userId, cid, token);
    
  17. Input the above drmSessionManager as a parameter when creating ExoPlayer

     player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager);
    
  18. Input the playerEventListener when registering Player Listener as well.

     player.addListener(playerEventListener);
    

Preventing screen recording

To prevent content leaks with screen recording apps, you should block the capture function by adding the following code to your application:

SurfaceView view = (SurfaceView)simpleExoPlayerView.getVideoSurfaceView();
view.setSecure(true);

API References

Please refer to the doc/en/api_reference.html file of the SDK zip file for detailed explanation of each API.


results matching ""

    No results matching ""