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

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: Re-design of VideoFileRendererTest Created 4 years, 1 month 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.File;
17 import java.io.IOException;
18 import java.io.RandomAccessFile;
19 import java.lang.Thread;
20 import java.nio.charset.StandardCharsets;
21 import java.nio.ByteBuffer;
22 import java.util.ArrayList;
23 import java.util.Random;
24
25 public class VideoFileRendererTest extends InstrumentationTestCase {
26 @SmallTest
27 public void testYuvRenderingToFile() throws InterruptedException, IOException {
28 EglBase eglBase = EglBase.create();
29 final String videoOutPath = "/sdcard/chromium_tests_root/testvideoout.y4m";
30 int frameWidth = 4;
31 int frameHeight = 4;
32 VideoFileRenderer videoFileRenderer =
33 new VideoFileRenderer(videoOutPath, frameWidth, frameHeight, eglBase.get EglBaseContext());
34
35 String[] frames = {
36 "THIS IS JUST SOME TEXT x", "THE SECOND FRAME qwerty.", "HERE IS THE THR ID FRAME!"};
37
38 for (String frameStr : frames) {
39 int[] planeSizes = {
40 frameWidth * frameWidth, frameWidth * frameHeight / 4, frameWidth * fr ameHeight / 4};
41
42 byte[] frameBytes = frameStr.getBytes(StandardCharsets.US_ASCII);
43 ByteBuffer[] yuvPlanes = new ByteBuffer[3];
44 int pos = 0;
45 for (int i = 0; i < 3; i++) {
46 yuvPlanes[i] = ByteBuffer.allocateDirect(planeSizes[i]);
47 yuvPlanes[i].put(frameBytes, pos, planeSizes[i]);
48 pos += planeSizes[i];
49 }
50
51 int[] yuvStrides = {frameWidth, frameWidth / 2, frameWidth / 2};
52
53 VideoRenderer.I420Frame frame =
54 new VideoRenderer.I420Frame(frameWidth, frameHeight, 0, yuvStrides, yu vPlanes, 0);
55
56 videoFileRenderer.renderFrame(frame);
57 }
58 videoFileRenderer.release();
59
60 RandomAccessFile writtenFile = new RandomAccessFile(videoOutPath, "r");
61 try {
62 int length = (int) writtenFile.length();
63 byte[] data = new byte[length];
64 writtenFile.readFully(data);
65 String fileContent = new String(data, StandardCharsets.US_ASCII);
66 String expected = "YUV4MPEG2 C420 W4 H4 Ip F30:1 A1:1\n"
67 + "FRAME\n"
68 + "THIS IS JUST SOME TEXT xFRAME\n"
69 + "THE SECOND FRAME qwerty.FRAME\n"
70 + "HERE IS THE THRID FRAME!";
71 assertEquals(expected, fileContent);
72 } finally {
73 writtenFile.close();
74 }
75
76 new File(videoOutPath).delete();
77 }
78 }
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