Skip to content

Commit c5b2093

Browse files
committed
Transfer arraybuffer to chunk
1 parent 661957e commit c5b2093

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/avcomponents.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,16 @@ const AVComponentsLoaded = loadPolyfills().catch((error) => {
151151
})
152152

153153
export const createEncodedAudioChunk = (input) => {
154-
return new EncodedAudioChunk(input)
154+
const init = { ...input, transfer: [] }
155+
const data = init.data
156+
if (data) {
157+
if (data instanceof ArrayBuffer) {
158+
init.transfer.push(data)
159+
} else if (ArrayBuffer.isView(data)) {
160+
init.transfer.push(data.buffer)
161+
}
162+
}
163+
return new EncodedAudioChunk(init)
155164
}
156165

157166
export const createAudioData = (input) => {

src/avworker.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,19 @@ class AVVideoOutputProcessor extends AVOutputProcessor {
14851485
})
14861486

14871487
this.decrypt = new AVDecrypt({
1488-
// eslint-disable-next-line no-undef
1489-
chunkMaker: (arg) => new EncodedVideoChunk(arg),
1488+
chunkMaker: (arg) => {
1489+
const init = { ...arg, transfer: [] }
1490+
const data = init.data
1491+
if (data) {
1492+
if (data instanceof ArrayBuffer) {
1493+
init.transfer.push(data)
1494+
} else if (ArrayBuffer.isView(data)) {
1495+
init.transfer.push(data.buffer)
1496+
}
1497+
}
1498+
// eslint-disable-next-line no-undef
1499+
return new EncodedVideoChunk(init)
1500+
},
14901501
keyStore: KeyStore.getKeyStore()
14911502
})
14921503

0 commit comments

Comments
 (0)