Update JavaI420Buffer.allocate to use native allocations.

This ensures memory is released timely and avoids problems with garbage
collection.

Native buffers don't support array operation, so FileVideoCapturer had
to be update to use FileChannel to write ByteBuffers directly.

Bug: None
Change-Id: I3f63d2adc159e9f39f0c68dd0bd6b1747686584e
Reviewed-on: https://webrtc-review.googlesource.com/55262
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22118}
This commit is contained in:
Sami Kalliomäki
2018-02-20 11:19:58 +01:00
committed by Commit Bot
parent defad847b1
commit 0611065256
5 changed files with 43 additions and 18 deletions

View File

@ -211,7 +211,6 @@ public class HardwareVideoEncoderTest {
public MockI420Buffer(int width, int height, Runnable releaseCallback) {
super(width, height, releaseCallback);
// We never release this but it is not a problem in practice because the release is a no-op.
realBuffer = JavaI420Buffer.allocate(width, height);
}
@ -251,6 +250,18 @@ public class HardwareVideoEncoderTest {
return this;
}
@Override
public void retain() {
super.retain();
realBuffer.retain();
}
@Override
public void release() {
super.release();
realBuffer.release();
}
@Override
public VideoFrame.Buffer cropAndScale(
int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight) {