webcodecs-utils 0.2.5 → 0.2.6

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 (54) hide show
  1. package/README.md +142 -0
  2. package/dist/audio/extract-channels.d.ts +45 -0
  3. package/dist/audio/extract-channels.d.ts.map +1 -0
  4. package/dist/audio/extract-channels.js +25 -0
  5. package/dist/audio/get-sample-rate.d.ts +19 -0
  6. package/dist/audio/get-sample-rate.d.ts.map +1 -0
  7. package/dist/audio/get-sample-rate.js +14 -0
  8. package/dist/audio/mp3.d.ts +162 -0
  9. package/dist/audio/mp3.d.ts.map +1 -0
  10. package/dist/audio/mp3.js +173 -0
  11. package/dist/demux/example-muxer.d.ts +74 -0
  12. package/dist/demux/example-muxer.d.ts.map +1 -0
  13. package/dist/demux/example-muxer.js +40 -0
  14. package/dist/demux/get-chunks.d.ts +81 -0
  15. package/dist/demux/get-chunks.d.ts.map +1 -0
  16. package/dist/demux/get-chunks.js +88 -0
  17. package/dist/demux/mp4-demuxer.d.ts +84 -0
  18. package/dist/demux/mp4-demuxer.d.ts.map +1 -0
  19. package/dist/demux/mp4-demuxer.js +215 -0
  20. package/dist/demux/simple-demuxer.d.ts +49 -0
  21. package/dist/demux/simple-demuxer.d.ts.map +1 -0
  22. package/dist/demux/simple-demuxer.js +87 -0
  23. package/dist/in-memory-storage.d.ts +30 -0
  24. package/dist/in-memory-storage.d.ts.map +1 -0
  25. package/dist/in-memory-storage.js +54 -0
  26. package/dist/index.cjs +5 -298
  27. package/dist/index.d.ts +17 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +36 -13877
  30. package/dist/mux/simple-muxer.d.ts +47 -0
  31. package/dist/mux/simple-muxer.d.ts.map +1 -0
  32. package/dist/mux/simple-muxer.js +83 -0
  33. package/dist/polyfills/media-stream-track-processor.d.ts +5 -0
  34. package/dist/polyfills/media-stream-track-processor.d.ts.map +1 -0
  35. package/dist/polyfills/media-stream-track-processor.js +109 -0
  36. package/dist/streams/video-decode-stream.d.ts +11 -0
  37. package/dist/streams/video-decode-stream.d.ts.map +1 -0
  38. package/dist/streams/video-decode-stream.js +39 -0
  39. package/dist/streams/video-encode-stream.d.ts +15 -0
  40. package/dist/streams/video-encode-stream.d.ts.map +1 -0
  41. package/dist/streams/video-encode-stream.js +40 -0
  42. package/dist/streams/video-process-stream.d.ts +22 -0
  43. package/dist/streams/video-process-stream.d.ts.map +1 -0
  44. package/dist/streams/video-process-stream.js +21 -0
  45. package/dist/video/get-bitrate.d.ts +35 -0
  46. package/dist/video/get-bitrate.d.ts.map +1 -0
  47. package/dist/video/get-bitrate.js +12 -0
  48. package/dist/video/get-codec-string.d.ts +46 -0
  49. package/dist/video/get-codec-string.d.ts.map +1 -0
  50. package/dist/video/get-codec-string.js +195 -0
  51. package/dist/video/gpu-renderer.d.ts +108 -0
  52. package/dist/video/gpu-renderer.d.ts.map +1 -0
  53. package/dist/video/gpu-renderer.js +266 -0
  54. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ class _ {
2
+ /**
3
+ * Create a new InMemoryStorage instance
4
+ * @param chunkSize Size of each chunk in bytes (default: 10MB)
5
+ */
6
+ constructor(s = 10 * 1024 * 1024) {
7
+ this.chunks = /* @__PURE__ */ new Map(), this._size = 0, this._chunkSize = s;
8
+ }
9
+ /**
10
+ * Write data to storage, handling overlaps efficiently
11
+ * @param data Data to write
12
+ * @param position Position to write at
13
+ */
14
+ write(s, e) {
15
+ this._size = Math.max(this._size, e + s.byteLength);
16
+ const h = Math.floor(e / this._chunkSize), u = Math.floor((e + s.byteLength - 1) / this._chunkSize);
17
+ for (let t = h; t <= u; t++) {
18
+ const n = t * this._chunkSize, i = n + this._chunkSize, c = Math.max(e, n), k = Math.min(e + s.byteLength, i) - c;
19
+ if (k <= 0) continue;
20
+ let o;
21
+ this.chunks.has(t) ? o = this.chunks.get(t) : (o = new Uint8Array(this._chunkSize), this.chunks.set(t, o));
22
+ const l = c - n, a = c - e;
23
+ for (let r = 0; r < k; r++)
24
+ o[l + r] = s[a + r];
25
+ }
26
+ }
27
+ /**
28
+ * Get the total size of data written
29
+ */
30
+ get size() {
31
+ return this._size;
32
+ }
33
+ /**
34
+ * Convert all stored chunks to a single Blob
35
+ * @param type MIME type for the Blob
36
+ */
37
+ toBlob(s = "application/octet-stream") {
38
+ if (this.chunks.size === 0)
39
+ return new Blob([], { type: s });
40
+ const e = Array.from(this.chunks.keys()).sort((t, n) => t - n), h = [];
41
+ for (let t = 0; t < e.length; t++) {
42
+ const n = e[t], i = this.chunks.get(n);
43
+ if (t === e.length - 1) {
44
+ const c = this._size - n * this._chunkSize;
45
+ c < this._chunkSize ? h.push(i.slice(0, c)) : h.push(i);
46
+ } else
47
+ h.push(i);
48
+ }
49
+ return new Blob(h, { type: s });
50
+ }
51
+ }
52
+ export {
53
+ _ as InMemoryStorage
54
+ };