Merge branch 'master' into feat/playback-ref-functions
This commit is contained in:
@@ -24,11 +24,20 @@ def getExtOrDefault(name, defaultValue) {
|
||||
}
|
||||
|
||||
def isNewArchitectureEnabled() {
|
||||
// To opt-in for the New Architecture, you can either:
|
||||
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
||||
// - Invoke gradle with `-newArchEnabled=true`
|
||||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
||||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
||||
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
||||
}
|
||||
|
||||
def supportsNamespace() {
|
||||
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
||||
def major = parsed[0].toInteger()
|
||||
def minor = parsed[1].toInteger()
|
||||
|
||||
// Namespace support was added in 7.3.0
|
||||
if (major == 7 && minor >= 3) {
|
||||
return true
|
||||
}
|
||||
|
||||
return major >= 8
|
||||
}
|
||||
|
||||
def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false)
|
||||
@@ -48,13 +57,29 @@ if (isNewArchitectureEnabled()) {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.brentvatne.react'
|
||||
if (supportsNamespace()) {
|
||||
namespace 'com.brentvatne.react'
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileSdkVersion safeExtGet('compileSdkVersion', 31)
|
||||
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
|
||||
|
||||
compileOptions {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
||||
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
@@ -69,13 +94,12 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude "**/libreact_render*.so"
|
||||
buildFeatures {
|
||||
buildConfig true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
packagingOptions {
|
||||
exclude "**/libreact_render*.so"
|
||||
}
|
||||
|
||||
buildDir 'buildOutput_' + configStringPath
|
||||
|
2
android/src/main/AndroidManifestNew.xml
Normal file
2
android/src/main/AndroidManifestNew.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
@@ -1,6 +1,7 @@
|
||||
package com.brentvatne.react;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecList;
|
||||
import android.media.MediaDrm;
|
||||
import android.media.MediaFormat;
|
||||
@@ -79,18 +80,36 @@ public class VideoDecoderPropertiesModule extends ReactContextBaseJavaModule {
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
@ReactMethod
|
||||
public void isCodecSupported(String mimeType, int width, int height, Promise p) {
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
p.resolve(false);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
p.resolve("unsupported");
|
||||
return;
|
||||
}
|
||||
|
||||
MediaCodecList mRegularCodecs = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
||||
MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);
|
||||
String codecName = mRegularCodecs.findDecoderForFormat(format);
|
||||
|
||||
if (codecName == null) {
|
||||
p.resolve(false);
|
||||
} else {
|
||||
p.resolve(true);
|
||||
p.resolve("unsupported");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback for android < 10
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
p.resolve("software");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isHardwareAccelerated = false;
|
||||
|
||||
for (MediaCodecInfo codecInfo : mRegularCodecs.getCodecInfos()) {
|
||||
if (codecInfo.getName().equalsIgnoreCase(codecName)) {
|
||||
isHardwareAccelerated = codecInfo.isHardwareAccelerated();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p.resolve(isHardwareAccelerated ? "software" : "hardware");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user