Add JavaI420Buffer to the API.

This renames I420BufferImpl to JavaI420Buffer and moves it as part of
the API.

Bug: webrtc:7749
Change-Id: I70726f248ba4601b4922996712bdfdafbfa4a1e1
Reviewed-on: https://webrtc-review.googlesource.com/5381
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20145}
This commit is contained in:
Sami Kalliomäki
2017-10-04 17:01:00 +02:00
committed by Commit Bot
parent 4332d09028
commit 48b3c0272f
11 changed files with 87 additions and 45 deletions

View File

@ -37,33 +37,32 @@ import org.junit.runner.RunWith;
// EmptyActivity is needed for the surface.
@RunWith(BaseJUnit4ClassRunner.class)
public class EglRendererTest {
final static String TAG = "EglRendererTest";
final static int RENDER_WAIT_MS = 1000;
final static int SURFACE_WAIT_MS = 1000;
final static int TEST_FRAME_WIDTH = 4;
final static int TEST_FRAME_HEIGHT = 4;
final static int REMOVE_FRAME_LISTENER_RACY_NUM_TESTS = 10;
private final static String TAG = "EglRendererTest";
private final static int RENDER_WAIT_MS = 1000;
private final static int SURFACE_WAIT_MS = 1000;
private final static int TEST_FRAME_WIDTH = 4;
private final static int TEST_FRAME_HEIGHT = 4;
private final static int REMOVE_FRAME_LISTENER_RACY_NUM_TESTS = 10;
// Some arbitrary frames.
final static ByteBuffer[][] TEST_FRAMES = {
private final static byte[][][] TEST_FRAMES_DATA = {
{
ByteBuffer.wrap(new byte[] {
11, -12, 13, -14, -15, 16, -17, 18, 19, -110, 111, -112, -113, 114, -115, 116}),
ByteBuffer.wrap(new byte[] {117, 118, 119, 120}),
ByteBuffer.wrap(new byte[] {121, 122, 123, 124}),
new byte[] {
11, -12, 13, -14, -15, 16, -17, 18, 19, -110, 111, -112, -113, 114, -115, 116},
new byte[] {117, 118, 119, 120}, new byte[] {121, 122, 123, 124},
},
{
ByteBuffer.wrap(new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -19, -110, -111, -112,
-113, -114, -115, -116}),
ByteBuffer.wrap(new byte[] {-121, -122, -123, -124}),
ByteBuffer.wrap(new byte[] {-117, -118, -119, -120}),
new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -19, -110, -111, -112, -113, -114,
-115, -116},
new byte[] {-121, -122, -123, -124}, new byte[] {-117, -118, -119, -120},
},
{
ByteBuffer.wrap(new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -19, -110, -111, -112,
-113, -114, -115, -116}),
ByteBuffer.wrap(new byte[] {117, 118, 119, 120}),
ByteBuffer.wrap(new byte[] {121, 122, 123, 124}),
new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -19, -110, -111, -112, -113, -114,
-115, -116},
new byte[] {117, 118, 119, 120}, new byte[] {121, 122, 123, 124},
},
};
private final static ByteBuffer[][] TEST_FRAMES =
copyTestDataToDirectByteBuffers(TEST_FRAMES_DATA);
private class TestFrameListener implements EglRenderer.FrameListener {
final private ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
@ -335,4 +334,18 @@ public class EglRendererTest {
feedFrame(1);
assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
}
private static ByteBuffer[][] copyTestDataToDirectByteBuffers(byte[][][] testData) {
final ByteBuffer[][] result = new ByteBuffer[testData.length][];
for (int i = 0; i < testData.length; i++) {
result[i] = new ByteBuffer[testData[i].length];
for (int j = 0; j < testData[i].length; j++) {
result[i][j] = ByteBuffer.allocateDirect(testData[i][j].length);
result[i][j].put(testData[i][j]);
result[i][j].rewind();
}
}
return result;
}
}

View File

@ -122,7 +122,7 @@ public final class HardwareVideoDecoderTest {
VideoCodecStatus.OK);
// First, encode a frame.
VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTINGS.height);
VideoFrame.I420Buffer buffer = JavaI420Buffer.allocate(SETTINGS.width, SETTINGS.height);
VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs * 1000);
VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo(
new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey});
@ -197,7 +197,7 @@ public final class HardwareVideoDecoderTest {
VideoCodecStatus.OK);
// First, encode a frame.
VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTINGS.height);
VideoFrame.I420Buffer buffer = JavaI420Buffer.allocate(SETTINGS.width, SETTINGS.height);
VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs * 1000);
VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo(
new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey});

View File

@ -179,7 +179,7 @@ public class HardwareVideoEncoderTest {
@Override
public VideoFrame.I420Buffer toI420() {
return I420BufferImpl.allocate(width, height);
return JavaI420Buffer.allocate(width, height);
}
@Override
@ -191,12 +191,12 @@ public class HardwareVideoEncoderTest {
}
private static class MockI420Buffer extends MockBufferBase implements VideoFrame.I420Buffer {
private final I420BufferImpl realBuffer;
private final JavaI420Buffer realBuffer;
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 = I420BufferImpl.allocate(width, height);
realBuffer = JavaI420Buffer.allocate(width, height);
}
@Override