react-native-alpha-video 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +903 -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 +85 -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 +1966 -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 +92 -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 +92 -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 +150 -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 +110 -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 +60 -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,49 @@
1
+ #!/bin/bash
2
+ # Builds the codec modules' binary targets in Package.swift, one xcframework per codec library:
3
+ # prebuilt/AlphaVideoLibvpx.xcframework libvpx, for AlphaVideoVPX
4
+ # prebuilt/AlphaVideoDav1d.xcframework dav1d, for AlphaVideoAV1
5
+ # from the static libraries that build_codecs_ios.sh leaves in prebuilt/ios and
6
+ # prebuilt/ios-simulator.
7
+ #
8
+ # Also writes a .zip of each and prints its SwiftPM checksum. Those zips are the files to attach
9
+ # to the GitHub Release; Package.swift's checksums must match them byte for byte.
10
+
11
+ set -euo pipefail
12
+
13
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
14
+ PREBUILT="$ROOT/prebuilt"
15
+ WORK="$(mktemp -d)"
16
+ trap 'rm -rf "$WORK"' EXIT
17
+
18
+ # build_xcframework <name> <library> <header directory>
19
+ build_xcframework() {
20
+ local name="$1" library="$2" headers="$3"
21
+ local out="$PREBUILT/$name.xcframework"
22
+ local args=()
23
+ mkdir -p "$WORK/$name/include"
24
+ cp -R "$PREBUILT/include/$headers" "$WORK/$name/include/"
25
+ for slice in ios ios-simulator; do
26
+ local lib="$PREBUILT/$slice/lib/lib$library.a"
27
+ if [ ! -f "$lib" ]; then
28
+ echo "Missing $lib: run scripts/build_codecs_ios.sh first" >&2
29
+ exit 1
30
+ fi
31
+ args+=(-library "$lib" -headers "$WORK/$name/include")
32
+ done
33
+
34
+ rm -rf "$out"
35
+ xcodebuild -create-xcframework "${args[@]}" -output "$out" >/dev/null
36
+
37
+ (
38
+ cd "$PREBUILT"
39
+ # Fixed times, so rebuilding from the same libraries gives the same zip and checksum.
40
+ find "$name.xcframework" -exec touch -h -t 202601010000 {} +
41
+ rm -f "$name.xcframework.zip"
42
+ find "$name.xcframework" | LC_ALL=C sort | zip -q -X -D -9 "$name.xcframework.zip" -@
43
+ echo "Wrote $out and $out.zip"
44
+ echo " checksum: $(swift package compute-checksum "$name.xcframework.zip")"
45
+ )
46
+ }
47
+
48
+ build_xcframework AlphaVideoLibvpx vpx vpx
49
+ build_xcframework AlphaVideoDav1d dav1d dav1d
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+ #
3
+ # fetch-prebuilt.sh [--force]
4
+ #
5
+ # Downloads the prebuilt libvpx + dav1d static libraries into prebuilt/ from this repo's GitHub
6
+ # Release. A git clone needs them to build; the npm package already contains them. To build them
7
+ # from source instead, run build_codecs_android.sh and build_codecs_ios.sh.
8
+ #
9
+ # Leaves an existing prebuilt/ alone unless --force is given.
10
+ #
11
+
12
+ set -euo pipefail
13
+
14
+ RELEASE="v1.0.0"
15
+ ARCHIVE="prebuilt-libvpx1.14.0-dav1d1.5.1.tar.gz"
16
+ SHA256="b95e75aed9a75c41f92388a31cb3e1e311ab44f81d02140c4fbf5e570865195e"
17
+ URL="https://github.com/MediaCacheDev/alpha-video/releases/download/$RELEASE/$ARCHIVE"
18
+
19
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
20
+ PREBUILT="$ROOT/prebuilt"
21
+
22
+ sha256() {
23
+ if command -v sha256sum > /dev/null; then
24
+ sha256sum "$1" | cut -d' ' -f1
25
+ else
26
+ shasum -a 256 "$1" | cut -d' ' -f1
27
+ fi
28
+ }
29
+
30
+ if [ "${1:-}" != "--force" ] && [ -d "$PREBUILT/android" ] && [ -d "$PREBUILT/ios/lib" ]; then
31
+ echo "prebuilt/ is already there (--force replaces it)"
32
+ exit 0
33
+ fi
34
+
35
+ TMP="$(mktemp -d)"
36
+ trap 'rm -rf "$TMP"' EXIT
37
+
38
+ echo "⬇️ $URL"
39
+ curl -fL --retry 3 -o "$TMP/$ARCHIVE" "$URL"
40
+ ACTUAL="$(sha256 "$TMP/$ARCHIVE")"
41
+ if [ "$ACTUAL" != "$SHA256" ]; then
42
+ echo "❌ Checksum mismatch for $ARCHIVE: expected $SHA256, got $ACTUAL" >&2
43
+ exit 1
44
+ fi
45
+
46
+ rm -rf "$PREBUILT/android" "$PREBUILT/ios" "$PREBUILT/ios-simulator" "$PREBUILT/include"
47
+ tar -xzf "$TMP/$ARCHIVE" -C "$ROOT"
48
+ echo "✅ prebuilt/ (libvpx 1.14.0, dav1d 1.5.1)"
@@ -0,0 +1,107 @@
1
+ #!/bin/bash
2
+ #
3
+ # package_release.sh
4
+ #
5
+ # Collects the GitHub Release assets for v<version> (package.json) in dist/release-v<version>/:
6
+ #
7
+ # prebuilt-libvpx<V>-dav1d<D>.tar.gz prebuilt/ for Android and iOS, what fetch-prebuilt.sh unpacks
8
+ # AlphaVideoLibvpx.xcframework.zip Package.swift's binary targets, as built by
9
+ # AlphaVideoDav1d.xcframework.zip build_xcframework.sh
10
+ # alpha-video-<version>-ios.zip the CocoaPods source (alpha-video.podspec): the iOS sources,
11
+ # the codec modules, libwebm's parser, range-source's
12
+ # headers and both xcframeworks
13
+ # SHA256SUMS
14
+ #
15
+ # Uploads nothing. Afterwards, fetch-prebuilt.sh's SHA256 must be the prebuilt archive's,
16
+ # alpha-video.podspec's sha256 the pod zip's, and Package.swift's checksums the xcframework zips';
17
+ # the script stops or warns when they differ.
18
+ #
19
+
20
+ set -euo pipefail
21
+
22
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
23
+ LIBVPX_VERSION="1.14.0"
24
+ DAV1D_VERSION="1.5.1"
25
+
26
+ VERSION="$(node -p "require('$ROOT/package.json').version")"
27
+ OUT="$ROOT/dist/release-v$VERSION"
28
+ PREBUILT_ARCHIVE="prebuilt-libvpx$LIBVPX_VERSION-dav1d$DAV1D_VERSION.tar.gz"
29
+
30
+ sha256() {
31
+ shasum -a 256 "$1" | cut -d' ' -f1
32
+ }
33
+
34
+ for dir in android ios/lib ios-simulator/lib include; do
35
+ if [ ! -d "$ROOT/prebuilt/$dir" ]; then
36
+ echo "❌ prebuilt/$dir is missing: run the build_codecs_*.sh scripts" >&2
37
+ exit 1
38
+ fi
39
+ done
40
+ XCFRAMEWORKS="AlphaVideoLibvpx AlphaVideoDav1d"
41
+ for name in $XCFRAMEWORKS; do
42
+ ZIP="$ROOT/prebuilt/$name.xcframework.zip"
43
+ if [ ! -f "$ZIP" ]; then
44
+ echo "❌ $ZIP is missing: run scripts/build_xcframework.sh" >&2
45
+ exit 1
46
+ fi
47
+ if ! grep -q "codecLibrary(\"$name\", checksum: \"$(sha256 "$ZIP")\")" "$ROOT/Package.swift"; then
48
+ echo "❌ Package.swift's checksum for $name is not $name.xcframework.zip's ($(sha256 "$ZIP"))" >&2
49
+ exit 1
50
+ fi
51
+ done
52
+
53
+ rm -rf "$OUT"
54
+ mkdir -p "$OUT"
55
+
56
+ # The archive carries the notices, since it is a copy of the libraries on its own.
57
+ STAGE="$(mktemp -d)"
58
+ trap 'rm -rf "$STAGE"' EXIT
59
+ mkdir -p "$STAGE/prebuilt/ios" "$STAGE/prebuilt/ios-simulator"
60
+ cp -R "$ROOT/prebuilt/android" "$ROOT/prebuilt/include" "$STAGE/prebuilt/"
61
+ cp -R "$ROOT/prebuilt/ios/lib" "$STAGE/prebuilt/ios/"
62
+ cp -R "$ROOT/prebuilt/ios-simulator/lib" "$STAGE/prebuilt/ios-simulator/"
63
+ cp "$ROOT/THIRD_PARTY_NOTICES.md" "$STAGE/prebuilt/"
64
+ cp -R "$ROOT/licenses" "$STAGE/prebuilt/"
65
+ find "$STAGE" -name .DS_Store -delete
66
+ # Reproducible, so packaging the same libraries again keeps fetch-prebuilt.sh's checksum valid:
67
+ # fixed times, sorted entries, no owners or macOS metadata, no gzip timestamp.
68
+ find "$STAGE/prebuilt" -exec touch -h -t 202601010000 {} +
69
+ (cd "$STAGE" && find prebuilt | LC_ALL=C sort) \
70
+ | COPYFILE_DISABLE=1 tar -c -n -T - -C "$STAGE" --no-mac-metadata \
71
+ --uid 0 --gid 0 --uname "" --gname "" -f - \
72
+ | gzip -n -9 > "$OUT/$PREBUILT_ARCHIVE"
73
+
74
+ # The CocoaPods source: prebuilt/ isn't in git, so the pod downloads the sources and the codecs
75
+ # together. Reproducible in the same way, for alpha-video.podspec's sha256.
76
+ POD="$STAGE/pod"
77
+ mkdir -p "$POD/cpp" "$POD/ios/Sources" "$POD/third_party"
78
+ cp "$ROOT"/cpp/*.h "$ROOT"/cpp/*.cpp "$POD/cpp/"
79
+ rm "$POD/cpp/WebMAlphaPlayer_jni.cpp"
80
+ cp -R "$ROOT/ios/Sources/AlphaVideo" "$ROOT/ios/Sources/AlphaVideoVPX" "$ROOT/ios/Sources/AlphaVideoAV1" "$POD/ios/Sources/"
81
+ cp -R "$ROOT/codecs" "$POD/"
82
+ cp -R "$ROOT/third_party/libwebm" "$ROOT/third_party/range-source" "$POD/third_party/"
83
+ for name in $XCFRAMEWORKS; do
84
+ cp -R "$ROOT/prebuilt/$name.xcframework" "$POD/"
85
+ done
86
+ cp -R "$ROOT/LICENSE" "$ROOT/THIRD_PARTY_NOTICES.md" "$ROOT/licenses" "$POD/"
87
+ find "$POD" -name .DS_Store -delete
88
+ find "$POD" -exec touch -h -t 202601010000 {} +
89
+ POD_ZIP="alpha-video-$VERSION-ios.zip"
90
+ (cd "$POD" && find . -mindepth 1 | sed 's#^\./##' | LC_ALL=C sort | zip -q -X -D -9 "$OUT/$POD_ZIP" -@)
91
+
92
+ for name in $XCFRAMEWORKS; do
93
+ cp "$ROOT/prebuilt/$name.xcframework.zip" "$OUT/"
94
+ done
95
+
96
+ (cd "$OUT" && shasum -a 256 -- * > SHA256SUMS)
97
+ echo "📦 $OUT"
98
+ sed 's/^/ /' "$OUT/SHA256SUMS"
99
+
100
+ PREBUILT_SHA256="$(sha256 "$OUT/$PREBUILT_ARCHIVE")"
101
+ if ! grep -q "^SHA256=\"$PREBUILT_SHA256\"" "$ROOT/scripts/fetch-prebuilt.sh"; then
102
+ echo "⚠️ Set SHA256=\"$PREBUILT_SHA256\" in scripts/fetch-prebuilt.sh before uploading"
103
+ fi
104
+ POD_SHA256="$(sha256 "$OUT/$POD_ZIP")"
105
+ if ! grep -q ":sha256 => '$POD_SHA256'" "$ROOT/alpha-video.podspec"; then
106
+ echo "⚠️ Set :sha256 => '$POD_SHA256' in alpha-video.podspec before uploading"
107
+ fi
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+ #
3
+ # publish-android.sh [local|central]
4
+ #
5
+ # Builds the standalone Android library in android/ and publishes it as
6
+ # dev.mediacache:alpha-video:<version>, the version in android/build.gradle, with the codec
7
+ # modules alpha-video-vpx (android/vpx, libvpx) and alpha-video-av1 (android/av1, dav1d). Needs
8
+ # libvpx and dav1d in prebuilt/android (build_codecs_android.sh, or fetch-prebuilt.sh).
9
+ # dev.mediacache:range-source, which the player depends on, comes from Maven Central.
10
+ #
11
+ # local publishToMavenLocal (~/.m2), unsigned unless a key is set. The default.
12
+ # central signs, bundles and uploads to the Maven Central Portal. Needs:
13
+ # ORG_GRADLE_PROJECT_mavenCentralUsername / …Password Central Portal user token
14
+ # ORG_GRADLE_PROJECT_signingInMemoryKey armored secret key
15
+ # ORG_GRADLE_PROJECT_signingInMemoryKeyPassword
16
+ # ORG_GRADLE_PROJECT_signingInMemoryKeyId optional
17
+ # The deployment waits in the portal for you to press Publish, unless
18
+ # PUBLISHING_TYPE=AUTOMATIC.
19
+ #
20
+
21
+ set -euo pipefail
22
+
23
+ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
24
+ GRADLE_DIR="$ROOT_DIR/android"
25
+ MODE="${1:-local}"
26
+ VERSION="$(sed -n "s/^version = '\(.*\)'/\1/p" "$GRADLE_DIR/build.gradle")"
27
+ GRADLE=("$GRADLE_DIR/gradlew" -p "$GRADLE_DIR" -q)
28
+
29
+ if [ -z "$VERSION" ]; then
30
+ echo "❌ No version = '…' line in android/build.gradle"
31
+ exit 1
32
+ fi
33
+ if [ ! -d "$ROOT_DIR/prebuilt/android" ]; then
34
+ echo "❌ prebuilt/android is missing: run scripts/build_codecs_android.sh"
35
+ exit 1
36
+ fi
37
+
38
+ case "$MODE" in
39
+ local)
40
+ "${GRADLE[@]}" publishToMavenLocal
41
+ echo "✅ dev.mediacache:alpha-video, -vpx and -av1 $VERSION in ~/.m2/repository"
42
+ ;;
43
+ central)
44
+ for var in ORG_GRADLE_PROJECT_mavenCentralUsername ORG_GRADLE_PROJECT_mavenCentralPassword \
45
+ ORG_GRADLE_PROJECT_signingInMemoryKey ORG_GRADLE_PROJECT_signingInMemoryKeyPassword; do
46
+ if [ -z "${!var:-}" ]; then
47
+ echo "❌ $var is not set"
48
+ exit 1
49
+ fi
50
+ done
51
+
52
+ STAGING="$GRADLE_DIR/build/staging-repo"
53
+ rm -rf "$STAGING"
54
+ "${GRADLE[@]}" publishReleasePublicationToStagingRepository
55
+
56
+ VERSION_DIRS=()
57
+ for artifact in alpha-video alpha-video-vpx alpha-video-av1; do
58
+ VERSION_DIRS+=("dev/mediacache/$artifact/$VERSION")
59
+ done
60
+ for dir in "${VERSION_DIRS[@]}"; do
61
+ if ! ls "$STAGING/$dir"/*.aar.asc > /dev/null 2>&1; then
62
+ echo "❌ $dir was not signed"
63
+ exit 1
64
+ fi
65
+ done
66
+
67
+ BUNDLE="$GRADLE_DIR/build/alpha-video-$VERSION-bundle.zip"
68
+ rm -f "$BUNDLE"
69
+ (cd "$STAGING" && zip -qr "$BUNDLE" "${VERSION_DIRS[@]}")
70
+ echo "📦 $BUNDLE"
71
+ unzip -l "$BUNDLE" | awk 'NR > 3 { print " " $4 }' | sed '/^ $/d'
72
+
73
+ TOKEN="$(printf '%s:%s' "$ORG_GRADLE_PROJECT_mavenCentralUsername" "$ORG_GRADLE_PROJECT_mavenCentralPassword" | base64 | tr -d "\n")"
74
+ DEPLOYMENT_ID="$(curl --fail-with-body -sS \
75
+ -H "Authorization: Bearer $TOKEN" \
76
+ -F "bundle=@$BUNDLE" \
77
+ "https://central.sonatype.com/api/v1/publisher/upload?name=alpha-video-$VERSION&publishingType=${PUBLISHING_TYPE:-USER_MANAGED}")"
78
+ echo "⬆️ Uploaded, deployment $DEPLOYMENT_ID"
79
+ echo " Watch https://central.sonatype.com/publishing/deployments"
80
+ ;;
81
+ *)
82
+ echo "Usage: $0 [local|central]"
83
+ exit 1
84
+ ;;
85
+ esac
@@ -0,0 +1,47 @@
1
+ #!/bin/bash
2
+ # Copies range-source's native headers (its C interface, and the basic input) from a range-source
3
+ # checkout into third_party/range-source, and records its commit there. The add-on itself is a
4
+ # dependency (dev.mediacache:range-source, the RangeSource SwiftPM product, the range-source pod).
5
+ #
6
+ # scripts/vendor_range_source.sh [path to range-source]
7
+ #
8
+ # Without a path it looks for a checkout beside this repository, or one folder further up.
9
+ set -euo pipefail
10
+
11
+ PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
12
+ if [ $# -ge 1 ]; then
13
+ SOURCE_DIR="$1"
14
+ else
15
+ SOURCE_DIR=""
16
+ for candidate in "$PROJECT_DIR/../range-source" "$PROJECT_DIR/../../range-source"; do
17
+ if [ -d "$candidate/native/include" ]; then SOURCE_DIR="$candidate"; break; fi
18
+ done
19
+ fi
20
+ if [ -z "$SOURCE_DIR" ] || [ ! -d "$SOURCE_DIR/native/include" ]; then
21
+ echo "No range-source checkout found${SOURCE_DIR:+ at $SOURCE_DIR}; pass its path." >&2
22
+ exit 1
23
+ fi
24
+ SOURCE_DIR="$(cd "$SOURCE_DIR" && pwd)"
25
+ DEST="$PROJECT_DIR/third_party/range-source"
26
+
27
+ COMMIT="$(git -C "$SOURCE_DIR" rev-parse HEAD)"
28
+ if [ -n "$(git -C "$SOURCE_DIR" status --porcelain -- native/include)" ]; then
29
+ COMMIT="$COMMIT, with uncommitted changes"
30
+ fi
31
+
32
+ rm -rf "$DEST/include" "$DEST/src"
33
+ mkdir -p "$DEST/include"
34
+ cp "$SOURCE_DIR"/native/include/*.h "$DEST/include/"
35
+ cp "$SOURCE_DIR/LICENSE" "$DEST/LICENSE"
36
+
37
+ cat > "$DEST/README.md" <<EOF
38
+ # range-source (native)
39
+
40
+ \`include/\` is \`native/include\` from [range-source](https://github.com/MediaCacheDev/range-source), unmodified, at commit \`$COMMIT\`. MIT, by the same author as this repository.
41
+
42
+ - \`include/range_source.h\` is the add-on's C interface, a table of functions, with a C++ wrapper over it. The player finds the add-on at runtime and reads URLs and data sources through it (\`cpp/RangeSourceClient.h\`).
43
+ - \`include/range_source_download.h\` is the basic input, for when the add-on isn't there: a URL downloaded whole into a temporary file, read as it arrives.
44
+
45
+ To update, run \`scripts/vendor_range_source.sh\` against a newer checkout. Its tests live in that repository (\`native/test\`).
46
+ EOF
47
+ echo "Vendored range-source's headers at $COMMIT"
@@ -0,0 +1,5 @@
1
+ # Names should be added to this file like so:
2
+ # Name or Organization <email address>
3
+
4
+ Google Inc.
5
+ Elijah Cirioli <eli.cirioli@gmail.com>
@@ -0,0 +1,30 @@
1
+ Copyright (c) 2010, Google Inc. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in
12
+ the documentation and/or other materials provided with the
13
+ distribution.
14
+
15
+ * Neither the name of Google nor the names of its contributors may
16
+ be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
@@ -0,0 +1,23 @@
1
+ Additional IP Rights Grant (Patents)
2
+ ------------------------------------
3
+
4
+ "These implementations" means the copyrightable works that implement the WebM
5
+ codecs distributed by Google as part of the WebM Project.
6
+
7
+ Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
8
+ royalty-free, irrevocable (except as stated in this section) patent license to
9
+ make, have made, use, offer to sell, sell, import, transfer, and otherwise
10
+ run, modify and propagate the contents of these implementations of WebM, where
11
+ such license applies only to those patent claims, both currently owned by
12
+ Google and acquired in the future, licensable by Google that are necessarily
13
+ infringed by these implementations of WebM. This grant does not include claims
14
+ that would be infringed only as a consequence of further modification of these
15
+ implementations. If you or your agent or exclusive licensee institute or order
16
+ or agree to the institution of patent litigation or any other patent
17
+ enforcement activity against any entity (including a cross-claim or
18
+ counterclaim in a lawsuit) alleging that any of these implementations of WebM
19
+ or any code incorporated within any of these implementations of WebM
20
+ constitute direct or contributory patent infringement, or inducement of
21
+ patent infringement, then any patent rights granted to you under this License
22
+ for these implementations of WebM shall terminate as of the date such
23
+ litigation is filed.
@@ -0,0 +1,7 @@
1
+ # libwebm's WebM parser
2
+
3
+ `webm_parser/` is `webm_parser/include` and `webm_parser/src` from [libwebm](https://chromium.googlesource.com/webm/libwebm), unmodified, at commit `6184f4484a826724b5293837134ab9492261b941` (21 April 2026). BSD licence: `LICENSE.TXT`, with the patent grant in `PATENTS.TXT`.
4
+
5
+ The C++ core's demuxer (`cpp/AlphaDemuxer.cpp`) reads WebM with it on Android and iOS. Its sources compile with the core's, with `webm_parser/` and `webm_parser/include` on the include path.
6
+
7
+ To update, copy the two directories from a newer libwebm checkout and change the commit above.
@@ -0,0 +1,138 @@
1
+ // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2
+ //
3
+ // Use of this source code is governed by a BSD-style license
4
+ // that can be found in the LICENSE file in the root of the source
5
+ // tree. An additional intellectual property rights grant can be found
6
+ // in the file PATENTS. All contributing project authors may
7
+ // be found in the AUTHORS file in the root of the source tree.
8
+ #ifndef INCLUDE_WEBM_BUFFER_READER_H_
9
+ #define INCLUDE_WEBM_BUFFER_READER_H_
10
+
11
+ #include <cstddef>
12
+ #include <cstdint>
13
+ #include <initializer_list>
14
+ #include <vector>
15
+
16
+ #include "./reader.h"
17
+ #include "./status.h"
18
+
19
+ /**
20
+ \file
21
+ A `Reader` implementation that reads from a `std::vector<std::uint8_t>`.
22
+ */
23
+
24
+ namespace webm {
25
+
26
+ /**
27
+ \addtogroup PUBLIC_API
28
+ @{
29
+ */
30
+
31
+ /**
32
+ A simple reader that reads data from a buffer of bytes.
33
+ */
34
+ class BufferReader : public Reader {
35
+ public:
36
+ /**
37
+ Constructs a new, empty reader.
38
+ */
39
+ BufferReader() = default;
40
+
41
+ /**
42
+ Constructs a new reader by copying the provided reader into the new reader.
43
+
44
+ \param other The source reader to copy.
45
+ */
46
+ BufferReader(const BufferReader& other) = default;
47
+
48
+ /**
49
+ Copies the provided reader into this reader.
50
+
51
+ \param other The source reader to copy. May be equal to `*this`, in which
52
+ case this is a no-op.
53
+ \return `*this`.
54
+ */
55
+ BufferReader& operator=(const BufferReader& other) = default;
56
+
57
+ /**
58
+ Constructs a new reader by moving the provided reader into the new reader.
59
+
60
+ \param other The source reader to move. After moving, it will be reset to an
61
+ empty stream.
62
+ */
63
+ BufferReader(BufferReader&&);
64
+
65
+ /**
66
+ Moves the provided reader into this reader.
67
+
68
+ \param other The source reader to move. After moving, it will be reset to an
69
+ empty stream. May be equal to `*this`, in which case this is a no-op.
70
+ \return `*this`.
71
+ */
72
+ BufferReader& operator=(BufferReader&&);
73
+
74
+ /**
75
+ Creates a new `BufferReader` populated with the provided bytes.
76
+
77
+ \param bytes Bytes that are assigned to the internal buffer and used as the
78
+ source which is read from.
79
+ */
80
+ BufferReader(std::initializer_list<std::uint8_t> bytes);
81
+
82
+ /**
83
+ Creates a new `BufferReader` populated with the provided data.
84
+
85
+ \param vector A vector of bytes that is copied to the internal buffer and
86
+ used as the source which is read from.
87
+ */
88
+ explicit BufferReader(const std::vector<std::uint8_t>& vector);
89
+
90
+ /**
91
+ Creates a new `BufferReader` populated with the provided data.
92
+
93
+ \param vector A vector of bytes that is moved to the internal buffer and used
94
+ as the source which is read from.
95
+ */
96
+ explicit BufferReader(std::vector<std::uint8_t>&& vector);
97
+
98
+ /**
99
+ Resets the reader to read from the given list of bytes, starting at the
100
+ beginning.
101
+
102
+ This makes `reader = {1, 2, 3};` effectively equivalent to `reader =
103
+ BufferReader({1, 2, 3});`.
104
+
105
+ \param bytes Bytes that are assigned to the internal buffer and used as the
106
+ source which is read from.
107
+ \return `*this`.
108
+ */
109
+ BufferReader& operator=(std::initializer_list<std::uint8_t> bytes);
110
+
111
+ Status Read(std::size_t num_to_read, std::uint8_t* buffer,
112
+ std::uint64_t* num_actually_read) override;
113
+
114
+ Status Skip(std::uint64_t num_to_skip,
115
+ std::uint64_t* num_actually_skipped) override;
116
+
117
+ std::uint64_t Position() const override;
118
+
119
+ /**
120
+ Gets the total size of the buffer.
121
+ */
122
+ std::size_t size() const { return data_.size(); }
123
+
124
+ private:
125
+ // Stores the byte buffer from which data is read.
126
+ std::vector<std::uint8_t> data_;
127
+
128
+ // The position of the reader in the byte buffer.
129
+ std::size_t pos_ = 0;
130
+ };
131
+
132
+ /**
133
+ @}
134
+ */
135
+
136
+ } // namespace webm
137
+
138
+ #endif // INCLUDE_WEBM_BUFFER_READER_H_