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,110 @@
|
|
|
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
|
+
#include "webm/buffer_reader.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
#include <cassert>
|
|
12
|
+
#include <cstddef>
|
|
13
|
+
#include <cstdint>
|
|
14
|
+
#include <initializer_list>
|
|
15
|
+
#include <utility>
|
|
16
|
+
#include <vector>
|
|
17
|
+
|
|
18
|
+
#include "webm/status.h"
|
|
19
|
+
|
|
20
|
+
namespace webm {
|
|
21
|
+
|
|
22
|
+
BufferReader::BufferReader(std::initializer_list<std::uint8_t> bytes)
|
|
23
|
+
: data_(bytes) {}
|
|
24
|
+
|
|
25
|
+
BufferReader::BufferReader(const std::vector<std::uint8_t>& vector)
|
|
26
|
+
: data_(vector) {}
|
|
27
|
+
|
|
28
|
+
BufferReader::BufferReader(std::vector<std::uint8_t>&& vector)
|
|
29
|
+
: data_(std::move(vector)) {}
|
|
30
|
+
|
|
31
|
+
BufferReader::BufferReader(BufferReader&& other)
|
|
32
|
+
: data_(std::move(other.data_)), pos_(other.pos_) {
|
|
33
|
+
other.pos_ = 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
BufferReader& BufferReader::operator=(BufferReader&& other) {
|
|
37
|
+
if (this != &other) {
|
|
38
|
+
data_ = std::move(other.data_);
|
|
39
|
+
pos_ = other.pos_;
|
|
40
|
+
other.pos_ = 0;
|
|
41
|
+
}
|
|
42
|
+
return *this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
BufferReader& BufferReader::operator=(
|
|
46
|
+
std::initializer_list<std::uint8_t> bytes) {
|
|
47
|
+
data_ = std::vector<std::uint8_t>(bytes);
|
|
48
|
+
pos_ = 0;
|
|
49
|
+
return *this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Status BufferReader::Read(std::size_t num_to_read, std::uint8_t* buffer,
|
|
53
|
+
std::uint64_t* num_actually_read) {
|
|
54
|
+
assert(num_to_read > 0);
|
|
55
|
+
assert(buffer != nullptr);
|
|
56
|
+
assert(num_actually_read != nullptr);
|
|
57
|
+
|
|
58
|
+
*num_actually_read = 0;
|
|
59
|
+
std::size_t expected = num_to_read;
|
|
60
|
+
|
|
61
|
+
std::size_t num_remaining = data_.size() - pos_;
|
|
62
|
+
if (num_remaining == 0) {
|
|
63
|
+
return Status(Status::kEndOfFile);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (num_to_read > num_remaining) {
|
|
67
|
+
num_to_read = static_cast<std::size_t>(num_remaining);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
std::copy_n(data_.data() + pos_, num_to_read, buffer);
|
|
71
|
+
*num_actually_read = num_to_read;
|
|
72
|
+
pos_ += num_to_read;
|
|
73
|
+
|
|
74
|
+
if (*num_actually_read != expected) {
|
|
75
|
+
return Status(Status::kOkPartial);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return Status(Status::kOkCompleted);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Status BufferReader::Skip(std::uint64_t num_to_skip,
|
|
82
|
+
std::uint64_t* num_actually_skipped) {
|
|
83
|
+
assert(num_to_skip > 0);
|
|
84
|
+
assert(num_actually_skipped != nullptr);
|
|
85
|
+
|
|
86
|
+
*num_actually_skipped = 0;
|
|
87
|
+
std::uint64_t expected = num_to_skip;
|
|
88
|
+
|
|
89
|
+
std::size_t num_remaining = data_.size() - pos_;
|
|
90
|
+
if (num_remaining == 0) {
|
|
91
|
+
return Status(Status::kEndOfFile);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (num_to_skip > num_remaining) {
|
|
95
|
+
num_to_skip = static_cast<std::uint64_t>(num_remaining);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
*num_actually_skipped = num_to_skip;
|
|
99
|
+
pos_ += num_to_skip;
|
|
100
|
+
|
|
101
|
+
if (*num_actually_skipped != expected) {
|
|
102
|
+
return Status(Status::kOkPartial);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return Status(Status::kOkCompleted);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
std::uint64_t BufferReader::Position() const { return pos_; }
|
|
109
|
+
|
|
110
|
+
} // namespace webm
|
|
@@ -0,0 +1,144 @@
|
|
|
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 SRC_BYTE_PARSER_H_
|
|
9
|
+
#define SRC_BYTE_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include <cassert>
|
|
12
|
+
#include <cstdint>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <utility>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
#include "src/element_parser.h"
|
|
18
|
+
#include "webm/callback.h"
|
|
19
|
+
#include "webm/element.h"
|
|
20
|
+
#include "webm/reader.h"
|
|
21
|
+
#include "webm/status.h"
|
|
22
|
+
|
|
23
|
+
namespace webm {
|
|
24
|
+
|
|
25
|
+
// Parses an EBML string (UTF-8 and ASCII) or binary element from a byte stream.
|
|
26
|
+
// Spec reference for string/binary elements:
|
|
27
|
+
// http://matroska.org/technical/specs/index.html#EBML_ex
|
|
28
|
+
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-element-types
|
|
29
|
+
template <typename T>
|
|
30
|
+
class ByteParser : public ElementParser {
|
|
31
|
+
public:
|
|
32
|
+
static_assert(std::is_same<T, std::vector<std::uint8_t>>::value ||
|
|
33
|
+
std::is_same<T, std::string>::value,
|
|
34
|
+
"T must be std::vector<std::uint8_t> or std::string");
|
|
35
|
+
|
|
36
|
+
// Constructs a new parser which will use the given default_value as the
|
|
37
|
+
// value for the element if its size is zero. Defaults to the empty string
|
|
38
|
+
// or empty binary element (as the EBML spec indicates).
|
|
39
|
+
explicit ByteParser(T default_value = {})
|
|
40
|
+
: default_value_(std::move(default_value)) {}
|
|
41
|
+
|
|
42
|
+
ByteParser(ByteParser&&) = default;
|
|
43
|
+
ByteParser& operator=(ByteParser&&) = default;
|
|
44
|
+
|
|
45
|
+
ByteParser(const ByteParser&) = delete;
|
|
46
|
+
ByteParser& operator=(const ByteParser&) = delete;
|
|
47
|
+
|
|
48
|
+
Status Init(const ElementMetadata& metadata,
|
|
49
|
+
std::uint64_t max_size) override {
|
|
50
|
+
assert(metadata.size == kUnknownElementSize || metadata.size <= max_size);
|
|
51
|
+
|
|
52
|
+
if (metadata.size == kUnknownElementSize) {
|
|
53
|
+
return Status(Status::kInvalidElementSize);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (metadata.size > std::numeric_limits<std::size_t>::max() ||
|
|
57
|
+
metadata.size > value_.max_size()) {
|
|
58
|
+
return Status(Status::kNotEnoughMemory);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#if WEBM_FUZZER_BYTE_ELEMENT_SIZE_LIMIT
|
|
62
|
+
// AFL and ASan just kill the process if too much memory is allocated, so
|
|
63
|
+
// let's cap the maximum size of the element. It's too easy for the fuzzer
|
|
64
|
+
// to make an element with a ridiculously huge size, and that just creates
|
|
65
|
+
// uninteresting false positives.
|
|
66
|
+
if (metadata.size > WEBM_FUZZER_BYTE_ELEMENT_SIZE_LIMIT) {
|
|
67
|
+
return Status(Status::kNotEnoughMemory);
|
|
68
|
+
}
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
if (metadata.size == 0) {
|
|
72
|
+
value_ = default_value_;
|
|
73
|
+
total_read_ = default_value_.size();
|
|
74
|
+
} else {
|
|
75
|
+
value_.resize(static_cast<std::size_t>(metadata.size));
|
|
76
|
+
total_read_ = 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return Status(Status::kOkCompleted);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Status Feed(Callback* callback, Reader* reader,
|
|
83
|
+
std::uint64_t* num_bytes_read) override {
|
|
84
|
+
assert(callback != nullptr);
|
|
85
|
+
assert(reader != nullptr);
|
|
86
|
+
assert(num_bytes_read != nullptr);
|
|
87
|
+
|
|
88
|
+
*num_bytes_read = 0;
|
|
89
|
+
|
|
90
|
+
if (total_read_ == value_.size()) {
|
|
91
|
+
return Status(Status::kOkCompleted);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Status status;
|
|
95
|
+
do {
|
|
96
|
+
std::uint64_t local_num_bytes_read = 0;
|
|
97
|
+
std::uint8_t* buffer =
|
|
98
|
+
reinterpret_cast<std::uint8_t*>(&value_.front()) + total_read_;
|
|
99
|
+
std::size_t buffer_size = value_.size() - total_read_;
|
|
100
|
+
status = reader->Read(buffer_size, buffer, &local_num_bytes_read);
|
|
101
|
+
assert((status.completed_ok() && local_num_bytes_read == buffer_size) ||
|
|
102
|
+
(status.ok() && local_num_bytes_read < buffer_size) ||
|
|
103
|
+
(!status.ok() && local_num_bytes_read == 0));
|
|
104
|
+
*num_bytes_read += local_num_bytes_read;
|
|
105
|
+
total_read_ += static_cast<std::size_t>(local_num_bytes_read);
|
|
106
|
+
} while (status.code == Status::kOkPartial);
|
|
107
|
+
|
|
108
|
+
// UTF-8 and ASCII string elements can be padded with NUL characters at the
|
|
109
|
+
// end, which should be ignored.
|
|
110
|
+
if (std::is_same<T, std::string>::value && status.completed_ok()) {
|
|
111
|
+
while (!value_.empty() && value_.back() == '\0') {
|
|
112
|
+
value_.pop_back();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return status;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Gets the parsed value. This must not be called until the parse has been
|
|
120
|
+
// successfully completed.
|
|
121
|
+
const T& value() const {
|
|
122
|
+
assert(total_read_ >= value_.size());
|
|
123
|
+
return value_;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Gets the parsed value. This must not be called until the parse has been
|
|
127
|
+
// successfully completed.
|
|
128
|
+
T* mutable_value() {
|
|
129
|
+
assert(total_read_ >= value_.size());
|
|
130
|
+
return &value_;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private:
|
|
134
|
+
T value_;
|
|
135
|
+
T default_value_;
|
|
136
|
+
std::size_t total_read_;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
using StringParser = ByteParser<std::string>;
|
|
140
|
+
using BinaryParser = ByteParser<std::vector<std::uint8_t>>;
|
|
141
|
+
|
|
142
|
+
} // namespace webm
|
|
143
|
+
|
|
144
|
+
#endif // SRC_BYTE_PARSER_H_
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
#include "webm/callback.h"
|
|
9
|
+
|
|
10
|
+
#include <cassert>
|
|
11
|
+
|
|
12
|
+
namespace webm {
|
|
13
|
+
|
|
14
|
+
Status Callback::OnElementBegin(const ElementMetadata& /* metadata */,
|
|
15
|
+
Action* action) {
|
|
16
|
+
assert(action != nullptr);
|
|
17
|
+
*action = Action::kRead;
|
|
18
|
+
return Status(Status::kOkCompleted);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Status Callback::OnUnknownElement(const ElementMetadata& /* metadata */,
|
|
22
|
+
Reader* reader,
|
|
23
|
+
std::uint64_t* bytes_remaining) {
|
|
24
|
+
assert(reader != nullptr);
|
|
25
|
+
assert(bytes_remaining != nullptr);
|
|
26
|
+
return Skip(reader, bytes_remaining);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Status Callback::OnEbml(const ElementMetadata& /* metadata */,
|
|
30
|
+
const Ebml& /* ebml */) {
|
|
31
|
+
return Status(Status::kOkCompleted);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Status Callback::OnVoid(const ElementMetadata& /* metadata */, Reader* reader,
|
|
35
|
+
std::uint64_t* bytes_remaining) {
|
|
36
|
+
assert(reader != nullptr);
|
|
37
|
+
assert(bytes_remaining != nullptr);
|
|
38
|
+
return Skip(reader, bytes_remaining);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Status Callback::OnSegmentBegin(const ElementMetadata& /* metadata */,
|
|
42
|
+
Action* action) {
|
|
43
|
+
assert(action != nullptr);
|
|
44
|
+
*action = Action::kRead;
|
|
45
|
+
return Status(Status::kOkCompleted);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Status Callback::OnSeek(const ElementMetadata& /* metadata */,
|
|
49
|
+
const Seek& /* seek */) {
|
|
50
|
+
return Status(Status::kOkCompleted);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Status Callback::OnInfo(const ElementMetadata& /* metadata */,
|
|
54
|
+
const Info& /* info */) {
|
|
55
|
+
return Status(Status::kOkCompleted);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Status Callback::OnClusterBegin(const ElementMetadata& /* metadata */,
|
|
59
|
+
const Cluster& /* cluster */, Action* action) {
|
|
60
|
+
assert(action != nullptr);
|
|
61
|
+
*action = Action::kRead;
|
|
62
|
+
return Status(Status::kOkCompleted);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Status Callback::OnSimpleBlockBegin(const ElementMetadata& /* metadata */,
|
|
66
|
+
const SimpleBlock& /* simple_block */,
|
|
67
|
+
Action* action) {
|
|
68
|
+
assert(action != nullptr);
|
|
69
|
+
*action = Action::kRead;
|
|
70
|
+
return Status(Status::kOkCompleted);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Status Callback::OnSimpleBlockEnd(const ElementMetadata& /* metadata */,
|
|
74
|
+
const SimpleBlock& /* simple_block */) {
|
|
75
|
+
return Status(Status::kOkCompleted);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Status Callback::OnBlockGroupBegin(const ElementMetadata& /* metadata */,
|
|
79
|
+
Action* action) {
|
|
80
|
+
assert(action != nullptr);
|
|
81
|
+
*action = Action::kRead;
|
|
82
|
+
return Status(Status::kOkCompleted);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Status Callback::OnBlockBegin(const ElementMetadata& /* metadata */,
|
|
86
|
+
const Block& /* block */, Action* action) {
|
|
87
|
+
assert(action != nullptr);
|
|
88
|
+
*action = Action::kRead;
|
|
89
|
+
return Status(Status::kOkCompleted);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Status Callback::OnBlockEnd(const ElementMetadata& /* metadata */,
|
|
93
|
+
const Block& /* block */) {
|
|
94
|
+
return Status(Status::kOkCompleted);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Status Callback::OnBlockGroupEnd(const ElementMetadata& /* metadata */,
|
|
98
|
+
const BlockGroup& /* block_group */) {
|
|
99
|
+
return Status(Status::kOkCompleted);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Status Callback::OnFrame(const FrameMetadata& /* metadata */, Reader* reader,
|
|
103
|
+
std::uint64_t* bytes_remaining) {
|
|
104
|
+
assert(reader != nullptr);
|
|
105
|
+
assert(bytes_remaining != nullptr);
|
|
106
|
+
return Skip(reader, bytes_remaining);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Status Callback::OnClusterEnd(const ElementMetadata& /* metadata */,
|
|
110
|
+
const Cluster& /* cluster */) {
|
|
111
|
+
return Status(Status::kOkCompleted);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Status Callback::OnTrackEntry(const ElementMetadata& /* metadata */,
|
|
115
|
+
const TrackEntry& /* track_entry */) {
|
|
116
|
+
return Status(Status::kOkCompleted);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Status Callback::OnCuePoint(const ElementMetadata& /* metadata */,
|
|
120
|
+
const CuePoint& /* cue_point */) {
|
|
121
|
+
return Status(Status::kOkCompleted);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Status Callback::OnEditionEntry(const ElementMetadata& /* metadata */,
|
|
125
|
+
const EditionEntry& /* edition_entry */) {
|
|
126
|
+
return Status(Status::kOkCompleted);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Status Callback::OnTag(const ElementMetadata& /* metadata */,
|
|
130
|
+
const Tag& /* tag */) {
|
|
131
|
+
return Status(Status::kOkCompleted);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Status Callback::OnSegmentEnd(const ElementMetadata& /* metadata */) {
|
|
135
|
+
return Status(Status::kOkCompleted);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Status Callback::Skip(Reader* reader, std::uint64_t* bytes_remaining) {
|
|
139
|
+
assert(reader != nullptr);
|
|
140
|
+
assert(bytes_remaining != nullptr);
|
|
141
|
+
|
|
142
|
+
if (*bytes_remaining == 0)
|
|
143
|
+
return Status(Status::kOkCompleted);
|
|
144
|
+
|
|
145
|
+
Status status;
|
|
146
|
+
do {
|
|
147
|
+
std::uint64_t num_actually_skipped;
|
|
148
|
+
status = reader->Skip(*bytes_remaining, &num_actually_skipped);
|
|
149
|
+
*bytes_remaining -= num_actually_skipped;
|
|
150
|
+
} while (status.code == Status::kOkPartial);
|
|
151
|
+
|
|
152
|
+
return status;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
} // namespace webm
|
|
@@ -0,0 +1,42 @@
|
|
|
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 SRC_CHAPTER_ATOM_PARSER_H_
|
|
9
|
+
#define SRC_CHAPTER_ATOM_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/byte_parser.h"
|
|
12
|
+
#include "src/chapter_display_parser.h"
|
|
13
|
+
#include "src/int_parser.h"
|
|
14
|
+
#include "src/master_value_parser.h"
|
|
15
|
+
#include "webm/dom_types.h"
|
|
16
|
+
#include "webm/id.h"
|
|
17
|
+
|
|
18
|
+
namespace webm {
|
|
19
|
+
|
|
20
|
+
// Spec reference:
|
|
21
|
+
// http://matroska.org/technical/specs/index.html#ChapterAtom
|
|
22
|
+
// http://www.webmproject.org/docs/container/#ChapterAtom
|
|
23
|
+
class ChapterAtomParser : public MasterValueParser<ChapterAtom> {
|
|
24
|
+
public:
|
|
25
|
+
explicit ChapterAtomParser(std::size_t max_recursive_depth = 25)
|
|
26
|
+
: MasterValueParser<ChapterAtom>(
|
|
27
|
+
MakeChild<UnsignedIntParser>(Id::kChapterUid, &ChapterAtom::uid),
|
|
28
|
+
MakeChild<StringParser>(Id::kChapterStringUid,
|
|
29
|
+
&ChapterAtom::string_uid),
|
|
30
|
+
MakeChild<UnsignedIntParser>(Id::kChapterTimeStart,
|
|
31
|
+
&ChapterAtom::time_start),
|
|
32
|
+
MakeChild<UnsignedIntParser>(Id::kChapterTimeEnd,
|
|
33
|
+
&ChapterAtom::time_end),
|
|
34
|
+
MakeChild<ChapterDisplayParser>(Id::kChapterDisplay,
|
|
35
|
+
&ChapterAtom::displays),
|
|
36
|
+
MakeChild<ChapterAtomParser>(Id::kChapterAtom, &ChapterAtom::atoms,
|
|
37
|
+
max_recursive_depth)) {}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace webm
|
|
41
|
+
|
|
42
|
+
#endif // SRC_CHAPTER_ATOM_PARSER_H_
|
|
@@ -0,0 +1,34 @@
|
|
|
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 SRC_CHAPTER_DISPLAY_PARSER_H_
|
|
9
|
+
#define SRC_CHAPTER_DISPLAY_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/byte_parser.h"
|
|
12
|
+
#include "src/master_value_parser.h"
|
|
13
|
+
#include "webm/dom_types.h"
|
|
14
|
+
#include "webm/id.h"
|
|
15
|
+
|
|
16
|
+
namespace webm {
|
|
17
|
+
|
|
18
|
+
// Spec reference:
|
|
19
|
+
// http://matroska.org/technical/specs/index.html#ChapterDisplay
|
|
20
|
+
// http://www.webmproject.org/docs/container/#ChapterDisplay
|
|
21
|
+
class ChapterDisplayParser : public MasterValueParser<ChapterDisplay> {
|
|
22
|
+
public:
|
|
23
|
+
ChapterDisplayParser()
|
|
24
|
+
: MasterValueParser<ChapterDisplay>(
|
|
25
|
+
MakeChild<StringParser>(Id::kChapString, &ChapterDisplay::string),
|
|
26
|
+
MakeChild<StringParser>(Id::kChapLanguage,
|
|
27
|
+
&ChapterDisplay::languages),
|
|
28
|
+
MakeChild<StringParser>(Id::kChapCountry,
|
|
29
|
+
&ChapterDisplay::countries)) {}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace webm
|
|
33
|
+
|
|
34
|
+
#endif // SRC_CHAPTER_DISPLAY_PARSER_H_
|
|
@@ -0,0 +1,28 @@
|
|
|
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 SRC_CHAPTERS_PARSER_H_
|
|
9
|
+
#define SRC_CHAPTERS_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/edition_entry_parser.h"
|
|
12
|
+
#include "src/master_parser.h"
|
|
13
|
+
#include "webm/id.h"
|
|
14
|
+
|
|
15
|
+
namespace webm {
|
|
16
|
+
|
|
17
|
+
// Spec reference:
|
|
18
|
+
// http://matroska.org/technical/specs/index.html#Chapters
|
|
19
|
+
// http://www.webmproject.org/docs/container/#Chapters
|
|
20
|
+
class ChaptersParser : public MasterParser {
|
|
21
|
+
public:
|
|
22
|
+
ChaptersParser()
|
|
23
|
+
: MasterParser(MakeChild<EditionEntryParser>(Id::kEditionEntry)) {}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace webm
|
|
27
|
+
|
|
28
|
+
#endif // SRC_CHAPTERS_PARSER_H_
|
|
@@ -0,0 +1,48 @@
|
|
|
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 SRC_CLUSTER_PARSER_H_
|
|
9
|
+
#define SRC_CLUSTER_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/block_group_parser.h"
|
|
12
|
+
#include "src/block_parser.h"
|
|
13
|
+
#include "src/int_parser.h"
|
|
14
|
+
#include "src/master_value_parser.h"
|
|
15
|
+
#include "webm/dom_types.h"
|
|
16
|
+
#include "webm/id.h"
|
|
17
|
+
|
|
18
|
+
namespace webm {
|
|
19
|
+
|
|
20
|
+
// Spec reference:
|
|
21
|
+
// http://matroska.org/technical/specs/index.html#Cluster
|
|
22
|
+
// http://www.webmproject.org/docs/container/#Cluster
|
|
23
|
+
class ClusterParser : public MasterValueParser<Cluster> {
|
|
24
|
+
public:
|
|
25
|
+
ClusterParser()
|
|
26
|
+
: MasterValueParser<Cluster>(
|
|
27
|
+
MakeChild<UnsignedIntParser>(Id::kTimecode, &Cluster::timecode),
|
|
28
|
+
MakeChild<UnsignedIntParser>(Id::kPrevSize,
|
|
29
|
+
&Cluster::previous_size),
|
|
30
|
+
MakeChild<SimpleBlockParser>(Id::kSimpleBlock,
|
|
31
|
+
&Cluster::simple_blocks)
|
|
32
|
+
.UseAsStartEvent(),
|
|
33
|
+
MakeChild<BlockGroupParser>(Id::kBlockGroup, &Cluster::block_groups)
|
|
34
|
+
.UseAsStartEvent()) {}
|
|
35
|
+
|
|
36
|
+
protected:
|
|
37
|
+
Status OnParseStarted(Callback* callback, Action* action) override {
|
|
38
|
+
return callback->OnClusterBegin(metadata(Id::kCluster), value(), action);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Status OnParseCompleted(Callback* callback) override {
|
|
42
|
+
return callback->OnClusterEnd(metadata(Id::kCluster), value());
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace webm
|
|
47
|
+
|
|
48
|
+
#endif // SRC_CLUSTER_PARSER_H_
|
|
@@ -0,0 +1,55 @@
|
|
|
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 SRC_COLOUR_PARSER_H_
|
|
9
|
+
#define SRC_COLOUR_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/int_parser.h"
|
|
12
|
+
#include "src/master_value_parser.h"
|
|
13
|
+
#include "src/mastering_metadata_parser.h"
|
|
14
|
+
#include "webm/dom_types.h"
|
|
15
|
+
#include "webm/id.h"
|
|
16
|
+
|
|
17
|
+
namespace webm {
|
|
18
|
+
|
|
19
|
+
// Spec reference:
|
|
20
|
+
// http://matroska.org/technical/specs/index.html#Colour
|
|
21
|
+
// http://www.webmproject.org/docs/container/#Colour
|
|
22
|
+
class ColourParser : public MasterValueParser<Colour> {
|
|
23
|
+
public:
|
|
24
|
+
ColourParser()
|
|
25
|
+
: MasterValueParser<Colour>(
|
|
26
|
+
MakeChild<IntParser<MatrixCoefficients>>(
|
|
27
|
+
Id::kMatrixCoefficients, &Colour::matrix_coefficients),
|
|
28
|
+
MakeChild<UnsignedIntParser>(Id::kBitsPerChannel,
|
|
29
|
+
&Colour::bits_per_channel),
|
|
30
|
+
MakeChild<UnsignedIntParser>(Id::kChromaSubsamplingHorz,
|
|
31
|
+
&Colour::chroma_subsampling_x),
|
|
32
|
+
MakeChild<UnsignedIntParser>(Id::kChromaSubsamplingVert,
|
|
33
|
+
&Colour::chroma_subsampling_y),
|
|
34
|
+
MakeChild<UnsignedIntParser>(Id::kCbSubsamplingHorz,
|
|
35
|
+
&Colour::cb_subsampling_x),
|
|
36
|
+
MakeChild<UnsignedIntParser>(Id::kCbSubsamplingVert,
|
|
37
|
+
&Colour::cb_subsampling_y),
|
|
38
|
+
MakeChild<UnsignedIntParser>(Id::kChromaSitingHorz,
|
|
39
|
+
&Colour::chroma_siting_x),
|
|
40
|
+
MakeChild<UnsignedIntParser>(Id::kChromaSitingVert,
|
|
41
|
+
&Colour::chroma_siting_y),
|
|
42
|
+
MakeChild<IntParser<Range>>(Id::kRange, &Colour::range),
|
|
43
|
+
MakeChild<IntParser<TransferCharacteristics>>(
|
|
44
|
+
Id::kTransferCharacteristics,
|
|
45
|
+
&Colour::transfer_characteristics),
|
|
46
|
+
MakeChild<IntParser<Primaries>>(Id::kPrimaries, &Colour::primaries),
|
|
47
|
+
MakeChild<UnsignedIntParser>(Id::kMaxCll, &Colour::max_cll),
|
|
48
|
+
MakeChild<UnsignedIntParser>(Id::kMaxFall, &Colour::max_fall),
|
|
49
|
+
MakeChild<MasteringMetadataParser>(Id::kMasteringMetadata,
|
|
50
|
+
&Colour::mastering_metadata)) {}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace webm
|
|
54
|
+
|
|
55
|
+
#endif // SRC_COLOUR_PARSER_H_
|
|
@@ -0,0 +1,32 @@
|
|
|
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 SRC_CONTENT_ENC_AES_SETTINGS_PARSER_H_
|
|
9
|
+
#define SRC_CONTENT_ENC_AES_SETTINGS_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/int_parser.h"
|
|
12
|
+
#include "src/master_value_parser.h"
|
|
13
|
+
#include "webm/dom_types.h"
|
|
14
|
+
#include "webm/id.h"
|
|
15
|
+
|
|
16
|
+
namespace webm {
|
|
17
|
+
|
|
18
|
+
// Spec reference:
|
|
19
|
+
// http://www.webmproject.org/docs/webm-encryption/#42-new-matroskawebm-elements
|
|
20
|
+
class ContentEncAesSettingsParser
|
|
21
|
+
: public MasterValueParser<ContentEncAesSettings> {
|
|
22
|
+
public:
|
|
23
|
+
ContentEncAesSettingsParser()
|
|
24
|
+
: MasterValueParser<ContentEncAesSettings>(
|
|
25
|
+
MakeChild<IntParser<AesSettingsCipherMode>>(
|
|
26
|
+
Id::kAesSettingsCipherMode,
|
|
27
|
+
&ContentEncAesSettings::aes_settings_cipher_mode)) {}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace webm
|
|
31
|
+
|
|
32
|
+
#endif // SRC_CONTENT_ENC_AES_SETTINGS_PARSER_H_
|