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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Promise;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Old architecture: the same methods as the spec codegen generates for the new one
|
|
11
|
+
* (NativeAlphaVideoModuleSpec), so the module compiles against either.
|
|
12
|
+
*/
|
|
13
|
+
public abstract class AlphaVideoModuleSpec extends ReactContextBaseJavaModule {
|
|
14
|
+
public static final String NAME = "RNAlphaVideo";
|
|
15
|
+
|
|
16
|
+
AlphaVideoModuleSpec(ReactApplicationContext context) {
|
|
17
|
+
super(context);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@NonNull
|
|
21
|
+
@Override
|
|
22
|
+
public String getName() {
|
|
23
|
+
return NAME;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public abstract void getDecoderInfo(Promise promise);
|
|
27
|
+
public abstract void getMaxDecoderInstances(String mimeType, Promise promise);
|
|
28
|
+
public abstract void getActiveDecoderCount(Promise promise);
|
|
29
|
+
public abstract void getDecoderStatus(Promise promise);
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package dev.mediacache.alphavideo.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Old architecture: the same methods as the interface codegen generates for the new one, so the
|
|
15
|
+
* manager compiles against either. Props arrive through its {@code @ReactProp} setters.
|
|
16
|
+
*/
|
|
17
|
+
public abstract class AlphaVideoViewManagerSpec<T extends View> extends SimpleViewManager<T> {
|
|
18
|
+
|
|
19
|
+
public abstract void setSource(T view, @Nullable ReadableMap value);
|
|
20
|
+
public abstract void setAutoPlay(T view, boolean value);
|
|
21
|
+
public abstract void setLoop(T view, boolean value);
|
|
22
|
+
public abstract void setPaused(T view, boolean value);
|
|
23
|
+
public abstract void setPlaybackSpeed(T view, double value);
|
|
24
|
+
public abstract void setCacheKey(T view, @Nullable String value);
|
|
25
|
+
public abstract void setStorage(T view, @Nullable String value);
|
|
26
|
+
public abstract void setMaxStorageBytes(T view, double value);
|
|
27
|
+
public abstract void setMode(T view, @Nullable String value);
|
|
28
|
+
public abstract void setDecoder(T view, @Nullable String value);
|
|
29
|
+
public abstract void setStreamPrefetchAhead(T view, int value);
|
|
30
|
+
public abstract void setUseDecodeQueue(T view, boolean value);
|
|
31
|
+
public abstract void setVerbose(T view, boolean value);
|
|
32
|
+
|
|
33
|
+
public abstract void play(T view);
|
|
34
|
+
public abstract void pause(T view);
|
|
35
|
+
public abstract void stop(T view);
|
|
36
|
+
public abstract void seekToFrame(T view, int frame);
|
|
37
|
+
public abstract void seekToTime(T view, double seconds);
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void receiveCommand(@NonNull T view, String commandName, @Nullable ReadableArray args) {
|
|
41
|
+
switch (commandName) {
|
|
42
|
+
case "play":
|
|
43
|
+
play(view);
|
|
44
|
+
break;
|
|
45
|
+
case "pause":
|
|
46
|
+
pause(view);
|
|
47
|
+
break;
|
|
48
|
+
case "stop":
|
|
49
|
+
stop(view);
|
|
50
|
+
break;
|
|
51
|
+
case "seekToFrame":
|
|
52
|
+
if (args != null && args.size() > 0) seekToFrame(view, args.getInt(0));
|
|
53
|
+
break;
|
|
54
|
+
case "seekToTime":
|
|
55
|
+
if (args != null && args.size() > 0) seekToTime(view, args.getDouble(0));
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
Log.w("AlphaVideoViewManager", "Unknown command: " + commandName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNAlphaVideoViewComponentView.mm
|
|
3
|
+
// Fabric component view for AlphaVideoView (new architecture)
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
7
|
+
|
|
8
|
+
#import <React/RCTConversions.h>
|
|
9
|
+
#import <React/RCTViewComponentView.h>
|
|
10
|
+
|
|
11
|
+
#import <react/renderer/components/RNAlphaVideoSpec/ComponentDescriptors.h>
|
|
12
|
+
#import <react/renderer/components/RNAlphaVideoSpec/EventEmitters.h>
|
|
13
|
+
#import <react/renderer/components/RNAlphaVideoSpec/Props.h>
|
|
14
|
+
#import <react/renderer/components/RNAlphaVideoSpec/RCTComponentViewHelpers.h>
|
|
15
|
+
|
|
16
|
+
#import "AlphaVideo.h"
|
|
17
|
+
|
|
18
|
+
using namespace facebook::react;
|
|
19
|
+
|
|
20
|
+
static const std::shared_ptr<const RNAlphaVideoViewProps> &RNAlphaVideoViewDefaultProps()
|
|
21
|
+
{
|
|
22
|
+
static const auto defaultProps = std::make_shared<const RNAlphaVideoViewProps>();
|
|
23
|
+
return defaultProps;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@interface RNAlphaVideoViewComponentView : RCTViewComponentView <RCTRNAlphaVideoViewViewProtocol, AlphaVideoViewDelegate>
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
@implementation RNAlphaVideoViewComponentView {
|
|
30
|
+
AlphaVideoView *_player;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
34
|
+
{
|
|
35
|
+
return concreteComponentDescriptorProvider<RNAlphaVideoViewComponentDescriptor>();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A player holds its decoded frames, so each mount gets a new one.
|
|
39
|
+
+ (BOOL)shouldBeRecycled
|
|
40
|
+
{
|
|
41
|
+
return NO;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
45
|
+
{
|
|
46
|
+
if (self = [super initWithFrame:frame]) {
|
|
47
|
+
_props = RNAlphaVideoViewDefaultProps();
|
|
48
|
+
[self createPlayer];
|
|
49
|
+
}
|
|
50
|
+
return self;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)createPlayer
|
|
54
|
+
{
|
|
55
|
+
_player = [[AlphaVideoView alloc] initWithFrame:self.bounds];
|
|
56
|
+
_player.delegate = self;
|
|
57
|
+
self.contentView = _player;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Older React Native versions ignore shouldBeRecycled and recycle every component view.
|
|
61
|
+
- (void)prepareForRecycle
|
|
62
|
+
{
|
|
63
|
+
[super prepareForRecycle];
|
|
64
|
+
[_player stop];
|
|
65
|
+
[self createPlayer];
|
|
66
|
+
_props = RNAlphaVideoViewDefaultProps();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Only the props that changed: the player's setters act (pause, play, reload), and its defaults
|
|
70
|
+
// match the spec's.
|
|
71
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
72
|
+
{
|
|
73
|
+
const auto &previous = *std::static_pointer_cast<const RNAlphaVideoViewProps>(_props);
|
|
74
|
+
const auto &next = *std::static_pointer_cast<const RNAlphaVideoViewProps>(props);
|
|
75
|
+
|
|
76
|
+
if (previous.mode != next.mode) _player.mode = RCTNSStringFromString(toString(next.mode));
|
|
77
|
+
if (previous.streamPrefetchAhead != next.streamPrefetchAhead) _player.streamPrefetchAhead = next.streamPrefetchAhead;
|
|
78
|
+
if (previous.useDecodeQueue != next.useDecodeQueue) _player.useDecodeQueue = next.useDecodeQueue;
|
|
79
|
+
if (previous.verbose != next.verbose) _player.verbose = next.verbose;
|
|
80
|
+
if (previous.autoPlay != next.autoPlay) _player.autoPlay = next.autoPlay;
|
|
81
|
+
if (previous.loop != next.loop) _player.loop = next.loop;
|
|
82
|
+
if (previous.paused != next.paused) _player.paused = next.paused;
|
|
83
|
+
if (previous.playbackSpeed != next.playbackSpeed) _player.playbackSpeed = next.playbackSpeed;
|
|
84
|
+
if (previous.cacheKey != next.cacheKey) _player.cacheKey = RCTNSStringFromStringNilIfEmpty(next.cacheKey);
|
|
85
|
+
if (previous.storage != next.storage) _player.storage = RCTNSStringFromString(toString(next.storage));
|
|
86
|
+
if (previous.maxStorageBytes != next.maxStorageBytes) _player.maxStorageBytes = (int64_t)next.maxStorageBytes;
|
|
87
|
+
// Before the source, so a new source loads with them; a change on its own reloads it
|
|
88
|
+
if (previous.source.headers != next.source.headers) {
|
|
89
|
+
NSMutableDictionary<NSString *, NSString *> *headers = [NSMutableDictionary dictionary];
|
|
90
|
+
for (size_t i = 0; i + 1 < next.source.headers.size(); i += 2) {
|
|
91
|
+
headers[RCTNSStringFromString(next.source.headers[i])] = RCTNSStringFromString(next.source.headers[i + 1]);
|
|
92
|
+
}
|
|
93
|
+
_player.headers = headers;
|
|
94
|
+
}
|
|
95
|
+
if (previous.source.dataSource != next.source.dataSource) {
|
|
96
|
+
_player.dataSource = RCTNSStringFromStringNilIfEmpty(next.source.dataSource);
|
|
97
|
+
}
|
|
98
|
+
if (previous.source.uri != next.source.uri) _player.source = RCTNSStringFromStringNilIfEmpty(next.source.uri);
|
|
99
|
+
|
|
100
|
+
[super updateProps:props oldProps:oldProps];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#pragma mark - AlphaVideoViewDelegate
|
|
104
|
+
|
|
105
|
+
- (std::shared_ptr<const RNAlphaVideoViewEventEmitter>)playerEventEmitter
|
|
106
|
+
{
|
|
107
|
+
return std::static_pointer_cast<const RNAlphaVideoViewEventEmitter>(_eventEmitter);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (void)alphaVideoView:(AlphaVideoView *)view didLoadFrames:(int)totalFrames width:(int)width height:(int)height
|
|
111
|
+
{
|
|
112
|
+
if (auto emitter = [self playerEventEmitter]) {
|
|
113
|
+
// iOS always decodes on the C++ core, so the decoder prop has nothing to choose
|
|
114
|
+
emitter->onLoad({.totalFrames = totalFrames, .width = width, .height = height,
|
|
115
|
+
.decoder = RCTStringFromNSString(view.loadedDecoder)});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (void)alphaVideoView:(AlphaVideoView *)view didFailWithError:(NSString *)error code:(NSString *)code
|
|
120
|
+
{
|
|
121
|
+
if (auto emitter = [self playerEventEmitter]) {
|
|
122
|
+
emitter->onError({.error = RCTStringFromNSString(error), .code = RCTStringFromNSString(code ?: @"")});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)alphaVideoViewDidEnd:(AlphaVideoView *)view
|
|
127
|
+
{
|
|
128
|
+
if (auto emitter = [self playerEventEmitter]) {
|
|
129
|
+
emitter->onEnd({});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#pragma mark - Commands
|
|
134
|
+
|
|
135
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
136
|
+
{
|
|
137
|
+
RCTRNAlphaVideoViewHandleCommand(self, commandName, args);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (void)play
|
|
141
|
+
{
|
|
142
|
+
[_player play];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
- (void)pause
|
|
146
|
+
{
|
|
147
|
+
[_player pause];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (void)stop
|
|
151
|
+
{
|
|
152
|
+
[_player stop];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)seekToFrame:(NSInteger)frame
|
|
156
|
+
{
|
|
157
|
+
[_player seekToFrame:(int)frame];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)seekToTime:(double)seconds
|
|
161
|
+
{
|
|
162
|
+
[_player seekToTime:seconds];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@end
|
|
166
|
+
|
|
167
|
+
// Older React Native versions look the class up by this name instead of codegenConfig.ios.componentProvider.
|
|
168
|
+
extern "C" Class<RCTComponentViewProtocol> RNAlphaVideoViewCls(void)
|
|
169
|
+
{
|
|
170
|
+
return RNAlphaVideoViewComponentView.class;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#endif
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNAlphaVideoViewManager.mm
|
|
3
|
+
// React Native view manager for AlphaVideoView (old architecture; the new one uses
|
|
4
|
+
// RNAlphaVideoViewComponentView.mm)
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
8
|
+
|
|
9
|
+
#import <React/RCTViewManager.h>
|
|
10
|
+
#import <React/RCTBridge.h>
|
|
11
|
+
#import <React/RCTUIManager.h>
|
|
12
|
+
#import "AlphaVideo.h"
|
|
13
|
+
|
|
14
|
+
#pragma mark - RNAlphaVideoView
|
|
15
|
+
|
|
16
|
+
/** AlphaVideoView with the React Native props and events. */
|
|
17
|
+
@interface RNAlphaVideoView : AlphaVideoView <AlphaVideoViewDelegate>
|
|
18
|
+
|
|
19
|
+
// `source` prop: { uri, headers?: [name, value, ...], dataSource? }
|
|
20
|
+
@property (nonatomic, copy) NSDictionary *reactSource;
|
|
21
|
+
// `decoder` prop: accepted for the shared JS API; iOS always decodes on the C++ core
|
|
22
|
+
@property (nonatomic, copy) NSString *decoder;
|
|
23
|
+
|
|
24
|
+
@property (nonatomic, copy) RCTDirectEventBlock onLoad;
|
|
25
|
+
@property (nonatomic, copy) RCTDirectEventBlock onError;
|
|
26
|
+
@property (nonatomic, copy) RCTDirectEventBlock onEnd;
|
|
27
|
+
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation RNAlphaVideoView
|
|
31
|
+
|
|
32
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
33
|
+
self = [super initWithFrame:frame];
|
|
34
|
+
if (self) {
|
|
35
|
+
self.delegate = self;
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)setReactSource:(NSDictionary *)reactSource {
|
|
41
|
+
_reactSource = [reactSource copy];
|
|
42
|
+
NSArray *flat = [reactSource[@"headers"] isKindOfClass:[NSArray class]] ? reactSource[@"headers"] : @[];
|
|
43
|
+
NSMutableDictionary<NSString *, NSString *> *headers = [NSMutableDictionary dictionary];
|
|
44
|
+
for (NSUInteger i = 0; i + 1 < flat.count; i += 2) {
|
|
45
|
+
if ([flat[i] isKindOfClass:[NSString class]] && [flat[i + 1] isKindOfClass:[NSString class]]) {
|
|
46
|
+
headers[flat[i]] = flat[i + 1];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
id dataSource = reactSource[@"dataSource"];
|
|
50
|
+
// Before the source, so a new source loads with them; a change on its own reloads it
|
|
51
|
+
self.headers = headers;
|
|
52
|
+
self.dataSource = [dataSource isKindOfClass:[NSString class]] && [dataSource length] > 0 ? dataSource : nil;
|
|
53
|
+
self.source = reactSource[@"uri"];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (void)alphaVideoView:(AlphaVideoView *)view didLoadFrames:(int)totalFrames width:(int)width height:(int)height {
|
|
57
|
+
if (self.onLoad) {
|
|
58
|
+
self.onLoad(@{
|
|
59
|
+
@"totalFrames": @(totalFrames),
|
|
60
|
+
@"width": @(width),
|
|
61
|
+
@"height": @(height),
|
|
62
|
+
@"decoder": view.loadedDecoder
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)alphaVideoView:(AlphaVideoView *)view didFailWithError:(NSString *)error code:(NSString *)code {
|
|
68
|
+
if (self.onError) {
|
|
69
|
+
self.onError(code ? @{@"error": error, @"code": code} : @{@"error": error});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)alphaVideoViewDidEnd:(AlphaVideoView *)view {
|
|
74
|
+
if (self.onEnd) {
|
|
75
|
+
self.onEnd(@{});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@end
|
|
80
|
+
|
|
81
|
+
#pragma mark - RNAlphaVideoViewManager
|
|
82
|
+
|
|
83
|
+
@interface RNAlphaVideoViewManager : RCTViewManager
|
|
84
|
+
@end
|
|
85
|
+
|
|
86
|
+
@implementation RNAlphaVideoViewManager
|
|
87
|
+
|
|
88
|
+
RCT_EXPORT_MODULE(RNAlphaVideoView)
|
|
89
|
+
|
|
90
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
91
|
+
return YES;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (UIView *)view {
|
|
95
|
+
return [[RNAlphaVideoView alloc] initWithFrame:CGRectZero];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
RCT_REMAP_VIEW_PROPERTY(source, reactSource, NSDictionary)
|
|
99
|
+
RCT_EXPORT_VIEW_PROPERTY(autoPlay, BOOL)
|
|
100
|
+
RCT_EXPORT_VIEW_PROPERTY(loop, BOOL)
|
|
101
|
+
RCT_EXPORT_VIEW_PROPERTY(paused, BOOL)
|
|
102
|
+
RCT_EXPORT_VIEW_PROPERTY(playbackSpeed, double)
|
|
103
|
+
RCT_EXPORT_VIEW_PROPERTY(cacheKey, NSString)
|
|
104
|
+
RCT_EXPORT_VIEW_PROPERTY(storage, NSString)
|
|
105
|
+
RCT_EXPORT_VIEW_PROPERTY(maxStorageBytes, int64_t)
|
|
106
|
+
RCT_EXPORT_VIEW_PROPERTY(mode, NSString)
|
|
107
|
+
RCT_EXPORT_VIEW_PROPERTY(decoder, NSString)
|
|
108
|
+
RCT_EXPORT_VIEW_PROPERTY(streamPrefetchAhead, int)
|
|
109
|
+
RCT_EXPORT_VIEW_PROPERTY(useDecodeQueue, BOOL)
|
|
110
|
+
RCT_EXPORT_VIEW_PROPERTY(verbose, BOOL)
|
|
111
|
+
|
|
112
|
+
RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock)
|
|
113
|
+
RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock)
|
|
114
|
+
RCT_EXPORT_VIEW_PROPERTY(onEnd, RCTDirectEventBlock)
|
|
115
|
+
|
|
116
|
+
- (void)withView:(NSNumber *)reactTag do:(void (^)(RNAlphaVideoView *view))block {
|
|
117
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
118
|
+
RNAlphaVideoView *view = (RNAlphaVideoView *)viewRegistry[reactTag];
|
|
119
|
+
if ([view isKindOfClass:[RNAlphaVideoView class]]) {
|
|
120
|
+
block(view);
|
|
121
|
+
}
|
|
122
|
+
}];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
RCT_EXPORT_METHOD(play:(nonnull NSNumber *)reactTag) {
|
|
126
|
+
[self withView:reactTag do:^(RNAlphaVideoView *view) { [view play]; }];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
RCT_EXPORT_METHOD(pause:(nonnull NSNumber *)reactTag) {
|
|
130
|
+
[self withView:reactTag do:^(RNAlphaVideoView *view) { [view pause]; }];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
RCT_EXPORT_METHOD(stop:(nonnull NSNumber *)reactTag) {
|
|
134
|
+
[self withView:reactTag do:^(RNAlphaVideoView *view) { [view stop]; }];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
RCT_EXPORT_METHOD(seekToFrame:(nonnull NSNumber *)reactTag frame:(nonnull NSNumber *)frame) {
|
|
138
|
+
[self withView:reactTag do:^(RNAlphaVideoView *view) { [view seekToFrame:[frame intValue]]; }];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
RCT_EXPORT_METHOD(seekToTime:(nonnull NSNumber *)reactTag seconds:(nonnull NSNumber *)seconds) {
|
|
142
|
+
[self withView:reactTag do:^(RNAlphaVideoView *view) { [view seekToTime:[seconds doubleValue]]; }];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@end
|
|
146
|
+
|
|
147
|
+
#endif
|