bare-ffmpeg 1.0.0-23 → 1.0.0-24

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.
package/binding.cc CHANGED
@@ -33,8 +33,8 @@ extern "C" {
33
33
  #include <libswscale/swscale.h>
34
34
  }
35
35
 
36
- using bare_ffmpeg_io_context_write_cb_t = js_function_t<void, js_typedarray_t<uint8_t>>;
37
- using bare_ffmpeg_io_context_read_cb_t = js_function_t<int32_t, js_typedarray_t<uint8_t>, int32_t>;
36
+ using bare_ffmpeg_io_context_write_cb_t = js_function_t<void, js_arraybuffer_t>;
37
+ using bare_ffmpeg_io_context_read_cb_t = js_function_t<int32_t, js_arraybuffer_t, int32_t>;
38
38
  using bare_ffmpeg_io_context_seek_cb_t = js_function_t<int64_t, int64_t, std::string>;
39
39
 
40
40
  typedef struct {
@@ -144,12 +144,7 @@ bare_ffmpeg__on_io_context_write(void *opaque, const uint8_t *buf, int len) {
144
144
  err = js_create_arraybuffer(env, buf, static_cast<size_t>(len), data);
145
145
  assert(err == 0);
146
146
 
147
- js_typedarray_t<uint8_t> view;
148
- err = js_create_typedarray(env, static_cast<size_t>(len), data, view);
149
- assert(err == 0);
150
-
151
-
152
- err = js_call_function(env, callback, view);
147
+ err = js_call_function(env, callback, data);
153
148
  assert(err == 0);
154
149
 
155
150
  return 0;
@@ -171,12 +166,8 @@ bare_ffmpeg__on_io_context_read(void *opaque, uint8_t *buf, int len) {
171
166
  err = js_create_external_arraybuffer(env, buf, static_cast<size_t>(len), arraybuffer);
172
167
  assert(err == 0);
173
168
 
174
- js_typedarray_t<uint8_t> view;
175
- err = js_create_typedarray(env, static_cast<size_t>(len), arraybuffer, view);
176
- assert(err == 0);
177
-
178
169
  int32_t result;
179
- int call_status = js_call_function<js_type_options_t{}, int32_t, js_typedarray_t<uint8_t>, int32_t>(env, callback, view, len, result);
170
+ int call_status = js_call_function<js_type_options_t{}, int32_t, js_arraybuffer_t, int32_t>(env, callback, arraybuffer, len, result);
180
171
 
181
172
  err = js_detach_arraybuffer(env, arraybuffer);
182
173
  assert(err == 0);
package/lib/io-context.js CHANGED
@@ -20,8 +20,8 @@ module.exports = class FFmpegIOContext {
20
20
  buffer,
21
21
  offset,
22
22
  len,
23
- opts.onwrite,
24
- opts.onread,
23
+ opts.onwrite && onwriteWrapper.bind(null, opts.onwrite),
24
+ opts.onread && onreadWrapper.bind(null, opts.onread),
25
25
  opts.onseek
26
26
  )
27
27
  }
@@ -35,3 +35,11 @@ module.exports = class FFmpegIOContext {
35
35
  this.destroy()
36
36
  }
37
37
  }
38
+
39
+ function onwriteWrapper(target, arraybuffer) {
40
+ return target(Buffer.from(arraybuffer))
41
+ }
42
+
43
+ function onreadWrapper(target, arraybuffer, requestedLen) {
44
+ return target(Buffer.from(arraybuffer), requestedLen)
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-ffmpeg",
3
- "version": "1.0.0-23",
3
+ "version": "1.0.0-24",
4
4
  "description": "Low-level FFmpeg bindings for Bare",
5
5
  "exports": {
6
6
  ".": "./index.js",