OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 VideoEncoder encoder = encoderFactory.createEncoder(supportedCodecs[0]); | 109 VideoEncoder encoder = encoderFactory.createEncoder(supportedCodecs[0]); |
110 final CountDownLatch encodeDone = new CountDownLatch(1); | 110 final CountDownLatch encodeDone = new CountDownLatch(1); |
111 final AtomicReference<EncodedImage> encoded = new AtomicReference<>(); | 111 final AtomicReference<EncodedImage> encoded = new AtomicReference<>(); |
112 VideoEncoder.Callback encodeCallback = new VideoEncoder.Callback() { | 112 VideoEncoder.Callback encodeCallback = new VideoEncoder.Callback() { |
113 @Override | 113 @Override |
114 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI
nfo info) { | 114 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI
nfo info) { |
115 encoded.set(image); | 115 encoded.set(image); |
116 encodeDone.countDown(); | 116 encodeDone.countDown(); |
117 } | 117 } |
118 }; | 118 }; |
119 assertEquals( | 119 assertEquals(encoder.initEncode(new VideoEncoder.Settings(1, SETTINGS.width,
SETTINGS.height, |
120 encoder.initEncode( | 120 300, 30, true /* automaticResizeOn */), |
121 new VideoEncoder.Settings(1, SETTINGS.width, SETTINGS.height, 300, 3
0), encodeCallback), | 121 encodeCallback), |
122 VideoCodecStatus.OK); | 122 VideoCodecStatus.OK); |
123 | 123 |
124 // First, encode a frame. | 124 // First, encode a frame. |
125 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI
NGS.height); | 125 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI
NGS.height); |
126 VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs
* 1000); | 126 VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs
* 1000); |
127 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( | 127 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( |
128 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); | 128 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); |
129 | 129 |
130 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); | 130 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); |
131 | 131 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 VideoEncoder encoder = encoderFactory.createEncoder(supportedCodecs[0]); | 184 VideoEncoder encoder = encoderFactory.createEncoder(supportedCodecs[0]); |
185 final CountDownLatch encodeDone = new CountDownLatch(1); | 185 final CountDownLatch encodeDone = new CountDownLatch(1); |
186 final AtomicReference<EncodedImage> encoded = new AtomicReference<>(); | 186 final AtomicReference<EncodedImage> encoded = new AtomicReference<>(); |
187 VideoEncoder.Callback encodeCallback = new VideoEncoder.Callback() { | 187 VideoEncoder.Callback encodeCallback = new VideoEncoder.Callback() { |
188 @Override | 188 @Override |
189 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI
nfo info) { | 189 public void onEncodedFrame(EncodedImage image, VideoEncoder.CodecSpecificI
nfo info) { |
190 encoded.set(image); | 190 encoded.set(image); |
191 encodeDone.countDown(); | 191 encodeDone.countDown(); |
192 } | 192 } |
193 }; | 193 }; |
194 assertEquals( | 194 assertEquals(encoder.initEncode(new VideoEncoder.Settings(1, SETTINGS.width,
SETTINGS.height, |
195 encoder.initEncode( | 195 300, 30, true /* automaticResizeOn */), |
196 new VideoEncoder.Settings(1, SETTINGS.width, SETTINGS.height, 300, 3
0), encodeCallback), | 196 encodeCallback), |
197 VideoCodecStatus.OK); | 197 VideoCodecStatus.OK); |
198 | 198 |
199 // First, encode a frame. | 199 // First, encode a frame. |
200 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI
NGS.height); | 200 VideoFrame.I420Buffer buffer = I420BufferImpl.allocate(SETTINGS.width, SETTI
NGS.height); |
201 VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs
* 1000); | 201 VideoFrame frame = new VideoFrame(buffer, rotation, presentationTimestampUs
* 1000); |
202 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( | 202 VideoEncoder.EncodeInfo info = new VideoEncoder.EncodeInfo( |
203 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); | 203 new EncodedImage.FrameType[] {EncodedImage.FrameType.VideoFrameKey}); |
204 | 204 |
205 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); | 205 assertEquals(encoder.encode(frame, info), VideoCodecStatus.OK); |
206 | 206 |
(...skipping 17 matching lines...) Expand all Loading... |
224 assertEquals(textureBuffer.getHeight(), SETTINGS.height); | 224 assertEquals(textureBuffer.getHeight(), SETTINGS.height); |
225 assertEquals(textureBuffer.getType(), VideoFrame.TextureBuffer.Type.OES); | 225 assertEquals(textureBuffer.getType(), VideoFrame.TextureBuffer.Type.OES); |
226 | 226 |
227 assertEquals(decoder.release(), VideoCodecStatus.OK); | 227 assertEquals(decoder.release(), VideoCodecStatus.OK); |
228 assertEquals(encoder.release(), VideoCodecStatus.OK); | 228 assertEquals(encoder.release(), VideoCodecStatus.OK); |
229 | 229 |
230 frame.release(); | 230 frame.release(); |
231 eglBase.release(); | 231 eglBase.release(); |
232 } | 232 } |
233 } | 233 } |
OLD | NEW |