@drutech/react-native-audio-analyzer 1.1.1-alpha.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 (223) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +124 -0
  3. package/android/CMakeCache.txt +372 -0
  4. package/android/CMakeLists.txt +44 -0
  5. package/android/Makefile +211 -0
  6. package/android/build.gradle +110 -0
  7. package/android/cmake_install.cmake +49 -0
  8. package/android/cpp-adapter.cpp +40 -0
  9. package/android/ffmpeg_16kb/include/config.h +749 -0
  10. package/android/ffmpeg_16kb/include/libavcodec/ac3_parser.h +36 -0
  11. package/android/ffmpeg_16kb/include/libavcodec/adts_parser.h +37 -0
  12. package/android/ffmpeg_16kb/include/libavcodec/arm/mathops.h +108 -0
  13. package/android/ffmpeg_16kb/include/libavcodec/avcodec.h +3192 -0
  14. package/android/ffmpeg_16kb/include/libavcodec/avdct.h +88 -0
  15. package/android/ffmpeg_16kb/include/libavcodec/avfft.h +118 -0
  16. package/android/ffmpeg_16kb/include/libavcodec/bsf.h +332 -0
  17. package/android/ffmpeg_16kb/include/libavcodec/codec.h +375 -0
  18. package/android/ffmpeg_16kb/include/libavcodec/codec_desc.h +128 -0
  19. package/android/ffmpeg_16kb/include/libavcodec/codec_id.h +661 -0
  20. package/android/ffmpeg_16kb/include/libavcodec/codec_par.h +247 -0
  21. package/android/ffmpeg_16kb/include/libavcodec/d3d11va.h +112 -0
  22. package/android/ffmpeg_16kb/include/libavcodec/defs.h +192 -0
  23. package/android/ffmpeg_16kb/include/libavcodec/dirac.h +131 -0
  24. package/android/ffmpeg_16kb/include/libavcodec/dv_profile.h +82 -0
  25. package/android/ffmpeg_16kb/include/libavcodec/dxva2.h +93 -0
  26. package/android/ffmpeg_16kb/include/libavcodec/jni.h +46 -0
  27. package/android/ffmpeg_16kb/include/libavcodec/mathops.h +255 -0
  28. package/android/ffmpeg_16kb/include/libavcodec/mediacodec.h +103 -0
  29. package/android/ffmpeg_16kb/include/libavcodec/packet.h +731 -0
  30. package/android/ffmpeg_16kb/include/libavcodec/qsv.h +109 -0
  31. package/android/ffmpeg_16kb/include/libavcodec/vdpau.h +157 -0
  32. package/android/ffmpeg_16kb/include/libavcodec/version.h +45 -0
  33. package/android/ffmpeg_16kb/include/libavcodec/version_major.h +52 -0
  34. package/android/ffmpeg_16kb/include/libavcodec/videotoolbox.h +150 -0
  35. package/android/ffmpeg_16kb/include/libavcodec/vorbis_parser.h +74 -0
  36. package/android/ffmpeg_16kb/include/libavcodec/x86/mathops.h +133 -0
  37. package/android/ffmpeg_16kb/include/libavcodec/xvmc.h +171 -0
  38. package/android/ffmpeg_16kb/include/libavdevice/avdevice.h +397 -0
  39. package/android/ffmpeg_16kb/include/libavdevice/version.h +45 -0
  40. package/android/ffmpeg_16kb/include/libavdevice/version_major.h +36 -0
  41. package/android/ffmpeg_16kb/include/libavfilter/avfilter.h +1491 -0
  42. package/android/ffmpeg_16kb/include/libavfilter/buffersink.h +173 -0
  43. package/android/ffmpeg_16kb/include/libavfilter/buffersrc.h +218 -0
  44. package/android/ffmpeg_16kb/include/libavfilter/version.h +48 -0
  45. package/android/ffmpeg_16kb/include/libavfilter/version_major.h +38 -0
  46. package/android/ffmpeg_16kb/include/libavformat/avformat.h +2826 -0
  47. package/android/ffmpeg_16kb/include/libavformat/avio.h +837 -0
  48. package/android/ffmpeg_16kb/include/libavformat/network.h +341 -0
  49. package/android/ffmpeg_16kb/include/libavformat/os_support.h +317 -0
  50. package/android/ffmpeg_16kb/include/libavformat/url.h +409 -0
  51. package/android/ffmpeg_16kb/include/libavformat/version.h +47 -0
  52. package/android/ffmpeg_16kb/include/libavformat/version_major.h +52 -0
  53. package/android/ffmpeg_16kb/include/libavutil/aarch64/timer.h +50 -0
  54. package/android/ffmpeg_16kb/include/libavutil/adler32.h +63 -0
  55. package/android/ffmpeg_16kb/include/libavutil/aes.h +69 -0
  56. package/android/ffmpeg_16kb/include/libavutil/aes_ctr.h +99 -0
  57. package/android/ffmpeg_16kb/include/libavutil/ambient_viewing_environment.h +72 -0
  58. package/android/ffmpeg_16kb/include/libavutil/arm/timer.h +46 -0
  59. package/android/ffmpeg_16kb/include/libavutil/attributes.h +173 -0
  60. package/android/ffmpeg_16kb/include/libavutil/attributes_internal.h +34 -0
  61. package/android/ffmpeg_16kb/include/libavutil/audio_fifo.h +186 -0
  62. package/android/ffmpeg_16kb/include/libavutil/avassert.h +75 -0
  63. package/android/ffmpeg_16kb/include/libavutil/avconfig.h +6 -0
  64. package/android/ffmpeg_16kb/include/libavutil/avstring.h +429 -0
  65. package/android/ffmpeg_16kb/include/libavutil/avutil.h +371 -0
  66. package/android/ffmpeg_16kb/include/libavutil/base64.h +72 -0
  67. package/android/ffmpeg_16kb/include/libavutil/blowfish.h +82 -0
  68. package/android/ffmpeg_16kb/include/libavutil/bprint.h +251 -0
  69. package/android/ffmpeg_16kb/include/libavutil/bswap.h +111 -0
  70. package/android/ffmpeg_16kb/include/libavutil/buffer.h +322 -0
  71. package/android/ffmpeg_16kb/include/libavutil/camellia.h +70 -0
  72. package/android/ffmpeg_16kb/include/libavutil/cast5.h +80 -0
  73. package/android/ffmpeg_16kb/include/libavutil/channel_layout.h +783 -0
  74. package/android/ffmpeg_16kb/include/libavutil/common.h +578 -0
  75. package/android/ffmpeg_16kb/include/libavutil/cpu.h +134 -0
  76. package/android/ffmpeg_16kb/include/libavutil/crc.h +102 -0
  77. package/android/ffmpeg_16kb/include/libavutil/csp.h +150 -0
  78. package/android/ffmpeg_16kb/include/libavutil/des.h +81 -0
  79. package/android/ffmpeg_16kb/include/libavutil/detection_bbox.h +108 -0
  80. package/android/ffmpeg_16kb/include/libavutil/dict.h +241 -0
  81. package/android/ffmpeg_16kb/include/libavutil/display.h +109 -0
  82. package/android/ffmpeg_16kb/include/libavutil/dovi_meta.h +236 -0
  83. package/android/ffmpeg_16kb/include/libavutil/downmix_info.h +115 -0
  84. package/android/ffmpeg_16kb/include/libavutil/encryption_info.h +205 -0
  85. package/android/ffmpeg_16kb/include/libavutil/error.h +128 -0
  86. package/android/ffmpeg_16kb/include/libavutil/eval.h +140 -0
  87. package/android/ffmpeg_16kb/include/libavutil/ffversion.h +5 -0
  88. package/android/ffmpeg_16kb/include/libavutil/fifo.h +448 -0
  89. package/android/ffmpeg_16kb/include/libavutil/file.h +115 -0
  90. package/android/ffmpeg_16kb/include/libavutil/film_grain_params.h +260 -0
  91. package/android/ffmpeg_16kb/include/libavutil/frame.h +964 -0
  92. package/android/ffmpeg_16kb/include/libavutil/getenv_utf8.h +86 -0
  93. package/android/ffmpeg_16kb/include/libavutil/hash.h +264 -0
  94. package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_metadata.h +343 -0
  95. package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_vivid_metadata.h +285 -0
  96. package/android/ffmpeg_16kb/include/libavutil/hmac.h +99 -0
  97. package/android/ffmpeg_16kb/include/libavutil/hwcontext.h +610 -0
  98. package/android/ffmpeg_16kb/include/libavutil/hwcontext_cuda.h +69 -0
  99. package/android/ffmpeg_16kb/include/libavutil/hwcontext_d3d11va.h +178 -0
  100. package/android/ffmpeg_16kb/include/libavutil/hwcontext_drm.h +169 -0
  101. package/android/ffmpeg_16kb/include/libavutil/hwcontext_dxva2.h +75 -0
  102. package/android/ffmpeg_16kb/include/libavutil/hwcontext_mediacodec.h +61 -0
  103. package/android/ffmpeg_16kb/include/libavutil/hwcontext_opencl.h +100 -0
  104. package/android/ffmpeg_16kb/include/libavutil/hwcontext_qsv.h +64 -0
  105. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vaapi.h +117 -0
  106. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vdpau.h +44 -0
  107. package/android/ffmpeg_16kb/include/libavutil/hwcontext_videotoolbox.h +96 -0
  108. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vulkan.h +281 -0
  109. package/android/ffmpeg_16kb/include/libavutil/imgutils.h +331 -0
  110. package/android/ffmpeg_16kb/include/libavutil/internal.h +190 -0
  111. package/android/ffmpeg_16kb/include/libavutil/intfloat.h +77 -0
  112. package/android/ffmpeg_16kb/include/libavutil/intreadwrite.h +644 -0
  113. package/android/ffmpeg_16kb/include/libavutil/lfg.h +81 -0
  114. package/android/ffmpeg_16kb/include/libavutil/libm.h +471 -0
  115. package/android/ffmpeg_16kb/include/libavutil/log.h +387 -0
  116. package/android/ffmpeg_16kb/include/libavutil/lzo.h +66 -0
  117. package/android/ffmpeg_16kb/include/libavutil/macros.h +80 -0
  118. package/android/ffmpeg_16kb/include/libavutil/mastering_display_metadata.h +128 -0
  119. package/android/ffmpeg_16kb/include/libavutil/mathematics.h +245 -0
  120. package/android/ffmpeg_16kb/include/libavutil/md5.h +89 -0
  121. package/android/ffmpeg_16kb/include/libavutil/mem.h +609 -0
  122. package/android/ffmpeg_16kb/include/libavutil/motion_vector.h +57 -0
  123. package/android/ffmpeg_16kb/include/libavutil/murmur3.h +115 -0
  124. package/android/ffmpeg_16kb/include/libavutil/opt.h +891 -0
  125. package/android/ffmpeg_16kb/include/libavutil/parseutils.h +197 -0
  126. package/android/ffmpeg_16kb/include/libavutil/pixdesc.h +435 -0
  127. package/android/ffmpeg_16kb/include/libavutil/pixelutils.h +51 -0
  128. package/android/ffmpeg_16kb/include/libavutil/pixfmt.h +691 -0
  129. package/android/ffmpeg_16kb/include/libavutil/random_seed.h +43 -0
  130. package/android/ffmpeg_16kb/include/libavutil/rational.h +221 -0
  131. package/android/ffmpeg_16kb/include/libavutil/rc4.h +69 -0
  132. package/android/ffmpeg_16kb/include/libavutil/replaygain.h +50 -0
  133. package/android/ffmpeg_16kb/include/libavutil/reverse.h +28 -0
  134. package/android/ffmpeg_16kb/include/libavutil/ripemd.h +83 -0
  135. package/android/ffmpeg_16kb/include/libavutil/samplefmt.h +269 -0
  136. package/android/ffmpeg_16kb/include/libavutil/sha.h +90 -0
  137. package/android/ffmpeg_16kb/include/libavutil/sha512.h +92 -0
  138. package/android/ffmpeg_16kb/include/libavutil/spherical.h +227 -0
  139. package/android/ffmpeg_16kb/include/libavutil/stereo3d.h +229 -0
  140. package/android/ffmpeg_16kb/include/libavutil/tea.h +71 -0
  141. package/android/ffmpeg_16kb/include/libavutil/thread.h +204 -0
  142. package/android/ffmpeg_16kb/include/libavutil/threadmessage.h +115 -0
  143. package/android/ffmpeg_16kb/include/libavutil/time.h +56 -0
  144. package/android/ffmpeg_16kb/include/libavutil/timecode.h +199 -0
  145. package/android/ffmpeg_16kb/include/libavutil/timer.h +156 -0
  146. package/android/ffmpeg_16kb/include/libavutil/timestamp.h +78 -0
  147. package/android/ffmpeg_16kb/include/libavutil/tree.h +137 -0
  148. package/android/ffmpeg_16kb/include/libavutil/twofish.h +70 -0
  149. package/android/ffmpeg_16kb/include/libavutil/tx.h +176 -0
  150. package/android/ffmpeg_16kb/include/libavutil/uuid.h +146 -0
  151. package/android/ffmpeg_16kb/include/libavutil/version.h +122 -0
  152. package/android/ffmpeg_16kb/include/libavutil/video_enc_params.h +171 -0
  153. package/android/ffmpeg_16kb/include/libavutil/x86/asm.h +154 -0
  154. package/android/ffmpeg_16kb/include/libavutil/x86/emms.h +58 -0
  155. package/android/ffmpeg_16kb/include/libavutil/x86/timer.h +50 -0
  156. package/android/ffmpeg_16kb/include/libavutil/xtea.h +94 -0
  157. package/android/ffmpeg_16kb/include/libswresample/swresample.h +650 -0
  158. package/android/ffmpeg_16kb/include/libswresample/version.h +46 -0
  159. package/android/ffmpeg_16kb/include/libswresample/version_major.h +31 -0
  160. package/android/ffmpeg_16kb/include/libswscale/swscale.h +436 -0
  161. package/android/ffmpeg_16kb/include/libswscale/version.h +44 -0
  162. package/android/ffmpeg_16kb/include/libswscale/version_major.h +35 -0
  163. package/android/ffmpeg_16kb/lib/arm64-v8a/libavcodec.so +0 -0
  164. package/android/ffmpeg_16kb/lib/arm64-v8a/libavdevice.so +0 -0
  165. package/android/ffmpeg_16kb/lib/arm64-v8a/libavfilter.so +0 -0
  166. package/android/ffmpeg_16kb/lib/arm64-v8a/libavformat.so +0 -0
  167. package/android/ffmpeg_16kb/lib/arm64-v8a/libavutil.so +0 -0
  168. package/android/ffmpeg_16kb/lib/arm64-v8a/libswresample.so +0 -0
  169. package/android/ffmpeg_16kb/lib/arm64-v8a/libswscale.so +0 -0
  170. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavcodec_neon.so +0 -0
  171. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavdevice_neon.so +0 -0
  172. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavfilter_neon.so +0 -0
  173. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavformat_neon.so +0 -0
  174. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavutil_neon.so +0 -0
  175. package/android/ffmpeg_16kb/lib/armeabi-v7a/libswresample_neon.so +0 -0
  176. package/android/ffmpeg_16kb/lib/armeabi-v7a/libswscale_neon.so +0 -0
  177. package/android/ffmpeg_16kb/lib/x86/libavcodec.so +0 -0
  178. package/android/ffmpeg_16kb/lib/x86/libavdevice.so +0 -0
  179. package/android/ffmpeg_16kb/lib/x86/libavfilter.so +0 -0
  180. package/android/ffmpeg_16kb/lib/x86/libavformat.so +0 -0
  181. package/android/ffmpeg_16kb/lib/x86/libavutil.so +0 -0
  182. package/android/ffmpeg_16kb/lib/x86/libswresample.so +0 -0
  183. package/android/ffmpeg_16kb/lib/x86/libswscale.so +0 -0
  184. package/android/ffmpeg_16kb/lib/x86_64/libavcodec.so +0 -0
  185. package/android/ffmpeg_16kb/lib/x86_64/libavdevice.so +0 -0
  186. package/android/ffmpeg_16kb/lib/x86_64/libavfilter.so +0 -0
  187. package/android/ffmpeg_16kb/lib/x86_64/libavformat.so +0 -0
  188. package/android/ffmpeg_16kb/lib/x86_64/libavutil.so +0 -0
  189. package/android/ffmpeg_16kb/lib/x86_64/libswresample.so +0 -0
  190. package/android/ffmpeg_16kb/lib/x86_64/libswscale.so +0 -0
  191. package/android/gradle.properties +5 -0
  192. package/android/src/main/AndroidManifest.xml +3 -0
  193. package/android/src/main/AndroidManifestNew.xml +2 -0
  194. package/android/src/main/java/com/audioanalyzer/AmplitudeData.java +20 -0
  195. package/android/src/main/java/com/audioanalyzer/AudioAnalyzerModule.java +52 -0
  196. package/android/src/main/java/com/audioanalyzer/AudioAnalyzerPackage.java +28 -0
  197. package/cpp/react-native-audio-analyzer.cpp +143 -0
  198. package/cpp/react-native-audio-analyzer.h +27 -0
  199. package/ios/AudioAnalyzer.h +19 -0
  200. package/ios/AudioAnalyzer.mm +43 -0
  201. package/lib/commonjs/helpers.js +34 -0
  202. package/lib/commonjs/helpers.js.map +1 -0
  203. package/lib/commonjs/helpers.test.js +49 -0
  204. package/lib/commonjs/helpers.test.js.map +1 -0
  205. package/lib/commonjs/index.js +35 -0
  206. package/lib/commonjs/index.js.map +1 -0
  207. package/lib/module/helpers.js +27 -0
  208. package/lib/module/helpers.js.map +1 -0
  209. package/lib/module/helpers.test.js +47 -0
  210. package/lib/module/helpers.test.js.map +1 -0
  211. package/lib/module/index.js +15 -0
  212. package/lib/module/index.js.map +1 -0
  213. package/lib/typescript/src/helpers.d.ts +3 -0
  214. package/lib/typescript/src/helpers.d.ts.map +1 -0
  215. package/lib/typescript/src/helpers.test.d.ts +2 -0
  216. package/lib/typescript/src/helpers.test.d.ts.map +1 -0
  217. package/lib/typescript/src/index.d.ts +7 -0
  218. package/lib/typescript/src/index.d.ts.map +1 -0
  219. package/package.json +163 -0
  220. package/react-native-audio-analyzer.podspec +44 -0
  221. package/src/helpers.test.ts +59 -0
  222. package/src/helpers.ts +34 -0
  223. package/src/index.tsx +30 -0
