@meframe/core 0.0.15 → 0.0.17

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 (53) hide show
  1. package/dist/cache/CacheManager.d.ts +2 -1
  2. package/dist/cache/CacheManager.d.ts.map +1 -1
  3. package/dist/cache/CacheManager.js +5 -2
  4. package/dist/cache/CacheManager.js.map +1 -1
  5. package/dist/cache/l1/AudioL1Cache.d.ts +1 -1
  6. package/dist/cache/l1/AudioL1Cache.d.ts.map +1 -1
  7. package/dist/cache/l1/AudioL1Cache.js +3 -2
  8. package/dist/cache/l1/AudioL1Cache.js.map +1 -1
  9. package/dist/controllers/PlaybackController.d.ts.map +1 -1
  10. package/dist/controllers/PlaybackController.js +1 -3
  11. package/dist/controllers/PlaybackController.js.map +1 -1
  12. package/dist/model/CompositionModel.d.ts +2 -2
  13. package/dist/model/CompositionModel.d.ts.map +1 -1
  14. package/dist/model/CompositionModel.js +23 -10
  15. package/dist/model/CompositionModel.js.map +1 -1
  16. package/dist/model/patch.js +3 -1
  17. package/dist/model/patch.js.map +1 -1
  18. package/dist/model/types.d.ts +9 -0
  19. package/dist/model/types.d.ts.map +1 -1
  20. package/dist/model/types.js +4 -0
  21. package/dist/model/types.js.map +1 -1
  22. package/dist/orchestrator/ClipSessionManager.d.ts +1 -1
  23. package/dist/orchestrator/ClipSessionManager.d.ts.map +1 -1
  24. package/dist/orchestrator/ClipSessionManager.js +7 -4
  25. package/dist/orchestrator/ClipSessionManager.js.map +1 -1
  26. package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
  27. package/dist/orchestrator/CompositionPlanner.js +4 -0
  28. package/dist/orchestrator/CompositionPlanner.js.map +1 -1
  29. package/dist/orchestrator/Orchestrator.d.ts.map +1 -1
  30. package/dist/orchestrator/Orchestrator.js +29 -1
  31. package/dist/orchestrator/Orchestrator.js.map +1 -1
  32. package/dist/orchestrator/VideoClipSession.d.ts +7 -0
  33. package/dist/orchestrator/VideoClipSession.d.ts.map +1 -1
  34. package/dist/orchestrator/VideoClipSession.js +55 -5
  35. package/dist/orchestrator/VideoClipSession.js.map +1 -1
  36. package/dist/stages/compose/GlobalAudioSession.d.ts +4 -0
  37. package/dist/stages/compose/GlobalAudioSession.d.ts.map +1 -1
  38. package/dist/stages/compose/GlobalAudioSession.js +122 -21
  39. package/dist/stages/compose/GlobalAudioSession.js.map +1 -1
  40. package/dist/stages/compose/OfflineAudioMixer.d.ts.map +1 -1
  41. package/dist/stages/compose/OfflineAudioMixer.js +21 -6
  42. package/dist/stages/compose/OfflineAudioMixer.js.map +1 -1
  43. package/dist/stages/decode/AudioChunkDecoder.d.ts +8 -1
  44. package/dist/stages/decode/AudioChunkDecoder.d.ts.map +1 -1
  45. package/dist/stages/demux/MP4Demuxer.d.ts +10 -4
  46. package/dist/stages/demux/MP4Demuxer.d.ts.map +1 -1
  47. package/dist/workers/MP4Demuxer.js +65 -29
  48. package/dist/workers/MP4Demuxer.js.map +1 -1
  49. package/dist/workers/stages/decode/audio-decode.worker.js +101 -7
  50. package/dist/workers/stages/decode/audio-decode.worker.js.map +1 -1
  51. package/dist/workers/stages/demux/video-demux.worker.js +48 -15
  52. package/dist/workers/stages/demux/video-demux.worker.js.map +1 -1
  53. package/package.json +1 -1
