@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,341 @@
1
+ /*
2
+ * Copyright (c) 2007 The FFmpeg Project
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ #ifndef AVFORMAT_NETWORK_H
22
+ #define AVFORMAT_NETWORK_H
23
+
24
+ #include <errno.h>
25
+ #include <stdint.h>
26
+
27
+ #include "config.h"
28
+ #include "libavutil/error.h"
29
+ #include "os_support.h"
30
+ #include "avio.h"
31
+ #include "url.h"
32
+
33
+ #if HAVE_UNISTD_H
34
+ #include <unistd.h>
35
+ #endif
36
+
37
+ #if HAVE_WINSOCK2_H
38
+ #include <winsock2.h>
39
+ #include <ws2tcpip.h>
40
+
41
+ #ifndef EPROTONOSUPPORT
42
+ #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
43
+ #endif
44
+ #ifndef ETIMEDOUT
45
+ #define ETIMEDOUT WSAETIMEDOUT
46
+ #endif
47
+ #ifndef ECONNREFUSED
48
+ #define ECONNREFUSED WSAECONNREFUSED
49
+ #endif
50
+ #ifndef EINPROGRESS
51
+ #define EINPROGRESS WSAEINPROGRESS
52
+ #endif
53
+ #ifndef ENOTCONN
54
+ #define ENOTCONN WSAENOTCONN
55
+ #endif
56
+
57
+ #define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
58
+ #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)
59
+
60
+ int ff_neterrno(void);
61
+ #else
62
+ #include <sys/types.h>
63
+ #include <sys/socket.h>
64
+ #include <netinet/in.h>
65
+ #include <netinet/tcp.h>
66
+ #include <netdb.h>
67
+
68
+ #define ff_neterrno() AVERROR(errno)
69
+ #endif /* HAVE_WINSOCK2_H */
70
+
71
+ #if HAVE_ARPA_INET_H
72
+ #include <arpa/inet.h>
73
+ #endif
74
+
75
+ #if HAVE_POLL_H
76
+ #include <poll.h>
77
+ #endif
78
+
79
+ int ff_socket_nonblock(int socket, int enable);
80
+
81
+ int ff_network_init(void);
82
+ void ff_network_close(void);
83
+
84
+ int ff_tls_init(void);
85
+ void ff_tls_deinit(void);
86
+
87
+ int ff_network_wait_fd(int fd, int write);
88
+
89
+ /**
90
+ * This works similarly to ff_network_wait_fd, but waits up to 'timeout' microseconds
91
+ * Uses ff_network_wait_fd in a loop
92
+ *
93
+ * @param fd Socket descriptor
94
+ * @param write Set 1 to wait for socket able to be read, 0 to be written
95
+ * @param timeout Timeout interval, in microseconds. Actual precision is 100000 mcs, due to ff_network_wait_fd usage
96
+ * @param int_cb Interrupt callback, is checked before each ff_network_wait_fd call
97
+ * @return 0 if data can be read/written, AVERROR(ETIMEDOUT) if timeout expired, or negative error code
98
+ */
99
+ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb);
100
+
101
+ /**
102
+ * Waits for up to 'timeout' microseconds. If the usert's int_cb is set and
103
+ * triggered, return before that.
104
+ * @param timeout Timeout in microseconds. Maybe have lower actual precision.
105
+ * @param int_cb Interrupt callback, is checked regularly.
106
+ * @return AVERROR(ETIMEDOUT) if timeout expirted, AVERROR_EXIT if interrupted by int_cb
107
+ */
108
+ int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb);
109
+
110
+ #if !HAVE_STRUCT_SOCKADDR_STORAGE
111
+ struct sockaddr_storage {
112
+ #if HAVE_STRUCT_SOCKADDR_SA_LEN
113
+ uint8_t ss_len;
114
+ uint8_t ss_family;
115
+ #else
116
+ uint16_t ss_family;
117
+ #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
118
+ char ss_pad1[6];
119
+ int64_t ss_align;
120
+ char ss_pad2[112];
121
+ };
122
+ #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
123
+
124
+ typedef union sockaddr_union {
125
+ struct sockaddr_storage storage;
126
+ struct sockaddr_in in;
127
+ #if HAVE_STRUCT_SOCKADDR_IN6
128
+ struct sockaddr_in6 in6;
129
+ #endif
130
+ } sockaddr_union;
131
+
132
+ #ifndef MSG_NOSIGNAL
133
+ #define MSG_NOSIGNAL 0
134
+ #endif
135
+
136
+ #if !HAVE_STRUCT_ADDRINFO
137
+ struct addrinfo {
138
+ int ai_flags;
139
+ int ai_family;
140
+ int ai_socktype;
141
+ int ai_protocol;
142
+ int ai_addrlen;
143
+ struct sockaddr *ai_addr;
144
+ char *ai_canonname;
145
+ struct addrinfo *ai_next;
146
+ };
147
+ #endif /* !HAVE_STRUCT_ADDRINFO */
148
+
149
+ /* getaddrinfo constants */
150
+ #ifndef EAI_AGAIN
151
+ #define EAI_AGAIN 2
152
+ #endif
153
+ #ifndef EAI_BADFLAGS
154
+ #define EAI_BADFLAGS 3
155
+ #endif
156
+ #ifndef EAI_FAIL
157
+ #define EAI_FAIL 4
158
+ #endif
159
+ #ifndef EAI_FAMILY
160
+ #define EAI_FAMILY 5
161
+ #endif
162
+ #ifndef EAI_MEMORY
163
+ #define EAI_MEMORY 6
164
+ #endif
165
+ #ifndef EAI_NODATA
166
+ #define EAI_NODATA 7
167
+ #endif
168
+ #ifndef EAI_NONAME
169
+ #define EAI_NONAME 8
170
+ #endif
171
+ #ifndef EAI_SERVICE
172
+ #define EAI_SERVICE 9
173
+ #endif
174
+ #ifndef EAI_SOCKTYPE
175
+ #define EAI_SOCKTYPE 10
176
+ #endif
177
+
178
+ #ifndef AI_PASSIVE
179
+ #define AI_PASSIVE 1
180
+ #endif
181
+
182
+ #ifndef AI_CANONNAME
183
+ #define AI_CANONNAME 2
184
+ #endif
185
+
186
+ #ifndef AI_NUMERICHOST
187
+ #define AI_NUMERICHOST 4
188
+ #endif
189
+
190
+ #ifndef NI_NOFQDN
191
+ #define NI_NOFQDN 1
192
+ #endif
193
+
194
+ #ifndef NI_NUMERICHOST
195
+ #define NI_NUMERICHOST 2
196
+ #endif
197
+
198
+ #ifndef NI_NAMERQD
199
+ #define NI_NAMERQD 4
200
+ #endif
201
+
202
+ #ifndef NI_NUMERICSERV
203
+ #define NI_NUMERICSERV 8
204
+ #endif
205
+
206
+ #ifndef NI_DGRAM
207
+ #define NI_DGRAM 16
208
+ #endif
209
+
210
+ #if !HAVE_GETADDRINFO
211
+ int ff_getaddrinfo(const char *node, const char *service,
212
+ const struct addrinfo *hints, struct addrinfo **res);
213
+ void ff_freeaddrinfo(struct addrinfo *res);
214
+ int ff_getnameinfo(const struct sockaddr *sa, int salen,
215
+ char *host, int hostlen,
216
+ char *serv, int servlen, int flags);
217
+ #define getaddrinfo ff_getaddrinfo
218
+ #define freeaddrinfo ff_freeaddrinfo
219
+ #define getnameinfo ff_getnameinfo
220
+ #endif /* !HAVE_GETADDRINFO */
221
+
222
+ #if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H
223
+ const char *ff_gai_strerror(int ecode);
224
+ #undef gai_strerror
225
+ #define gai_strerror ff_gai_strerror
226
+ #endif /* !HAVE_GETADDRINFO || HAVE_WINSOCK2_H */
227
+
228
+ #ifndef INADDR_LOOPBACK
229
+ #define INADDR_LOOPBACK 0x7f000001
230
+ #endif
231
+
232
+ #ifndef INET_ADDRSTRLEN
233
+ #define INET_ADDRSTRLEN 16
234
+ #endif
235
+
236
+ #ifndef INET6_ADDRSTRLEN
237
+ #define INET6_ADDRSTRLEN INET_ADDRSTRLEN
238
+ #endif
239
+
240
+ #ifndef IN_MULTICAST
241
+ #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
242
+ #endif
243
+ #ifndef IN6_IS_ADDR_MULTICAST
244
+ #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
245
+ #endif
246
+
247
+ int ff_is_multicast_address(struct sockaddr *addr);
248
+
249
+ #define POLLING_TIME 100 /// Time in milliseconds between interrupt check
250
+
251
+ /**
252
+ * Bind to a file descriptor and poll for a connection.
253
+ *
254
+ * @param fd First argument of bind().
255
+ * @param addr Second argument of bind().
256
+ * @param addrlen Third argument of bind().
257
+ * @param timeout Polling timeout in milliseconds.
258
+ * @param h URLContext providing interrupt check
259
+ * callback and logging context.
260
+ * @return A non-blocking file descriptor on success
261
+ * or an AVERROR on failure.
262
+ */
263
+ int ff_listen_bind(int fd, const struct sockaddr *addr,
264
+ socklen_t addrlen, int timeout,
265
+ URLContext *h);
266
+
267
+ /**
268
+ * Bind to a file descriptor to an address without accepting connections.
269
+ * @param fd First argument of bind().
270
+ * @param addr Second argument of bind().
271
+ * @param addrlen Third argument of bind().
272
+ * @return 0 on success or an AVERROR on failure.
273
+ */
274
+ int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen,
275
+ void *logctx);
276
+
277
+ /**
278
+ * Poll for a single connection on the passed file descriptor.
279
+ * @param fd The listening socket file descriptor.
280
+ * @param timeout Polling timeout in milliseconds.
281
+ * @param h URLContext providing interrupt check
282
+ * callback and logging context.
283
+ * @return A non-blocking file descriptor on success
284
+ * or an AVERROR on failure.
285
+ */
286
+ int ff_accept(int fd, int timeout, URLContext *h);
287
+
288
+ /**
289
+ * Connect to a file descriptor and poll for result.
290
+ *
291
+ * @param fd First argument of connect(),
292
+ * will be set as non-blocking.
293
+ * @param addr Second argument of connect().
294
+ * @param addrlen Third argument of connect().
295
+ * @param timeout Polling timeout in milliseconds.
296
+ * @param h URLContext providing interrupt check
297
+ * callback and logging context.
298
+ * @param will_try_next Whether the caller will try to connect to another
299
+ * address for the same host name, affecting the form of
300
+ * logged errors.
301
+ * @return 0 on success, AVERROR on failure.
302
+ */
303
+ int ff_listen_connect(int fd, const struct sockaddr *addr,
304
+ socklen_t addrlen, int timeout,
305
+ URLContext *h, int will_try_next);
306
+
307
+ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
308
+
309
+ int ff_socket(int domain, int type, int protocol, void *logctx);
310
+
311
+ void ff_log_net_error(void *ctx, int level, const char* prefix);
312
+
313
+ /**
314
+ * Connect to any of the given addrinfo addresses, with multiple attempts
315
+ * running in parallel.
316
+ *
317
+ * @param addrs The list of addresses to try to connect to.
318
+ * This list will be mutated internally, but the list head
319
+ * will remain as such, so this doesn't affect the caller
320
+ * freeing the list afterwards.
321
+ * @param timeout_ms_per_address The number of milliseconds to wait for each
322
+ * connection attempt. Since multiple addresses are tried,
323
+ * some of them in parallel, the total run time will at most
324
+ * be timeout_ms_per_address*ceil(nb_addrs/parallel) +
325
+ * (parallel - 1) * NEXT_ATTEMPT_DELAY_MS.
326
+ * @param parallel The maximum number of connections to attempt in parallel.
327
+ * This is limited to an internal maximum capacity.
328
+ * @param h URLContext providing interrupt check
329
+ * callback and logging context.
330
+ * @param fd If successful, the connected socket is returned here.
331
+ * @param customize_fd Function that will be called for each socket created,
332
+ * to allow the caller to set socket options before calling
333
+ * connect() on it, may be NULL.
334
+ * @param customize_ctx Context parameter passed to customize_fd.
335
+ * @return 0 on success, AVERROR on failure.
336
+ */
337
+ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
338
+ int parallel, URLContext *h, int *fd,
339
+ void (*customize_fd)(void *, int), void *customize_ctx);
340
+
341
+ #endif /* AVFORMAT_NETWORK_H */
@@ -0,0 +1,317 @@
1
+ /*
2
+ * various OS-feature replacement utilities
3
+ * copyright (c) 2000, 2001, 2002 Fabrice Bellard
4
+ *
5
+ * This file is part of FFmpeg.
6
+ *
7
+ * FFmpeg is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * FFmpeg is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with FFmpeg; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ */
21
+
22
+ #ifndef AVFORMAT_OS_SUPPORT_H
23
+ #define AVFORMAT_OS_SUPPORT_H
24
+
25
+ /**
26
+ * @file
27
+ * miscellaneous OS support macros and functions.
28
+ */
29
+
30
+ #include "config.h"
31
+
32
+ #include <sys/stat.h>
33
+
34
+ #ifdef _WIN32
35
+ #if HAVE_DIRECT_H
36
+ #include <direct.h>
37
+ #endif
38
+ #if HAVE_IO_H
39
+ #include <io.h>
40
+ #endif
41
+ #endif
42
+
43
+ #ifdef _WIN32
44
+ # include <fcntl.h>
45
+ # include <stdint.h>
46
+ # ifdef lseek
47
+ # undef lseek
48
+ # endif
49
+ # define lseek(f,p,w) _lseeki64((f), (p), (w))
50
+ # ifdef stat
51
+ # undef stat
52
+ # endif
53
+
54
+ # define stat win32_stat
55
+
56
+ /*
57
+ * The POSIX definition for the stat() function uses a struct of the
58
+ * same name (struct stat), that why it takes this extra effort for
59
+ * redirecting/replacing the stat() function with our own one which
60
+ * is capable to handle long path names on Windows.
61
+ * The struct below roughly follows the POSIX definition. Time values
62
+ * are 64bit, but in cases when _USE_32BIT_TIME_T is defined, they
63
+ * will be set to values no larger than INT32_MAX which corresponds
64
+ * to file times up to the year 2038.
65
+ */
66
+ struct win32_stat
67
+ {
68
+ _dev_t st_dev; /* ID of device containing file */
69
+ _ino_t st_ino; /* inode number */
70
+ unsigned short st_mode; /* protection */
71
+ short st_nlink; /* number of hard links */
72
+ short st_uid; /* user ID of owner */
73
+ short st_gid; /* group ID of owner */
74
+ _dev_t st_rdev; /* device ID (if special file) */
75
+ int64_t st_size; /* total size, in bytes */
76
+ int64_t st_atime; /* time of last access */
77
+ int64_t st_mtime; /* time of last modification */
78
+ int64_t st_ctime; /* time of last status change */
79
+ };
80
+
81
+ # ifdef fstat
82
+ # undef fstat
83
+ # endif
84
+ # define fstat win32_fstat
85
+ #endif /* defined(_WIN32) */
86
+
87
+
88
+ #ifdef __ANDROID__
89
+ # if HAVE_UNISTD_H
90
+ # include <unistd.h>
91
+ # endif
92
+ # ifdef lseek
93
+ # undef lseek
94
+ # endif
95
+ # define lseek(f,p,w) lseek64((f), (p), (w))
96
+ #endif
97
+
98
+ static inline int is_dos_path(const char *path)
99
+ {
100
+ #if HAVE_DOS_PATHS
101
+ if (path[0] && path[1] == ':')
102
+ return 1;
103
+ #endif
104
+ return 0;
105
+ }
106
+
107
+ #if defined(_WIN32)
108
+ #ifndef S_IRUSR
109
+ #define S_IRUSR S_IREAD
110
+ #endif
111
+ #ifndef S_IWUSR
112
+ #define S_IWUSR S_IWRITE
113
+ #endif
114
+ #endif
115
+
116
+ #if CONFIG_NETWORK
117
+ #if defined(_WIN32)
118
+ #define SHUT_RD SD_RECEIVE
119
+ #define SHUT_WR SD_SEND
120
+ #define SHUT_RDWR SD_BOTH
121
+ #else
122
+ #include <sys/socket.h>
123
+ #if !defined(SHUT_RD) /* OS/2, DJGPP */
124
+ #define SHUT_RD 0
125
+ #define SHUT_WR 1
126
+ #define SHUT_RDWR 2
127
+ #endif
128
+ #endif
129
+
130
+ #if !HAVE_SOCKLEN_T
131
+ typedef int socklen_t;
132
+ #endif
133
+
134
+ /* most of the time closing a socket is just closing an fd */
135
+ #if !HAVE_CLOSESOCKET
136
+ #define closesocket close
137
+ #endif
138
+
139
+ #if !HAVE_POLL_H
140
+ typedef unsigned long nfds_t;
141
+
142
+ #if HAVE_WINSOCK2_H
143
+ #include <winsock2.h>
144
+ #endif
145
+ #if !HAVE_STRUCT_POLLFD
146
+ struct pollfd {
147
+ int fd;
148
+ short events; /* events to look for */
149
+ short revents; /* events that occurred */
150
+ };
151
+
152
+ /* events & revents */
153
+ #define POLLIN 0x0001 /* any readable data available */
154
+ #define POLLOUT 0x0002 /* file descriptor is writeable */
155
+ #define POLLRDNORM POLLIN
156
+ #define POLLWRNORM POLLOUT
157
+ #define POLLRDBAND 0x0008 /* priority readable data */
158
+ #define POLLWRBAND 0x0010 /* priority data can be written */
159
+ #define POLLPRI 0x0020 /* high priority readable data */
160
+
161
+ /* revents only */
162
+ #define POLLERR 0x0004 /* errors pending */
163
+ #define POLLHUP 0x0080 /* disconnected */
164
+ #define POLLNVAL 0x1000 /* invalid file descriptor */
165
+ #endif
166
+
167
+
168
+ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout);
169
+ #define poll ff_poll
170
+ #endif /* HAVE_POLL_H */
171
+ #endif /* CONFIG_NETWORK */
172
+
173
+ #ifdef _WIN32
174
+ #include <stdio.h>
175
+ #include <windows.h>
176
+ #include "libavutil/wchar_filename.h"
177
+
178
+ #define DEF_FS_FUNCTION(name, wfunc, afunc) \
179
+ static inline int win32_##name(const char *filename_utf8) \
180
+ { \
181
+ wchar_t *filename_w; \
182
+ int ret; \
183
+ \
184
+ if (get_extended_win32_path(filename_utf8, &filename_w)) \
185
+ return -1; \
186
+ if (!filename_w) \
187
+ goto fallback; \
188
+ \
189
+ ret = wfunc(filename_w); \
190
+ av_free(filename_w); \
191
+ return ret; \
192
+ \
193
+ fallback: \
194
+ /* filename may be be in CP_ACP */ \
195
+ return afunc(filename_utf8); \
196
+ }
197
+
198
+ DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
199
+ DEF_FS_FUNCTION(mkdir, _wmkdir, _mkdir)
200
+ DEF_FS_FUNCTION(rmdir, _wrmdir , _rmdir)
201
+
202
+ static inline int win32_access(const char *filename_utf8, int mode)
203
+ {
204
+ wchar_t *filename_w;
205
+ int ret;
206
+ if (get_extended_win32_path(filename_utf8, &filename_w))
207
+ return -1;
208
+ if (!filename_w)
209
+ goto fallback;
210
+ ret = _waccess(filename_w, mode);
211
+ av_free(filename_w);
212
+ return ret;
213
+ fallback:
214
+ return _access(filename_utf8, mode);
215
+ }
216
+
217
+ static inline void copy_stat(struct _stat64 *crtstat, struct win32_stat *buf)
218
+ {
219
+ buf->st_dev = crtstat->st_dev;
220
+ buf->st_ino = crtstat->st_ino;
221
+ buf->st_mode = crtstat->st_mode;
222
+ buf->st_nlink = crtstat->st_nlink;
223
+ buf->st_uid = crtstat->st_uid;
224
+ buf->st_gid = crtstat->st_gid;
225
+ buf->st_rdev = crtstat->st_rdev;
226
+ buf->st_size = crtstat->st_size;
227
+ buf->st_atime = crtstat->st_atime;
228
+ buf->st_mtime = crtstat->st_mtime;
229
+ buf->st_ctime = crtstat->st_ctime;
230
+ }
231
+
232
+ static inline int win32_stat(const char *filename_utf8, struct win32_stat *buf)
233
+ {
234
+ struct _stat64 crtstat = { 0 };
235
+ wchar_t *filename_w;
236
+ int ret;
237
+
238
+ if (get_extended_win32_path(filename_utf8, &filename_w))
239
+ return -1;
240
+
241
+ if (filename_w) {
242
+ ret = _wstat64(filename_w, &crtstat);
243
+ av_free(filename_w);
244
+ } else
245
+ ret = _stat64(filename_utf8, &crtstat);
246
+
247
+ copy_stat(&crtstat, buf);
248
+
249
+ return ret;
250
+ }
251
+
252
+ static inline int win32_fstat(int fd, struct win32_stat *buf)
253
+ {
254
+ struct _stat64 crtstat = { 0 };
255
+ int ret;
256
+
257
+ ret = _fstat64(fd, &crtstat);
258
+
259
+ copy_stat(&crtstat, buf);
260
+
261
+ return ret;
262
+ }
263
+
264
+ static inline int win32_rename(const char *src_utf8, const char *dest_utf8)
265
+ {
266
+ wchar_t *src_w, *dest_w;
267
+ int ret;
268
+
269
+ if (get_extended_win32_path(src_utf8, &src_w))
270
+ return -1;
271
+ if (get_extended_win32_path(dest_utf8, &dest_w)) {
272
+ av_free(src_w);
273
+ return -1;
274
+ }
275
+ if (!src_w || !dest_w) {
276
+ av_free(src_w);
277
+ av_free(dest_w);
278
+ goto fallback;
279
+ }
280
+
281
+ ret = MoveFileExW(src_w, dest_w, MOVEFILE_REPLACE_EXISTING);
282
+ av_free(src_w);
283
+ av_free(dest_w);
284
+ // Lacking proper mapping from GetLastError() error codes to errno codes
285
+ if (ret)
286
+ errno = EPERM;
287
+ return ret;
288
+
289
+ fallback:
290
+ /* filename may be be in CP_ACP */
291
+ #if !HAVE_UWP
292
+ ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
293
+ if (ret)
294
+ errno = EPERM;
295
+ #else
296
+ /* Windows Phone doesn't have MoveFileExA, and for Windows Store apps,
297
+ * it is available but not allowed by the app certification kit. However,
298
+ * it's unlikely that anybody would input filenames in CP_ACP there, so this
299
+ * fallback is kept mostly for completeness. Alternatively we could
300
+ * do MultiByteToWideChar(CP_ACP) and use MoveFileExW, but doing
301
+ * explicit conversions with CP_ACP is allegedly forbidden in windows
302
+ * store apps (or windows phone), and the notion of a native code page
303
+ * doesn't make much sense there. */
304
+ ret = rename(src_utf8, dest_utf8);
305
+ #endif
306
+ return ret;
307
+ }
308
+
309
+ #define mkdir(a, b) win32_mkdir(a)
310
+ #define rename win32_rename
311
+ #define rmdir win32_rmdir
312
+ #define unlink win32_unlink
313
+ #define access win32_access
314
+
315
+ #endif
316
+
317
+ #endif /* AVFORMAT_OS_SUPPORT_H */