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, |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 import android.hardware.Camera; | 29 import android.hardware.Camera; |
30 import android.test.ActivityTestCase; | 30 import android.test.ActivityTestCase; |
31 import android.test.suitebuilder.annotation.SmallTest; | 31 import android.test.suitebuilder.annotation.SmallTest; |
32 import android.test.suitebuilder.annotation.MediumTest; | 32 import android.test.suitebuilder.annotation.MediumTest; |
33 import android.util.Size; | 33 import android.util.Size; |
34 | 34 |
35 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; | 35 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; |
36 import org.webrtc.VideoRenderer.I420Frame; | 36 import org.webrtc.VideoRenderer.I420Frame; |
37 | 37 |
38 import java.nio.ByteBuffer; | |
39 import java.util.ArrayList; | 38 import java.util.ArrayList; |
40 import java.util.HashSet; | 39 import java.util.HashSet; |
41 import java.util.List; | 40 import java.util.List; |
42 import java.util.Set; | 41 import java.util.Set; |
43 import java.util.concurrent.CountDownLatch; | 42 import java.util.concurrent.CountDownLatch; |
44 | 43 |
45 @SuppressWarnings("deprecation") | 44 @SuppressWarnings("deprecation") |
46 public class VideoCapturerAndroidTest extends ActivityTestCase { | 45 public class VideoCapturerAndroidTest extends ActivityTestCase { |
47 static class RendererCallbacks implements VideoRenderer.Callbacks { | 46 static class RendererCallbacks implements VideoRenderer.Callbacks { |
48 private int framesRendered = 0; | 47 private int framesRendered = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 97 |
99 @Override | 98 @Override |
100 public void OnCapturerStarted(boolean success) { | 99 public void OnCapturerStarted(boolean success) { |
101 synchronized (capturerStartLock) { | 100 synchronized (capturerStartLock) { |
102 captureStartResult = success; | 101 captureStartResult = success; |
103 capturerStartLock.notify(); | 102 capturerStartLock.notify(); |
104 } | 103 } |
105 } | 104 } |
106 | 105 |
107 @Override | 106 @Override |
108 public void OnFrameCaptured(ByteBuffer frame, int width, int height, | 107 public void OnFrameCaptured(byte[] frame, int length, int width, int height, |
109 int rotation, long timeStamp) { | 108 int rotation, long timeStamp) { |
110 synchronized (frameLock) { | 109 synchronized (frameLock) { |
111 ++framesCaptured; | 110 ++framesCaptured; |
112 frameSize = frame.capacity(); | 111 frameSize = length; |
113 timestamps.add(timeStamp); | 112 timestamps.add(timeStamp); |
114 frameLock.notify(); | 113 frameLock.notify(); |
115 } | 114 } |
116 } | 115 } |
117 | 116 |
118 @Override | 117 @Override |
119 public void OnOutputFormatRequest(int width, int height, int fps) {} | 118 public void OnOutputFormatRequest(int width, int height, int fps) {} |
120 | 119 |
121 public boolean WaitForCapturerToStart() throws InterruptedException { | 120 public boolean WaitForCapturerToStart() throws InterruptedException { |
122 synchronized (capturerStartLock) { | 121 synchronized (capturerStartLock) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 449 } |
451 } | 450 } |
452 }); | 451 }); |
453 returnThread.start(); | 452 returnThread.start(); |
454 returnThread.join(); | 453 returnThread.join(); |
455 | 454 |
456 // Check that frames have successfully returned. This will cause |capturer|
to be released. | 455 // Check that frames have successfully returned. This will cause |capturer|
to be released. |
457 assertTrue(capturer.isReleased()); | 456 assertTrue(capturer.isReleased()); |
458 } | 457 } |
459 } | 458 } |
OLD | NEW |