@lumen5/beamcoder 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.circleci/config.yml +41 -0
  2. package/.circleci/images/testbeam10-4.1/Dockerfile +12 -0
  3. package/.circleci/test_image/Dockerfile +14 -0
  4. package/.circleci/test_image/build.md +13 -0
  5. package/.eslintrc.js +27 -0
  6. package/.github/workflows/publish-npm.yml +33 -0
  7. package/LICENSE +674 -0
  8. package/README.md +1221 -0
  9. package/beamstreams.js +692 -0
  10. package/binding.gyp +103 -0
  11. package/examples/encode_h264.js +92 -0
  12. package/examples/jpeg_app.js +55 -0
  13. package/examples/jpeg_filter_app.js +101 -0
  14. package/examples/make_mp4.js +123 -0
  15. package/images/beamcoder_small.jpg +0 -0
  16. package/index.d.ts +83 -0
  17. package/index.js +44 -0
  18. package/install_ffmpeg.js +240 -0
  19. package/package.json +45 -0
  20. package/scratch/decode_aac.js +38 -0
  21. package/scratch/decode_avci.js +50 -0
  22. package/scratch/decode_hevc.js +38 -0
  23. package/scratch/decode_pcm.js +39 -0
  24. package/scratch/make_a_mux.js +68 -0
  25. package/scratch/muxer.js +74 -0
  26. package/scratch/read_wav.js +35 -0
  27. package/scratch/simple_mux.js +39 -0
  28. package/scratch/stream_avci.js +127 -0
  29. package/scratch/stream_mp4.js +78 -0
  30. package/scratch/stream_mux.js +47 -0
  31. package/scratch/stream_pcm.js +82 -0
  32. package/scratch/stream_wav.js +62 -0
  33. package/scripts/install_beamcoder_dependencies.sh +25 -0
  34. package/src/adaptor.h +202 -0
  35. package/src/beamcoder.cc +937 -0
  36. package/src/beamcoder_util.cc +1129 -0
  37. package/src/beamcoder_util.h +206 -0
  38. package/src/codec.cc +7386 -0
  39. package/src/codec.h +44 -0
  40. package/src/codec_par.cc +1818 -0
  41. package/src/codec_par.h +40 -0
  42. package/src/decode.cc +569 -0
  43. package/src/decode.h +75 -0
  44. package/src/demux.cc +584 -0
  45. package/src/demux.h +88 -0
  46. package/src/encode.cc +496 -0
  47. package/src/encode.h +72 -0
  48. package/src/filter.cc +1888 -0
  49. package/src/filter.h +30 -0
  50. package/src/format.cc +5287 -0
  51. package/src/format.h +77 -0
  52. package/src/frame.cc +2681 -0
  53. package/src/frame.h +52 -0
  54. package/src/governor.cc +286 -0
  55. package/src/governor.h +30 -0
  56. package/src/hwcontext.cc +378 -0
  57. package/src/hwcontext.h +35 -0
  58. package/src/log.cc +186 -0
  59. package/src/log.h +20 -0
  60. package/src/mux.cc +834 -0
  61. package/src/mux.h +106 -0
  62. package/src/packet.cc +762 -0
  63. package/src/packet.h +49 -0
  64. package/test/codecParamsSpec.js +148 -0
  65. package/test/decoderSpec.js +56 -0
  66. package/test/demuxerSpec.js +41 -0
  67. package/test/encoderSpec.js +69 -0
  68. package/test/filtererSpec.js +47 -0
  69. package/test/formatSpec.js +343 -0
  70. package/test/frameSpec.js +145 -0
  71. package/test/introspectionSpec.js +73 -0
  72. package/test/muxerSpec.js +34 -0
  73. package/test/packetSpec.js +122 -0
  74. package/types/Beamstreams.d.ts +98 -0
  75. package/types/Codec.d.ts +123 -0
  76. package/types/CodecContext.d.ts +555 -0
  77. package/types/CodecPar.d.ts +108 -0
  78. package/types/Decoder.d.ts +137 -0
  79. package/types/Demuxer.d.ts +113 -0
  80. package/types/Encoder.d.ts +94 -0
  81. package/types/Filter.d.ts +324 -0
  82. package/types/FormatContext.d.ts +380 -0
  83. package/types/Frame.d.ts +295 -0
  84. package/types/HWContext.d.ts +62 -0
  85. package/types/Muxer.d.ts +121 -0
  86. package/types/Packet.d.ts +82 -0
  87. package/types/PrivClass.d.ts +25 -0
  88. package/types/Stream.d.ts +165 -0
