2023-11-07 23:41:17 -07:00
|
|
|
import com.android.Version
|
|
|
|
|
2017-01-11 05:51:45 -07:00
|
|
|
apply plugin: 'com.android.library'
|
2023-05-01 03:09:58 -06:00
|
|
|
apply plugin: 'kotlin-android'
|
|
|
|
|
|
|
|
buildscript {
|
2023-11-07 23:41:17 -07:00
|
|
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNVideo_kotlinVersion']
|
2023-05-01 03:09:58 -06:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
|
|
|
}
|
|
|
|
}
|
2017-01-11 05:51:45 -07:00
|
|
|
|
2023-11-07 23:41:17 -07:00
|
|
|
def safeExtGet(prop) {
|
|
|
|
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : project.properties["RNVideo_" + prop]
|
2018-07-24 14:19:45 -06:00
|
|
|
}
|
2018-06-21 11:29:38 -06:00
|
|
|
|
2023-05-01 03:09:58 -06:00
|
|
|
def isNewArchitectureEnabled() {
|
2023-09-25 04:08:11 -06:00
|
|
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
def supportsNamespace() {
|
2023-11-18 06:13:54 -07:00
|
|
|
def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
|
|
def major = parsed[0].toInteger()
|
|
|
|
def minor = parsed[1].toInteger()
|
2023-09-25 04:08:11 -06:00
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
// Namespace support was added in 7.3.0
|
|
|
|
if (major == 7 && minor >= 3) {
|
|
|
|
return true
|
|
|
|
}
|
2023-09-25 04:08:11 -06:00
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
return major >= 8
|
2023-05-01 03:09:58 -06:00
|
|
|
}
|
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA")?.toBoolean() ?: false
|
2023-02-07 15:14:50 -07:00
|
|
|
|
|
|
|
println "useExoplayerIMA:" + useExoplayerIMA
|
|
|
|
|
|
|
|
// This string is used to define build path.
|
|
|
|
// As react native build output directory is react-native path of the module.
|
|
|
|
// We need to force a new path on each configuration change.
|
|
|
|
// If you add a new build parameter, please add the new value in this string
|
|
|
|
def configStringPath = (
|
|
|
|
'useExoplayerIMA' + useExoplayerIMA \
|
|
|
|
).md5()
|
|
|
|
|
2023-05-01 03:09:58 -06:00
|
|
|
if (isNewArchitectureEnabled()) {
|
|
|
|
apply plugin: "com.facebook.react"
|
|
|
|
}
|
|
|
|
|
2017-01-11 05:51:45 -07:00
|
|
|
android {
|
2023-09-25 04:08:11 -06:00
|
|
|
if (supportsNamespace()) {
|
2023-11-18 06:13:54 -07:00
|
|
|
namespace 'com.brentvatne.react'
|
2023-09-25 04:08:11 -06:00
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
|
|
}
|
2023-09-25 04:08:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-07 23:41:17 -07:00
|
|
|
compileSdkVersion safeExtGet('compileSdkVersion')
|
|
|
|
buildToolsVersion safeExtGet('buildToolsVersion')
|
2019-09-16 14:29:31 -06:00
|
|
|
|
2023-11-07 23:41:17 -07:00
|
|
|
def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION
|
2023-09-25 04:24:08 -06:00
|
|
|
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
2023-11-18 06:13:54 -07:00
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_11
|
|
|
|
targetCompatibility JavaVersion.VERSION_11
|
|
|
|
}
|
|
|
|
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
|
|
}
|
2019-02-26 03:21:28 -07:00
|
|
|
}
|
2017-01-11 05:51:45 -07:00
|
|
|
|
|
|
|
defaultConfig {
|
2023-11-07 23:41:17 -07:00
|
|
|
minSdkVersion safeExtGet('minSdkVersion')
|
|
|
|
targetSdkVersion safeExtGet('targetSdkVersion')
|
2018-06-21 11:29:38 -06:00
|
|
|
versionCode 1
|
|
|
|
versionName "1.0"
|
2023-05-01 03:09:58 -06:00
|
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
|
|
|
|
|
|
ndk {
|
|
|
|
abiFilters(*reactNativeArchitectures())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-25 04:24:08 -06:00
|
|
|
buildFeatures {
|
|
|
|
buildConfig true
|
|
|
|
}
|
|
|
|
|
2023-05-01 03:09:58 -06:00
|
|
|
packagingOptions {
|
|
|
|
exclude "**/libreact_render*.so"
|
2017-01-11 05:51:45 -07:00
|
|
|
}
|
Add iOS and Android basic DRM support (#1445)
This PR adds support for DRM streams on iOS (Fairplay) and Android (Playready, Widevine, Clearkey)
I am neither Android nor iOS developer, so feel free to provide feedback to improve this PR.
**Test stream for ANDROID:**
```
testStream = {
uri: 'http://profficialsite.origin.mediaservices.windows.net/c51358ea-9a5e-4322-8951-897d640fdfd7/tearsofsteel_4k.ism/manifest(format=mpd-time-csf)',
type: 'mpd',
drm: {
type: DRMType.PLAYREADY,
licenseServer: 'http://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(persist:false,sl:150)'
}
};
```
or
```
{
uri: 'https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd',
drm: {
type: 'widevine', //or DRMType.WIDEVINE
licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense',
headers: {
'X-AxDRM-Message': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU'
},
}
}
```
**Test stream for iOS:**
Sorry but I can not provide free streams to test. If anyone can provide test streams, or found some we can use, please let me know to also test them.
It has been tested with a private provider and they work, at least with the `getLicense` override method. (An example implementation is provided in the README)
2020-08-12 19:56:21 -06:00
|
|
|
|
2023-02-07 15:14:50 -07:00
|
|
|
buildDir 'buildOutput_' + configStringPath
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
if (useExoplayerIMA) {
|
|
|
|
exclude 'com/google/ads/interactivemedia/v3/api'
|
2023-02-09 15:20:10 -07:00
|
|
|
exclude 'com/google/android/exoplayer2/ext/ima'
|
2023-02-07 15:14:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-01 03:09:58 -06:00
|
|
|
|
|
|
|
sourceSets.main {
|
|
|
|
java {
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
|
|
srcDirs += [
|
2023-11-18 06:13:54 -07:00
|
|
|
"src/fabric/java",
|
|
|
|
"${project.buildDir}/generated/source/codegen/java"
|
2023-05-01 03:09:58 -06:00
|
|
|
]
|
|
|
|
} else {
|
|
|
|
srcDirs += [
|
2023-11-18 06:13:54 -07:00
|
|
|
"src/oldarch/java"
|
2023-05-01 03:09:58 -06:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def reactNativeArchitectures() {
|
|
|
|
def value = project.getProperties().get("reactNativeArchitectures")
|
|
|
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
2017-01-11 05:51:45 -07:00
|
|
|
}
|
|
|
|
|
2021-12-09 11:23:48 -07:00
|
|
|
repositories {
|
2022-09-19 03:44:49 -06:00
|
|
|
google()
|
2023-05-01 03:09:58 -06:00
|
|
|
maven {
|
|
|
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
|
|
url "$rootDir/../node_modules/react-native/android"
|
|
|
|
}
|
|
|
|
mavenCentral()
|
2021-12-09 11:23:48 -07:00
|
|
|
}
|
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
def media3_version = safeExtGet('media3Version')
|
2023-11-07 23:41:17 -07:00
|
|
|
def kotlin_version = safeExtGet('kotlinVersion')
|
2023-05-01 03:09:58 -06:00
|
|
|
|
2017-01-11 05:51:45 -07:00
|
|
|
dependencies {
|
2023-11-07 23:41:17 -07:00
|
|
|
// For < 0.71, this will be from the local maven repo
|
|
|
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
|
|
//noinspection GradleDynamicVersion
|
|
|
|
implementation "com.facebook.react:react-native:+"
|
2018-08-08 00:10:03 -06:00
|
|
|
|
2023-11-04 07:59:59 -06:00
|
|
|
implementation "androidx.core:core:1.9.0"
|
2018-08-08 00:10:03 -06:00
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
// For media playback using ExoPlayer
|
|
|
|
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
2022-11-09 06:26:39 -07:00
|
|
|
|
2023-11-18 06:13:54 -07:00
|
|
|
// For Smooth Streaming playback support with ExoPlayer
|
|
|
|
implementation "androidx.media3:media3-exoplayer-smoothstreaming:$media3_version"
|
|
|
|
// For DASH playback support with ExoPlayer
|
|
|
|
implementation "androidx.media3:media3-exoplayer-dash:$media3_version"
|
|
|
|
// For HLS playback support with ExoPlayer
|
|
|
|
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
|
|
|
|
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
|
2023-02-07 15:14:50 -07:00
|
|
|
if (useExoplayerIMA) {
|
2023-11-18 06:13:54 -07:00
|
|
|
implementation "androidx.media3:media3-exoplayer-ima:$media3_version"
|
2023-02-07 15:14:50 -07:00
|
|
|
}
|
2023-11-18 06:13:54 -07:00
|
|
|
|
|
|
|
// For loading data using the OkHttp network stack
|
|
|
|
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
|
|
|
|
|
|
|
|
// For building media playback UIs
|
|
|
|
implementation "androidx.media3:media3-ui:$media3_version"
|
|
|
|
|
|
|
|
// For exposing and controlling media sessions
|
|
|
|
implementation "androidx.media3:media3-session:$media3_version"
|
|
|
|
|
|
|
|
// Common functionality for loading data
|
|
|
|
implementation "androidx.media3:media3-datasource:$media3_version"
|
|
|
|
// Common functionality used across multiple media libraries
|
|
|
|
implementation "androidx.media3:media3-common:$media3_version"
|
|
|
|
|
2023-05-01 03:09:58 -06:00
|
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
2019-02-26 03:21:28 -07:00
|
|
|
}
|