OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * libjingle | |
3 * Copyright 2015 Google Inc. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright notice, | |
9 * this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
11 * this list of conditions and the following disclaimer in the documentation | |
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 | |
14 * derived from this software without specific prior written permission. | |
15 * | |
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 | |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
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, | |
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 | |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 package org.webrtc; | |
28 | |
29 import java.nio.ByteBuffer; | |
30 | |
31 import android.opengl.EGL14; | |
magjed_webrtc
2015/10/12 08:22:52
Not used: EGL14,GLES11Ext,GLES20.
perkj_webrtc
2015/10/12 09:16:05
Done.
| |
32 import android.opengl.GLES11Ext; | |
33 import android.opengl.GLES20; | |
34 import android.test.ActivityTestCase; | |
35 import android.test.suitebuilder.annotation.SmallTest; | |
36 import android.util.Log; | |
37 | |
38 import org.webrtc.MediaCodecVideoEncoder.OutputBufferInfo; | |
39 | |
40 public final class MediaCodecVideoEncoderTest extends ActivityTestCase { | |
41 final static String TAG = "MediaCodecVideoEncoderTest"; | |
42 | |
43 @SmallTest | |
44 public static void testInitReleaseUsingByteBuffer() { | |
45 if (!MediaCodecVideoEncoder.isVp8HwSupported()) { | |
46 Log.i(TAG, | |
47 "Hardware does not support VP8 encoding, skipping testInitReleaseUsi ngByteBuffer"); | |
48 return; | |
49 } | |
50 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); | |
51 assertTrue(encoder.initEncode( | |
52 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, 640, 480, 300, 30 )); | |
53 encoder.release(); | |
54 } | |
55 | |
56 @SmallTest | |
57 public static void testEncoderUsingByteBuffer() throws InterruptedException { | |
58 if (!MediaCodecVideoEncoder.isVp8HwSupported()) { | |
59 Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUs ingByteBuffer"); | |
60 return; | |
61 } | |
62 | |
63 final int width = 640; | |
64 final int height = 480; | |
65 final int min_size = width * height * 3 / 2; | |
66 final long presentationTimestampUs = 2; | |
67 | |
68 MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder(); | |
69 | |
70 assertTrue(encoder.initEncode( | |
71 MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, width, height, 30 0, 30)); | |
72 ByteBuffer[] inputBuffers = encoder.getInputBuffers(); | |
73 assertNotNull(inputBuffers); | |
74 assertTrue(min_size <= inputBuffers[0].capacity()); | |
75 | |
76 int bufferIndex; | |
77 do { | |
78 Thread.sleep(10); | |
79 bufferIndex = encoder.dequeueInputBuffer(); | |
80 } while (bufferIndex == -1); // |-1| is returned when there is no buffer ava ilable yet. | |
81 | |
82 assertTrue(bufferIndex >= 0); | |
83 assertTrue(bufferIndex < inputBuffers.length); | |
84 assertTrue(encoder.encodeBuffer(true, bufferIndex, min_size, presentationTim estampUs)); | |
85 | |
86 OutputBufferInfo info; | |
87 do { | |
88 info = encoder.dequeueOutputBuffer(); | |
89 Thread.sleep(10); | |
90 } while (info == null); | |
91 assertTrue(info.index >=0); | |
magjed_webrtc
2015/10/12 08:22:52
Missing space: >=0
perkj_webrtc
2015/10/12 09:16:05
Done.
| |
92 assertEquals(presentationTimestampUs, info.presentationTimestampUs); | |
93 assertTrue(info.buffer.capacity() > 0); | |
94 encoder.releaseOutputBuffer(info.index); | |
95 | |
96 encoder.release(); | |
97 } | |
98 } | |
OLD | NEW |