TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.15k stars 2.88k forks source link

DRM on iOS does not work on 5.1.1 anymore #2305

Closed rogerkerse closed 2 years ago

rogerkerse commented 3 years ago

Bug

With "react-native-video": "5.1.0-alpha8" fairplay drm videos worked fine. When upgrading to "react-native-video": "5.1.1" we started getting the following error. Nothing else changed.

Bad response from URI https://drm-fairplay-licensing.axprod.net/AcquireLicense: 
Client error: POS T https://drm-fairplay-licensing.axprod.net/AcquireLicense resulted in a 400 Invalid license request. Supported version is 1, but used version is 1936745277. response

Platform

Which player are you experiencing the problem on:

Environment info

React native info output:


info Fetching system and libraries information...
System:
    OS: macOS 11.2.2
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 368.69 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.3.0 - ~/.nvm/versions/node/v15.3.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.0.14 - ~/.nvm/versions/node/v15.3.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 10.0.2 - /usr/bin/javac
    Python: 2.7.17 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: x.x.x

Steps To Reproduce

  1. Upgrade to 5.1.1
  2. Start video (which fails)

Expected behaviour

  1. Video would start playing as it did on version 5.1.0-alpha8

Reproducible sample code

Since it is a DRM content, I do not have precise urls to give, but I used props in following way. The only thing that stopped videos from playing was updating the patch version.

Props are following:

drm={{
    certificateUrl: ...,
    headers: {
        'X-AxDRM-Message': ...,
    },
    licenseServer: ...,
    type: DRMType.FAIRPLAY,
}}
source={{
    uri: ..,
    type: 'm3u8',
}}

Video sample

-

EyMaddis commented 3 years ago

You can configure this getLicense for iOS function (I do not use it for android). It manually switches from the base 64 string form into a simple octet-stream that Axinom needs :)

import { Buffer } from 'buffer' // provided by react-native 

....
<Video 
 ...
 getLicense={
  async (
      spc: string,
      _contentId: string,
      licenseURL: string
    ) => {
      try {
        const blob = Buffer.from(spc, 'base64')
        const licenseResponse = await fetch(licenseURL, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/octet-stream',
            // TODO: Add axinom details here, or better run them through a proxy server that adds X-AxDRM-Message
          },
          body: blob,
        })
        const licenseBlob = await licenseResponse.blob()

        // manually convert the blob into an octet-stream
        const license = await new Promise((resolve, reject) => {
          const reader = new FileReader() // use file reader to avoid external dependencies
          reader.onload = () => {
            const dataURL = reader.result
            resolve(
              // @ts-ignore
              dataURL.replace(
                'data:application/octet-stream;base64,',
                ''
              )
            )
          }
          reader.onerror = err => {
            console.error('could not turn license data into blob', err)
            reject(err)
          }
          reader.readAsDataURL(licenseBlob)
        })
        return license
      } catch (e) {
        console.error('could not get license', e)
      }
    }
 }
/>
freeboub commented 2 years ago

A pr has been merge to fix the issue, is it solved ?