react-native-alpha-video 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +908 -2
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/android/av1/build.gradle +67 -0
- package/android/av1/consumer-rules.pro +4 -0
- package/android/av1/src/main/cpp/Av1Codec_jni.cpp +8 -0
- package/android/av1/src/main/cpp/CMakeLists.txt +34 -0
- package/android/av1/src/main/java/dev/mediacache/alphavideo/av1/Av1Codec.java +21 -0
- package/android/build.gradle +90 -0
- package/android/consumer-rules.pro +2 -0
- package/android/gradle.properties +1 -0
- package/android/publish.gradle +82 -0
- package/android/settings.gradle +5 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/CMakeLists.txt +59 -0
- package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoCodecs.java +73 -0
- package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoView.java +1982 -0
- package/android/src/main/java/dev/mediacache/alphavideo/BufferedDualStreamPlayer.java +978 -0
- package/android/src/main/java/dev/mediacache/alphavideo/Fetcher.java +37 -0
- package/android/src/main/java/dev/mediacache/alphavideo/HttpFetcher.java +156 -0
- package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecColor.java +47 -0
- package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecDecoders.java +135 -0
- package/android/src/main/java/dev/mediacache/alphavideo/RangeSourceLink.java +54 -0
- package/android/src/main/java/dev/mediacache/alphavideo/SourceReader.java +174 -0
- package/android/src/main/java/dev/mediacache/alphavideo/SurfaceTextureVideoDecoder.java +802 -0
- package/android/src/main/java/dev/mediacache/alphavideo/WebMAlphaPlayerNative.java +95 -0
- package/android/src/main/java/dev/mediacache/alphavideo/WebMFrame.java +54 -0
- package/android/src/main/java/dev/mediacache/alphavideo/WebMSource.java +160 -0
- package/android/src/rangesource/java/dev/mediacache/alphavideo/AppDataSource.java +50 -0
- package/android/vpx/build.gradle +67 -0
- package/android/vpx/consumer-rules.pro +4 -0
- package/android/vpx/src/main/cpp/CMakeLists.txt +34 -0
- package/android/vpx/src/main/cpp/VpxCodec_jni.cpp +8 -0
- package/android/vpx/src/main/java/dev/mediacache/alphavideo/vpx/VpxCodec.java +21 -0
- package/codecs/av1/Dav1dDecoderPlugin.cpp +157 -0
- package/codecs/av1/Dav1dDecoderPlugin.h +17 -0
- package/codecs/vpx/VpxDecoderPlugin.cpp +103 -0
- package/codecs/vpx/VpxDecoderPlugin.h +17 -0
- package/cpp/AlphaDemuxer.cpp +984 -0
- package/cpp/AlphaDemuxer.h +123 -0
- package/cpp/AlphaVideoDecoderPlugin.h +84 -0
- package/cpp/Av1SequenceHeader.cpp +175 -0
- package/cpp/Av1SequenceHeader.h +25 -0
- package/cpp/ByteSource.cpp +116 -0
- package/cpp/ByteSource.h +59 -0
- package/cpp/RangeSourceClient.h +40 -0
- package/cpp/VideoDecoder.cpp +157 -0
- package/cpp/VideoDecoder.h +83 -0
- package/cpp/WebMAlphaPlayer.cpp +1666 -0
- package/cpp/WebMAlphaPlayer.h +389 -0
- package/cpp/WebMAlphaPlayer_jni.cpp +1380 -0
- package/cpp/YuvToRgb.cpp +39 -0
- package/cpp/YuvToRgb.h +40 -0
- package/ios/Sources/AlphaVideo/AlphaVideoCodecs.mm +63 -0
- package/ios/Sources/AlphaVideo/AlphaVideoInternal.h +70 -0
- package/ios/Sources/AlphaVideo/AlphaVideoPlayer.mm +994 -0
- package/ios/Sources/AlphaVideo/AlphaVideoSource.mm +476 -0
- package/ios/Sources/AlphaVideo/AlphaVideoView.mm +374 -0
- package/ios/Sources/AlphaVideo/include/AlphaVideo.h +303 -0
- package/ios/Sources/AlphaVideoAV1/AlphaVideoAV1Codec.mm +16 -0
- package/ios/Sources/AlphaVideoAV1/include/AlphaVideoAV1.h +18 -0
- package/ios/Sources/AlphaVideoVPX/AlphaVideoVPXCodec.mm +16 -0
- package/ios/Sources/AlphaVideoVPX/include/AlphaVideoVPX.h +17 -0
- package/lib/commonjs/AlphaVideoView.js +187 -0
- package/lib/commonjs/AlphaVideoView.js.map +1 -0
- package/lib/commonjs/AlphaVideoViewNativeComponent.js +47 -0
- package/lib/commonjs/AlphaVideoViewNativeComponent.js.map +1 -0
- package/lib/commonjs/AlphaVideoViewNativeComponent.web.js +11 -0
- package/lib/commonjs/AlphaVideoViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/NativeAlphaVideoModule.js +10 -0
- package/lib/commonjs/NativeAlphaVideoModule.js.map +1 -0
- package/lib/commonjs/NativeAlphaVideoModule.web.js +9 -0
- package/lib/commonjs/NativeAlphaVideoModule.web.js.map +1 -0
- package/lib/commonjs/WebPlayer.js +12 -0
- package/lib/commonjs/WebPlayer.js.map +1 -0
- package/lib/commonjs/WebPlayer.web.js +115 -0
- package/lib/commonjs/WebPlayer.web.js.map +1 -0
- package/lib/commonjs/index.js +124 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/AlphaVideoView.js +187 -0
- package/lib/module/AlphaVideoView.js.map +1 -0
- package/lib/module/AlphaVideoViewNativeComponent.js +47 -0
- package/lib/module/AlphaVideoViewNativeComponent.js.map +1 -0
- package/lib/module/AlphaVideoViewNativeComponent.web.js +11 -0
- package/lib/module/AlphaVideoViewNativeComponent.web.js.map +1 -0
- package/lib/module/NativeAlphaVideoModule.js +10 -0
- package/lib/module/NativeAlphaVideoModule.js.map +1 -0
- package/lib/module/NativeAlphaVideoModule.web.js +9 -0
- package/lib/module/NativeAlphaVideoModule.web.js.map +1 -0
- package/lib/module/WebPlayer.js +12 -0
- package/lib/module/WebPlayer.js.map +1 -0
- package/lib/module/WebPlayer.web.js +115 -0
- package/lib/module/WebPlayer.web.js.map +1 -0
- package/lib/module/index.js +124 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/react-native/src/AlphaVideoView.d.ts +189 -0
- package/lib/typescript/react-native/src/AlphaVideoView.d.ts.map +1 -0
- package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts +109 -0
- package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts +5 -0
- package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts +21 -0
- package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts.map +1 -0
- package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts +3 -0
- package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts.map +1 -0
- package/lib/typescript/react-native/src/WebPlayer.d.ts +3 -0
- package/lib/typescript/react-native/src/WebPlayer.d.ts.map +1 -0
- package/lib/typescript/react-native/src/WebPlayer.web.d.ts +9 -0
- package/lib/typescript/react-native/src/WebPlayer.web.d.ts.map +1 -0
- package/lib/typescript/react-native/src/index.d.ts +77 -0
- package/lib/typescript/react-native/src/index.d.ts.map +1 -0
- package/licenses/dav1d-COPYING.txt +23 -0
- package/licenses/libvpx-LICENSE.txt +31 -0
- package/licenses/libvpx-PATENTS.txt +23 -0
- package/licenses/libwebm-LICENSE.txt +30 -0
- package/licenses/libwebm-PATENTS.txt +23 -0
- package/package.json +152 -4
- package/prebuilt/android/arm64-v8a/lib/libdav1d.a +0 -0
- package/prebuilt/android/arm64-v8a/lib/libvpx.a +0 -0
- package/prebuilt/android/armeabi-v7a/lib/libdav1d.a +0 -0
- package/prebuilt/android/armeabi-v7a/lib/libvpx.a +0 -0
- package/prebuilt/android/x86_64/lib/libdav1d.a +0 -0
- package/prebuilt/android/x86_64/lib/libvpx.a +0 -0
- package/prebuilt/include/dav1d/common.h +94 -0
- package/prebuilt/include/dav1d/data.h +117 -0
- package/prebuilt/include/dav1d/dav1d.h +329 -0
- package/prebuilt/include/dav1d/headers.h +440 -0
- package/prebuilt/include/dav1d/picture.h +157 -0
- package/prebuilt/include/dav1d/version.h +50 -0
- package/prebuilt/include/vpx/vp8.h +136 -0
- package/prebuilt/include/vpx/vp8dx.h +228 -0
- package/prebuilt/include/vpx/vpx_codec.h +475 -0
- package/prebuilt/include/vpx/vpx_decoder.h +365 -0
- package/prebuilt/include/vpx/vpx_frame_buffer.h +83 -0
- package/prebuilt/include/vpx/vpx_image.h +209 -0
- package/prebuilt/include/vpx/vpx_integer.h +40 -0
- package/prebuilt/ios/lib/libdav1d.a +0 -0
- package/prebuilt/ios/lib/libvpx.a +0 -0
- package/prebuilt/ios-simulator/include/dav1d/common.h +94 -0
- package/prebuilt/ios-simulator/include/dav1d/data.h +117 -0
- package/prebuilt/ios-simulator/include/dav1d/dav1d.h +329 -0
- package/prebuilt/ios-simulator/include/dav1d/headers.h +440 -0
- package/prebuilt/ios-simulator/include/dav1d/picture.h +157 -0
- package/prebuilt/ios-simulator/include/dav1d/version.h +50 -0
- package/prebuilt/ios-simulator/include/vpx/vp8.h +136 -0
- package/prebuilt/ios-simulator/include/vpx/vp8dx.h +228 -0
- package/prebuilt/ios-simulator/include/vpx/vpx_codec.h +475 -0
- package/prebuilt/ios-simulator/include/vpx/vpx_decoder.h +365 -0
- package/prebuilt/ios-simulator/include/vpx/vpx_frame_buffer.h +83 -0
- package/prebuilt/ios-simulator/include/vpx/vpx_image.h +209 -0
- package/prebuilt/ios-simulator/include/vpx/vpx_integer.h +40 -0
- package/prebuilt/ios-simulator/lib/libdav1d.a +0 -0
- package/prebuilt/ios-simulator/lib/libvpx.a +0 -0
- package/react-native/android/CMakeLists.txt +14 -0
- package/react-native/android/build.gradle +113 -0
- package/react-native/android/src/main/AndroidManifest.xml +1 -0
- package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModule.java +102 -0
- package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoPackage.java +50 -0
- package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManager.java +317 -0
- package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +10 -0
- package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +23 -0
- package/react-native/android/src/norangesource/java/dev/mediacache/alphavideo/AppDataSource.java +15 -0
- package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +30 -0
- package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +61 -0
- package/react-native/ios/RNAlphaVideoViewComponentView.mm +173 -0
- package/react-native/ios/RNAlphaVideoViewManager.mm +147 -0
- package/react-native/src/AlphaVideoView.tsx +329 -0
- package/react-native/src/AlphaVideoViewNativeComponent.ts +132 -0
- package/react-native/src/AlphaVideoViewNativeComponent.web.ts +5 -0
- package/react-native/src/NativeAlphaVideoModule.ts +22 -0
- package/react-native/src/NativeAlphaVideoModule.web.ts +2 -0
- package/react-native/src/WebPlayer.tsx +7 -0
- package/react-native/src/WebPlayer.web.tsx +87 -0
- package/react-native/src/index.tsx +144 -0
- package/react-native-alpha-video.podspec +99 -0
- package/react-native.config.js +12 -0
- package/scripts/build_codecs_android.sh +246 -0
- package/scripts/build_codecs_ios.sh +31 -0
- package/scripts/build_codecs_ios_device.sh +210 -0
- package/scripts/build_codecs_ios_simulator.sh +256 -0
- package/scripts/build_wasm.sh +230 -0
- package/scripts/build_xcframework.sh +49 -0
- package/scripts/fetch-prebuilt.sh +48 -0
- package/scripts/package_release.sh +107 -0
- package/scripts/publish-android.sh +85 -0
- package/scripts/vendor_range_source.sh +47 -0
- package/third_party/libwebm/AUTHORS.TXT +5 -0
- package/third_party/libwebm/LICENSE.TXT +30 -0
- package/third_party/libwebm/PATENTS.TXT +23 -0
- package/third_party/libwebm/README.md +7 -0
- package/third_party/libwebm/webm_parser/include/webm/buffer_reader.h +138 -0
- package/third_party/libwebm/webm_parser/include/webm/callback.h +363 -0
- package/third_party/libwebm/webm_parser/include/webm/dom_types.h +1781 -0
- package/third_party/libwebm/webm_parser/include/webm/element.h +208 -0
- package/third_party/libwebm/webm_parser/include/webm/file_reader.h +103 -0
- package/third_party/libwebm/webm_parser/include/webm/id.h +1085 -0
- package/third_party/libwebm/webm_parser/include/webm/istream_reader.h +99 -0
- package/third_party/libwebm/webm_parser/include/webm/reader.h +94 -0
- package/third_party/libwebm/webm_parser/include/webm/status.h +166 -0
- package/third_party/libwebm/webm_parser/include/webm/webm_parser.h +133 -0
- package/third_party/libwebm/webm_parser/src/ancestory.cc +334 -0
- package/third_party/libwebm/webm_parser/src/ancestory.h +83 -0
- package/third_party/libwebm/webm_parser/src/audio_parser.h +84 -0
- package/third_party/libwebm/webm_parser/src/bit_utils.cc +26 -0
- package/third_party/libwebm/webm_parser/src/bit_utils.h +24 -0
- package/third_party/libwebm/webm_parser/src/block_additions_parser.h +30 -0
- package/third_party/libwebm/webm_parser/src/block_group_parser.h +71 -0
- package/third_party/libwebm/webm_parser/src/block_header_parser.cc +76 -0
- package/third_party/libwebm/webm_parser/src/block_header_parser.h +65 -0
- package/third_party/libwebm/webm_parser/src/block_more_parser.h +32 -0
- package/third_party/libwebm/webm_parser/src/block_parser.cc +285 -0
- package/third_party/libwebm/webm_parser/src/block_parser.h +126 -0
- package/third_party/libwebm/webm_parser/src/bool_parser.h +95 -0
- package/third_party/libwebm/webm_parser/src/buffer_reader.cc +110 -0
- package/third_party/libwebm/webm_parser/src/byte_parser.h +144 -0
- package/third_party/libwebm/webm_parser/src/callback.cc +155 -0
- package/third_party/libwebm/webm_parser/src/chapter_atom_parser.h +42 -0
- package/third_party/libwebm/webm_parser/src/chapter_display_parser.h +34 -0
- package/third_party/libwebm/webm_parser/src/chapters_parser.h +28 -0
- package/third_party/libwebm/webm_parser/src/cluster_parser.h +48 -0
- package/third_party/libwebm/webm_parser/src/colour_parser.h +55 -0
- package/third_party/libwebm/webm_parser/src/content_enc_aes_settings_parser.h +32 -0
- package/third_party/libwebm/webm_parser/src/content_encoding_parser.h +38 -0
- package/third_party/libwebm/webm_parser/src/content_encodings_parser.h +30 -0
- package/third_party/libwebm/webm_parser/src/content_encryption_parser.h +37 -0
- package/third_party/libwebm/webm_parser/src/cue_point_parser.h +38 -0
- package/third_party/libwebm/webm_parser/src/cue_track_positions_parser.h +39 -0
- package/third_party/libwebm/webm_parser/src/cues_parser.h +27 -0
- package/third_party/libwebm/webm_parser/src/date_parser.cc +72 -0
- package/third_party/libwebm/webm_parser/src/date_parser.h +64 -0
- package/third_party/libwebm/webm_parser/src/ebml_parser.h +48 -0
- package/third_party/libwebm/webm_parser/src/edition_entry_parser.h +35 -0
- package/third_party/libwebm/webm_parser/src/element_parser.h +102 -0
- package/third_party/libwebm/webm_parser/src/file_reader.cc +142 -0
- package/third_party/libwebm/webm_parser/src/float_parser.cc +77 -0
- package/third_party/libwebm/webm_parser/src/float_parser.h +65 -0
- package/third_party/libwebm/webm_parser/src/id_element_parser.cc +49 -0
- package/third_party/libwebm/webm_parser/src/id_element_parser.h +56 -0
- package/third_party/libwebm/webm_parser/src/id_parser.cc +75 -0
- package/third_party/libwebm/webm_parser/src/id_parser.h +45 -0
- package/third_party/libwebm/webm_parser/src/info_parser.h +44 -0
- package/third_party/libwebm/webm_parser/src/int_parser.h +121 -0
- package/third_party/libwebm/webm_parser/src/istream_reader.cc +133 -0
- package/third_party/libwebm/webm_parser/src/master_parser.cc +298 -0
- package/third_party/libwebm/webm_parser/src/master_parser.h +230 -0
- package/third_party/libwebm/webm_parser/src/master_value_parser.h +533 -0
- package/third_party/libwebm/webm_parser/src/mastering_metadata_parser.h +57 -0
- package/third_party/libwebm/webm_parser/src/parser.h +34 -0
- package/third_party/libwebm/webm_parser/src/parser_utils.cc +34 -0
- package/third_party/libwebm/webm_parser/src/parser_utils.h +64 -0
- package/third_party/libwebm/webm_parser/src/projection_parser.h +40 -0
- package/third_party/libwebm/webm_parser/src/recursive_parser.h +93 -0
- package/third_party/libwebm/webm_parser/src/seek_head_parser.h +27 -0
- package/third_party/libwebm/webm_parser/src/seek_parser.h +37 -0
- package/third_party/libwebm/webm_parser/src/segment_parser.cc +86 -0
- package/third_party/libwebm/webm_parser/src/segment_parser.h +53 -0
- package/third_party/libwebm/webm_parser/src/simple_tag_parser.h +37 -0
- package/third_party/libwebm/webm_parser/src/size_parser.cc +56 -0
- package/third_party/libwebm/webm_parser/src/size_parser.h +43 -0
- package/third_party/libwebm/webm_parser/src/skip_callback.h +63 -0
- package/third_party/libwebm/webm_parser/src/skip_parser.cc +59 -0
- package/third_party/libwebm/webm_parser/src/skip_parser.h +35 -0
- package/third_party/libwebm/webm_parser/src/slices_parser.h +30 -0
- package/third_party/libwebm/webm_parser/src/tag_parser.h +37 -0
- package/third_party/libwebm/webm_parser/src/tags_parser.h +27 -0
- package/third_party/libwebm/webm_parser/src/targets_parser.h +35 -0
- package/third_party/libwebm/webm_parser/src/time_slice_parser.h +30 -0
- package/third_party/libwebm/webm_parser/src/track_entry_parser.h +65 -0
- package/third_party/libwebm/webm_parser/src/tracks_parser.h +27 -0
- package/third_party/libwebm/webm_parser/src/unknown_parser.cc +49 -0
- package/third_party/libwebm/webm_parser/src/unknown_parser.h +38 -0
- package/third_party/libwebm/webm_parser/src/var_int_parser.cc +71 -0
- package/third_party/libwebm/webm_parser/src/var_int_parser.h +56 -0
- package/third_party/libwebm/webm_parser/src/video_parser.h +122 -0
- package/third_party/libwebm/webm_parser/src/virtual_block_parser.cc +72 -0
- package/third_party/libwebm/webm_parser/src/virtual_block_parser.h +69 -0
- package/third_party/libwebm/webm_parser/src/void_parser.cc +49 -0
- package/third_party/libwebm/webm_parser/src/void_parser.h +41 -0
- package/third_party/libwebm/webm_parser/src/webm_parser.cc +282 -0
- package/third_party/range-source/LICENSE +21 -0
- package/third_party/range-source/README.md +8 -0
- package/third_party/range-source/include/range_source.h +395 -0
- package/third_party/range-source/include/range_source_download.h +309 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# The React Native package's native libraries: the standalone library's core, and the codec
|
|
2
|
+
# modules in ALPHA_VIDEO_CODECS (build.gradle), each its own library as in the Maven artifacts.
|
|
3
|
+
cmake_minimum_required(VERSION 3.22.1)
|
|
4
|
+
project(alphavideo_reactnative)
|
|
5
|
+
|
|
6
|
+
# "none" rather than empty: an empty -D value doesn't reach CMake, which would then build both.
|
|
7
|
+
set(ALPHA_VIDEO_CODECS "vpx;av1" CACHE STRING "Codec modules to build: vpx, av1, or none")
|
|
8
|
+
set(ANDROID_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../android")
|
|
9
|
+
|
|
10
|
+
add_subdirectory("${ANDROID_DIR}/src/main/cpp" core)
|
|
11
|
+
list(REMOVE_ITEM ALPHA_VIDEO_CODECS none)
|
|
12
|
+
foreach(codec IN LISTS ALPHA_VIDEO_CODECS)
|
|
13
|
+
add_subdirectory("${ANDROID_DIR}/${codec}/src/main/cpp" "${codec}")
|
|
14
|
+
endforeach()
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// The React Native package's Android module. It compiles the standalone library's sources
|
|
2
|
+
// (../../android) together with the React Native glue, because autolinking adds only this one
|
|
3
|
+
// Gradle project to the app.
|
|
4
|
+
|
|
5
|
+
def isNewArchitectureEnabled() {
|
|
6
|
+
// Set by the app's gradle.properties, and always "true" from React Native 0.82
|
|
7
|
+
return project.findProperty('newArchEnabled')?.toString() == 'true'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
apply plugin: 'com.android.library'
|
|
11
|
+
if (isNewArchitectureEnabled()) {
|
|
12
|
+
apply plugin: 'com.facebook.react'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
def safeExtGet(name, fallback) {
|
|
16
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : fallback
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def coreDir = file('../../android')
|
|
20
|
+
def packageRoot = file('../..')
|
|
21
|
+
|
|
22
|
+
// The codec modules built in, android/vpx (libvpx) and android/av1 (dav1d): the app's package.json
|
|
23
|
+
// "react-native-alpha-video": { "codecs": [...] }, else both. The podspec reads the same setting.
|
|
24
|
+
def readCodecs() {
|
|
25
|
+
def allCodecs = ['vpx', 'av1']
|
|
26
|
+
def appPackageJson = rootProject.file('../package.json')
|
|
27
|
+
if (!appPackageJson.exists()) return allCodecs
|
|
28
|
+
def config = new groovy.json.JsonSlurper().parse(appPackageJson)['react-native-alpha-video']
|
|
29
|
+
if (config?.codecs == null) return allCodecs
|
|
30
|
+
def unknown = config.codecs.findAll { !allCodecs.contains(it) }
|
|
31
|
+
if (!(config.codecs instanceof List) || unknown) {
|
|
32
|
+
throw new GradleException("react-native-alpha-video: \"codecs\" in ${appPackageJson} must list some of ${allCodecs}, not ${config.codecs}")
|
|
33
|
+
}
|
|
34
|
+
return allCodecs.findAll { config.codecs.contains(it) }
|
|
35
|
+
}
|
|
36
|
+
def codecs = readCodecs()
|
|
37
|
+
logger.lifecycle("react-native-alpha-video: codecs ${codecs.isEmpty() ? 'none (MediaCodec only)' : codecs.join(', ')}")
|
|
38
|
+
|
|
39
|
+
// range-source, the add-on the player reads URLs and data sources through, is the app's own
|
|
40
|
+
// dependency, react-native-range-source, which autolinking adds; the player finds it at run time
|
|
41
|
+
// (RangeSourceLink) and plays URLs without it.
|
|
42
|
+
def rangeSourceProject = rootProject.findProject(':react-native-range-source')
|
|
43
|
+
logger.lifecycle("react-native-alpha-video: range-source ${rangeSourceProject ? 'from react-native-range-source' : 'not installed (URLs are downloaded whole; npm i react-native-range-source for range streaming and storage)'}")
|
|
44
|
+
|
|
45
|
+
if (isNewArchitectureEnabled()) {
|
|
46
|
+
// The codegen tasks look for package.json and the specs next to this folder; both are two
|
|
47
|
+
// levels up, in the package root.
|
|
48
|
+
tasks.named('generateCodegenSchemaFromJavaScript').configure {
|
|
49
|
+
jsRootDir.set(file("${packageRoot}/react-native/src"))
|
|
50
|
+
// A property in newer React Native; in 0.76 and earlier, a file tree that follows jsRootDir
|
|
51
|
+
if (jsInputFiles instanceof org.gradle.api.provider.Property) {
|
|
52
|
+
jsInputFiles.set(fileTree("${packageRoot}/react-native/src") { include '**/*.ts', '**/*.tsx' })
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
tasks.named('generateCodegenArtifactsFromSchema').configure {
|
|
56
|
+
packageJsonFile.set(file("${packageRoot}/package.json"))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
android {
|
|
61
|
+
namespace 'dev.mediacache.alphavideo.reactnative'
|
|
62
|
+
compileSdk safeExtGet('compileSdkVersion', 36)
|
|
63
|
+
ndkVersion safeExtGet('ndkVersion', '27.1.12297006')
|
|
64
|
+
|
|
65
|
+
defaultConfig {
|
|
66
|
+
minSdk safeExtGet('minSdkVersion', 24)
|
|
67
|
+
buildConfigField 'boolean', 'IS_NEW_ARCHITECTURE_ENABLED', isNewArchitectureEnabled().toString()
|
|
68
|
+
consumerProguardFiles("${coreDir}/consumer-rules.pro", *codecs.collect { "${coreDir}/${it}/consumer-rules.pro" })
|
|
69
|
+
|
|
70
|
+
externalNativeBuild {
|
|
71
|
+
cmake {
|
|
72
|
+
cppFlags '-std=c++17 -frtti -fexceptions -O3'
|
|
73
|
+
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
|
74
|
+
arguments '-DANDROID_STL=c++_shared', "-DALPHA_VIDEO_CODECS=${codecs.isEmpty() ? 'none' : codecs.join(';')}"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
externalNativeBuild {
|
|
80
|
+
cmake {
|
|
81
|
+
path 'CMakeLists.txt'
|
|
82
|
+
version '3.22.1'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
buildFeatures {
|
|
87
|
+
buildConfig true
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
compileOptions {
|
|
91
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
92
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
sourceSets {
|
|
96
|
+
main {
|
|
97
|
+
java.srcDirs = [
|
|
98
|
+
'src/main/java',
|
|
99
|
+
"${coreDir}/src/main/java",
|
|
100
|
+
isNewArchitectureEnabled() ? 'src/newarch/java' : 'src/oldarch/java',
|
|
101
|
+
// AppDataSource, against range-source's classes, or a stub without them
|
|
102
|
+
rangeSourceProject ? "${coreDir}/src/rangesource/java" : 'src/norangesource/java',
|
|
103
|
+
] + codecs.collect { "${coreDir}/${it}/src/main/java" }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
dependencies {
|
|
109
|
+
implementation 'com.facebook.react:react-android'
|
|
110
|
+
if (rangeSourceProject) {
|
|
111
|
+
compileOnly rangeSourceProject
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import dev.mediacache.alphavideo.AlphaVideoCodecs;
|
|
4
|
+
import dev.mediacache.alphavideo.SurfaceTextureVideoDecoder;
|
|
5
|
+
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Promise;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
11
|
+
import com.facebook.react.bridge.WritableArray;
|
|
12
|
+
import com.facebook.react.bridge.WritableMap;
|
|
13
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
14
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* React Native Module for WebM Alpha Player utility functions.
|
|
18
|
+
* Provides access to video decoder information and diagnostics.
|
|
19
|
+
*/
|
|
20
|
+
public class AlphaVideoModule extends AlphaVideoModuleSpec {
|
|
21
|
+
|
|
22
|
+
private static final String TAG = "RNAlphaVideo";
|
|
23
|
+
|
|
24
|
+
public AlphaVideoModule(ReactApplicationContext reactContext) {
|
|
25
|
+
super(reactContext);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get detailed decoder information for all supported codecs (VP9, AV1).
|
|
30
|
+
*/
|
|
31
|
+
@Override
|
|
32
|
+
@ReactMethod
|
|
33
|
+
public void getDecoderInfo(Promise promise) {
|
|
34
|
+
try {
|
|
35
|
+
String info = SurfaceTextureVideoDecoder.getDecoderInfo();
|
|
36
|
+
Log.i(TAG, info);
|
|
37
|
+
promise.resolve(info);
|
|
38
|
+
} catch (Exception e) {
|
|
39
|
+
promise.reject("DECODER_INFO_ERROR", e.getMessage());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the maximum number of concurrent decoder instances for a given codec.
|
|
45
|
+
*/
|
|
46
|
+
@Override
|
|
47
|
+
@ReactMethod
|
|
48
|
+
public void getMaxDecoderInstances(String mimeType, Promise promise) {
|
|
49
|
+
try {
|
|
50
|
+
int max = SurfaceTextureVideoDecoder.getMaxInstances(mimeType);
|
|
51
|
+
promise.resolve(max);
|
|
52
|
+
} catch (Exception e) {
|
|
53
|
+
promise.reject("DECODER_INFO_ERROR", e.getMessage());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the current number of active decoder instances.
|
|
59
|
+
*/
|
|
60
|
+
@Override
|
|
61
|
+
@ReactMethod
|
|
62
|
+
public void getActiveDecoderCount(Promise promise) {
|
|
63
|
+
try {
|
|
64
|
+
int count = SurfaceTextureVideoDecoder.getActiveDecoderCount();
|
|
65
|
+
promise.resolve(count);
|
|
66
|
+
} catch (Exception e) {
|
|
67
|
+
promise.reject("DECODER_INFO_ERROR", e.getMessage());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get comprehensive decoder status as a structured object.
|
|
73
|
+
*/
|
|
74
|
+
@Override
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void getDecoderStatus(Promise promise) {
|
|
77
|
+
try {
|
|
78
|
+
int maxVp9 = SurfaceTextureVideoDecoder.getMaxInstances(SurfaceTextureVideoDecoder.MIME_VP9);
|
|
79
|
+
int maxAv1 = SurfaceTextureVideoDecoder.getMaxInstances(SurfaceTextureVideoDecoder.MIME_AV1);
|
|
80
|
+
int activeCount = SurfaceTextureVideoDecoder.getActiveDecoderCount();
|
|
81
|
+
boolean hasVp9Hw = SurfaceTextureVideoDecoder.isVp9HardwareDecoderAvailable();
|
|
82
|
+
boolean hasAv1Hw = SurfaceTextureVideoDecoder.isAv1HardwareDecoderAvailable();
|
|
83
|
+
|
|
84
|
+
WritableMap result = new WritableNativeMap();
|
|
85
|
+
result.putInt("maxVp9Instances", maxVp9);
|
|
86
|
+
result.putInt("maxAv1Instances", maxAv1);
|
|
87
|
+
result.putBoolean("vp9HardwareAvailable", hasVp9Hw);
|
|
88
|
+
result.putBoolean("av1HardwareAvailable", hasAv1Hw);
|
|
89
|
+
result.putInt("activeDecoders", activeCount);
|
|
90
|
+
result.putInt("availableVp9Slots", Math.max(0, maxVp9 - activeCount));
|
|
91
|
+
result.putInt("maxDualStreamPlayers", Math.max(maxVp9, maxAv1) / 2);
|
|
92
|
+
result.putBoolean("canCreateMore", activeCount < Math.max(maxVp9, maxAv1) - 1);
|
|
93
|
+
WritableArray softwareDecoders = new WritableNativeArray();
|
|
94
|
+
for (String decoder : AlphaVideoCodecs.softwareDecoders()) softwareDecoders.pushString(decoder);
|
|
95
|
+
result.putArray("softwareDecoders", softwareDecoders);
|
|
96
|
+
|
|
97
|
+
promise.resolve(result);
|
|
98
|
+
} catch (Exception e) {
|
|
99
|
+
promise.reject("DECODER_INFO_ERROR", e.getMessage());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.TurboReactPackage;
|
|
7
|
+
import com.facebook.react.bridge.NativeModule;
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
10
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
11
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
12
|
+
|
|
13
|
+
import java.util.Collections;
|
|
14
|
+
import java.util.List;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* React Native Package for WebM Alpha Player
|
|
18
|
+
*/
|
|
19
|
+
// TurboReactPackage is deprecated in favour of BaseReactPackage, which React Native before 0.74 lacks.
|
|
20
|
+
@SuppressWarnings("deprecation")
|
|
21
|
+
public class AlphaVideoPackage extends TurboReactPackage {
|
|
22
|
+
|
|
23
|
+
@Nullable
|
|
24
|
+
@Override
|
|
25
|
+
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return AlphaVideoModule.NAME.equals(name) ? new AlphaVideoModule(reactContext) : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@NonNull
|
|
30
|
+
@Override
|
|
31
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
32
|
+
return () -> Collections.singletonMap(
|
|
33
|
+
AlphaVideoModule.NAME,
|
|
34
|
+
new ReactModuleInfo(
|
|
35
|
+
AlphaVideoModule.NAME,
|
|
36
|
+
AlphaVideoModule.class.getName(),
|
|
37
|
+
false, // canOverrideExistingModule
|
|
38
|
+
false, // needsEagerInit
|
|
39
|
+
false, // isCxxModule
|
|
40
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED // isTurboModule
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@NonNull
|
|
46
|
+
@Override
|
|
47
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
48
|
+
return Collections.singletonList(new AlphaVideoViewManager(reactContext));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import dev.mediacache.alphavideo.AlphaVideoView;
|
|
4
|
+
|
|
5
|
+
import android.graphics.Color;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.bridge.Arguments;
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.bridge.ReactContext;
|
|
13
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
14
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.bridge.WritableMap;
|
|
16
|
+
import com.facebook.react.common.MapBuilder;
|
|
17
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
18
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
19
|
+
import com.facebook.react.uimanager.ViewProps;
|
|
20
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
21
|
+
import com.facebook.react.uimanager.events.Event;
|
|
22
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
23
|
+
|
|
24
|
+
import java.util.LinkedHashMap;
|
|
25
|
+
import java.util.Map;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* React Native ViewManager for AlphaVideoView
|
|
29
|
+
* Uses TextureView for proper z-ordering and ScrollView compatibility
|
|
30
|
+
*
|
|
31
|
+
* Props match WebMAlphaView interface:
|
|
32
|
+
* - source: { uri, headers?, dataSource? } or { path }, where uri is https://, file://, an
|
|
33
|
+
* absolute path, asset:// or content://, or anything the named data source reads; headers come
|
|
34
|
+
* as a flat [name, value, ...] array
|
|
35
|
+
* - autoPlay: boolean (default true)
|
|
36
|
+
* - loop: boolean (default true)
|
|
37
|
+
* - paused: boolean (default false)
|
|
38
|
+
* - playbackSpeed: double (default 1.0, changeable while playing)
|
|
39
|
+
* - cacheKey: string (what the store keeps the source under, instead of its URL)
|
|
40
|
+
* - storage: "auto" | "disk" | "memory" | "none"; maxStorageBytes: double (0 for 512 MB)
|
|
41
|
+
*
|
|
42
|
+
* Commands: play, pause, stop, seekToFrame(frame), seekToTime(seconds). Events: onLoad, onError, onEnd, onPreloadComplete.
|
|
43
|
+
* Every prop and event is declared in the codegen spec, react-native/src/AlphaVideoViewNativeComponent.ts.
|
|
44
|
+
*/
|
|
45
|
+
public class AlphaVideoViewManager extends AlphaVideoViewManagerSpec<AlphaVideoView> {
|
|
46
|
+
|
|
47
|
+
public static final String REACT_CLASS = "RNAlphaVideoView";
|
|
48
|
+
|
|
49
|
+
public AlphaVideoViewManager(ReactApplicationContext context) {
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@NonNull
|
|
53
|
+
@Override
|
|
54
|
+
public String getName() {
|
|
55
|
+
return REACT_CLASS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@NonNull
|
|
59
|
+
@Override
|
|
60
|
+
protected AlphaVideoView createViewInstance(@NonNull ThemedReactContext context) {
|
|
61
|
+
AlphaVideoView view = new AlphaVideoView(context);
|
|
62
|
+
view.setCallback(new EventForwarder(view));
|
|
63
|
+
return view;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void onDropViewInstance(@NonNull AlphaVideoView view) {
|
|
68
|
+
view.release();
|
|
69
|
+
super.onDropViewInstance(view);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* TextureView throws on a background drawable, so a backgroundColor style would crash the
|
|
74
|
+
* app. The view stays transparent; put a background on a parent view instead.
|
|
75
|
+
*/
|
|
76
|
+
@Override
|
|
77
|
+
@ReactProp(name = ViewProps.BACKGROUND_COLOR, defaultInt = Color.TRANSPARENT, customType = "Color")
|
|
78
|
+
public void setBackgroundColor(@NonNull AlphaVideoView view, int backgroundColor) {
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactProp(name = "source")
|
|
82
|
+
@Override
|
|
83
|
+
public void setSource(AlphaVideoView view, @Nullable ReadableMap source) {
|
|
84
|
+
String sourceUri = null;
|
|
85
|
+
if (source != null) {
|
|
86
|
+
if (source.hasKey("uri") && !source.isNull("uri")) {
|
|
87
|
+
sourceUri = source.getString("uri");
|
|
88
|
+
} else if (source.hasKey("path") && !source.isNull("path")) {
|
|
89
|
+
sourceUri = source.getString("path");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (sourceUri == null || sourceUri.isEmpty()) return;
|
|
94
|
+
Map<String, String> headers = new LinkedHashMap<>();
|
|
95
|
+
if (source.hasKey("headers") && !source.isNull("headers")) {
|
|
96
|
+
ReadableArray flat = source.getArray("headers");
|
|
97
|
+
for (int i = 0; flat != null && i + 1 < flat.size(); i += 2) {
|
|
98
|
+
headers.put(flat.getString(i), flat.getString(i + 1));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
view.setHeaders(headers);
|
|
102
|
+
view.setDataSource(source.hasKey("dataSource") && !source.isNull("dataSource")
|
|
103
|
+
? source.getString("dataSource") : null);
|
|
104
|
+
view.setSource(sourceUri);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactProp(name = "autoPlay", defaultBoolean = true)
|
|
108
|
+
@Override
|
|
109
|
+
public void setAutoPlay(AlphaVideoView view, boolean autoPlay) {
|
|
110
|
+
view.setAutoPlay(autoPlay);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@ReactProp(name = "loop", defaultBoolean = true)
|
|
114
|
+
@Override
|
|
115
|
+
public void setLoop(AlphaVideoView view, boolean loop) {
|
|
116
|
+
view.setLoop(loop);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@ReactProp(name = "paused", defaultBoolean = false)
|
|
120
|
+
@Override
|
|
121
|
+
public void setPaused(AlphaVideoView view, boolean paused) {
|
|
122
|
+
view.setPaused(paused);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Playback rate. iOS and web have had this; Android had the plumbing but no prop, so the
|
|
127
|
+
* value never left JS.
|
|
128
|
+
*/
|
|
129
|
+
@ReactProp(name = "playbackSpeed", defaultDouble = 1.0)
|
|
130
|
+
@Override
|
|
131
|
+
public void setPlaybackSpeed(AlphaVideoView view, double playbackSpeed) {
|
|
132
|
+
view.setPlaybackSpeed(playbackSpeed);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@ReactProp(name = "cacheKey")
|
|
136
|
+
@Override
|
|
137
|
+
public void setCacheKey(AlphaVideoView view, @Nullable String cacheKey) {
|
|
138
|
+
view.setCacheKey(cacheKey);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** "auto" (default), "disk", "memory" or "none"; see AlphaVideoView.setStorage. */
|
|
142
|
+
@ReactProp(name = "storage")
|
|
143
|
+
@Override
|
|
144
|
+
public void setStorage(AlphaVideoView view, @Nullable String storage) {
|
|
145
|
+
view.setStorage(storage);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 0 for the default, 512 MB. */
|
|
149
|
+
@ReactProp(name = "maxStorageBytes", defaultDouble = 0)
|
|
150
|
+
@Override
|
|
151
|
+
public void setMaxStorageBytes(AlphaVideoView view, double maxStorageBytes) {
|
|
152
|
+
view.setMaxStorageBytes((long) maxStorageBytes);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Set the playback mode.
|
|
157
|
+
* - "preload": decode all frames upfront, then play
|
|
158
|
+
* - "stream" (default): decode on-demand with sliding window cache
|
|
159
|
+
* - "streamAndPreload": start playing immediately, cache all frames for smooth looping
|
|
160
|
+
*/
|
|
161
|
+
@ReactProp(name = "mode")
|
|
162
|
+
@Override
|
|
163
|
+
public void setMode(AlphaVideoView view, @Nullable String mode) {
|
|
164
|
+
view.setMode(mode != null ? mode : "stream");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** "auto" (default), "mediacodec", "mediacodec-hw", "mediacodec-sw" or "software"; see AlphaVideoView.setDecoder. */
|
|
168
|
+
@ReactProp(name = "decoder")
|
|
169
|
+
@Override
|
|
170
|
+
public void setDecoder(AlphaVideoView view, @Nullable String decoder) {
|
|
171
|
+
view.setDecoder(decoder);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Set how many frames to decode ahead of the shown one when streaming
|
|
176
|
+
* Default: 8 frames (about 0.27 seconds at 30fps)
|
|
177
|
+
*/
|
|
178
|
+
@ReactProp(name = "streamPrefetchAhead", defaultInt = 8)
|
|
179
|
+
@Override
|
|
180
|
+
public void setStreamPrefetchAhead(AlphaVideoView view, int frames) {
|
|
181
|
+
view.setStreamPrefetchAhead(frames);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Enable/disable global decode queue for preload/streamAndPreload modes.
|
|
186
|
+
* When true (default): decoding is serialized across all players, preventing CPU saturation
|
|
187
|
+
* When false: each player decodes independently (can freeze with many)
|
|
188
|
+
* Has no effect when mode='stream'.
|
|
189
|
+
*/
|
|
190
|
+
@ReactProp(name = "useDecodeQueue", defaultBoolean = true)
|
|
191
|
+
@Override
|
|
192
|
+
public void setUseDecodeQueue(AlphaVideoView view, boolean use) {
|
|
193
|
+
view.setUseDecodeQueue(use);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Enable verbose logging for debugging: lifecycle, performance, and per-frame events.
|
|
198
|
+
* When false (default): only warnings and errors.
|
|
199
|
+
*/
|
|
200
|
+
@ReactProp(name = "verbose", defaultBoolean = false)
|
|
201
|
+
@Override
|
|
202
|
+
public void setVerbose(AlphaVideoView view, boolean verbose) {
|
|
203
|
+
view.setVerbose(verbose);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@Override
|
|
207
|
+
public void play(AlphaVideoView view) {
|
|
208
|
+
view.play();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@Override
|
|
212
|
+
public void pause(AlphaVideoView view) {
|
|
213
|
+
view.pause();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@Override
|
|
217
|
+
public void stop(AlphaVideoView view) {
|
|
218
|
+
view.stop();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Override
|
|
222
|
+
public void seekToFrame(AlphaVideoView view, int frame) {
|
|
223
|
+
view.seekToFrame(frame);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@Override
|
|
227
|
+
public void seekToTime(AlphaVideoView view, double seconds) {
|
|
228
|
+
view.seekToTime(seconds);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@Nullable
|
|
232
|
+
@Override
|
|
233
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
234
|
+
return MapBuilder.<String, Object>builder()
|
|
235
|
+
.put("onLoad", MapBuilder.of("registrationName", "onLoad"))
|
|
236
|
+
.put("onError", MapBuilder.of("registrationName", "onError"))
|
|
237
|
+
.put("onEnd", MapBuilder.of("registrationName", "onEnd"))
|
|
238
|
+
.put("onPreloadComplete", MapBuilder.of("registrationName", "onPreloadComplete"))
|
|
239
|
+
.build();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Turns player callbacks into React events on the view. */
|
|
243
|
+
private static final class EventForwarder implements AlphaVideoView.PlayerCallback {
|
|
244
|
+
private final AlphaVideoView view;
|
|
245
|
+
|
|
246
|
+
EventForwarder(AlphaVideoView view) {
|
|
247
|
+
this.view = view;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@Override
|
|
251
|
+
public void onLoad(int totalFrames, int width, int height, String decoder) {
|
|
252
|
+
WritableMap event = Arguments.createMap();
|
|
253
|
+
event.putInt("totalFrames", totalFrames);
|
|
254
|
+
event.putInt("width", width);
|
|
255
|
+
event.putInt("height", height);
|
|
256
|
+
event.putString("decoder", decoder);
|
|
257
|
+
send("onLoad", event);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@Override
|
|
261
|
+
public void onError(String error, String code) {
|
|
262
|
+
WritableMap event = Arguments.createMap();
|
|
263
|
+
event.putString("error", error);
|
|
264
|
+
if (code != null) event.putString("code", code);
|
|
265
|
+
send("onError", event);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@Override
|
|
269
|
+
public void onEnd() {
|
|
270
|
+
send("onEnd", Arguments.createMap());
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
@Override
|
|
274
|
+
public void onPreloadComplete(int frames, double timeMs) {
|
|
275
|
+
WritableMap event = Arguments.createMap();
|
|
276
|
+
event.putInt("totalFrames", frames);
|
|
277
|
+
event.putDouble("timeMs", timeMs);
|
|
278
|
+
send("onPreloadComplete", event);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private void send(String eventName, WritableMap params) {
|
|
282
|
+
ReactContext context = (ReactContext) view.getContext();
|
|
283
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, view.getId());
|
|
284
|
+
if (dispatcher == null) return;
|
|
285
|
+
dispatcher.dispatchEvent(
|
|
286
|
+
new PlayerEvent(UIManagerHelper.getSurfaceId(view), view.getId(), eventName, params));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private static final class PlayerEvent extends Event<PlayerEvent> {
|
|
291
|
+
private final String eventName;
|
|
292
|
+
private final WritableMap eventData;
|
|
293
|
+
|
|
294
|
+
PlayerEvent(int surfaceId, int viewTag, String eventName, WritableMap eventData) {
|
|
295
|
+
super(surfaceId, viewTag);
|
|
296
|
+
this.eventName = eventName;
|
|
297
|
+
this.eventData = eventData;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@NonNull
|
|
301
|
+
@Override
|
|
302
|
+
public String getEventName() {
|
|
303
|
+
return eventName;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@Override
|
|
307
|
+
public boolean canCoalesce() {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@Nullable
|
|
312
|
+
@Override
|
|
313
|
+
protected WritableMap getEventData() {
|
|
314
|
+
return eventData;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
|
|
5
|
+
/** New architecture: the TurboModule spec generated from NativeAlphaVideoModule.ts. */
|
|
6
|
+
public abstract class AlphaVideoModuleSpec extends NativeAlphaVideoModuleSpec {
|
|
7
|
+
AlphaVideoModuleSpec(ReactApplicationContext context) {
|
|
8
|
+
super(context);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
9
|
+
import com.facebook.react.viewmanagers.RNAlphaVideoViewManagerDelegate;
|
|
10
|
+
import com.facebook.react.viewmanagers.RNAlphaVideoViewManagerInterface;
|
|
11
|
+
|
|
12
|
+
/** New architecture: props and commands arrive through the delegate generated from the codegen spec. */
|
|
13
|
+
public abstract class AlphaVideoViewManagerSpec<T extends View> extends SimpleViewManager<T>
|
|
14
|
+
implements RNAlphaVideoViewManagerInterface<T> {
|
|
15
|
+
|
|
16
|
+
private final ViewManagerDelegate<T> delegate = new RNAlphaVideoViewManagerDelegate<>(this);
|
|
17
|
+
|
|
18
|
+
@Nullable
|
|
19
|
+
@Override
|
|
20
|
+
protected ViewManagerDelegate<T> getDelegate() {
|
|
21
|
+
return delegate;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/react-native/android/src/norangesource/java/dev/mediacache/alphavideo/AppDataSource.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stands in for android/src/rangesource's AppDataSource when the app hasn't installed
|
|
5
|
+
* react-native-range-source, so the package builds without range-source's classes. Never
|
|
6
|
+
* reached: {@link RangeSourceLink#available()} is false without the add-on.
|
|
7
|
+
*/
|
|
8
|
+
final class AppDataSource {
|
|
9
|
+
|
|
10
|
+
private AppDataSource() {}
|
|
11
|
+
|
|
12
|
+
static Fetcher create(String name) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|