2

I am trying to use the v3 CAF receiver app using DRM to casting videos, from my IOS app. If I use the basic v3 CAF receiver app (default receiver) it is working fine, but when I using DRM url (dash/.mpd and licenseUrl ) it will throw below error Error

[ 20.844s] [Error] [INFO] {"type":"LOAD_CANCELLED","requestId":0}

See the below code.

const playerManager = context.getPlayerManager();
const playbackConfig = new cast.framework.PlaybackConfig();
/** Debug Logger **/
const castDebugLogger = cast.debug.CastDebugLogger.getInstance();

var manifestUri = 'https://example.domain.video/prod/drm/1/7e942940-d705-4417-b552-796e8fd25460/Media_1_20_d2aaec7102dc42c09dd54e4f00cbea412019062801270383196000/dash/manifest.mpd';
var licenseServer = 'https://wv.example.domain.com/hms/wv/rights/?ExpressPlayToken=BQALuGDeKZcAJDE2YzAwYTRkLTYwZWYtNGJiZC1hZmEzLTdhMmZhYTY2NzM5OQAAAHCZzHVjRyfs3AEgxFuwPvZsrqMndjiBPzLQ5_VUx6rJOEDD5noQmXJoVP-Va1gQzxfp9eHux15_pEr6g0RxXNZIjlsN6b7SIfpHPyS9iuPQqgvEgq5I_tV9k1lhQvKuqgpBN0Z5BtxCLwHc8xrnLbuUK6fiThcLMR4He_x38reAsumjFYg';

// setting manually licenseUrl from here 
playbackConfig.licenseUrl = licenseServer;

playbackConfig.manifestRequestHandler = requestInfo => {
  requestInfo.withCredentials = true;
};

playbackConfig.licenseRequestHandler = requestInfo => {
  requestInfo.withCredentials = true;
  requestInfo.headers = {
    // 'Content-type':'application/dash+xml', // trying this also
    'Content-type':'application/octet-stream'
    }
 playbackConfig.licenseUrl = requestInfo.media.customData.licenseUrl;
 return playbackConfig;
};

// MessageInterceptor
playerManager.setMessageInterceptor(
  cast.framework.messages.MessageType.LOAD,
  request => {
    const error = new cast.framework.messages.ErrorData(cast.framework.messages.ErrorType.LOAD_CANCELLED);
    castDebugLogger.info('Error', error);
    if (!request.media) {
      error.reason = cast.framework.messages.ErrorReason.INVALID_PARAM;
      castDebugLogger.info('reason', error.reason);
      return error;
    }
    if (request.media && request.media.entity) {
      request.media.contentId = request.media.entity;
    }

    return new Promise((resolve, reject) => {
      if (!request.media) {
        castDebugLogger.error('MyAPP.LOG', 'Content not found');
        reject();
      } else {

        // I have passed manually data (license Url and content Id etc.) from here for testing purpose
        const item = new cast.framework.messages.QueueItem();
        item.media = new cast.framework.messages.MediaInformation();
        item.media.contentId = manifestUri;
        item.media.streamType = cast.framework.messages.StreamType.BUFFERED;

// Trying all options of contentType

        item.media.contentType = "application/octet-stream";
        //request.media.contentType = 'application/x-mpegurl'; 
        //item.media.contentType = "video/mp4";
        //request.media.contentType = 'video/mp4';
        //request.media.contentType = 'application/dash+xml';
        item.media.metadata = new cast.framework.messages.MovieMediaMetadata();
        item.media.metadata.title = "Example title";
        item.media.metadata.subtitle = "Example subtitle ";
        item.media.metadata.images = [new cast.framework.messages.Image("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg")];
        request.media = item.media;
        playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;

        resolve(request);
      }
    });
  });

// start 
context.start({
  playbackConfig: playbackConfig,
  touchScreenOptimizedApp: true
});

LA_URL and .mpd url is working fine with another online shaka player.

Naveen
  • 1,441
  • 2
  • 16
  • 41
Tushar Kadam
  • 173
  • 1
  • 1
  • 9

1 Answers1

0

Did you check in the remote web inspector if the network request is sent to the licenser when the load request is issued for the encoded dash stream? Most probably this will help to find where the problem is.

Possibly you will have to add some inteligence to your licenseRequestHandler to add a token of some sort. Or possibly there's a CORS issue.

Note: Before you post some code to stackoverflow, it might be wize to clean it up a bit: remove dead code, remove confusing commented code, provide proper indentation. You're wasting brain cycles of everybody reading your code and trying to process what you shared with the world!

Gr. Tom
  • 56
  • 3