react-native-alpha-video 0.0.0-stage → 1.0.0
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 +903 -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 +85 -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 +1966 -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 +92 -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 +92 -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 +150 -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 +110 -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 +60 -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,208 @@
|
|
|
1
|
+
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
|
2
|
+
//
|
|
3
|
+
// Use of this source code is governed by a BSD-style license
|
|
4
|
+
// that can be found in the LICENSE file in the root of the source
|
|
5
|
+
// tree. An additional intellectual property rights grant can be found
|
|
6
|
+
// in the file PATENTS. All contributing project authors may
|
|
7
|
+
// be found in the AUTHORS file in the root of the source tree.
|
|
8
|
+
#ifndef INCLUDE_WEBM_ELEMENT_H_
|
|
9
|
+
#define INCLUDE_WEBM_ELEMENT_H_
|
|
10
|
+
|
|
11
|
+
#include <cstdint>
|
|
12
|
+
#include <limits>
|
|
13
|
+
#include <utility>
|
|
14
|
+
|
|
15
|
+
#include "./id.h"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
\file
|
|
19
|
+
A wrapper around an object that represents a WebM element, including its parsed
|
|
20
|
+
metadata.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
namespace webm {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
\addtogroup PUBLIC_API
|
|
27
|
+
@{
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
A wrapper around an object that represents a WebM element.
|
|
32
|
+
|
|
33
|
+
Since some elements may be absent, this wrapper is used to indicate the
|
|
34
|
+
presence (or lack thereof) of an element in a WebM document. If the element is
|
|
35
|
+
encoded in the file and it has been parsed, `is_present()` will return true.
|
|
36
|
+
Otherwise it will return false since the element was ommitted or skipped when
|
|
37
|
+
parsing.
|
|
38
|
+
*/
|
|
39
|
+
template <typename T>
|
|
40
|
+
class Element {
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
Value-initializes the element's value and makes `is_present()` false.
|
|
44
|
+
*/
|
|
45
|
+
constexpr Element() = default;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
Creates an element with the given value and makes `is_present()` false.
|
|
49
|
+
|
|
50
|
+
\param value The value of the element.
|
|
51
|
+
*/
|
|
52
|
+
explicit constexpr Element(const T& value) : value_(value) {}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
Creates an element with the given value and makes `is_present()` false.
|
|
56
|
+
|
|
57
|
+
\param value The value of the element.
|
|
58
|
+
*/
|
|
59
|
+
explicit constexpr Element(T&& value) : value_(std::move(value)) {}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
Creates an element with the given value and presence state.
|
|
63
|
+
|
|
64
|
+
\param value The value of the element.
|
|
65
|
+
\param is_present True if the element is present, false if it is absent.
|
|
66
|
+
*/
|
|
67
|
+
constexpr Element(const T& value, bool is_present)
|
|
68
|
+
: value_(value), is_present_(is_present) {}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
Creates an element with the given value and presence state.
|
|
72
|
+
|
|
73
|
+
\param value The value of the element.
|
|
74
|
+
\param is_present True if the element is present, false if it is absent.
|
|
75
|
+
*/
|
|
76
|
+
constexpr Element(T&& value, bool is_present)
|
|
77
|
+
: value_(std::move(value)), is_present_(is_present) {}
|
|
78
|
+
|
|
79
|
+
constexpr Element(const Element<T>& other) = default;
|
|
80
|
+
constexpr Element(Element<T>&& other) = default;
|
|
81
|
+
|
|
82
|
+
~Element() = default;
|
|
83
|
+
|
|
84
|
+
Element<T>& operator=(const Element<T>& other) = default;
|
|
85
|
+
Element<T>& operator=(Element<T>&& other) = default;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
Sets the element's value and state.
|
|
89
|
+
|
|
90
|
+
\param value The new value for the element.
|
|
91
|
+
\param is_present The new presence state for the element.
|
|
92
|
+
*/
|
|
93
|
+
void Set(const T& value, bool is_present) {
|
|
94
|
+
value_ = value;
|
|
95
|
+
is_present_ = is_present;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
Sets the element's value and state.
|
|
100
|
+
|
|
101
|
+
\param value The new value for the element.
|
|
102
|
+
\param is_present The new presence state for the element.
|
|
103
|
+
*/
|
|
104
|
+
void Set(T&& value, bool is_present) {
|
|
105
|
+
value_ = std::move(value);
|
|
106
|
+
is_present_ = is_present;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
Gets the element's value.
|
|
111
|
+
*/
|
|
112
|
+
constexpr const T& value() const { return value_; }
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
Gets a mutuable pointer to the element's value (will never be null).
|
|
116
|
+
*/
|
|
117
|
+
T* mutable_value() { return &value_; }
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
Returns true if the element is present, false otherwise.
|
|
121
|
+
*/
|
|
122
|
+
constexpr bool is_present() const { return is_present_; }
|
|
123
|
+
|
|
124
|
+
bool operator==(const Element<T>& other) const {
|
|
125
|
+
return is_present_ == other.is_present_ && value_ == other.value_;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private:
|
|
129
|
+
T value_{};
|
|
130
|
+
bool is_present_ = false;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
Metadata for WebM elements that are encountered when parsing.
|
|
135
|
+
*/
|
|
136
|
+
struct ElementMetadata {
|
|
137
|
+
/**
|
|
138
|
+
The EBML ID of the element.
|
|
139
|
+
*/
|
|
140
|
+
Id id;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
The number of bytes that were used to encode the EBML ID and element size.
|
|
144
|
+
|
|
145
|
+
If the size of the header is unknown (which is only the case if a seek was
|
|
146
|
+
performed to the middle of an element, so its header was not parsed), this
|
|
147
|
+
will be the value `kUnknownHeaderSize`.
|
|
148
|
+
*/
|
|
149
|
+
std::uint32_t header_size;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
The size of the element.
|
|
153
|
+
|
|
154
|
+
This is number of bytes in the element's body, which excludes the header
|
|
155
|
+
bytes.
|
|
156
|
+
|
|
157
|
+
If the size of the element's body is unknown, this will be the value
|
|
158
|
+
`kUnknownElementSize`.
|
|
159
|
+
*/
|
|
160
|
+
std::uint64_t size;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
The absolute byte position of the element, starting at the first byte of the
|
|
164
|
+
element's header.
|
|
165
|
+
|
|
166
|
+
If the position of the element is unknown (which is only the case if a seek
|
|
167
|
+
was performed to the middle of an element), this will be the value
|
|
168
|
+
`kUnknownElementPosition`.
|
|
169
|
+
*/
|
|
170
|
+
std::uint64_t position;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
Returns true if every member within the two objects are equal.
|
|
174
|
+
*/
|
|
175
|
+
bool operator==(const ElementMetadata& other) const {
|
|
176
|
+
return id == other.id && header_size == other.header_size &&
|
|
177
|
+
size == other.size && position == other.position;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
A special value for `ElementMetadata::header_size` indicating the header size
|
|
183
|
+
is not known.
|
|
184
|
+
*/
|
|
185
|
+
constexpr std::uint64_t kUnknownHeaderSize =
|
|
186
|
+
std::numeric_limits<std::uint32_t>::max();
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
A special value for `ElementMetadata::size` indicating the element's size is
|
|
190
|
+
not known.
|
|
191
|
+
*/
|
|
192
|
+
constexpr std::uint64_t kUnknownElementSize =
|
|
193
|
+
std::numeric_limits<std::uint64_t>::max();
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
A special value for `ElementMetadata::position` indicating the element's
|
|
197
|
+
position is not known.
|
|
198
|
+
*/
|
|
199
|
+
constexpr std::uint64_t kUnknownElementPosition =
|
|
200
|
+
std::numeric_limits<std::uint64_t>::max();
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
@}
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
} // namespace webm
|
|
207
|
+
|
|
208
|
+
#endif // INCLUDE_WEBM_ELEMENT_H_
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
|
2
|
+
//
|
|
3
|
+
// Use of this source code is governed by a BSD-style license
|
|
4
|
+
// that can be found in the LICENSE file in the root of the source
|
|
5
|
+
// tree. An additional intellectual property rights grant can be found
|
|
6
|
+
// in the file PATENTS. All contributing project authors may
|
|
7
|
+
// be found in the AUTHORS file in the root of the source tree.
|
|
8
|
+
#ifndef INCLUDE_WEBM_FILE_READER_H_
|
|
9
|
+
#define INCLUDE_WEBM_FILE_READER_H_
|
|
10
|
+
|
|
11
|
+
#include <cstdint>
|
|
12
|
+
#include <cstdio>
|
|
13
|
+
#include <cstdlib>
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
16
|
+
#include "./reader.h"
|
|
17
|
+
#include "./status.h"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
\file
|
|
21
|
+
A `Reader` implementation that reads from a `FILE*`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
namespace webm {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
A `Reader` implementation that can read from `FILE*` resources.
|
|
28
|
+
*/
|
|
29
|
+
class FileReader : public Reader {
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
Constructs a new, empty reader.
|
|
33
|
+
*/
|
|
34
|
+
FileReader() = default;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
Constructs a new reader, using the provided file as the data source.
|
|
38
|
+
|
|
39
|
+
Ownership of the file is taken, and `std::fclose()` will be called when the
|
|
40
|
+
object is destroyed.
|
|
41
|
+
|
|
42
|
+
\param file The file to use as a data source. Must not be null. The file will
|
|
43
|
+
be closed (via `std::fclose()`) when the `FileReader`'s destructor runs.
|
|
44
|
+
*/
|
|
45
|
+
explicit FileReader(FILE* file);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
Constructs a new reader by moving the provided reader into the new reader.
|
|
49
|
+
|
|
50
|
+
\param other The source reader to move. After moving, it will be reset to an
|
|
51
|
+
empty stream.
|
|
52
|
+
*/
|
|
53
|
+
FileReader(FileReader&& other);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
Moves the provided reader into this reader.
|
|
57
|
+
|
|
58
|
+
\param other The source reader to move. After moving, it will be reset to an
|
|
59
|
+
empty stream. May be equal to `*this`, in which case this is a no-op.
|
|
60
|
+
\return `*this`.
|
|
61
|
+
*/
|
|
62
|
+
FileReader& operator=(FileReader&& other);
|
|
63
|
+
|
|
64
|
+
Status Read(std::size_t num_to_read, std::uint8_t* buffer,
|
|
65
|
+
std::uint64_t* num_actually_read) override;
|
|
66
|
+
|
|
67
|
+
Status Skip(std::uint64_t num_to_skip,
|
|
68
|
+
std::uint64_t* num_actually_skipped) override;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
Moves the reader to a new absolute byte position in the file.
|
|
72
|
+
|
|
73
|
+
It is required to call DidSeek() on the parser after successfully seeking.
|
|
74
|
+
Seeking will only work on actual files, not stdin or pipes.
|
|
75
|
+
|
|
76
|
+
\param seek_position The new absolute byte position in the file.
|
|
77
|
+
\return `Status::kOkCompleted` if reader position is now `seek_position`.
|
|
78
|
+
`Status::kSeekFailed` if the reader was unable to seek to `seek_position`
|
|
79
|
+
such as when the file is stdin.
|
|
80
|
+
*/
|
|
81
|
+
Status Seek(std::uint64_t seek_position);
|
|
82
|
+
|
|
83
|
+
std::uint64_t Position() const override;
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
struct FileCloseFunctor {
|
|
87
|
+
void operator()(FILE* file) const {
|
|
88
|
+
if (file)
|
|
89
|
+
std::fclose(file);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
std::unique_ptr<FILE, FileCloseFunctor> file_;
|
|
94
|
+
|
|
95
|
+
// We can't rely on ftell() for the position (since it only returns long, and
|
|
96
|
+
// doesn't work on things like pipes); we need to manually track the reading
|
|
97
|
+
// position.
|
|
98
|
+
std::uint64_t position_ = 0;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace webm
|
|
102
|
+
|
|
103
|
+
#endif // INCLUDE_WEBM_FILE_READER_H_
|