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.
Files changed (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +908 -2
  3. package/THIRD_PARTY_NOTICES.md +30 -0
  4. package/android/av1/build.gradle +67 -0
  5. package/android/av1/consumer-rules.pro +4 -0
  6. package/android/av1/src/main/cpp/Av1Codec_jni.cpp +8 -0
  7. package/android/av1/src/main/cpp/CMakeLists.txt +34 -0
  8. package/android/av1/src/main/java/dev/mediacache/alphavideo/av1/Av1Codec.java +21 -0
  9. package/android/build.gradle +90 -0
  10. package/android/consumer-rules.pro +2 -0
  11. package/android/gradle.properties +1 -0
  12. package/android/publish.gradle +82 -0
  13. package/android/settings.gradle +5 -0
  14. package/android/src/main/AndroidManifest.xml +1 -0
  15. package/android/src/main/cpp/CMakeLists.txt +59 -0
  16. package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoCodecs.java +73 -0
  17. package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoView.java +1982 -0
  18. package/android/src/main/java/dev/mediacache/alphavideo/BufferedDualStreamPlayer.java +978 -0
  19. package/android/src/main/java/dev/mediacache/alphavideo/Fetcher.java +37 -0
  20. package/android/src/main/java/dev/mediacache/alphavideo/HttpFetcher.java +156 -0
  21. package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecColor.java +47 -0
  22. package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecDecoders.java +135 -0
  23. package/android/src/main/java/dev/mediacache/alphavideo/RangeSourceLink.java +54 -0
  24. package/android/src/main/java/dev/mediacache/alphavideo/SourceReader.java +174 -0
  25. package/android/src/main/java/dev/mediacache/alphavideo/SurfaceTextureVideoDecoder.java +802 -0
  26. package/android/src/main/java/dev/mediacache/alphavideo/WebMAlphaPlayerNative.java +95 -0
  27. package/android/src/main/java/dev/mediacache/alphavideo/WebMFrame.java +54 -0
  28. package/android/src/main/java/dev/mediacache/alphavideo/WebMSource.java +160 -0
  29. package/android/src/rangesource/java/dev/mediacache/alphavideo/AppDataSource.java +50 -0
  30. package/android/vpx/build.gradle +67 -0
  31. package/android/vpx/consumer-rules.pro +4 -0
  32. package/android/vpx/src/main/cpp/CMakeLists.txt +34 -0
  33. package/android/vpx/src/main/cpp/VpxCodec_jni.cpp +8 -0
  34. package/android/vpx/src/main/java/dev/mediacache/alphavideo/vpx/VpxCodec.java +21 -0
  35. package/codecs/av1/Dav1dDecoderPlugin.cpp +157 -0
  36. package/codecs/av1/Dav1dDecoderPlugin.h +17 -0
  37. package/codecs/vpx/VpxDecoderPlugin.cpp +103 -0
  38. package/codecs/vpx/VpxDecoderPlugin.h +17 -0
  39. package/cpp/AlphaDemuxer.cpp +984 -0
  40. package/cpp/AlphaDemuxer.h +123 -0
  41. package/cpp/AlphaVideoDecoderPlugin.h +84 -0
  42. package/cpp/Av1SequenceHeader.cpp +175 -0
  43. package/cpp/Av1SequenceHeader.h +25 -0
  44. package/cpp/ByteSource.cpp +116 -0
  45. package/cpp/ByteSource.h +59 -0
  46. package/cpp/RangeSourceClient.h +40 -0
  47. package/cpp/VideoDecoder.cpp +157 -0
  48. package/cpp/VideoDecoder.h +83 -0
  49. package/cpp/WebMAlphaPlayer.cpp +1666 -0
  50. package/cpp/WebMAlphaPlayer.h +389 -0
  51. package/cpp/WebMAlphaPlayer_jni.cpp +1380 -0
  52. package/cpp/YuvToRgb.cpp +39 -0
  53. package/cpp/YuvToRgb.h +40 -0
  54. package/ios/Sources/AlphaVideo/AlphaVideoCodecs.mm +63 -0
  55. package/ios/Sources/AlphaVideo/AlphaVideoInternal.h +70 -0
  56. package/ios/Sources/AlphaVideo/AlphaVideoPlayer.mm +994 -0
  57. package/ios/Sources/AlphaVideo/AlphaVideoSource.mm +476 -0
  58. package/ios/Sources/AlphaVideo/AlphaVideoView.mm +374 -0
  59. package/ios/Sources/AlphaVideo/include/AlphaVideo.h +303 -0
  60. package/ios/Sources/AlphaVideoAV1/AlphaVideoAV1Codec.mm +16 -0
  61. package/ios/Sources/AlphaVideoAV1/include/AlphaVideoAV1.h +18 -0
  62. package/ios/Sources/AlphaVideoVPX/AlphaVideoVPXCodec.mm +16 -0
  63. package/ios/Sources/AlphaVideoVPX/include/AlphaVideoVPX.h +17 -0
  64. package/lib/commonjs/AlphaVideoView.js +187 -0
  65. package/lib/commonjs/AlphaVideoView.js.map +1 -0
  66. package/lib/commonjs/AlphaVideoViewNativeComponent.js +47 -0
  67. package/lib/commonjs/AlphaVideoViewNativeComponent.js.map +1 -0
  68. package/lib/commonjs/AlphaVideoViewNativeComponent.web.js +11 -0
  69. package/lib/commonjs/AlphaVideoViewNativeComponent.web.js.map +1 -0
  70. package/lib/commonjs/NativeAlphaVideoModule.js +10 -0
  71. package/lib/commonjs/NativeAlphaVideoModule.js.map +1 -0
  72. package/lib/commonjs/NativeAlphaVideoModule.web.js +9 -0
  73. package/lib/commonjs/NativeAlphaVideoModule.web.js.map +1 -0
  74. package/lib/commonjs/WebPlayer.js +12 -0
  75. package/lib/commonjs/WebPlayer.js.map +1 -0
  76. package/lib/commonjs/WebPlayer.web.js +115 -0
  77. package/lib/commonjs/WebPlayer.web.js.map +1 -0
  78. package/lib/commonjs/index.js +124 -0
  79. package/lib/commonjs/index.js.map +1 -0
  80. package/lib/module/AlphaVideoView.js +187 -0
  81. package/lib/module/AlphaVideoView.js.map +1 -0
  82. package/lib/module/AlphaVideoViewNativeComponent.js +47 -0
  83. package/lib/module/AlphaVideoViewNativeComponent.js.map +1 -0
  84. package/lib/module/AlphaVideoViewNativeComponent.web.js +11 -0
  85. package/lib/module/AlphaVideoViewNativeComponent.web.js.map +1 -0
  86. package/lib/module/NativeAlphaVideoModule.js +10 -0
  87. package/lib/module/NativeAlphaVideoModule.js.map +1 -0
  88. package/lib/module/NativeAlphaVideoModule.web.js +9 -0
  89. package/lib/module/NativeAlphaVideoModule.web.js.map +1 -0
  90. package/lib/module/WebPlayer.js +12 -0
  91. package/lib/module/WebPlayer.js.map +1 -0
  92. package/lib/module/WebPlayer.web.js +115 -0
  93. package/lib/module/WebPlayer.web.js.map +1 -0
  94. package/lib/module/index.js +124 -0
  95. package/lib/module/index.js.map +1 -0
  96. package/lib/typescript/react-native/src/AlphaVideoView.d.ts +189 -0
  97. package/lib/typescript/react-native/src/AlphaVideoView.d.ts.map +1 -0
  98. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts +109 -0
  99. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts.map +1 -0
  100. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts +5 -0
  101. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts.map +1 -0
  102. package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts +21 -0
  103. package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts.map +1 -0
  104. package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts +3 -0
  105. package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts.map +1 -0
  106. package/lib/typescript/react-native/src/WebPlayer.d.ts +3 -0
  107. package/lib/typescript/react-native/src/WebPlayer.d.ts.map +1 -0
  108. package/lib/typescript/react-native/src/WebPlayer.web.d.ts +9 -0
  109. package/lib/typescript/react-native/src/WebPlayer.web.d.ts.map +1 -0
  110. package/lib/typescript/react-native/src/index.d.ts +77 -0
  111. package/lib/typescript/react-native/src/index.d.ts.map +1 -0
  112. package/licenses/dav1d-COPYING.txt +23 -0
  113. package/licenses/libvpx-LICENSE.txt +31 -0
  114. package/licenses/libvpx-PATENTS.txt +23 -0
  115. package/licenses/libwebm-LICENSE.txt +30 -0
  116. package/licenses/libwebm-PATENTS.txt +23 -0
  117. package/package.json +152 -4
  118. package/prebuilt/android/arm64-v8a/lib/libdav1d.a +0 -0
  119. package/prebuilt/android/arm64-v8a/lib/libvpx.a +0 -0
  120. package/prebuilt/android/armeabi-v7a/lib/libdav1d.a +0 -0
  121. package/prebuilt/android/armeabi-v7a/lib/libvpx.a +0 -0
  122. package/prebuilt/android/x86_64/lib/libdav1d.a +0 -0
  123. package/prebuilt/android/x86_64/lib/libvpx.a +0 -0
  124. package/prebuilt/include/dav1d/common.h +94 -0
  125. package/prebuilt/include/dav1d/data.h +117 -0
  126. package/prebuilt/include/dav1d/dav1d.h +329 -0
  127. package/prebuilt/include/dav1d/headers.h +440 -0
  128. package/prebuilt/include/dav1d/picture.h +157 -0
  129. package/prebuilt/include/dav1d/version.h +50 -0
  130. package/prebuilt/include/vpx/vp8.h +136 -0
  131. package/prebuilt/include/vpx/vp8dx.h +228 -0
  132. package/prebuilt/include/vpx/vpx_codec.h +475 -0
  133. package/prebuilt/include/vpx/vpx_decoder.h +365 -0
  134. package/prebuilt/include/vpx/vpx_frame_buffer.h +83 -0
  135. package/prebuilt/include/vpx/vpx_image.h +209 -0
  136. package/prebuilt/include/vpx/vpx_integer.h +40 -0
  137. package/prebuilt/ios/lib/libdav1d.a +0 -0
  138. package/prebuilt/ios/lib/libvpx.a +0 -0
  139. package/prebuilt/ios-simulator/include/dav1d/common.h +94 -0
  140. package/prebuilt/ios-simulator/include/dav1d/data.h +117 -0
  141. package/prebuilt/ios-simulator/include/dav1d/dav1d.h +329 -0
  142. package/prebuilt/ios-simulator/include/dav1d/headers.h +440 -0
  143. package/prebuilt/ios-simulator/include/dav1d/picture.h +157 -0
  144. package/prebuilt/ios-simulator/include/dav1d/version.h +50 -0
  145. package/prebuilt/ios-simulator/include/vpx/vp8.h +136 -0
  146. package/prebuilt/ios-simulator/include/vpx/vp8dx.h +228 -0
  147. package/prebuilt/ios-simulator/include/vpx/vpx_codec.h +475 -0
  148. package/prebuilt/ios-simulator/include/vpx/vpx_decoder.h +365 -0
  149. package/prebuilt/ios-simulator/include/vpx/vpx_frame_buffer.h +83 -0
  150. package/prebuilt/ios-simulator/include/vpx/vpx_image.h +209 -0
  151. package/prebuilt/ios-simulator/include/vpx/vpx_integer.h +40 -0
  152. package/prebuilt/ios-simulator/lib/libdav1d.a +0 -0
  153. package/prebuilt/ios-simulator/lib/libvpx.a +0 -0
  154. package/react-native/android/CMakeLists.txt +14 -0
  155. package/react-native/android/build.gradle +113 -0
  156. package/react-native/android/src/main/AndroidManifest.xml +1 -0
  157. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModule.java +102 -0
  158. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoPackage.java +50 -0
  159. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManager.java +317 -0
  160. package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +10 -0
  161. package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +23 -0
  162. package/react-native/android/src/norangesource/java/dev/mediacache/alphavideo/AppDataSource.java +15 -0
  163. package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +30 -0
  164. package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +61 -0
  165. package/react-native/ios/RNAlphaVideoViewComponentView.mm +173 -0
  166. package/react-native/ios/RNAlphaVideoViewManager.mm +147 -0
  167. package/react-native/src/AlphaVideoView.tsx +329 -0
  168. package/react-native/src/AlphaVideoViewNativeComponent.ts +132 -0
  169. package/react-native/src/AlphaVideoViewNativeComponent.web.ts +5 -0
  170. package/react-native/src/NativeAlphaVideoModule.ts +22 -0
  171. package/react-native/src/NativeAlphaVideoModule.web.ts +2 -0
  172. package/react-native/src/WebPlayer.tsx +7 -0
  173. package/react-native/src/WebPlayer.web.tsx +87 -0
  174. package/react-native/src/index.tsx +144 -0
  175. package/react-native-alpha-video.podspec +99 -0
  176. package/react-native.config.js +12 -0
  177. package/scripts/build_codecs_android.sh +246 -0
  178. package/scripts/build_codecs_ios.sh +31 -0
  179. package/scripts/build_codecs_ios_device.sh +210 -0
  180. package/scripts/build_codecs_ios_simulator.sh +256 -0
  181. package/scripts/build_wasm.sh +230 -0
  182. package/scripts/build_xcframework.sh +49 -0
  183. package/scripts/fetch-prebuilt.sh +48 -0
  184. package/scripts/package_release.sh +107 -0
  185. package/scripts/publish-android.sh +85 -0
  186. package/scripts/vendor_range_source.sh +47 -0
  187. package/third_party/libwebm/AUTHORS.TXT +5 -0
  188. package/third_party/libwebm/LICENSE.TXT +30 -0
  189. package/third_party/libwebm/PATENTS.TXT +23 -0
  190. package/third_party/libwebm/README.md +7 -0
  191. package/third_party/libwebm/webm_parser/include/webm/buffer_reader.h +138 -0
  192. package/third_party/libwebm/webm_parser/include/webm/callback.h +363 -0
  193. package/third_party/libwebm/webm_parser/include/webm/dom_types.h +1781 -0
  194. package/third_party/libwebm/webm_parser/include/webm/element.h +208 -0
  195. package/third_party/libwebm/webm_parser/include/webm/file_reader.h +103 -0
  196. package/third_party/libwebm/webm_parser/include/webm/id.h +1085 -0
  197. package/third_party/libwebm/webm_parser/include/webm/istream_reader.h +99 -0
  198. package/third_party/libwebm/webm_parser/include/webm/reader.h +94 -0
  199. package/third_party/libwebm/webm_parser/include/webm/status.h +166 -0
  200. package/third_party/libwebm/webm_parser/include/webm/webm_parser.h +133 -0
  201. package/third_party/libwebm/webm_parser/src/ancestory.cc +334 -0
  202. package/third_party/libwebm/webm_parser/src/ancestory.h +83 -0
  203. package/third_party/libwebm/webm_parser/src/audio_parser.h +84 -0
  204. package/third_party/libwebm/webm_parser/src/bit_utils.cc +26 -0
  205. package/third_party/libwebm/webm_parser/src/bit_utils.h +24 -0
  206. package/third_party/libwebm/webm_parser/src/block_additions_parser.h +30 -0
  207. package/third_party/libwebm/webm_parser/src/block_group_parser.h +71 -0
  208. package/third_party/libwebm/webm_parser/src/block_header_parser.cc +76 -0
  209. package/third_party/libwebm/webm_parser/src/block_header_parser.h +65 -0
  210. package/third_party/libwebm/webm_parser/src/block_more_parser.h +32 -0
  211. package/third_party/libwebm/webm_parser/src/block_parser.cc +285 -0
  212. package/third_party/libwebm/webm_parser/src/block_parser.h +126 -0
  213. package/third_party/libwebm/webm_parser/src/bool_parser.h +95 -0
  214. package/third_party/libwebm/webm_parser/src/buffer_reader.cc +110 -0
  215. package/third_party/libwebm/webm_parser/src/byte_parser.h +144 -0
  216. package/third_party/libwebm/webm_parser/src/callback.cc +155 -0
  217. package/third_party/libwebm/webm_parser/src/chapter_atom_parser.h +42 -0
  218. package/third_party/libwebm/webm_parser/src/chapter_display_parser.h +34 -0
  219. package/third_party/libwebm/webm_parser/src/chapters_parser.h +28 -0
  220. package/third_party/libwebm/webm_parser/src/cluster_parser.h +48 -0
  221. package/third_party/libwebm/webm_parser/src/colour_parser.h +55 -0
  222. package/third_party/libwebm/webm_parser/src/content_enc_aes_settings_parser.h +32 -0
  223. package/third_party/libwebm/webm_parser/src/content_encoding_parser.h +38 -0
  224. package/third_party/libwebm/webm_parser/src/content_encodings_parser.h +30 -0
  225. package/third_party/libwebm/webm_parser/src/content_encryption_parser.h +37 -0
  226. package/third_party/libwebm/webm_parser/src/cue_point_parser.h +38 -0
  227. package/third_party/libwebm/webm_parser/src/cue_track_positions_parser.h +39 -0
  228. package/third_party/libwebm/webm_parser/src/cues_parser.h +27 -0
  229. package/third_party/libwebm/webm_parser/src/date_parser.cc +72 -0
  230. package/third_party/libwebm/webm_parser/src/date_parser.h +64 -0
  231. package/third_party/libwebm/webm_parser/src/ebml_parser.h +48 -0
  232. package/third_party/libwebm/webm_parser/src/edition_entry_parser.h +35 -0
  233. package/third_party/libwebm/webm_parser/src/element_parser.h +102 -0
  234. package/third_party/libwebm/webm_parser/src/file_reader.cc +142 -0
  235. package/third_party/libwebm/webm_parser/src/float_parser.cc +77 -0
  236. package/third_party/libwebm/webm_parser/src/float_parser.h +65 -0
  237. package/third_party/libwebm/webm_parser/src/id_element_parser.cc +49 -0
  238. package/third_party/libwebm/webm_parser/src/id_element_parser.h +56 -0
  239. package/third_party/libwebm/webm_parser/src/id_parser.cc +75 -0
  240. package/third_party/libwebm/webm_parser/src/id_parser.h +45 -0
  241. package/third_party/libwebm/webm_parser/src/info_parser.h +44 -0
  242. package/third_party/libwebm/webm_parser/src/int_parser.h +121 -0
  243. package/third_party/libwebm/webm_parser/src/istream_reader.cc +133 -0
  244. package/third_party/libwebm/webm_parser/src/master_parser.cc +298 -0
  245. package/third_party/libwebm/webm_parser/src/master_parser.h +230 -0
  246. package/third_party/libwebm/webm_parser/src/master_value_parser.h +533 -0
  247. package/third_party/libwebm/webm_parser/src/mastering_metadata_parser.h +57 -0
  248. package/third_party/libwebm/webm_parser/src/parser.h +34 -0
  249. package/third_party/libwebm/webm_parser/src/parser_utils.cc +34 -0
  250. package/third_party/libwebm/webm_parser/src/parser_utils.h +64 -0
  251. package/third_party/libwebm/webm_parser/src/projection_parser.h +40 -0
  252. package/third_party/libwebm/webm_parser/src/recursive_parser.h +93 -0
  253. package/third_party/libwebm/webm_parser/src/seek_head_parser.h +27 -0
  254. package/third_party/libwebm/webm_parser/src/seek_parser.h +37 -0
  255. package/third_party/libwebm/webm_parser/src/segment_parser.cc +86 -0
  256. package/third_party/libwebm/webm_parser/src/segment_parser.h +53 -0
  257. package/third_party/libwebm/webm_parser/src/simple_tag_parser.h +37 -0
  258. package/third_party/libwebm/webm_parser/src/size_parser.cc +56 -0
  259. package/third_party/libwebm/webm_parser/src/size_parser.h +43 -0
  260. package/third_party/libwebm/webm_parser/src/skip_callback.h +63 -0
  261. package/third_party/libwebm/webm_parser/src/skip_parser.cc +59 -0
  262. package/third_party/libwebm/webm_parser/src/skip_parser.h +35 -0
  263. package/third_party/libwebm/webm_parser/src/slices_parser.h +30 -0
  264. package/third_party/libwebm/webm_parser/src/tag_parser.h +37 -0
  265. package/third_party/libwebm/webm_parser/src/tags_parser.h +27 -0
  266. package/third_party/libwebm/webm_parser/src/targets_parser.h +35 -0
  267. package/third_party/libwebm/webm_parser/src/time_slice_parser.h +30 -0
  268. package/third_party/libwebm/webm_parser/src/track_entry_parser.h +65 -0
  269. package/third_party/libwebm/webm_parser/src/tracks_parser.h +27 -0
  270. package/third_party/libwebm/webm_parser/src/unknown_parser.cc +49 -0
  271. package/third_party/libwebm/webm_parser/src/unknown_parser.h +38 -0
  272. package/third_party/libwebm/webm_parser/src/var_int_parser.cc +71 -0
  273. package/third_party/libwebm/webm_parser/src/var_int_parser.h +56 -0
  274. package/third_party/libwebm/webm_parser/src/video_parser.h +122 -0
  275. package/third_party/libwebm/webm_parser/src/virtual_block_parser.cc +72 -0
  276. package/third_party/libwebm/webm_parser/src/virtual_block_parser.h +69 -0
  277. package/third_party/libwebm/webm_parser/src/void_parser.cc +49 -0
  278. package/third_party/libwebm/webm_parser/src/void_parser.h +41 -0
  279. package/third_party/libwebm/webm_parser/src/webm_parser.cc +282 -0
  280. package/third_party/range-source/LICENSE +21 -0
  281. package/third_party/range-source/README.md +8 -0
  282. package/third_party/range-source/include/range_source.h +395 -0
  283. package/third_party/range-source/include/range_source_download.h +309 -0
@@ -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_SKIP_PARSER_H_
9
+ #define SRC_SKIP_PARSER_H_
10
+
11
+ #include <cstdint>
12
+
13
+ #include "src/element_parser.h"
14
+ #include "webm/callback.h"
15
+ #include "webm/reader.h"
16
+ #include "webm/status.h"
17
+
18
+ namespace webm {
19
+
20
+ // A simple parser that merely skips (via Reader::Skip) ahead in the stream
21
+ // until the element has been fully skipped.
22
+ class SkipParser : public ElementParser {
23
+ public:
24
+ Status Init(const ElementMetadata& metadata, std::uint64_t max_size) override;
25
+
26
+ Status Feed(Callback* callback, Reader* reader,
27
+ std::uint64_t* num_bytes_read) override;
28
+
29
+ private:
30
+ std::uint64_t num_bytes_remaining_;
31
+ };
32
+
33
+ } // namespace webm
34
+
35
+ #endif // SRC_SKIP_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_SLICES_PARSER_H_
9
+ #define SRC_SLICES_PARSER_H_
10
+
11
+ #include "src/master_value_parser.h"
12
+ #include "src/time_slice_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#Slices
20
+ // http://www.webmproject.org/docs/container/#Slices
21
+ class SlicesParser : public MasterValueParser<Slices> {
22
+ public:
23
+ SlicesParser()
24
+ : MasterValueParser<Slices>(
25
+ MakeChild<TimeSliceParser>(Id::kTimeSlice, &Slices::slices)) {}
26
+ };
27
+
28
+ } // namespace webm
29
+
30
+ #endif // SRC_SLICES_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_TAG_PARSER_H_
9
+ #define SRC_TAG_PARSER_H_
10
+
11
+ #include "src/master_value_parser.h"
12
+ #include "src/simple_tag_parser.h"
13
+ #include "src/targets_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#Tag
21
+ // http://www.webmproject.org/docs/container/#Tag
22
+ class TagParser : public MasterValueParser<Tag> {
23
+ public:
24
+ TagParser()
25
+ : MasterValueParser<Tag>(
26
+ MakeChild<TargetsParser>(Id::kTargets, &Tag::targets),
27
+ MakeChild<SimpleTagParser>(Id::kSimpleTag, &Tag::tags)) {}
28
+
29
+ protected:
30
+ Status OnParseCompleted(Callback* callback) override {
31
+ return callback->OnTag(metadata(Id::kTag), value());
32
+ }
33
+ };
34
+
35
+ } // namespace webm
36
+
37
+ #endif // SRC_TAG_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_TAGS_PARSER_H_
9
+ #define SRC_TAGS_PARSER_H_
10
+
11
+ #include "src/master_parser.h"
12
+ #include "src/tag_parser.h"
13
+ #include "webm/id.h"
14
+
15
+ namespace webm {
16
+
17
+ // Spec reference:
18
+ // http://matroska.org/technical/specs/index.html#Tags
19
+ // http://www.webmproject.org/docs/container/#Tags
20
+ class TagsParser : public MasterParser {
21
+ public:
22
+ TagsParser() : MasterParser(MakeChild<TagParser>(Id::kTag)) {}
23
+ };
24
+
25
+ } // namespace webm
26
+
27
+ #endif // SRC_TAGS_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_TARGETS_PARSER_H_
9
+ #define SRC_TARGETS_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 reference:
20
+ // http://matroska.org/technical/specs/index.html#Targets
21
+ // http://www.webmproject.org/docs/container/#Targets
22
+ class TargetsParser : public MasterValueParser<Targets> {
23
+ public:
24
+ TargetsParser()
25
+ : MasterValueParser<Targets>(
26
+ MakeChild<UnsignedIntParser>(Id::kTargetTypeValue,
27
+ &Targets::type_value),
28
+ MakeChild<StringParser>(Id::kTargetType, &Targets::type),
29
+ MakeChild<UnsignedIntParser>(Id::kTagTrackUid,
30
+ &Targets::track_uids)) {}
31
+ };
32
+
33
+ } // namespace webm
34
+
35
+ #endif // SRC_TARGETS_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_TIME_SLICE_PARSER_H_
9
+ #define SRC_TIME_SLICE_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#TimeSlice
20
+ // http://www.webmproject.org/docs/container/#TimeSlice
21
+ class TimeSliceParser : public MasterValueParser<TimeSlice> {
22
+ public:
23
+ TimeSliceParser()
24
+ : MasterValueParser<TimeSlice>(MakeChild<UnsignedIntParser>(
25
+ Id::kLaceNumber, &TimeSlice::lace_number)) {}
26
+ };
27
+
28
+ } // namespace webm
29
+
30
+ #endif // SRC_TIME_SLICE_PARSER_H_
@@ -0,0 +1,65 @@
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
+
9
+ #ifndef SRC_TRACK_ENTRY_PARSER_H_
10
+ #define SRC_TRACK_ENTRY_PARSER_H_
11
+
12
+ #include "src/audio_parser.h"
13
+ #include "src/bool_parser.h"
14
+ #include "src/byte_parser.h"
15
+ #include "src/content_encodings_parser.h"
16
+ #include "src/int_parser.h"
17
+ #include "src/master_value_parser.h"
18
+ #include "src/video_parser.h"
19
+ #include "webm/dom_types.h"
20
+ #include "webm/id.h"
21
+
22
+ namespace webm {
23
+
24
+ // Spec reference:
25
+ // http://matroska.org/technical/specs/index.html#TrackEntry
26
+ // http://www.webmproject.org/docs/container/#TrackEntry
27
+ class TrackEntryParser : public MasterValueParser<TrackEntry> {
28
+ public:
29
+ TrackEntryParser()
30
+ : MasterValueParser<TrackEntry>(
31
+ MakeChild<UnsignedIntParser>(Id::kTrackNumber,
32
+ &TrackEntry::track_number),
33
+ MakeChild<UnsignedIntParser>(Id::kTrackUid, &TrackEntry::track_uid),
34
+ MakeChild<IntParser<TrackType>>(Id::kTrackType,
35
+ &TrackEntry::track_type),
36
+ MakeChild<BoolParser>(Id::kFlagEnabled, &TrackEntry::is_enabled),
37
+ MakeChild<BoolParser>(Id::kFlagDefault, &TrackEntry::is_default),
38
+ MakeChild<BoolParser>(Id::kFlagForced, &TrackEntry::is_forced),
39
+ MakeChild<BoolParser>(Id::kFlagLacing, &TrackEntry::uses_lacing),
40
+ MakeChild<UnsignedIntParser>(Id::kDefaultDuration,
41
+ &TrackEntry::default_duration),
42
+ MakeChild<StringParser>(Id::kName, &TrackEntry::name),
43
+ MakeChild<StringParser>(Id::kLanguage, &TrackEntry::language),
44
+ MakeChild<StringParser>(Id::kCodecId, &TrackEntry::codec_id),
45
+ MakeChild<BinaryParser>(Id::kCodecPrivate,
46
+ &TrackEntry::codec_private),
47
+ MakeChild<StringParser>(Id::kCodecName, &TrackEntry::codec_name),
48
+ MakeChild<UnsignedIntParser>(Id::kCodecDelay,
49
+ &TrackEntry::codec_delay),
50
+ MakeChild<UnsignedIntParser>(Id::kSeekPreRoll,
51
+ &TrackEntry::seek_pre_roll),
52
+ MakeChild<VideoParser>(Id::kVideo, &TrackEntry::video),
53
+ MakeChild<AudioParser>(Id::kAudio, &TrackEntry::audio),
54
+ MakeChild<ContentEncodingsParser>(
55
+ Id::kContentEncodings, &TrackEntry::content_encodings)) {}
56
+
57
+ protected:
58
+ Status OnParseCompleted(Callback* callback) override {
59
+ return callback->OnTrackEntry(metadata(Id::kTrackEntry), value());
60
+ }
61
+ };
62
+
63
+ } // namespace webm
64
+
65
+ #endif // SRC_TRACK_ENTRY_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_TRACKS_PARSER_H_
9
+ #define SRC_TRACKS_PARSER_H_
10
+
11
+ #include "src/master_parser.h"
12
+ #include "src/track_entry_parser.h"
13
+ #include "webm/id.h"
14
+
15
+ namespace webm {
16
+
17
+ // Spec reference:
18
+ // http://matroska.org/technical/specs/index.html#Tracks
19
+ // http://www.webmproject.org/docs/container/#Tracks
20
+ class TracksParser : public MasterParser {
21
+ public:
22
+ TracksParser() : MasterParser(MakeChild<TrackEntryParser>(Id::kTrackEntry)) {}
23
+ };
24
+
25
+ } // namespace webm
26
+
27
+ #endif // SRC_TRACKS_PARSER_H_
@@ -0,0 +1,49 @@
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/unknown_parser.h"
9
+
10
+ #include <cassert>
11
+ #include <cstdint>
12
+
13
+ #include "webm/element.h"
14
+ #include "webm/reader.h"
15
+ #include "webm/status.h"
16
+
17
+ namespace webm {
18
+
19
+ Status UnknownParser::Init(const ElementMetadata& metadata,
20
+ std::uint64_t max_size) {
21
+ assert(metadata.size == kUnknownElementSize || metadata.size <= max_size);
22
+
23
+ if (metadata.size == kUnknownElementSize) {
24
+ return Status(Status::kIndefiniteUnknownElement);
25
+ }
26
+
27
+ metadata_ = metadata;
28
+ bytes_remaining_ = metadata.size;
29
+
30
+ return Status(Status::kOkCompleted);
31
+ }
32
+
33
+ Status UnknownParser::Feed(Callback* callback, Reader* reader,
34
+ std::uint64_t* num_bytes_read) {
35
+ assert(callback != nullptr);
36
+ assert(reader != nullptr);
37
+ assert(num_bytes_read != nullptr);
38
+
39
+ const std::uint64_t original_bytes_remaining = bytes_remaining_;
40
+ const Status status =
41
+ callback->OnUnknownElement(metadata_, reader, &bytes_remaining_);
42
+ assert(bytes_remaining_ <= original_bytes_remaining);
43
+
44
+ *num_bytes_read = original_bytes_remaining - bytes_remaining_;
45
+
46
+ return status;
47
+ }
48
+
49
+ } // namespace webm
@@ -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_UNKNOWN_PARSER_H_
9
+ #define SRC_UNKNOWN_PARSER_H_
10
+
11
+ #include <cstdint>
12
+
13
+ #include "src/element_parser.h"
14
+ #include "webm/callback.h"
15
+ #include "webm/reader.h"
16
+ #include "webm/status.h"
17
+
18
+ namespace webm {
19
+
20
+ // Parses unknown elements by delegating to Callback::OnUnknownElement.
21
+ class UnknownParser : public ElementParser {
22
+ public:
23
+ Status Init(const ElementMetadata& metadata, std::uint64_t max_size) override;
24
+
25
+ Status Feed(Callback* callback, Reader* reader,
26
+ std::uint64_t* num_bytes_read) override;
27
+
28
+ private:
29
+ // The metadata for this element.
30
+ ElementMetadata metadata_;
31
+
32
+ // The number of bytes remaining that have not been read in the element.
33
+ std::uint64_t bytes_remaining_;
34
+ };
35
+
36
+ } // namespace webm
37
+
38
+ #endif // SRC_UNKNOWN_PARSER_H_
@@ -0,0 +1,71 @@
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/var_int_parser.h"
9
+
10
+ #include <cassert>
11
+ #include <cstdint>
12
+ #include <limits>
13
+
14
+ #include "src/bit_utils.h"
15
+ #include "src/parser_utils.h"
16
+ #include "webm/reader.h"
17
+ #include "webm/status.h"
18
+
19
+ namespace webm {
20
+
21
+ // Spec references:
22
+ // http://matroska.org/technical/specs/index.html#EBML_ex
23
+ // https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#variable-size-integer
24
+ Status VarIntParser::Feed(Callback* callback, Reader* reader,
25
+ std::uint64_t* num_bytes_read) {
26
+ assert(callback != nullptr);
27
+ assert(reader != nullptr);
28
+ assert(num_bytes_read != nullptr);
29
+ assert(num_bytes_remaining_ != 0);
30
+
31
+ *num_bytes_read = 0;
32
+
33
+ if (num_bytes_remaining_ == -1) {
34
+ std::uint8_t first_byte;
35
+ const Status status = ReadByte(reader, &first_byte);
36
+ if (!status.completed_ok()) {
37
+ return status;
38
+ }
39
+ ++*num_bytes_read;
40
+
41
+ // The first byte must have a marker bit set to indicate how many octets are
42
+ // used.
43
+ if (first_byte == 0) {
44
+ return Status(Status::kInvalidElementValue);
45
+ }
46
+
47
+ total_data_bytes_ = CountLeadingZeros(first_byte);
48
+ num_bytes_remaining_ = total_data_bytes_;
49
+
50
+ value_ = first_byte;
51
+ }
52
+
53
+ std::uint64_t local_num_bytes_read;
54
+ const Status status = AccumulateIntegerBytes(num_bytes_remaining_, reader,
55
+ &value_, &local_num_bytes_read);
56
+ *num_bytes_read += local_num_bytes_read;
57
+ num_bytes_remaining_ -= static_cast<int>(local_num_bytes_read);
58
+
59
+ if (!status.completed_ok()) {
60
+ return status;
61
+ }
62
+
63
+ // Clear the marker bit.
64
+ constexpr std::uint64_t all_bits = std::numeric_limits<std::uint64_t>::max();
65
+ const std::uint64_t data_bits = all_bits >> (57 - 7 * total_data_bytes_);
66
+ value_ &= data_bits;
67
+
68
+ return Status(Status::kOkCompleted);
69
+ }
70
+
71
+ } // namespace webm
@@ -0,0 +1,56 @@
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_VAR_INT_PARSER_H_
9
+ #define SRC_VAR_INT_PARSER_H_
10
+
11
+ #include <cassert>
12
+ #include <cstdint>
13
+
14
+ #include "src/parser.h"
15
+ #include "webm/callback.h"
16
+ #include "webm/reader.h"
17
+ #include "webm/status.h"
18
+
19
+ namespace webm {
20
+
21
+ class VarIntParser : public Parser {
22
+ public:
23
+ VarIntParser() = default;
24
+ VarIntParser(VarIntParser&&) = default;
25
+ VarIntParser& operator=(VarIntParser&&) = default;
26
+
27
+ VarIntParser(const VarIntParser&) = delete;
28
+ VarIntParser& operator=(const VarIntParser&) = delete;
29
+
30
+ Status Feed(Callback* callback, Reader* reader,
31
+ std::uint64_t* num_bytes_read) override;
32
+
33
+ // Gets the parsed value. This must not be called until the parse had been
34
+ // successfully completed.
35
+ std::uint64_t value() const {
36
+ assert(num_bytes_remaining_ == 0);
37
+ return value_;
38
+ }
39
+
40
+ // Gets the number of bytes which were used to encode the integer value in the
41
+ // byte stream. This must not be called until the parse had been successfully
42
+ // completed.
43
+ int encoded_length() const {
44
+ assert(num_bytes_remaining_ == 0);
45
+ return total_data_bytes_ + 1;
46
+ }
47
+
48
+ private:
49
+ int num_bytes_remaining_ = -1;
50
+ int total_data_bytes_;
51
+ std::uint64_t value_;
52
+ };
53
+
54
+ } // namespace webm
55
+
56
+ #endif // SRC_VAR_INT_PARSER_H_
@@ -0,0 +1,122 @@
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_VIDEO_PARSER_H_
9
+ #define SRC_VIDEO_PARSER_H_
10
+
11
+ #include <cassert>
12
+ #include <cstdint>
13
+
14
+ #include "src/bool_parser.h"
15
+ #include "src/colour_parser.h"
16
+ #include "src/float_parser.h"
17
+ #include "src/int_parser.h"
18
+ #include "src/master_value_parser.h"
19
+ #include "src/projection_parser.h"
20
+ #include "webm/callback.h"
21
+ #include "webm/dom_types.h"
22
+ #include "webm/id.h"
23
+ #include "webm/reader.h"
24
+ #include "webm/status.h"
25
+
26
+ namespace webm {
27
+
28
+ // Spec reference:
29
+ // http://matroska.org/technical/specs/index.html#Video
30
+ // http://www.webmproject.org/docs/container/#Video
31
+ class VideoParser : public MasterValueParser<Video> {
32
+ public:
33
+ VideoParser()
34
+ : MasterValueParser<Video>(
35
+ MakeChild<IntParser<FlagInterlaced>>(Id::kFlagInterlaced,
36
+ &Video::interlaced),
37
+ MakeChild<IntParser<StereoMode>>(Id::kStereoMode,
38
+ &Video::stereo_mode),
39
+ MakeChild<UnsignedIntParser>(Id::kAlphaMode, &Video::alpha_mode),
40
+ MakeChild<UnsignedIntParser>(Id::kPixelWidth, &Video::pixel_width),
41
+ MakeChild<UnsignedIntParser>(Id::kPixelHeight,
42
+ &Video::pixel_height),
43
+ MakeChild<UnsignedIntParser>(Id::kPixelCropBottom,
44
+ &Video::pixel_crop_bottom),
45
+ MakeChild<UnsignedIntParser>(Id::kPixelCropTop,
46
+ &Video::pixel_crop_top),
47
+ MakeChild<UnsignedIntParser>(Id::kPixelCropLeft,
48
+ &Video::pixel_crop_left),
49
+ MakeChild<UnsignedIntParser>(Id::kPixelCropRight,
50
+ &Video::pixel_crop_right),
51
+ MakeChild<UnsignedIntParser>(Id::kDisplayWidth,
52
+ &Video::display_width)
53
+ .NotifyOnParseComplete(),
54
+ MakeChild<UnsignedIntParser>(Id::kDisplayHeight,
55
+ &Video::display_height)
56
+ .NotifyOnParseComplete(),
57
+ MakeChild<IntParser<DisplayUnit>>(Id::kDisplayUnit,
58
+ &Video::display_unit),
59
+ MakeChild<IntParser<AspectRatioType>>(Id::kAspectRatioType,
60
+ &Video::aspect_ratio_type),
61
+ MakeChild<FloatParser>(Id::kFrameRate, &Video::frame_rate),
62
+ MakeChild<ColourParser>(Id::kColour, &Video::colour),
63
+ MakeChild<ProjectionParser>(Id::kProjection, &Video::projection)) {}
64
+
65
+ Status Init(const ElementMetadata& metadata,
66
+ std::uint64_t max_size) override {
67
+ display_width_has_value_ = false;
68
+ display_height_has_value_ = false;
69
+
70
+ return MasterValueParser::Init(metadata, max_size);
71
+ }
72
+
73
+ void InitAfterSeek(const Ancestory& child_ancestory,
74
+ const ElementMetadata& child_metadata) override {
75
+ display_width_has_value_ = false;
76
+ display_height_has_value_ = false;
77
+
78
+ return MasterValueParser::InitAfterSeek(child_ancestory, child_metadata);
79
+ }
80
+
81
+ Status Feed(Callback* callback, Reader* reader,
82
+ std::uint64_t* num_bytes_read) override {
83
+ const Status status =
84
+ MasterValueParser::Feed(callback, reader, num_bytes_read);
85
+ if (status.completed_ok()) {
86
+ FixMissingDisplaySize();
87
+ }
88
+ return status;
89
+ }
90
+
91
+ protected:
92
+ void OnChildParsed(const ElementMetadata& metadata) override {
93
+ assert(metadata.id == Id::kDisplayWidth ||
94
+ metadata.id == Id::kDisplayHeight);
95
+
96
+ if (metadata.id == Id::kDisplayWidth) {
97
+ display_width_has_value_ = metadata.size > 0;
98
+ } else {
99
+ display_height_has_value_ = metadata.size > 0;
100
+ }
101
+ }
102
+
103
+ private:
104
+ bool display_width_has_value_;
105
+ bool display_height_has_value_;
106
+
107
+ void FixMissingDisplaySize() {
108
+ if (!display_width_has_value_) {
109
+ *mutable_value()->display_width.mutable_value() =
110
+ value().pixel_width.value();
111
+ }
112
+
113
+ if (!display_height_has_value_) {
114
+ *mutable_value()->display_height.mutable_value() =
115
+ value().pixel_height.value();
116
+ }
117
+ }
118
+ };
119
+
120
+ } // namespace webm
121
+
122
+ #endif // SRC_VIDEO_PARSER_H_