@@ -7054,9 +7054,11 @@ class MP4Demuxer {
7054
7054
  fileOffset = 0;
7055
7055
  videoTimestampOffset = null;
7056
7056
  audioTimestampOffset = null;
7057
+ skipAudio = false;
7057
7058
  constructor(config = {}) {
7058
7059
  this.mp4boxFile = mp4box_all.createFile();
7059
7060
  this.onReadyCallback = config.onReady;
7061
+ this.skipAudio = config.skipAudio ?? false;
7060
7062
  const DEFAULT_HIGH_WATER_MARK = 10;
7061
7063
  this.demuxHighWaterMark = config.highWaterMark ?? DEFAULT_HIGH_WATER_MARK;
7062
7064
  this.setupHandlers();
@@ -7129,7 +7131,12 @@ class MP4Demuxer {
7129
7131
  data: sample.data
7130
7132
  });
7131
7133
  this.videoController.enqueue(chunk);
7132
- } else if (track.type === "audio" && this.audioController) {
7134
+ } else if (track.type === "audio") {
7135
+ if (!this.audioController) {
7136
+ const last2 = samples[samples.length - 1].number;
7137
+ this.mp4boxFile.releaseUsedSamples(trackId, last2 + 1);
7138
+ return;
7139
+ }
7133
7140
  if (this.audioTimestampOffset === null) {
7134
7141
  this.audioTimestampOffset = rawTimestamp;
7135
7142
  }
@@ -7175,9 +7182,27 @@ class MP4Demuxer {
7175
7182
  try {
7176
7183
  const fullTrack = this.mp4boxFile.getTrackById(track.id);
7177
7184
  for (const entry of fullTrack.mdia.minf.stbl.stsd.entries) {
7178
- if (entry.esds || entry.dOps) {
7179
- const stream = new mp4box_all.DataStream();
7180
- (entry.esds || entry.dOps).write(stream);
7185
+ if (entry.esds) {
7186
+ const decConfigDesc = entry.esds.esd?.descs?.[0];
7187
+ const decSpecInfo = decConfigDesc?.descs?.[0];
7188
+ if (decSpecInfo?.data) {
7189
+ const data = decSpecInfo.data;
7190
+ if (data instanceof Uint8Array) {
7191
+ const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
7192
+ return buffer instanceof ArrayBuffer ? buffer : void 0;
7193
+ } else if (Array.isArray(data)) {
7194
+ return new Uint8Array(data).buffer;
7195
+ }
7196
+ }
7197
+ console.warn("[MP4Demuxer] Could not extract AudioSpecificConfig from esds structure");
7198
+ return void 0;
7199
+ } else if (entry.dOps) {
7200
+ const stream = new mp4box_all.DataStream(
7201
+ void 0,
7202
+ 0,
7203
+ mp4box_all.DataStream.BIG_ENDIAN
7204
+ );
7205
+ entry.dOps.write(stream);
7181
7206
  return new Uint8Array(stream.buffer.slice(8)).buffer;
7182
7207
  }
7183
7208
  }
@@ -7187,56 +7212,67 @@ class MP4Demuxer {
7187
7212
  return void 0;
7188
7213
  }
7189
7214
  /**
7190
- * Create transform stream for video track
7215
+ * Create readable stream for video chunks (output only)
7191
7216
  */
7192
7217
  createVideoStream() {
7193
- return new TransformStream(
7218
+ return new ReadableStream(
7194
7219
  {
7195
- start: (controller) => {
7196
- this.videoController = controller;
7197
- },
7198
- transform: (chunk, _controller) => {
7199
- const chunkData = new Uint8Array(chunk);
7200
- this.appendBuffer(chunkData);
7201
- this.mp4boxFile.flush();
7220
+ start: (ctrl) => {
7221
+ this.videoController = ctrl;
7202
7222
  },
7203
- flush: async () => {
7204
- this.mp4boxFile.flush();
7205
- await new Promise((resolve) => setTimeout(resolve, 100));
7223
+ cancel: () => {
7224
+ this.videoController = void 0;
7206
7225
  }
7207
7226
  },
7208
- // Queuing strategy: use configuration
7209
7227
  {
7210
7228
  highWaterMark: this.demuxHighWaterMark,
7211
7229
  size: () => 1
7212
- // Count-based
7213
7230
  }
7214
7231
  );
7215
7232
  }
7216
7233
  /**
7217
- * Create transform stream for audio track
7234
+ * Create readable stream for audio chunks (output only)
7218
7235
  */
7219
7236
  createAudioStream() {
7220
- const hasAudio = Array.from(this.tracks.values()).some((t) => t.type === "audio");
7221
- if (!hasAudio) return null;
7222
- return new TransformStream(
7237
+ if (this.skipAudio) {
7238
+ return null;
7239
+ }
7240
+ return new ReadableStream(
7223
7241
  {
7224
- start: (controller) => {
7225
- this.audioController = controller;
7242
+ start: (ctrl) => {
7243
+ this.audioController = ctrl;
7226
7244
  },
7227
- transform: (chunk, _controller) => {
7245
+ cancel: () => {
7246
+ this.audioController = void 0;
7247
+ }
7248
+ },
7249
+ {
7250
+ highWaterMark: this.demuxHighWaterMark,
7251
+ size: () => 1
7252
+ }
7253
+ );
7254
+ }
7255
+ /**
7256
+ * Create writable stream for input data (single source)
7257
+ * This is the only stream that should receive the input data
7258
+ */
7259
+ createInputStream() {
7260
+ return new WritableStream(
7261
+ {
7262
+ write: (chunk) => {
7228
7263
  const chunkData = new Uint8Array(chunk);
7229
7264
  this.appendBuffer(chunkData);
7230
7265
  this.mp4boxFile.flush();
7231
7266
  },
7232
- flush: () => {
7267
+ close: async () => {
7233
7268
  this.mp4boxFile.flush();
7269
+ await new Promise((resolve) => setTimeout(resolve, 100));
7270
+ this.videoController?.close();
7271
+ this.audioController?.close();
7234
7272
  }
7235
7273
  },
7236
- // Queuing strategy: use configuration
7237
7274
  {
7238
- highWaterMark: this.demuxHighWaterMark,
7239
- size: () => 1
7275
+ highWaterMark: this.demuxHighWaterMark
7240
7276
  }
7241
7277
  );
7242
7278
  }