-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into refactor/migrate-to-command
- Loading branch information
Showing
31 changed files
with
2,766 additions
and
1,581 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
android/src/main/java/com/brentvatne/react/ReactVideoPackage.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
android/src/main/java/com/brentvatne/react/ReactVideoPackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.brentvatne.react | ||
|
||
import com.brentvatne.exoplayer.DefaultReactExoplayerConfig | ||
import com.brentvatne.exoplayer.ReactExoplayerConfig | ||
import com.brentvatne.exoplayer.ReactExoplayerViewManager | ||
import com.facebook.react.ReactPackage | ||
import com.facebook.react.bridge.JavaScriptModule | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.uimanager.ViewManager | ||
|
||
class ReactVideoPackage @JvmOverloads constructor(private var config: ReactExoplayerConfig? = null) : ReactPackage { | ||
|
||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = | ||
listOf( | ||
VideoDecoderPropertiesModule(reactContext), | ||
VideoManagerModule(reactContext) | ||
) | ||
|
||
// Deprecated RN 0.47 | ||
fun createJSModules(): List<Class<out JavaScriptModule>> = emptyList() | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> { | ||
if (config == null) { | ||
config = DefaultReactExoplayerConfig(reactContext) | ||
} | ||
return listOf(ReactExoplayerViewManager(config!!)) | ||
} | ||
} |
126 changes: 0 additions & 126 deletions
126
android/src/main/java/com/brentvatne/react/VideoDecoderPropertiesModule.java
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
android/src/main/java/com/brentvatne/react/VideoDecoderPropertiesModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.brentvatne.react | ||
|
||
import android.media.MediaCodecList | ||
import android.media.MediaDrm | ||
import android.media.MediaFormat | ||
import android.media.UnsupportedSchemeException | ||
import android.os.Build | ||
import com.facebook.react.bridge.Promise | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule | ||
import com.facebook.react.bridge.ReactMethod | ||
import java.util.UUID | ||
|
||
class VideoDecoderPropertiesModule(reactContext: ReactApplicationContext?) : ReactContextBaseJavaModule(reactContext) { | ||
override fun getName(): String = REACT_CLASS | ||
|
||
@ReactMethod | ||
fun getWidevineLevel(p: Promise) { | ||
var widevineLevel = 0 | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { | ||
p.resolve(widevineLevel) | ||
return | ||
} | ||
try { | ||
val mediaDrm = MediaDrm(WIDEVINE_UUID) | ||
val securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY) | ||
widevineLevel = when (securityProperty) { | ||
"L1" -> 1 | ||
"L2" -> 2 | ||
"L3" -> 3 | ||
else -> 0 | ||
} | ||
} catch (e: UnsupportedSchemeException) { | ||
e.printStackTrace() | ||
} | ||
p.resolve(widevineLevel) | ||
} | ||
|
||
@ReactMethod | ||
fun isCodecSupported(mimeType: String?, width: Int, height: Int, p: Promise) { | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | ||
p.resolve("unsupported") | ||
return | ||
} | ||
val mRegularCodecs = MediaCodecList(MediaCodecList.REGULAR_CODECS) | ||
val format = MediaFormat.createVideoFormat(mimeType!!, width, height) | ||
val codecName = mRegularCodecs.findDecoderForFormat(format) | ||
if (codecName == null) { | ||
p.resolve("unsupported") | ||
return | ||
} | ||
|
||
// Fallback for android < 10 | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { | ||
p.resolve("software") | ||
return | ||
} | ||
val isHardwareAccelerated = mRegularCodecs.codecInfos.any { | ||
it.name.equals(codecName, ignoreCase = true) && it.isHardwareAccelerated | ||
} | ||
p.resolve(if (isHardwareAccelerated) "software" else "hardware") | ||
} | ||
|
||
@ReactMethod | ||
fun isHEVCSupported(p: Promise) = isCodecSupported("video/hevc", 1920, 1080, p) | ||
|
||
companion object { | ||
private val WIDEVINE_UUID = UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L) | ||
private const val SECURITY_LEVEL_PROPERTY = "securityLevel" | ||
private const val REACT_CLASS = "RNVDecoderPropertiesModule" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,6 @@ buck-out/ | |
# Ruby / CocoaPods | ||
/ios/Pods/ | ||
/vendor/bundle/ | ||
|
||
# testing | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version | ||
ruby '2.7.5' | ||
ruby ">= 2.6.10" | ||
|
||
gem 'cocoapods', '~> 1.11', '>= 1.11.2' | ||
gem 'cocoapods', '~> 1.13' | ||
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0' |
Oops, something went wrong.