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,38 @@
|
|
|
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_ENCODING_PARSER_H_
|
|
9
|
+
#define SRC_CONTENT_ENCODING_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/content_encryption_parser.h"
|
|
12
|
+
#include "src/int_parser.h"
|
|
13
|
+
#include "src/master_value_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#ContentEncoding
|
|
21
|
+
// http://www.webmproject.org/docs/container/#ContentEncoding
|
|
22
|
+
class ContentEncodingParser : public MasterValueParser<ContentEncoding> {
|
|
23
|
+
public:
|
|
24
|
+
ContentEncodingParser()
|
|
25
|
+
: MasterValueParser<ContentEncoding>(
|
|
26
|
+
MakeChild<UnsignedIntParser>(Id::kContentEncodingOrder,
|
|
27
|
+
&ContentEncoding::order),
|
|
28
|
+
MakeChild<UnsignedIntParser>(Id::kContentEncodingScope,
|
|
29
|
+
&ContentEncoding::scope),
|
|
30
|
+
MakeChild<IntParser<ContentEncodingType>>(Id::kContentEncodingType,
|
|
31
|
+
&ContentEncoding::type),
|
|
32
|
+
MakeChild<ContentEncryptionParser>(Id::kContentEncryption,
|
|
33
|
+
&ContentEncoding::encryption)) {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
} // namespace webm
|
|
37
|
+
|
|
38
|
+
#endif // SRC_CONTENT_ENCODING_PARSER_H_
|
|
@@ -0,0 +1,30 @@
|
|
|
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_ENCODINGS_PARSER_H_
|
|
9
|
+
#define SRC_CONTENT_ENCODINGS_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/content_encoding_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#ContentEncodings
|
|
20
|
+
// http://www.webmproject.org/docs/container/#ContentEncodings
|
|
21
|
+
class ContentEncodingsParser : public MasterValueParser<ContentEncodings> {
|
|
22
|
+
public:
|
|
23
|
+
ContentEncodingsParser()
|
|
24
|
+
: MasterValueParser<ContentEncodings>(MakeChild<ContentEncodingParser>(
|
|
25
|
+
Id::kContentEncoding, &ContentEncodings::encodings)) {}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace webm
|
|
29
|
+
|
|
30
|
+
#endif // SRC_CONTENT_ENCODINGS_PARSER_H_
|
|
@@ -0,0 +1,37 @@
|
|
|
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_ENCRYPTION_PARSER_H_
|
|
9
|
+
#define SRC_CONTENT_ENCRYPTION_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/byte_parser.h"
|
|
12
|
+
#include "src/content_enc_aes_settings_parser.h"
|
|
13
|
+
#include "src/master_value_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#ContentEncryption
|
|
21
|
+
// http://www.webmproject.org/docs/container/#ContentEncryption
|
|
22
|
+
class ContentEncryptionParser : public MasterValueParser<ContentEncryption> {
|
|
23
|
+
public:
|
|
24
|
+
ContentEncryptionParser()
|
|
25
|
+
: MasterValueParser<ContentEncryption>(
|
|
26
|
+
MakeChild<IntParser<ContentEncAlgo>>(Id::kContentEncAlgo,
|
|
27
|
+
&ContentEncryption::algorithm),
|
|
28
|
+
MakeChild<BinaryParser>(Id::kContentEncKeyId,
|
|
29
|
+
&ContentEncryption::key_id),
|
|
30
|
+
MakeChild<ContentEncAesSettingsParser>(
|
|
31
|
+
Id::kContentEncAesSettings, &ContentEncryption::aes_settings)) {
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
} // namespace webm
|
|
36
|
+
|
|
37
|
+
#endif // SRC_CONTENT_ENCRYPTION_PARSER_H_
|
|
@@ -0,0 +1,38 @@
|
|
|
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_CUE_POINT_PARSER_H_
|
|
9
|
+
#define SRC_CUE_POINT_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/cue_track_positions_parser.h"
|
|
12
|
+
#include "src/int_parser.h"
|
|
13
|
+
#include "src/master_value_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#CuePoint
|
|
21
|
+
// http://www.webmproject.org/docs/container/#CuePoint
|
|
22
|
+
class CuePointParser : public MasterValueParser<CuePoint> {
|
|
23
|
+
public:
|
|
24
|
+
CuePointParser()
|
|
25
|
+
: MasterValueParser<CuePoint>(
|
|
26
|
+
MakeChild<UnsignedIntParser>(Id::kCueTime, &CuePoint::time),
|
|
27
|
+
MakeChild<CueTrackPositionsParser>(
|
|
28
|
+
Id::kCueTrackPositions, &CuePoint::cue_track_positions)) {}
|
|
29
|
+
|
|
30
|
+
protected:
|
|
31
|
+
Status OnParseCompleted(Callback* callback) override {
|
|
32
|
+
return callback->OnCuePoint(metadata(Id::kCuePoint), value());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
} // namespace webm
|
|
37
|
+
|
|
38
|
+
#endif // SRC_CUE_POINT_PARSER_H_
|
|
@@ -0,0 +1,39 @@
|
|
|
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_CUE_TRACK_POSITIONS_PARSER_H_
|
|
9
|
+
#define SRC_CUE_TRACK_POSITIONS_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://matroska.org/technical/specs/index.html#CueTrackPositions
|
|
20
|
+
// http://www.webmproject.org/docs/container/#CueTrackPositions
|
|
21
|
+
class CueTrackPositionsParser : public MasterValueParser<CueTrackPositions> {
|
|
22
|
+
public:
|
|
23
|
+
CueTrackPositionsParser()
|
|
24
|
+
: MasterValueParser<CueTrackPositions>(
|
|
25
|
+
MakeChild<UnsignedIntParser>(Id::kCueTrack,
|
|
26
|
+
&CueTrackPositions::track),
|
|
27
|
+
MakeChild<UnsignedIntParser>(Id::kCueClusterPosition,
|
|
28
|
+
&CueTrackPositions::cluster_position),
|
|
29
|
+
MakeChild<UnsignedIntParser>(Id::kCueRelativePosition,
|
|
30
|
+
&CueTrackPositions::relative_position),
|
|
31
|
+
MakeChild<UnsignedIntParser>(Id::kCueDuration,
|
|
32
|
+
&CueTrackPositions::duration),
|
|
33
|
+
MakeChild<UnsignedIntParser>(Id::kCueBlockNumber,
|
|
34
|
+
&CueTrackPositions::block_number)) {}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace webm
|
|
38
|
+
|
|
39
|
+
#endif // SRC_CUE_TRACK_POSITIONS_PARSER_H_
|
|
@@ -0,0 +1,27 @@
|
|
|
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_CUES_PARSER_H_
|
|
9
|
+
#define SRC_CUES_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/cue_point_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#Cues
|
|
19
|
+
// http://www.webmproject.org/docs/container/#Cues
|
|
20
|
+
class CuesParser : public MasterParser {
|
|
21
|
+
public:
|
|
22
|
+
CuesParser() : MasterParser(MakeChild<CuePointParser>(Id::kCuePoint)) {}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace webm
|
|
26
|
+
|
|
27
|
+
#endif // SRC_CUES_PARSER_H_
|
|
@@ -0,0 +1,72 @@
|
|
|
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 "src/date_parser.h"
|
|
9
|
+
|
|
10
|
+
#include <cassert>
|
|
11
|
+
#include <cstdint>
|
|
12
|
+
#include <limits>
|
|
13
|
+
|
|
14
|
+
#include "src/parser_utils.h"
|
|
15
|
+
#include "webm/element.h"
|
|
16
|
+
#include "webm/reader.h"
|
|
17
|
+
#include "webm/status.h"
|
|
18
|
+
|
|
19
|
+
namespace webm {
|
|
20
|
+
|
|
21
|
+
// Spec reference:
|
|
22
|
+
// http://matroska.org/technical/specs/index.html#EBML_ex
|
|
23
|
+
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-element-types
|
|
24
|
+
DateParser::DateParser(std::int64_t default_value)
|
|
25
|
+
: default_value_(default_value) {}
|
|
26
|
+
|
|
27
|
+
Status DateParser::Init(const ElementMetadata& metadata,
|
|
28
|
+
std::uint64_t max_size) {
|
|
29
|
+
assert(metadata.size == kUnknownElementSize || metadata.size <= max_size);
|
|
30
|
+
|
|
31
|
+
if (metadata.size != 0 && metadata.size != 8) {
|
|
32
|
+
return Status(Status::kInvalidElementSize);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
num_bytes_remaining_ = static_cast<int>(metadata.size);
|
|
36
|
+
|
|
37
|
+
// The meaning of a 0-byte element is still being debated. EBML says the value
|
|
38
|
+
// is zero; Matroska says it's the default according to whatever the document
|
|
39
|
+
// spec says. Neither specifies what a 0-byte mandatory element means. I've
|
|
40
|
+
// asked about this on the Matroska mailing list. I'm going to assume a 0-byte
|
|
41
|
+
// mandatory element should be treated the same as a 0-byte optional element,
|
|
42
|
+
// meaning that they both get their default value (which may be some value
|
|
43
|
+
// other than zero). This applies to all non-master-elements (not just dates).
|
|
44
|
+
// This parser is an EBML-level parser, and so will default to a value of
|
|
45
|
+
// zero. The Matroska-level parser can reset this default value to something
|
|
46
|
+
// else after parsing (as needed).
|
|
47
|
+
// See:
|
|
48
|
+
// https://github.com/Matroska-Org/ebml-specification/pull/17
|
|
49
|
+
// http://lists.matroska.org/pipermail/matroska-devel/2015-October/004866.html
|
|
50
|
+
if (metadata.size == 0) {
|
|
51
|
+
value_ = default_value_;
|
|
52
|
+
} else {
|
|
53
|
+
value_ = 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return Status(Status::kOkCompleted);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Status DateParser::Feed(Callback* callback, Reader* reader,
|
|
60
|
+
std::uint64_t* num_bytes_read) {
|
|
61
|
+
assert(callback != nullptr);
|
|
62
|
+
assert(reader != nullptr);
|
|
63
|
+
assert(num_bytes_read != nullptr);
|
|
64
|
+
|
|
65
|
+
const Status status = AccumulateIntegerBytes(num_bytes_remaining_, reader,
|
|
66
|
+
&value_, num_bytes_read);
|
|
67
|
+
num_bytes_remaining_ -= static_cast<int>(*num_bytes_read);
|
|
68
|
+
|
|
69
|
+
return status;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
} // namespace webm
|
|
@@ -0,0 +1,64 @@
|
|
|
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_DATE_PARSER_H_
|
|
9
|
+
#define SRC_DATE_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include <cassert>
|
|
12
|
+
#include <cstdint>
|
|
13
|
+
|
|
14
|
+
#include "src/element_parser.h"
|
|
15
|
+
#include "webm/callback.h"
|
|
16
|
+
#include "webm/element.h"
|
|
17
|
+
#include "webm/reader.h"
|
|
18
|
+
#include "webm/status.h"
|
|
19
|
+
|
|
20
|
+
namespace webm {
|
|
21
|
+
|
|
22
|
+
// Parses an EBML date from a byte stream. EBML dates are signed integer values
|
|
23
|
+
// that represent the offset, in nanoseconds, from 2001-01-01T00:00:00.00 UTC.
|
|
24
|
+
class DateParser : public ElementParser {
|
|
25
|
+
public:
|
|
26
|
+
// Constructs a new parser which will use the given default_value as the
|
|
27
|
+
// value for the element if its size is zero. Defaults to the value zero (as
|
|
28
|
+
// the EBML spec indicates).
|
|
29
|
+
explicit DateParser(std::int64_t default_value = 0);
|
|
30
|
+
|
|
31
|
+
DateParser(DateParser&&) = default;
|
|
32
|
+
DateParser& operator=(DateParser&&) = default;
|
|
33
|
+
|
|
34
|
+
DateParser(const DateParser&) = delete;
|
|
35
|
+
DateParser& operator=(const DateParser&) = delete;
|
|
36
|
+
|
|
37
|
+
Status Init(const ElementMetadata& metadata, std::uint64_t max_size) override;
|
|
38
|
+
|
|
39
|
+
Status Feed(Callback* callback, Reader* reader,
|
|
40
|
+
std::uint64_t* num_bytes_read) override;
|
|
41
|
+
|
|
42
|
+
// Gets the parsed date. This must not be called until the parse had been
|
|
43
|
+
// successfully completed.
|
|
44
|
+
std::int64_t value() const {
|
|
45
|
+
assert(num_bytes_remaining_ == 0);
|
|
46
|
+
return value_;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Gets the parsed date. This must not be called until the parse had been
|
|
50
|
+
// successfully completed.
|
|
51
|
+
std::int64_t* mutable_value() {
|
|
52
|
+
assert(num_bytes_remaining_ == 0);
|
|
53
|
+
return &value_;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private:
|
|
57
|
+
std::int64_t value_;
|
|
58
|
+
std::int64_t default_value_;
|
|
59
|
+
int num_bytes_remaining_ = -1;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace webm
|
|
63
|
+
|
|
64
|
+
#endif // SRC_DATE_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_EBML_PARSER_H_
|
|
9
|
+
#define SRC_EBML_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/byte_parser.h"
|
|
12
|
+
#include "src/int_parser.h"
|
|
13
|
+
#include "src/master_value_parser.h"
|
|
14
|
+
#include "webm/dom_types.h"
|
|
15
|
+
#include "webm/id.h"
|
|
16
|
+
|
|
17
|
+
namespace webm {
|
|
18
|
+
|
|
19
|
+
// Spec references:
|
|
20
|
+
// http://matroska.org/technical/specs/index.html#EBML
|
|
21
|
+
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-header-elements
|
|
22
|
+
// http://www.webmproject.org/docs/container/#EBML
|
|
23
|
+
class EbmlParser : public MasterValueParser<Ebml> {
|
|
24
|
+
public:
|
|
25
|
+
EbmlParser()
|
|
26
|
+
: MasterValueParser<Ebml>(
|
|
27
|
+
MakeChild<UnsignedIntParser>(Id::kEbmlVersion, &Ebml::ebml_version),
|
|
28
|
+
MakeChild<UnsignedIntParser>(Id::kEbmlReadVersion,
|
|
29
|
+
&Ebml::ebml_read_version),
|
|
30
|
+
MakeChild<UnsignedIntParser>(Id::kEbmlMaxIdLength,
|
|
31
|
+
&Ebml::ebml_max_id_length),
|
|
32
|
+
MakeChild<UnsignedIntParser>(Id::kEbmlMaxSizeLength,
|
|
33
|
+
&Ebml::ebml_max_size_length),
|
|
34
|
+
MakeChild<StringParser>(Id::kDocType, &Ebml::doc_type),
|
|
35
|
+
MakeChild<UnsignedIntParser>(Id::kDocTypeVersion,
|
|
36
|
+
&Ebml::doc_type_version),
|
|
37
|
+
MakeChild<UnsignedIntParser>(Id::kDocTypeReadVersion,
|
|
38
|
+
&Ebml::doc_type_read_version)) {}
|
|
39
|
+
|
|
40
|
+
protected:
|
|
41
|
+
Status OnParseCompleted(Callback* callback) override {
|
|
42
|
+
return callback->OnEbml(metadata(Id::kEbml), value());
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace webm
|
|
47
|
+
|
|
48
|
+
#endif // SRC_EBML_PARSER_H_
|
|
@@ -0,0 +1,35 @@
|
|
|
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_EDITION_ENTRY_PARSER_H_
|
|
9
|
+
#define SRC_EDITION_ENTRY_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include "src/chapter_atom_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#EditionEntry
|
|
20
|
+
// http://www.webmproject.org/docs/container/#EditionEntry
|
|
21
|
+
class EditionEntryParser : public MasterValueParser<EditionEntry> {
|
|
22
|
+
public:
|
|
23
|
+
EditionEntryParser()
|
|
24
|
+
: MasterValueParser<EditionEntry>(MakeChild<ChapterAtomParser>(
|
|
25
|
+
Id::kChapterAtom, &EditionEntry::atoms)) {}
|
|
26
|
+
|
|
27
|
+
protected:
|
|
28
|
+
Status OnParseCompleted(Callback* callback) override {
|
|
29
|
+
return callback->OnEditionEntry(metadata(Id::kEditionEntry), value());
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace webm
|
|
34
|
+
|
|
35
|
+
#endif // SRC_EDITION_ENTRY_PARSER_H_
|
|
@@ -0,0 +1,102 @@
|
|
|
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_ELEMENT_PARSER_H_
|
|
9
|
+
#define SRC_ELEMENT_PARSER_H_
|
|
10
|
+
|
|
11
|
+
#include <cassert>
|
|
12
|
+
#include <cstdint>
|
|
13
|
+
|
|
14
|
+
#include "src/ancestory.h"
|
|
15
|
+
#include "src/parser.h"
|
|
16
|
+
#include "webm/callback.h"
|
|
17
|
+
#include "webm/element.h"
|
|
18
|
+
|
|
19
|
+
namespace webm {
|
|
20
|
+
|
|
21
|
+
// Parses an element from a WebM byte stream. Objects that implement this
|
|
22
|
+
// interface are expected to be used as follows in order to parse the specific
|
|
23
|
+
// WebM element that they are designed to handle.
|
|
24
|
+
//
|
|
25
|
+
// Reader* reader = ...; // Create some Reader.
|
|
26
|
+
// Callback* callback = ...; // Create some Callback.
|
|
27
|
+
//
|
|
28
|
+
// ElementMetadata metadata = {
|
|
29
|
+
// id, // Element parsed from the reader.
|
|
30
|
+
// header_size, // The number of bytes used to encode the id and size.
|
|
31
|
+
// size_in_bytes, // The number of bytes in the element body.
|
|
32
|
+
// position, // The position of the element (starting at the ID).
|
|
33
|
+
// };
|
|
34
|
+
//
|
|
35
|
+
// std::uint64_t max_size = ...; // Some upper bound on this element's size.
|
|
36
|
+
// ElementParser* parser = ...; // Create some parser capable of handling
|
|
37
|
+
// // elements that match id.
|
|
38
|
+
//
|
|
39
|
+
// Status status = parser->Init(metadata, max_size);
|
|
40
|
+
// if (!status.completed_ok()) {
|
|
41
|
+
// // An error occurred. See status.code for the reason.
|
|
42
|
+
// } else {
|
|
43
|
+
// do {
|
|
44
|
+
// std::uint64_t num_bytes_read = 0;
|
|
45
|
+
// status = parser->Feed(callback, reader, &num_bytes_read);
|
|
46
|
+
// } while (status.code == Status::kOkPartial);
|
|
47
|
+
//
|
|
48
|
+
// if (status.completed_ok()) {
|
|
49
|
+
// // Parsing successfully completed.
|
|
50
|
+
// } else {
|
|
51
|
+
// // An error occurred. If status.code is a parsing error (see status.h for
|
|
52
|
+
// // errors that are considered parsing errors), do not call Feed again;
|
|
53
|
+
// // parsing has already failed and further progress can't be made. If
|
|
54
|
+
// // status.code is not a parsing error (i.e. Status::kWouldBlock), then
|
|
55
|
+
// // Feed may be called again to attempt resuming parsing.
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
class ElementParser : public Parser {
|
|
59
|
+
public:
|
|
60
|
+
// Initializes the parser and prepares it for parsing its element. Returns
|
|
61
|
+
// Status::kOkCompleted if successful. Must not return Status::kOkPartial (it
|
|
62
|
+
// is not resumable). metadata is the metadata associated with this element.
|
|
63
|
+
// max_size must be <= metadata.size (unless metadata.size is
|
|
64
|
+
// kUnknownElementSize).
|
|
65
|
+
virtual Status Init(const ElementMetadata& metadata,
|
|
66
|
+
std::uint64_t max_size) = 0;
|
|
67
|
+
|
|
68
|
+
// Initializes the parser after a seek was done and prepares it for parsing.
|
|
69
|
+
// The reader is now at the position of the child element indicated by
|
|
70
|
+
// child_metadata, whose ancestory is child_ancestory. The child element for
|
|
71
|
+
// this parser is the first element in child_ancestory, or if that is empty,
|
|
72
|
+
// then child_metadata itself. If the child is not a valid child of this
|
|
73
|
+
// parser, then a debug assertion is made (because that indicates a bug).
|
|
74
|
+
virtual void InitAfterSeek(const Ancestory& /* child_ancestory */,
|
|
75
|
+
const ElementMetadata& /* child_metadata */) {
|
|
76
|
+
assert(false);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Returns true and sets metadata if this parser read too far and read the
|
|
80
|
+
// element metadata for an element that is not its child. This may happen, for
|
|
81
|
+
// example, when an element with unknown size is being read (because its end
|
|
82
|
+
// is considered the first element that is not a valid child, so it must read
|
|
83
|
+
// further to detect this). If this did not happen and false is returned, then
|
|
84
|
+
// metadata will not be modified. metadata must not be null.
|
|
85
|
+
virtual bool GetCachedMetadata(ElementMetadata* metadata) {
|
|
86
|
+
assert(metadata != nullptr);
|
|
87
|
+
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Returns true if this parser skipped the element instead of fully parsing
|
|
92
|
+
// it. This will be true if the user requested a kSkip action from the
|
|
93
|
+
// Callback in Feed(). This method should only be called after Feed() has
|
|
94
|
+
// returned kOkCompleted. If the element was skipped, do not try to access its
|
|
95
|
+
// value; it has no meaningful value and doing so will likely result in an
|
|
96
|
+
// assertion failing.
|
|
97
|
+
virtual bool WasSkipped() const { return false; }
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace webm
|
|
101
|
+
|
|
102
|
+
#endif // SRC_ELEMENT_PARSER_H_
|