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

Side by Side Diff: talk/app/webrtc/androidtests/src/org/webrtc/MediaCodecVideoEncoderTest.java

Issue 1461083002: Use EGL14 if supported on Android (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changed VideoRendererGui to return an EglBase.Context. Created 5 years 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 20 matching lines...) Expand all
31 import android.opengl.GLES20; 31 import android.opengl.GLES20;
32 import android.os.Build; 32 import android.os.Build;
33 import android.test.ActivityTestCase; 33 import android.test.ActivityTestCase;
34 import android.test.suitebuilder.annotation.SmallTest; 34 import android.test.suitebuilder.annotation.SmallTest;
35 import android.util.Log; 35 import android.util.Log;
36 36
37 import org.webrtc.MediaCodecVideoEncoder.OutputBufferInfo; 37 import org.webrtc.MediaCodecVideoEncoder.OutputBufferInfo;
38 38
39 import java.nio.ByteBuffer; 39 import java.nio.ByteBuffer;
40 40
41 import javax.microedition.khronos.egl.EGL10;
42
43 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) 41 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
44 public final class MediaCodecVideoEncoderTest extends ActivityTestCase { 42 public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
45 final static String TAG = "MediaCodecVideoEncoderTest"; 43 final static String TAG = "MediaCodecVideoEncoderTest";
46 44
47 @SmallTest 45 @SmallTest
48 public static void testInitializeUsingByteBuffer() { 46 public static void testInitializeUsingByteBuffer() {
49 if (!MediaCodecVideoEncoder.isVp8HwSupported()) { 47 if (!MediaCodecVideoEncoder.isVp8HwSupported()) {
50 Log.i(TAG, 48 Log.i(TAG,
51 "Hardware does not support VP8 encoding, skipping testInitReleaseUsi ngByteBuffer"); 49 "Hardware does not support VP8 encoding, skipping testInitReleaseUsi ngByteBuffer");
52 return; 50 return;
53 } 51 }
54 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); 52 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
55 assertTrue(encoder.initEncode( 53 assertTrue(encoder.initEncode(
56 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 , null)); 54 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 , null));
57 encoder.release(); 55 encoder.release();
58 } 56 }
59 57
60 @SmallTest 58 @SmallTest
61 public static void testInitilizeUsingTextures() { 59 public static void testInitilizeUsingTextures() {
62 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { 60 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
63 Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUs ingTextures"); 61 Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUs ingTextures");
64 return; 62 return;
65 } 63 }
64 EglBase eglBase = EglBase.create();
66 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); 65 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
67 assertTrue(encoder.initEncode( 66 assertTrue(encoder.initEncode(
68 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 , 67 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 ,
69 EGL10.EGL_NO_CONTEXT)); 68 eglBase.getEglBaseContext()));
70 encoder.release(); 69 encoder.release();
70 eglBase.release();
71 } 71 }
72 72
73 @SmallTest 73 @SmallTest
74 public static void testInitializeUsingByteBufferReInitilizeUsingTextures() { 74 public static void testInitializeUsingByteBufferReInitilizeUsingTextures() {
75 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { 75 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
76 Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUs ingTextures"); 76 Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUs ingTextures");
77 return; 77 return;
78 } 78 }
79 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); 79 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
80 assertTrue(encoder.initEncode( 80 assertTrue(encoder.initEncode(
81 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 , 81 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 ,
82 null)); 82 null));
83 encoder.release(); 83 encoder.release();
84 EglBase eglBase = EglBase.create();
84 assertTrue(encoder.initEncode( 85 assertTrue(encoder.initEncode(
85 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 , 86 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 ,
86 EGL10.EGL_NO_CONTEXT)); 87 eglBase.getEglBaseContext()));
87 encoder.release(); 88 encoder.release();
89 eglBase.release();
88 } 90 }
89 91
90 @SmallTest 92 @SmallTest
91 public static void testEncoderUsingByteBuffer() throws InterruptedException { 93 public static void testEncoderUsingByteBuffer() throws InterruptedException {
92 if (!MediaCodecVideoEncoder.isVp8HwSupported()) { 94 if (!MediaCodecVideoEncoder.isVp8HwSupported()) {
93 Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUs ingByteBuffer"); 95 Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUs ingByteBuffer");
94 return; 96 return;
95 } 97 }
96 98
97 final int width = 640; 99 final int width = 640;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 public static void testEncoderUsingTextures() throws InterruptedException { 136 public static void testEncoderUsingTextures() throws InterruptedException {
135 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { 137 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
136 Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUs ingTextures"); 138 Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUs ingTextures");
137 return; 139 return;
138 } 140 }
139 141
140 final int width = 640; 142 final int width = 640;
141 final int height = 480; 143 final int height = 480;
142 final long presentationTs = 2; 144 final long presentationTs = 2;
143 145
144 final EglBase eglOesBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigT ype.PIXEL_BUFFER); 146 final EglBase eglOesBase = EglBase.create(null, EglBase.ConfigType.PIXEL_BUF FER);
145 eglOesBase.createDummyPbufferSurface(); 147 eglOesBase.createDummyPbufferSurface();
146 eglOesBase.makeCurrent(); 148 eglOesBase.makeCurrent();
147 int oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES) ; 149 int oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES) ;
148 150
149 // TODO(perkj): This test is week since we don't fill the texture with valid data with correct 151 // TODO(perkj): This test is week since we don't fill the texture with valid data with correct
150 // width and height and verify the encoded data. Fill the OES texture and fi gure out a way to 152 // width and height and verify the encoded data. Fill the OES texture and fi gure out a way to
151 // verify that the output make sense. 153 // verify that the output make sense.
152 154
153 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); 155 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
154 156
155 assertTrue(encoder.initEncode( 157 assertTrue(encoder.initEncode(
156 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, width, height, 30 0, 30, 158 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, width, height, 30 0, 30,
157 eglOesBase.getContext())); 159 eglOesBase.getEglBaseContext()));
158 assertTrue(encoder.encodeTexture(true, oesTextureId, RendererCommon.identity Matrix(), 160 assertTrue(encoder.encodeTexture(true, oesTextureId, RendererCommon.identity Matrix(),
159 presentationTs)); 161 presentationTs));
160 GlUtil.checkNoGLES2Error("encodeTexture"); 162 GlUtil.checkNoGLES2Error("encodeTexture");
161 163
162 // It should be Ok to delete the texture after calling encodeTexture. 164 // It should be Ok to delete the texture after calling encodeTexture.
163 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); 165 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0);
164 166
165 OutputBufferInfo info = encoder.dequeueOutputBuffer(); 167 OutputBufferInfo info = encoder.dequeueOutputBuffer();
166 while (info == null) { 168 while (info == null) {
167 info = encoder.dequeueOutputBuffer(); 169 info = encoder.dequeueOutputBuffer();
168 Thread.sleep(20); 170 Thread.sleep(20);
169 } 171 }
170 assertTrue(info.index != -1); 172 assertTrue(info.index != -1);
171 assertTrue(info.buffer.capacity() > 0); 173 assertTrue(info.buffer.capacity() > 0);
172 encoder.releaseOutputBuffer(info.index); 174 encoder.releaseOutputBuffer(info.index);
173 175
174 encoder.release(); 176 encoder.release();
175 eglOesBase.release(); 177 eglOesBase.release();
176 } 178 }
177 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698