Developer Portal

Video DRM

The Roku platform supports various types of DRM, see the Roku documentation for more details. With You.i Engine One, you can specify the DRM scheme and attributes you need for your video steam. See below for instructions specific to your implementation type.

Note that if using Widevine, you'll also need to update your manifest file.

React Native Apps

If your application uses only the required attributes for the PlayReady or Widevine DRM scheme, it's simple to specify the needed DRM attributes in the source prop.

Here is an example with PlayReady DRM:

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { Video } from '@youi/react-native-youi';

export default class YiReactApp extends Component {

  render() {
    const content = {
      type: 'DASH',
      uri: 'http://amssamples.streaming.mediaservices.windows.net/d444b1c9-c64a-4d65-b0f4-433810cf5e92/SintelMultiAudio.ism/manifest(format=mpd-time-csf)',
      drmScheme: "playready",
      drmInfo: "https://amssamples.keydelivery.mediaservices.windows.net/PlayReady/",
      // Note, if using a custom PlayReady license acquisition request, specify drmInfo in the format: "<AcquisitionUrl>%%%<CustomData>"
    };

    return (
      <Video 
        style={{ flex: 1 }}
        source={content}
        ref={ref => this.videoRef = ref}
        onReady={() => this.videoRef.play()}
        />
    );
  }
}

AppRegistry.registerComponent('YiReactApp', () => YiReactApp);

Or, for WideVine, structure your video prop as follows:

 
    const content = {
      type: 'DASH',
      uri: 'http://amssamples.streaming.mediaservices.windows.net/d444b1c9-c64a-4d65-b0f4-433810cf5e92/SintelMultiAudio.ism/manifest(format=mpd-time-csf)',
      drmScheme: "widevine_modular",
      drmInfo: {
                  licenseAcquisitionUrl:"<WidevineLicenseServerURL>"
               },
    };

If you need to set optional Roku DRM parameters, you must use the metadata prop of the Video or Video Ref component. Remove drmScheme and drmInfo from the source prop, and add the metadata prop as shown below. Then pass this metadata prop into your Video or VideoRef component:

//for playready
const metadata = {
   drmParams = {
      keySystem: 'playready',
      encodingType: 'PlayReadyLicenseAcquisitionUrl',
      encodingKey: '<PlayReadyLicenseServerURL>'
   }
};


//for widevine
const metadata = {
   drmParams = {
      keySystem: 'widevine',
      licenseServerURL: '<WidevineLicenseServerUrl>',
   }
};


C++ Apps

You.i Engine One supports Roku DRM schemes in two ways via C++ applications. For Widevine and Playready DRM, the preferred way of providing the DRM attributes is to use CYIAbstractVideoPlayer::DRMConfiguration.

DRMConfiguration

Widevine has only one required attribute, licenseServerURL. The following example shows how to configure that attribute for Widevine DRM. If you need to set any of the optional attributes, use the Generic DRM method described below instead.

std::unique_ptr<CYIWidevineModularDRMConfiguration> pDRMConfiguration(new CYIWidevineModularDRMConfiguration());
pDRMConfiguration->SetLicenseAcquisitionUrl(licenseServerUrl);
pPlayer->Prepare(videoUrl, CYIAbstractVideoPlayer::StreamingFormat::DASH, CYIAbstractVideoPlayer::PlaybackState::Paused, std::move(pDRMConfiguration));
pPlayer->Play()

Playready has the required attributes: encodingKey and encodingType. Unless you're using a custom license acquisition request, encodingType is always "PlayReadyLicenseAcquisitionUrl". You.i Engine One handles setting that for you. To specify your encodingKey, use SetLicenseAcquisitionUrl() as in the following example for PlayReady DRM:

std::unique_ptr<CYIPlayReadyDRMConfiguration> pDRMConfiguration(new c());
pDRMConfiguration->SetLicenseAcquisitionUrl(licenseServerUrl);
pPlayer->Prepare(videoUrl, CYIAbstractVideoPlayer::StreamingFormat::DASH, CYIAbstractVideoPlayer::PlaybackState::Paused, std::move(pDRMConfiguration));
pPlayer->Play()

If your PlayReady implementation requires custom license acquisition, set your custom data with the following command, before calling Prepare() on your player. You.i Engine One will automatically change the encodingType to "PlayReadyLicenseAcquisitionAndChallenge" and correctly format encodingKey with your URL and custom data.

  • CYIPlayReadyDRMConfiguration::SetLicenseAcquisitionCustomData(const CYIString)

If you need to set any of the optional attributes for PlayReady, use the Generic DRM method described below instead.

Generic DRM

For other DRM schemes, or alternately for PlayReady and Widevine, you can use a generic method to specify the required metadata. Craft a JSON object and pass it in to the player as in the following example.

yi::rapidjson::Document drmParam;
drmParam.SetObject();
CYIRapidJSONUtility::AddStringField(&drmParam, "name", "AdobeAccess");
CYIRapidJSONUtility::AddStringField(&drmParam, "appData", "drm-token-as-a-string");
CYIRapidJSONUtility::AddStringField(&drmParam, "test", "Random_drm_property");
 
CYIAbstractVideoPlayer::VideoMetadata metadata;
metadata.insert({"drmParam", CYIRapidJSONUtility::CreateStringFromDocument(drmParam)});
CYICloud::GetInterface().SetVideoMetadata(m_pPlayer.get(), metadata);

For more information on how to debug the drmParam and videoHeaders properties , see DEBUG_PRINT_VIDEO_DRM.

Note

Only Roku's specified list of drmParam attributes are supported.