Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: webrtc/examples/androidtests/src/org/appspot/apprtc/test/VideoFileRendererTest.java

Issue 2415563002: Testing of VideoFileRenderer with byte frames (Closed)
Patch Set: Merging to be up to date with master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 package org.webrtc;
12
13 import android.test.InstrumentationTestCase;
14 import android.test.suitebuilder.annotation.SmallTest;
15
16 import java.io.IOException;
17 import java.io.RandomAccessFile;
18 import java.lang.Thread;
19 import java.nio.ByteBuffer;
20 import java.util.ArrayList;
21 import java.util.Random;
22
23 public class VideoFileRendererTest extends InstrumentationTestCase {
sakal 2016/10/19 11:13:35 Try to make it a Robolectric test if possible. Fil
mandermo 2016/10/19 16:38:43 The problem that native code is called in VideoFil
24 @SmallTest
25 public void testYuvRenderingToFile() throws InterruptedException, IOException {
26 EglBase eglBase = EglBase.create();
27 int outputWidth = 64;
28 int outputHeight = 64;
29 final String videoOutpath = "/sdcard/chromium_tests_root/testvideoout.y4m";
30 VideoFileRenderer videoFileRenderer =
31 new VideoFileRenderer(videoOutpath, outputWidth, outputHeight, eglBase.g etEglBaseContext());
32
33 int inputWidth = 32;
34 int inputHeight = 32;
35 for (int frameIdx = 0; frameIdx < 4; frameIdx++) {
36 Random random = new Random(frameIdx * 42);
37 ByteBuffer[] yuvPlanes = new ByteBuffer[3];
38 int inputFrameSize = inputWidth * inputHeight * 3 / 2;
39 int[] planeSizes = {
40 inputWidth * inputWidth, inputWidth * inputHeight / 4, inputWidth * in putHeight / 4};
41 int[] yuvStrides = {inputWidth, inputWidth / 2, inputWidth / 2};
42 for (int i = 0; i < 3; i++) {
43 byte[] planeBytes = new byte[planeSizes[i]];
44 random.nextBytes(planeBytes);
45 ByteBuffer buffer = ByteBuffer.allocateDirect(inputFrameSize);
46 buffer.put(planeBytes);
sakal 2016/10/19 11:13:35 nit: Seems there is some unnecessary double alloca
mandermo 2016/10/19 16:38:43 As you said, it doesn't matter.
47 yuvPlanes[i] = buffer;
48 }
49 VideoRenderer.I420Frame frame =
50 new VideoRenderer.I420Frame(inputWidth, inputHeight, 0, yuvStrides, yu vPlanes, 0);
51
52 videoFileRenderer.renderFrame(frame);
53 }
54 videoFileRenderer.release();
55
56 RandomAccessFile writtenFile = new RandomAccessFile(videoOutpath, "r");
57 StringBuilder builder = new StringBuilder();
58 Random verificationRandom = new Random(23423);
59 String expectedData = "A5CC23AF39B91850A58176866D597446A49A9BA2C29F65B87B";
sakal 2016/10/19 11:13:35 I am assuming you ran this once and got this hash
mandermo 2016/10/19 16:38:43 Added some testing for the header now.
60 for (int i = 0; i < expectedData.length() / 2; i++) {
61 int pos = verificationRandom.nextInt((int) writtenFile.length());
62 writtenFile.seek(pos);
63 builder.append(String.format("%02X", writtenFile.readByte()));
64 }
65
66 assertEquals(expectedData, builder.toString());
67 }
68 }
OLDNEW
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698