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

Side by Side Diff: webrtc/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java

Issue 3010623002: Change capture time format to nanoseconds in EncodedImage. (Closed)
Patch Set: Update decoder wrapper. Created 3 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 HardwareVideoEncoderFactory factory = 73 HardwareVideoEncoderFactory factory =
74 new HardwareVideoEncoderFactory(ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HI GH_PROFILE); 74 new HardwareVideoEncoderFactory(ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HI GH_PROFILE);
75 VideoCodecInfo[] supportedCodecs = factory.getSupportedCodecs(); 75 VideoCodecInfo[] supportedCodecs = factory.getSupportedCodecs();
76 if (supportedCodecs.length == 0) { 76 if (supportedCodecs.length == 0) {
77 Log.w(TAG, "No hardware encoding support, skipping testEncodeYuvBuffer"); 77 Log.w(TAG, "No hardware encoding support, skipping testEncodeYuvBuffer");
78 return; 78 return;
79 } 79 }
80 80
81 VideoEncoder encoder = factory.createEncoder(supportedCodecs[0]); 81 VideoEncoder encoder = factory.createEncoder(supportedCodecs[0]);
82 82
83 final long presentationTimestampUs = 20000; 83 final long presentationTimestampNs = 20000;
84 final CountDownLatch encodeDone = new CountDownLatch(1); 84 final CountDownLatch encodeDone = new CountDownLatch(1);
85 85
86 VideoEncoder.Callback callback = new VideoEncoder.Callback() { 86 VideoEncoder.Callback callback = new VideoEncoder.Callback() {
87 @Override 87 @Override
88 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI nfo info) { 88 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI nfo info) {
89 assertTrue(image.buffer.capacity() > 0); 89 assertTrue(image.buffer.capacity() > 0);
90 assertEquals(image.encodedWidth, SETTINGS.width); 90 assertEquals(image.encodedWidth, SETTINGS.width);
91 assertEquals(image.encodedHeight, SETTINGS.height); 91 assertEquals(image.encodedHeight, SETTINGS.height);
92 assertEquals(image.captureTimeMs, presentationTimestampUs / 1000); 92 assertEquals(image.captureTimeNs, presentationTimestampNs);
93 assertEquals(image.frameType, EncodedImage.FrameType.VideoFrameKey); 93 assertEquals(image.frameType, EncodedImage.FrameType.VideoFrameKey);
94 assertEquals(image.rotation, 0); 94 assertEquals(image.rotation, 0);
95 assertTrue(image.completeFrame); 95 assertTrue(image.completeFrame);
96 96
97 encodeDone.countDown(); 97 encodeDone.countDown();
98 } 98 }
99 }; 99 };
100 100
101 assertEquals(encoder.initEncode(SETTINGS, callback), VideoCodecStatus.OK); 101 assertEquals(encoder.initEncode(SETTINGS, callback), VideoCodecStatus.OK);
102 102
103 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI NGS.height); 103 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI NGS.height);
104 VideoFrame frame = new VideoFrame(buffer, 0 /* rotation */, presentationTime stampUs * 1000); 104 VideoFrame frame = new VideoFrame(buffer, 0 /* rotation */, presentationTime stampNs);
105 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( 105 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo(
106 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); 106 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey});
107 107
108 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); 108 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK);
109 109
110 ThreadUtils.awaitUninterruptibly(encodeDone); 110 ThreadUtils.awaitUninterruptibly(encodeDone);
111 111
112 assertEquals(encoder.release(), VideoCodecStatus.OK); 112 assertEquals(encoder.release(), VideoCodecStatus.OK);
113 } 113 }
114 114
115 @Test 115 @Test
116 @SmallTest 116 @SmallTest
117 public void testEncodeTextures() throws InterruptedException { 117 public void testEncodeTextures() throws InterruptedException {
118 final EglBase14 eglOesBase = new EglBase14(null, EglBase.CONFIG_PIXEL_BUFFER ); 118 final EglBase14 eglOesBase = new EglBase14(null, EglBase.CONFIG_PIXEL_BUFFER );
119 HardwareVideoEncoderFactory factory = new HardwareVideoEncoderFactory( 119 HardwareVideoEncoderFactory factory = new HardwareVideoEncoderFactory(
120 eglOesBase.getEglBaseContext(), ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HI GH_PROFILE); 120 eglOesBase.getEglBaseContext(), ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HI GH_PROFILE);
121 VideoCodecInfo[] supportedCodecs = factory.getSupportedCodecs(); 121 VideoCodecInfo[] supportedCodecs = factory.getSupportedCodecs();
122 if (supportedCodecs.length == 0) { 122 if (supportedCodecs.length == 0) {
123 Log.w(TAG, "No hardware encoding support, skipping testEncodeTextures"); 123 Log.w(TAG, "No hardware encoding support, skipping testEncodeTextures");
124 return; 124 return;
125 } 125 }
126 126
127 eglOesBase.createDummyPbufferSurface(); 127 eglOesBase.createDummyPbufferSurface();
128 eglOesBase.makeCurrent(); 128 eglOesBase.makeCurrent();
129 final int oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNA L_OES); 129 final int oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNA L_OES);
130 130
131 VideoEncoder encoder = factory.createEncoder(supportedCodecs[0]); 131 VideoEncoder encoder = factory.createEncoder(supportedCodecs[0]);
132 132
133 final long presentationTimestampUs = 20000; 133 final long presentationTimestampNs = 20000;
134 final CountDownLatch encodeDone = new CountDownLatch(1); 134 final CountDownLatch encodeDone = new CountDownLatch(1);
135 135
136 VideoEncoder.Callback callback = new VideoEncoder.Callback() { 136 VideoEncoder.Callback callback = new VideoEncoder.Callback() {
137 @Override 137 @Override
138 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI nfo info) { 138 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI nfo info) {
139 assertTrue(image.buffer.capacity() > 0); 139 assertTrue(image.buffer.capacity() > 0);
140 assertEquals(image.encodedWidth, SETTINGS.width); 140 assertEquals(image.encodedWidth, SETTINGS.width);
141 assertEquals(image.encodedHeight, SETTINGS.height); 141 assertEquals(image.encodedHeight, SETTINGS.height);
142 assertEquals(image.captureTimeMs, presentationTimestampUs / 1000); 142 assertEquals(image.captureTimeNs, presentationTimestampNs);
143 assertEquals(image.frameType, EncodedImage.FrameType.VideoFrameKey); 143 assertEquals(image.frameType, EncodedImage.FrameType.VideoFrameKey);
144 assertEquals(image.rotation, 0); 144 assertEquals(image.rotation, 0);
145 assertTrue(image.completeFrame); 145 assertTrue(image.completeFrame);
146 146
147 encodeDone.countDown(); 147 encodeDone.countDown();
148 } 148 }
149 }; 149 };
150 150
151 assertEquals(encoder.initEncode(SETTINGS, callback), VideoCodecStatus.OK); 151 assertEquals(encoder.initEncode(SETTINGS, callback), VideoCodecStatus.OK);
152 152
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 @Override 187 @Override
188 public void release() {} 188 public void release() {}
189 189
190 @Override 190 @Override
191 public VideoFrame.Buffer cropAndScale( 191 public VideoFrame.Buffer cropAndScale(
192 int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, i nt scaleHeight) { 192 int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, i nt scaleHeight) {
193 return null; 193 return null;
194 } 194 }
195 }; 195 };
196 VideoFrame frame = new VideoFrame(buffer, 0 /* rotation */, presentationTime stampUs * 1000); 196 VideoFrame frame = new VideoFrame(buffer, 0 /* rotation */, presentationTime stampNs);
197 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( 197 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo(
198 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); 198 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey});
199 199
200 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); 200 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK);
201 GlUtil.checkNoGLES2Error("encodeTexture"); 201 GlUtil.checkNoGLES2Error("encodeTexture");
202 202
203 // It should be Ok to delete the texture after calling encodeTexture. 203 // It should be Ok to delete the texture after calling encodeTexture.
204 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); 204 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0);
205 205
206 ThreadUtils.awaitUninterruptibly(encodeDone); 206 ThreadUtils.awaitUninterruptibly(encodeDone);
207 207
208 assertEquals(encoder.release(), VideoCodecStatus.OK); 208 assertEquals(encoder.release(), VideoCodecStatus.OK);
209 eglOesBase.release(); 209 eglOesBase.release();
210 } 210 }
211 } 211 }
OLDNEW
« no previous file with comments | « webrtc/sdk/android/api/org/webrtc/EncodedImage.java ('k') | webrtc/sdk/android/src/java/org/webrtc/HardwareVideoDecoder.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698