@@ -0,0 +1,448 @@
1
+ /*
2
+ * This file is part of FFmpeg.
3
+ *
4
+ * FFmpeg is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * FFmpeg is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with FFmpeg; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ /**
20
+ * @file
21
+ * @ingroup lavu_fifo
22
+ * A generic FIFO API
23
+ */
24
+
25
+ #ifndef AVUTIL_FIFO_H
26
+ #define AVUTIL_FIFO_H
27
+
28
+ #include <stddef.h>
29
+ #include <stdint.h>
30
+
31
+ #include "attributes.h"
32
+ #include "version.h"
33
+
34
+ /**
35
+ * @defgroup lavu_fifo AVFifo
36
+ * @ingroup lavu_data
37
+ *
38
+ * @{
39
+ * A generic FIFO API
40
+ */
41
+
42
+ typedef struct AVFifo AVFifo;
43
+
44
+ /**
45
+ * Callback for writing or reading from a FIFO, passed to (and invoked from) the
46
+ * av_fifo_*_cb() functions. It may be invoked multiple times from a single
47
+ * av_fifo_*_cb() call and may process less data than the maximum size indicated
48
+ * by nb_elems.
49
+ *
50
+ * @param opaque the opaque pointer provided to the av_fifo_*_cb() function
51
+ * @param buf the buffer for reading or writing the data, depending on which
52
+ * av_fifo_*_cb function is called
53
+ * @param nb_elems On entry contains the maximum number of elements that can be
54
+ * read from / written into buf. On success, the callback should
55
+ * update it to contain the number of elements actually written.
56
+ *
57
+ * @return 0 on success, a negative error code on failure (will be returned from
58
+ * the invoking av_fifo_*_cb() function)
59
+ */
60
+ typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems);
61
+
62
+ /**
63
+ * Automatically resize the FIFO on writes, so that the data fits. This
64
+ * automatic resizing happens up to a limit that can be modified with
65
+ * av_fifo_auto_grow_limit().
66
+ */
67
+ #define AV_FIFO_FLAG_AUTO_GROW (1 << 0)
68
+
69
+ /**
70
+ * Allocate and initialize an AVFifo with a given element size.
71
+ *
72
+ * @param elems initial number of elements that can be stored in the FIFO
73
+ * @param elem_size Size in bytes of a single element. Further operations on
74
+ * the returned FIFO will implicitly use this element size.
75
+ * @param flags a combination of AV_FIFO_FLAG_*
76
+ *
77
+ * @return newly-allocated AVFifo on success, a negative error code on failure
78
+ */
79
+ AVFifo *av_fifo_alloc2(size_t elems, size_t elem_size,
80
+ unsigned int flags);
81
+
82
+ /**
83
+ * @return Element size for FIFO operations. This element size is set at
84
+ * FIFO allocation and remains constant during its lifetime
85
+ */
86
+ size_t av_fifo_elem_size(const AVFifo *f);
87
+
88
+ /**
89
+ * Set the maximum size (in elements) to which the FIFO can be resized
90
+ * automatically. Has no effect unless AV_FIFO_FLAG_AUTO_GROW is used.
91
+ */
92
+ void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems);
93
+
94
+ /**
95
+ * @return number of elements available for reading from the given FIFO.
96
+ */
97
+ size_t av_fifo_can_read(const AVFifo *f);
98
+
99
+ /**
100
+ * @return Number of elements that can be written into the given FIFO without
101
+ * growing it.
102
+ *
103
+ * In other words, this number of elements or less is guaranteed to fit
104
+ * into the FIFO. More data may be written when the
105
+ * AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this
106
+ * may involve memory allocation, which can fail.
107
+ */
108
+ size_t av_fifo_can_write(const AVFifo *f);
109
+
110
+ /**
111
+ * Enlarge an AVFifo.
112
+ *
113
+ * On success, the FIFO will be large enough to hold exactly
114
+ * inc + av_fifo_can_read() + av_fifo_can_write()
115
+ * elements. In case of failure, the old FIFO is kept unchanged.
116
+ *
117
+ * @param f AVFifo to resize
118
+ * @param inc number of elements to allocate for, in addition to the current
119
+ * allocated size
120
+ * @return a non-negative number on success, a negative error code on failure
121
+ */
122
+ int av_fifo_grow2(AVFifo *f, size_t inc);
123
+
124
+ /**
125
+ * Write data into a FIFO.
126
+ *
127
+ * In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag
128
+ * was not specified at FIFO creation, nothing is written and an error
129
+ * is returned.
130
+ *
131
+ * Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f).
132
+ *
133
+ * @param f the FIFO buffer
134
+ * @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be
135
+ * read from buf on success.
136
+ * @param nb_elems number of elements to write into FIFO
137
+ *
138
+ * @return a non-negative number on success, a negative error code on failure
139
+ */
140
+ int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems);
141
+
142
+ /**
143
+ * Write data from a user-provided callback into a FIFO.
144
+ *
145
+ * @param f the FIFO buffer
146
+ * @param read_cb Callback supplying the data to the FIFO. May be called
147
+ * multiple times.
148
+ * @param opaque opaque user data to be provided to read_cb
149
+ * @param nb_elems Should point to the maximum number of elements that can be
150
+ * written. Will be updated to contain the number of elements
151
+ * actually written.
152
+ *
153
+ * @return non-negative number on success, a negative error code on failure
154
+ */
155
+ int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb,
156
+ void *opaque, size_t *nb_elems);
157
+
158
+ /**
159
+ * Read data from a FIFO.
160
+ *
161
+ * In case nb_elems > av_fifo_can_read(f), nothing is read and an error
162
+ * is returned.
163
+ *
164
+ * @param f the FIFO buffer
165
+ * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes
166
+ * will be written into buf on success.
167
+ * @param nb_elems number of elements to read from FIFO
168
+ *
169
+ * @return a non-negative number on success, a negative error code on failure
170
+ */
171
+ int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems);
172
+
173
+ /**
174
+ * Feed data from a FIFO into a user-provided callback.
175
+ *
176
+ * @param f the FIFO buffer
177
+ * @param write_cb Callback the data will be supplied to. May be called
178
+ * multiple times.
179
+ * @param opaque opaque user data to be provided to write_cb
180
+ * @param nb_elems Should point to the maximum number of elements that can be
181
+ * read. Will be updated to contain the total number of elements
182
+ * actually sent to the callback.
183
+ *
184
+ * @return non-negative number on success, a negative error code on failure
185
+ */
186
+ int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb,
187
+ void *opaque, size_t *nb_elems);
188
+
189
+ /**
190
+ * Read data from a FIFO without modifying FIFO state.
191
+ *
192
+ * Returns an error if an attempt is made to peek to nonexistent elements
193
+ * (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)).
194
+ *
195
+ * @param f the FIFO buffer
196
+ * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes
197
+ * will be written into buf.
198
+ * @param nb_elems number of elements to read from FIFO
199
+ * @param offset number of initial elements to skip.
200
+ *
201
+ * @return a non-negative number on success, a negative error code on failure
202
+ */
203
+ int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset);
204
+
205
+ /**
206
+ * Feed data from a FIFO into a user-provided callback.
207
+ *
208
+ * @param f the FIFO buffer
209
+ * @param write_cb Callback the data will be supplied to. May be called
210
+ * multiple times.
211
+ * @param opaque opaque user data to be provided to write_cb
212
+ * @param nb_elems Should point to the maximum number of elements that can be
213
+ * read. Will be updated to contain the total number of elements
214
+ * actually sent to the callback.
215
+ * @param offset number of initial elements to skip; offset + *nb_elems must not
216
+ * be larger than av_fifo_can_read(f).
217
+ *
218
+ * @return a non-negative number on success, a negative error code on failure
219
+ */
220
+ int av_fifo_peek_to_cb(AVFifo *f, AVFifoCB write_cb, void *opaque,
221
+ size_t *nb_elems, size_t offset);
222
+
223
+ /**
224
+ * Discard the specified amount of data from an AVFifo.
225
+ * @param size number of elements to discard, MUST NOT be larger than
226
+ * av_fifo_can_read(f)
227
+ */
228
+ void av_fifo_drain2(AVFifo *f, size_t size);
229
+
230
+ /*
231
+ * Empty the AVFifo.
232
+ * @param f AVFifo to reset
233
+ */
234
+ void av_fifo_reset2(AVFifo *f);
235
+
236
+ /**
237
+ * Free an AVFifo and reset pointer to NULL.
238
+ * @param f Pointer to an AVFifo to free. *f == NULL is allowed.
239
+ */
240
+ void av_fifo_freep2(AVFifo **f);
241
+
242
+
243
+ #if FF_API_FIFO_OLD_API
244
+ typedef struct AVFifoBuffer {
245
+ uint8_t *buffer;
246
+ uint8_t *rptr, *wptr, *end;
247
+ uint32_t rndx, wndx;
248
+ } AVFifoBuffer;
249
+
250
+ /**
251
+ * Initialize an AVFifoBuffer.
252
+ * @param size of FIFO
253
+ * @return AVFifoBuffer or NULL in case of memory allocation failure
254
+ * @deprecated use av_fifo_alloc2()
255
+ */
256
+ attribute_deprecated
257
+ AVFifoBuffer *av_fifo_alloc(unsigned int size);
258
+
259
+ /**
260
+ * Initialize an AVFifoBuffer.
261
+ * @param nmemb number of elements
262
+ * @param size size of the single element
263
+ * @return AVFifoBuffer or NULL in case of memory allocation failure
264
+ * @deprecated use av_fifo_alloc2()
265
+ */
266
+ attribute_deprecated
267
+ AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
268
+
269
+ /**
270
+ * Free an AVFifoBuffer.
271
+ * @param f AVFifoBuffer to free
272
+ * @deprecated use the AVFifo API with av_fifo_freep2()
273
+ */
274
+ attribute_deprecated
275
+ void av_fifo_free(AVFifoBuffer *f);
276
+
277
+ /**
278
+ * Free an AVFifoBuffer and reset pointer to NULL.
279
+ * @param f AVFifoBuffer to free
280
+ * @deprecated use the AVFifo API with av_fifo_freep2()
281
+ */
282
+ attribute_deprecated
283
+ void av_fifo_freep(AVFifoBuffer **f);
284
+
285
+ /**
286
+ * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
287
+ * @param f AVFifoBuffer to reset
288
+ * @deprecated use av_fifo_reset2() with the new AVFifo-API
289
+ */
290
+ attribute_deprecated
291
+ void av_fifo_reset(AVFifoBuffer *f);
292
+
293
+ /**
294
+ * Return the amount of data in bytes in the AVFifoBuffer, that is the
295
+ * amount of data you can read from it.
296
+ * @param f AVFifoBuffer to read from
297
+ * @return size
298
+ * @deprecated use av_fifo_can_read() with the new AVFifo-API
299
+ */
300
+ attribute_deprecated
301
+ int av_fifo_size(const AVFifoBuffer *f);
302
+
303
+ /**
304
+ * Return the amount of space in bytes in the AVFifoBuffer, that is the
305
+ * amount of data you can write into it.
306
+ * @param f AVFifoBuffer to write into
307
+ * @return size
308
+ * @deprecated use av_fifo_can_write() with the new AVFifo-API
309
+ */
310
+ attribute_deprecated
311
+ int av_fifo_space(const AVFifoBuffer *f);
312
+
313
+ /**
314
+ * Feed data at specific position from an AVFifoBuffer to a user-supplied callback.
315
+ * Similar as av_fifo_gereric_read but without discarding data.
316
+ * @param f AVFifoBuffer to read from
317
+ * @param offset offset from current read position
318
+ * @param buf_size number of bytes to read
319
+ * @param func generic read function
320
+ * @param dest data destination
321
+ *
322
+ * @return a non-negative number on success, a negative error code on failure
323
+ *
324
+ * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
325
+ * av_fifo_peek_to_cb() otherwise
326
+ */
327
+ attribute_deprecated
328
+ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
329
+
330
+ /**
331
+ * Feed data from an AVFifoBuffer to a user-supplied callback.
332
+ * Similar as av_fifo_gereric_read but without discarding data.
333
+ * @param f AVFifoBuffer to read from
334
+ * @param buf_size number of bytes to read
335
+ * @param func generic read function
336
+ * @param dest data destination
337
+ *
338
+ * @return a non-negative number on success, a negative error code on failure
339
+ *
340
+ * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
341
+ * av_fifo_peek_to_cb() otherwise
342
+ */
343
+ attribute_deprecated
344
+ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
345
+
346
+ /**
347
+ * Feed data from an AVFifoBuffer to a user-supplied callback.
348
+ * @param f AVFifoBuffer to read from
349
+ * @param buf_size number of bytes to read
350
+ * @param func generic read function
351
+ * @param dest data destination
352
+ *
353
+ * @return a non-negative number on success, a negative error code on failure
354
+ *
355
+ * @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL,
356
+ * av_fifo_read_to_cb() otherwise
357
+ */
358
+ attribute_deprecated
359
+ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
360
+
361
+ /**
362
+ * Feed data from a user-supplied callback to an AVFifoBuffer.
363
+ * @param f AVFifoBuffer to write to
364
+ * @param src data source; non-const since it may be used as a
365
+ * modifiable context by the function defined in func
366
+ * @param size number of bytes to write
367
+ * @param func generic write function; the first parameter is src,
368
+ * the second is dest_buf, the third is dest_buf_size.
369
+ * func must return the number of bytes written to dest_buf, or <= 0 to
370
+ * indicate no more data available to write.
371
+ * If func is NULL, src is interpreted as a simple byte array for source data.
372
+ * @return the number of bytes written to the FIFO or a negative error code on failure
373
+ *
374
+ * @deprecated use the new AVFifo-API with av_fifo_write() when func == NULL,
375
+ * av_fifo_write_from_cb() otherwise
376
+ */
377
+ attribute_deprecated
378
+ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
379
+
380
+ /**
381
+ * Resize an AVFifoBuffer.
382
+ * In case of reallocation failure, the old FIFO is kept unchanged.
383
+ *
384
+ * @param f AVFifoBuffer to resize
385
+ * @param size new AVFifoBuffer size in bytes
386
+ * @return <0 for failure, >=0 otherwise
387
+ *
388
+ * @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size,
389
+ * decreasing FIFO size is not supported
390
+ */
391
+ attribute_deprecated
392
+ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
393
+
394
+ /**
395
+ * Enlarge an AVFifoBuffer.
396
+ * In case of reallocation failure, the old FIFO is kept unchanged.
397
+ * The new fifo size may be larger than the requested size.
398
+ *
399
+ * @param f AVFifoBuffer to resize
400
+ * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
401
+ * @return <0 for failure, >=0 otherwise
402
+ *
403
+ * @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike
404
+ * this function it adds to the allocated size, rather than to the used size
405
+ */
406
+ attribute_deprecated
407
+ int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
408
+
409
+ /**
410
+ * Read and discard the specified amount of data from an AVFifoBuffer.
411
+ * @param f AVFifoBuffer to read from
412
+ * @param size amount of data to read in bytes
413
+ *
414
+ * @deprecated use the new AVFifo-API with av_fifo_drain2()
415
+ */
416
+ attribute_deprecated
417
+ void av_fifo_drain(AVFifoBuffer *f, int size);
418
+
419
+ #if FF_API_FIFO_PEEK2
420
+ /**
421
+ * Return a pointer to the data stored in a FIFO buffer at a certain offset.
422
+ * The FIFO buffer is not modified.
423
+ *
424
+ * @param f AVFifoBuffer to peek at, f must be non-NULL
425
+ * @param offs an offset in bytes, its absolute value must be less
426
+ * than the used buffer size or the returned pointer will
427
+ * point outside to the buffer data.
428
+ * The used buffer size can be checked with av_fifo_size().
429
+ * @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb()
430
+ */
431
+ attribute_deprecated
432
+ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
433
+ {
434
+ uint8_t *ptr = f->rptr + offs;
435
+ if (ptr >= f->end)
436
+ ptr = f->buffer + (ptr - f->end);
437
+ else if (ptr < f->buffer)
438
+ ptr = f->end - (f->buffer - ptr);
439
+ return ptr;
440
+ }
441
+ #endif
442
+ #endif
443
+
444
+ /**
445
+ * @}
446
+ */
447
+
448
+ #endif /* AVUTIL_FIFO_H */
@@ -0,0 +1,115 @@
1
+ /*
2
+ * This file is part of FFmpeg.
3
+ *
4
+ * FFmpeg is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * FFmpeg is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with FFmpeg; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ #ifndef AVUTIL_FILE_H
20
+ #define AVUTIL_FILE_H
21
+
22
+ #include <stddef.h>
23
+ #include <stdint.h>
24
+
25
+ #include "version.h"
26
+ #include "attributes.h"
27
+
28
+ /**
29
+ * @file
30
+ * Misc file utilities.
31
+ */
32
+
33
+ /**
34
+ * Read the file with name filename, and put its content in a newly
35
+ * allocated buffer or map it with mmap() when available.
36
+ * In case of success set *bufptr to the read or mmapped buffer, and
37
+ * *size to the size in bytes of the buffer in *bufptr.
38
+ * Unlike mmap this function succeeds with zero sized files, in this
39
+ * case *bufptr will be set to NULL and *size will be set to 0.
40
+ * The returned buffer must be released with av_file_unmap().
41
+ *
42
+ * @param filename path to the file
43
+ * @param[out] bufptr pointee is set to the mapped or allocated buffer
44
+ * @param[out] size pointee is set to the size in bytes of the buffer
45
+ * @param log_offset loglevel offset used for logging
46
+ * @param log_ctx context used for logging
47
+ * @return a non negative number in case of success, a negative value
48
+ * corresponding to an AVERROR error code in case of failure
49
+ */
50
+ av_warn_unused_result
51
+ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
52
+ int log_offset, void *log_ctx);
53
+
54
+ /**
55
+ * Unmap or free the buffer bufptr created by av_file_map().
56
+ *
57
+ * @param bufptr the buffer previously created with av_file_map()
58
+ * @param size size in bytes of bufptr, must be the same as returned
59
+ * by av_file_map()
60
+ */
61
+ void av_file_unmap(uint8_t *bufptr, size_t size);
62
+
63
+ #if FF_API_AV_FOPEN_UTF8
64
+ /**
65
+ * Wrapper to work around the lack of mkstemp() on mingw.
66
+ * Also, tries to create file in /tmp first, if possible.
67
+ * *prefix can be a character constant; *filename will be allocated internally.
68
+ * @return file descriptor of opened file (or negative value corresponding to an
69
+ * AVERROR code on error)
70
+ * and opened file name in **filename.
71
+ * @note On very old libcs it is necessary to set a secure umask before
72
+ * calling this, av_tempfile() can't call umask itself as it is used in
73
+ * libraries and could interfere with the calling application.
74
+ * @deprecated as fd numbers cannot be passed saftely between libs on some platforms
75
+ */
76
+ attribute_deprecated
77
+ int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
78
+ #endif
79
+
80
+ #endif /* AVUTIL_FILE_H */
81
+ /*
82
+ * Copyright (c) 2021 Taner Sener
83
+ *
84
+ * This file is part of FFmpegKit.
85
+ *
86
+ * FFmpegKit is free software: you can redistribute it and/or modify
87
+ * it under the terms of the GNU Lesser General Public License as published by
88
+ * the Free Software Foundation, either version 3 of the License, or
89
+ * (at your option) any later version.
90
+ *
91
+ * FFmpegKit is distributed in the hope that it will be useful,
92
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
93
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94
+ * GNU Lesser General Public License for more details.
95
+ *
96
+ * You should have received a copy of the GNU Lesser General Public License
97
+ * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
98
+ */
99
+
100
+ #ifndef AVUTIL_FILE_FFMPEG_KIT_PROTOCOLS_H
101
+ #define AVUTIL_FILE_FFMPEG_KIT_PROTOCOLS_H
102
+
103
+ typedef int (*saf_open_function)(int);
104
+
105
+ typedef int (*saf_close_function)(int);
106
+
107
+ saf_open_function av_get_saf_open(void);
108
+
109
+ saf_close_function av_get_saf_close(void);
110
+
111
+ void av_set_saf_open(saf_open_function);
112
+
113
+ void av_set_saf_close(saf_close_function);
114
+
115
+ #endif /* AVUTIL_FILE_FFMPEG_KIT_PROTOCOLS_H */