OLD | NEW |
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, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 package org.webrtc; | 27 package org.webrtc; |
28 | 28 |
29 import android.opengl.EGL14; | |
30 import android.os.Build; | |
31 import android.test.ActivityTestCase; | 29 import android.test.ActivityTestCase; |
32 import android.test.suitebuilder.annotation.MediumTest; | 30 import android.test.suitebuilder.annotation.MediumTest; |
33 import android.test.suitebuilder.annotation.SmallTest; | 31 import android.test.suitebuilder.annotation.SmallTest; |
34 import android.util.Log; | 32 import android.util.Log; |
35 import android.util.Size; | 33 import android.util.Size; |
36 | 34 |
37 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; | 35 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; |
38 | 36 |
39 import java.util.HashSet; | 37 import java.util.HashSet; |
40 import java.util.Set; | 38 import java.util.Set; |
41 | 39 |
| 40 import javax.microedition.khronos.egl.EGL10; |
| 41 |
42 @SuppressWarnings("deprecation") | 42 @SuppressWarnings("deprecation") |
43 public class VideoCapturerAndroidTest extends ActivityTestCase { | 43 public class VideoCapturerAndroidTest extends ActivityTestCase { |
44 static final String TAG = "VideoCapturerAndroidTest"; | 44 static final String TAG = "VideoCapturerAndroidTest"; |
45 | 45 |
46 @Override | 46 @Override |
47 protected void setUp() { | 47 protected void setUp() { |
48 assertTrue(PeerConnectionFactory.initializeAndroidGlobals( | 48 assertTrue(PeerConnectionFactory.initializeAndroidGlobals( |
49 getInstrumentation().getContext(), true, true, true)); | 49 getInstrumentation().getContext(), true, true, true)); |
50 } | 50 } |
51 | 51 |
(...skipping 28 matching lines...) Expand all Loading... |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 @SmallTest | 83 @SmallTest |
84 public void testCreateAndRelease() { | 84 public void testCreateAndRelease() { |
85 VideoCapturerAndroidTestFixtures.release(VideoCapturerAndroid.create("", nul
l)); | 85 VideoCapturerAndroidTestFixtures.release(VideoCapturerAndroid.create("", nul
l)); |
86 } | 86 } |
87 | 87 |
88 @SmallTest | 88 @SmallTest |
89 public void testCreateAndReleaseUsingTextures() { | 89 public void testCreateAndReleaseUsingTextures() { |
90 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
91 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
92 return; | |
93 } | |
94 VideoCapturerAndroidTestFixtures.release( | 90 VideoCapturerAndroidTestFixtures.release( |
95 VideoCapturerAndroid.create("", null, EGL14.EGL_NO_CONTEXT)); | 91 VideoCapturerAndroid.create("", null, EGL10.EGL_NO_CONTEXT)); |
96 } | 92 } |
97 | 93 |
98 @SmallTest | 94 @SmallTest |
99 public void testCreateNonExistingCamera() { | 95 public void testCreateNonExistingCamera() { |
100 VideoCapturerAndroid capturer = VideoCapturerAndroid.create( | 96 VideoCapturerAndroid capturer = VideoCapturerAndroid.create( |
101 "non-existing camera", null); | 97 "non-existing camera", null); |
102 assertNull(capturer); | 98 assertNull(capturer); |
103 } | 99 } |
104 | 100 |
105 @SmallTest | 101 @SmallTest |
106 // This test that the camera can be started and that the frames are forwarded | 102 // This test that the camera can be started and that the frames are forwarded |
107 // to a Java video renderer using a "default" capturer. | 103 // to a Java video renderer using a "default" capturer. |
108 // It tests both the Java and the C++ layer. | 104 // It tests both the Java and the C++ layer. |
109 public void testStartVideoCapturer() throws InterruptedException { | 105 public void testStartVideoCapturer() throws InterruptedException { |
110 VideoCapturerAndroid capturer = | 106 VideoCapturerAndroid capturer = |
111 VideoCapturerAndroid.create("", null); | 107 VideoCapturerAndroid.create("", null); |
112 VideoCapturerAndroidTestFixtures.startCapturerAndRender(capturer); | 108 VideoCapturerAndroidTestFixtures.startCapturerAndRender(capturer); |
113 } | 109 } |
114 | 110 |
115 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. | 111 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. |
116 @SmallTest | 112 @SmallTest |
117 public void DISABLED_testStartVideoCapturerUsingTextures() throws InterruptedE
xception { | 113 public void DISABLED_testStartVideoCapturerUsingTextures() throws InterruptedE
xception { |
118 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
119 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
120 return; | |
121 } | |
122 VideoCapturerAndroid capturer = | 114 VideoCapturerAndroid capturer = |
123 VideoCapturerAndroid.create("", null, EGL14.EGL_NO_CONTEXT); | 115 VideoCapturerAndroid.create("", null, EGL10.EGL_NO_CONTEXT); |
124 VideoCapturerAndroidTestFixtures.startCapturerAndRender(capturer); | 116 VideoCapturerAndroidTestFixtures.startCapturerAndRender(capturer); |
125 } | 117 } |
126 | 118 |
127 @SmallTest | 119 @SmallTest |
128 // This test that the camera can be started and that the frames are forwarded | 120 // This test that the camera can be started and that the frames are forwarded |
129 // to a Java video renderer using the front facing video capturer. | 121 // to a Java video renderer using the front facing video capturer. |
130 // It tests both the Java and the C++ layer. | 122 // It tests both the Java and the C++ layer. |
131 public void testStartFrontFacingVideoCapturer() throws InterruptedException { | 123 public void testStartFrontFacingVideoCapturer() throws InterruptedException { |
132 String deviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice(); | 124 String deviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice(); |
133 VideoCapturerAndroid capturer = | 125 VideoCapturerAndroid capturer = |
(...skipping 21 matching lines...) Expand all Loading... |
155 // later be switched to another camera. | 147 // later be switched to another camera. |
156 // It tests both the Java and the C++ layer. | 148 // It tests both the Java and the C++ layer. |
157 public void testSwitchVideoCapturer() throws InterruptedException { | 149 public void testSwitchVideoCapturer() throws InterruptedException { |
158 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); | 150 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); |
159 VideoCapturerAndroidTestFixtures.switchCamera(capturer); | 151 VideoCapturerAndroidTestFixtures.switchCamera(capturer); |
160 } | 152 } |
161 | 153 |
162 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. | 154 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. |
163 @SmallTest | 155 @SmallTest |
164 public void DISABLED_testSwitchVideoCapturerUsingTextures() throws Interrupted
Exception { | 156 public void DISABLED_testSwitchVideoCapturerUsingTextures() throws Interrupted
Exception { |
165 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | 157 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null, EGL10.
EGL_NO_CONTEXT); |
166 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
167 return; | |
168 } | |
169 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null, EGL14.
EGL_NO_CONTEXT); | |
170 VideoCapturerAndroidTestFixtures.switchCamera(capturer); | 158 VideoCapturerAndroidTestFixtures.switchCamera(capturer); |
171 } | 159 } |
172 | 160 |
173 @MediumTest | 161 @MediumTest |
174 public void testCameraEvents() throws InterruptedException { | 162 public void testCameraEvents() throws InterruptedException { |
175 VideoCapturerAndroidTestFixtures.CameraEvents cameraEvents = | 163 VideoCapturerAndroidTestFixtures.CameraEvents cameraEvents = |
176 VideoCapturerAndroidTestFixtures.createCameraEvents(); | 164 VideoCapturerAndroidTestFixtures.createCameraEvents(); |
177 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", cameraEvents
); | 165 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", cameraEvents
); |
178 VideoCapturerAndroidTestFixtures.cameraEventsInvoked( | 166 VideoCapturerAndroidTestFixtures.cameraEventsInvoked( |
179 capturer, cameraEvents, getInstrumentation().getContext()); | 167 capturer, cameraEvents, getInstrumentation().getContext()); |
180 } | 168 } |
181 | 169 |
182 @MediumTest | 170 @MediumTest |
183 // Test what happens when attempting to call e.g. switchCamera() after camera
has been stopped. | 171 // Test what happens when attempting to call e.g. switchCamera() after camera
has been stopped. |
184 public void testCameraCallsAfterStop() throws InterruptedException { | 172 public void testCameraCallsAfterStop() throws InterruptedException { |
185 final String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 173 final String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
186 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create(deviceName
, null); | 174 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create(deviceName
, null); |
187 | 175 |
188 VideoCapturerAndroidTestFixtures.cameraCallsAfterStop(capturer, | 176 VideoCapturerAndroidTestFixtures.cameraCallsAfterStop(capturer, |
189 getInstrumentation().getContext()); | 177 getInstrumentation().getContext()); |
190 } | 178 } |
191 | 179 |
192 @MediumTest | 180 @MediumTest |
193 public void testCameraCallsAfterStopUsingTextures() throws InterruptedExceptio
n { | 181 public void testCameraCallsAfterStopUsingTextures() throws InterruptedExceptio
n { |
194 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
195 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
196 return; | |
197 } | |
198 final String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 182 final String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
199 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create(deviceName
, null, | 183 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create(deviceName
, null, |
200 EGL14.EGL_NO_CONTEXT); | 184 EGL10.EGL_NO_CONTEXT); |
201 | 185 |
202 VideoCapturerAndroidTestFixtures.cameraCallsAfterStop(capturer, | 186 VideoCapturerAndroidTestFixtures.cameraCallsAfterStop(capturer, |
203 getInstrumentation().getContext()); | 187 getInstrumentation().getContext()); |
204 } | 188 } |
205 | 189 |
206 @SmallTest | 190 @SmallTest |
207 // This test that the VideoSource that the VideoCapturer is connected to can | 191 // This test that the VideoSource that the VideoCapturer is connected to can |
208 // be stopped and restarted. It tests both the Java and the C++ layer. | 192 // be stopped and restarted. It tests both the Java and the C++ layer. |
209 public void testStopRestartVideoSource() throws InterruptedException { | 193 public void testStopRestartVideoSource() throws InterruptedException { |
210 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); | 194 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); |
211 VideoCapturerAndroidTestFixtures.stopRestartVideoSource(capturer); | 195 VideoCapturerAndroidTestFixtures.stopRestartVideoSource(capturer); |
212 } | 196 } |
213 | 197 |
214 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. | 198 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. |
215 @SmallTest | 199 @SmallTest |
216 public void DISABLED_testStopRestartVideoSourceUsingTextures() throws Interrup
tedException { | 200 public void DISABLED_testStopRestartVideoSourceUsingTextures() throws Interrup
tedException { |
217 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | 201 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null, EGL10.
EGL_NO_CONTEXT); |
218 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
219 return; | |
220 } | |
221 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null, EGL14.
EGL_NO_CONTEXT); | |
222 VideoCapturerAndroidTestFixtures.stopRestartVideoSource(capturer); | 202 VideoCapturerAndroidTestFixtures.stopRestartVideoSource(capturer); |
223 } | 203 } |
224 | 204 |
225 @SmallTest | 205 @SmallTest |
226 // This test that the camera can be started at different resolutions. | 206 // This test that the camera can be started at different resolutions. |
227 // It does not test or use the C++ layer. | 207 // It does not test or use the C++ layer. |
228 public void testStartStopWithDifferentResolutions() throws InterruptedExceptio
n { | 208 public void testStartStopWithDifferentResolutions() throws InterruptedExceptio
n { |
229 String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 209 String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
230 VideoCapturerAndroid capturer = | 210 VideoCapturerAndroid capturer = |
231 VideoCapturerAndroid.create(deviceName, null); | 211 VideoCapturerAndroid.create(deviceName, null); |
232 VideoCapturerAndroidTestFixtures.startStopWithDifferentResolutions(capturer, | 212 VideoCapturerAndroidTestFixtures.startStopWithDifferentResolutions(capturer, |
233 getInstrumentation().getContext()); | 213 getInstrumentation().getContext()); |
234 } | 214 } |
235 | 215 |
236 @SmallTest | 216 @SmallTest |
237 public void testStartStopWithDifferentResolutionsUsingTextures() throws Interr
uptedException { | 217 public void testStartStopWithDifferentResolutionsUsingTextures() throws Interr
uptedException { |
238 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
239 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
240 return; | |
241 } | |
242 String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 218 String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
243 VideoCapturerAndroid capturer = | 219 VideoCapturerAndroid capturer = |
244 VideoCapturerAndroid.create(deviceName, null, EGL14.EGL_NO_CONTEXT); | 220 VideoCapturerAndroid.create(deviceName, null, EGL10.EGL_NO_CONTEXT); |
245 VideoCapturerAndroidTestFixtures.startStopWithDifferentResolutions(capturer, | 221 VideoCapturerAndroidTestFixtures.startStopWithDifferentResolutions(capturer, |
246 getInstrumentation().getContext()); | 222 getInstrumentation().getContext()); |
247 } | 223 } |
248 | 224 |
249 @SmallTest | 225 @SmallTest |
250 // This test what happens if buffers are returned after the capturer have | 226 // This test what happens if buffers are returned after the capturer have |
251 // been stopped and restarted. It does not test or use the C++ layer. | 227 // been stopped and restarted. It does not test or use the C++ layer. |
252 public void testReturnBufferLate() throws InterruptedException { | 228 public void testReturnBufferLate() throws InterruptedException { |
253 String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 229 String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
254 VideoCapturerAndroid capturer = | 230 VideoCapturerAndroid capturer = |
255 VideoCapturerAndroid.create(deviceName, null); | 231 VideoCapturerAndroid.create(deviceName, null); |
256 VideoCapturerAndroidTestFixtures.returnBufferLate(capturer, | 232 VideoCapturerAndroidTestFixtures.returnBufferLate(capturer, |
257 getInstrumentation().getContext()); | 233 getInstrumentation().getContext()); |
258 } | 234 } |
259 | 235 |
260 @SmallTest | 236 @SmallTest |
261 public void testReturnBufferLateUsingTextures() throws InterruptedException { | 237 public void testReturnBufferLateUsingTextures() throws InterruptedException { |
262 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
263 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
264 return; | |
265 } | |
266 String deviceName = CameraEnumerationAndroid.getDeviceName(0); | 238 String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
267 VideoCapturerAndroid capturer = | 239 VideoCapturerAndroid capturer = |
268 VideoCapturerAndroid.create(deviceName, null, EGL14.EGL_NO_CONTEXT); | 240 VideoCapturerAndroid.create(deviceName, null, EGL10.EGL_NO_CONTEXT); |
269 VideoCapturerAndroidTestFixtures.returnBufferLate(capturer, | 241 VideoCapturerAndroidTestFixtures.returnBufferLate(capturer, |
270 getInstrumentation().getContext()); | 242 getInstrumentation().getContext()); |
271 } | 243 } |
272 | 244 |
273 @MediumTest | 245 @MediumTest |
274 // This test that we can capture frames, keep the frames in a local renderer,
stop capturing, | 246 // This test that we can capture frames, keep the frames in a local renderer,
stop capturing, |
275 // and then return the frames. The difference between the test testReturnBuffe
rLate() is that we | 247 // and then return the frames. The difference between the test testReturnBuffe
rLate() is that we |
276 // also test the JNI and C++ AndroidVideoCapturer parts. | 248 // also test the JNI and C++ AndroidVideoCapturer parts. |
277 public void testReturnBufferLateEndToEnd() throws InterruptedException { | 249 public void testReturnBufferLateEndToEnd() throws InterruptedException { |
278 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); | 250 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); |
279 VideoCapturerAndroidTestFixtures.returnBufferLateEndToEnd(capturer); | 251 VideoCapturerAndroidTestFixtures.returnBufferLateEndToEnd(capturer); |
280 } | 252 } |
281 | 253 |
282 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. | 254 // TODO(perkj): Enable once VideoCapture to texture support has landed in C++. |
283 @MediumTest | 255 @MediumTest |
284 public void DISABLED_testReturnBufferLateEndToEndUsingTextures() throws Interr
uptedException { | 256 public void DISABLED_testReturnBufferLateEndToEndUsingTextures() throws Interr
uptedException { |
285 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
286 Log.i(TAG, "Capturing to textures is not supported, requires EGL14."); | |
287 return; | |
288 } | |
289 final VideoCapturerAndroid capturer = | 257 final VideoCapturerAndroid capturer = |
290 VideoCapturerAndroid.create("", null, EGL14.EGL_NO_CONTEXT); | 258 VideoCapturerAndroid.create("", null, EGL10.EGL_NO_CONTEXT); |
291 VideoCapturerAndroidTestFixtures.returnBufferLateEndToEnd(capturer); | 259 VideoCapturerAndroidTestFixtures.returnBufferLateEndToEnd(capturer); |
292 } | 260 } |
293 } | 261 } |
OLD | NEW |