OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 /** | 92 /** |
93 * Class used to display stream of YUV420 frames at particular location | 93 * Class used to display stream of YUV420 frames at particular location |
94 * on a screen. New video frames are sent to display using renderFrame() | 94 * on a screen. New video frames are sent to display using renderFrame() |
95 * call. | 95 * call. |
96 */ | 96 */ |
97 private static class YuvImageRenderer implements VideoRenderer.Callbacks { | 97 private static class YuvImageRenderer implements VideoRenderer.Callbacks { |
98 // |surface| is synchronized on |this|. | 98 // |surface| is synchronized on |this|. |
99 private GLSurfaceView surface; | 99 private GLSurfaceView surface; |
100 private int id; | 100 private int id; |
101 private int[] yuvTextures = { -1, -1, -1 }; | 101 private int[] yuvTextures = { -1, -1, -1 }; |
102 private int oesTexture = -1; | 102 private int oesTexture = -1; |
hbos
2015/09/02 08:57:55
Oh, more -1 instead of 0.
These are created and u
magjed_webrtc
2015/09/02 10:15:39
Done.
| |
103 | 103 |
104 // Render frame queue - accessed by two threads. renderFrame() call does | 104 // Render frame queue - accessed by two threads. renderFrame() call does |
105 // an offer (writing I420Frame to render) and early-returns (recording | 105 // an offer (writing I420Frame to render) and early-returns (recording |
106 // a dropped frame) if that queue is full. draw() call does a peek(), | 106 // a dropped frame) if that queue is full. draw() call does a peek(), |
107 // copies frame to texture and then removes it from a queue using poll(). | 107 // copies frame to texture and then removes it from a queue using poll(). |
108 private final LinkedBlockingQueue<I420Frame> frameToRenderQueue; | 108 private final LinkedBlockingQueue<I420Frame> frameToRenderQueue; |
109 // Local copy of incoming video frame. Synchronized on |frameToRenderQueue|. | 109 // Local copy of incoming video frame. Synchronized on |frameToRenderQueue|. |
110 private I420Frame yuvFrameToRender; | 110 private I420Frame yuvFrameToRender; |
111 private I420Frame textureFrameToRender; | 111 private I420Frame textureFrameToRender; |
112 // Type of video frame used for recent frame rendering. | 112 // Type of video frame used for recent frame rendering. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 yuvFrameToRender = null; | 175 yuvFrameToRender = null; |
176 textureFrameToRender = null; | 176 textureFrameToRender = null; |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 private void createTextures() { | 180 private void createTextures() { |
181 Log.d(TAG, " YuvImageRenderer.createTextures " + id + " on GL thread:" + | 181 Log.d(TAG, " YuvImageRenderer.createTextures " + id + " on GL thread:" + |
182 Thread.currentThread().getId()); | 182 Thread.currentThread().getId()); |
183 | 183 |
184 // Generate 3 texture ids for Y/U/V and place them into |yuvTextures|. | 184 // Generate 3 texture ids for Y/U/V and place them into |yuvTextures|. |
185 GLES20.glGenTextures(3, yuvTextures, 0); | |
186 for (int i = 0; i < 3; i++) { | 185 for (int i = 0; i < 3; i++) { |
187 GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); | 186 yuvTextures[i] = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); |
188 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]); | |
189 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | |
190 GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); | |
191 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | |
192 GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); | |
193 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | |
194 GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); | |
195 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | |
196 GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); | |
197 } | 187 } |
198 GlUtil.checkNoGLES2Error("y/u/v glGenTextures"); | |
199 } | 188 } |
200 | 189 |
201 private void checkAdjustTextureCoords() { | 190 private void checkAdjustTextureCoords() { |
202 synchronized(updateTextureLock) { | 191 synchronized(updateTextureLock) { |
203 if (!updateTextureProperties) { | 192 if (!updateTextureProperties) { |
204 return; | 193 return; |
205 } | 194 } |
206 // Initialize to maximum allowed area. Round to integer coordinates inwa rds the layout | 195 // Initialize to maximum allowed area. Round to integer coordinates inwa rds the layout |
207 // bounding box (ceil left/top and floor right/bottom) to not break cons traints. | 196 // bounding box (ceil left/top and floor right/bottom) to not break cons traints. |
208 displayLayout.set( | 197 displayLayout.set( |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 GLES20.glViewport(0, 0, screenWidth, screenHeight); | 626 GLES20.glViewport(0, 0, screenWidth, screenHeight); |
638 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 627 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
639 synchronized (yuvImageRenderers) { | 628 synchronized (yuvImageRenderers) { |
640 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) { | 629 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) { |
641 yuvImageRenderer.draw(drawer); | 630 yuvImageRenderer.draw(drawer); |
642 } | 631 } |
643 } | 632 } |
644 } | 633 } |
645 | 634 |
646 } | 635 } |
OLD | NEW |