package/src/mux.h ADDED
@@ -0,0 +1,106 @@
1
+ /*
2
+ Aerostat Beam Coder - Node.js native bindings for FFmpeg.
3
+ Copyright (C) 2019 Streampunk Media Ltd.
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ https://www.streampunk.media/ mailto:furnace@streampunk.media
19
+ 14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
20
+ */
21
+
22
+ #ifndef MUX_H
23
+ #define MUX_H
24
+
25
+ #include "node_api.h"
26
+ #include "beamcoder_util.h"
27
+ #include "format.h"
28
+ #include "frame.h"
29
+ #include "adaptor.h"
30
+
31
+ extern "C" {
32
+ #include <libavformat/avformat.h>
33
+ }
34
+
35
+ napi_value muxer(napi_env env, napi_callback_info info); // Set to interleaving once
36
+
37
+ void openIOExecute(napi_env env, void* data);
38
+ void openIOComplete(napi_env env, napi_status asyncStatus, void* data);
39
+ napi_value openIO(napi_env env, napi_callback_info info);
40
+
41
+ void writeHeaderExecute(napi_env env, void* data);
42
+ void writeHeaderComplete(napi_env env, napi_status asyncStatus, void* data);
43
+ napi_value writeHeader(napi_env env, napi_callback_info info);
44
+
45
+ void initOutputExecute(napi_env env, void* data);
46
+ void initOutputComplete(napi_env env, napi_status asyncStatus, void* data);
47
+ napi_value initOutput(napi_env env, napi_callback_info info);
48
+
49
+ void writeFrameExecute(napi_env env, void* data);
50
+ void writeFrameComplete(napi_env env, napi_status asyncStatus, void* data);
51
+ napi_value writeFrame(napi_env env, napi_callback_info info); // IF AVFrame, must include stream_index
52
+
53
+ void writeTrailerExecute(napi_env env, void* data);
54
+ void writeTrailerComplete(napi_env env, napi_status asyncStatus, void* data);
55
+ napi_value writeTrailer(napi_env env, napi_callback_info info);
56
+
57
+ napi_value forceClose(napi_env env, napi_callback_info info);
58
+
59
+ struct openIOCarrier : carrier {
60
+ AVFormatContext* format;
61
+ int flags = AVIO_FLAG_WRITE;
62
+ AVDictionary* options = nullptr;
63
+ ~openIOCarrier() {
64
+ if (options != nullptr) av_dict_free(&options);
65
+ }
66
+ };
67
+
68
+ struct writeHeaderCarrier : carrier {
69
+ AVFormatContext* format;
70
+ AVDictionary* options = nullptr;
71
+ int result = -1;
72
+ ~writeHeaderCarrier() {
73
+ if (options != nullptr) av_dict_free(&options);
74
+ }
75
+ };
76
+
77
+ struct initOutputCarrier : carrier {
78
+ AVFormatContext* format;
79
+ AVDictionary* options = nullptr;
80
+ int result = -1;
81
+ ~initOutputCarrier() {
82
+ if (options != nullptr) av_dict_free(&options);
83
+ }
84
+ };
85
+
86
+ struct writeFrameCarrier : carrier {
87
+ AVFormatContext* format;
88
+ Adaptor *adaptor = nullptr;
89
+ AVPacket* packet = nullptr;
90
+ AVFrame* frame = nullptr;
91
+ int streamIndex = 0;
92
+ bool interleaved = true;
93
+ ~writeFrameCarrier() {
94
+ if (packet != nullptr) { av_packet_free(&packet); }
95
+ if (frame != nullptr) { av_frame_free(&frame); }
96
+ }
97
+ };
98
+
99
+ struct writeTrailerCarrier : carrier {
100
+ AVFormatContext* format;
101
+ Adaptor *adaptor = nullptr;
102
+ ~writeTrailerCarrier() {
103
+ }
104
+ };
105
+
106
+ #endif // MUX_H