| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return new SurfaceTextureHelper(sharedContext, handler); | 69 return new SurfaceTextureHelper(sharedContext, handler); |
| 70 } catch (RuntimeException e) { | 70 } catch (RuntimeException e) { |
| 71 Logging.e(TAG, threadName + " create failure", e); | 71 Logging.e(TAG, threadName + " create failure", e); |
| 72 return null; | 72 return null; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 }); | 75 }); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // State for YUV conversion, instantiated on demand. | 78 // State for YUV conversion, instantiated on demand. |
| 79 static private class YuvConverter { | 79 static public class YuvConverter { |
| 80 private final EglBase eglBase; | 80 private final EglBase eglBase; |
| 81 private final GlShader shader; | 81 private final GlShader shader; |
| 82 private boolean released = false; | 82 private boolean released = false; |
| 83 | 83 |
| 84 // Vertex coordinates in Normalized Device Coordinates, i.e. | 84 // Vertex coordinates in Normalized Device Coordinates, i.e. |
| 85 // (-1, -1) is bottom-left and (1, 1) is top-right. | 85 // (-1, -1) is bottom-left and (1, 1) is top-right. |
| 86 private static final FloatBuffer DEVICE_RECTANGLE = | 86 private static final FloatBuffer DEVICE_RECTANGLE = |
| 87 GlUtil.createFloatBuffer(new float[] { | 87 GlUtil.createFloatBuffer(new float[] { |
| 88 -1.0f, -1.0f, // Bottom left. | 88 -1.0f, -1.0f, // Bottom left. |
| 89 1.0f, -1.0f, // Bottom right. | 89 1.0f, -1.0f, // Bottom right. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 surfaceTexture = new SurfaceTexture(oesTextureId); | 339 surfaceTexture = new SurfaceTexture(oesTextureId); |
| 340 surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailab
leListener() { | 340 surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailab
leListener() { |
| 341 @Override | 341 @Override |
| 342 public void onFrameAvailable(SurfaceTexture surfaceTexture) { | 342 public void onFrameAvailable(SurfaceTexture surfaceTexture) { |
| 343 hasPendingTexture = true; | 343 hasPendingTexture = true; |
| 344 tryDeliverTextureFrame(); | 344 tryDeliverTextureFrame(); |
| 345 } | 345 } |
| 346 }); | 346 }); |
| 347 } | 347 } |
| 348 | 348 |
| 349 private YuvConverter getYuvConverter() { | 349 public YuvConverter getYuvConverter() { |
| 350 // yuvConverter is assigned once | 350 // yuvConverter is assigned once |
| 351 if (yuvConverter != null) | 351 if (yuvConverter != null) |
| 352 return yuvConverter; | 352 return yuvConverter; |
| 353 | 353 |
| 354 synchronized(this) { | 354 synchronized(this) { |
| 355 if (yuvConverter == null) | 355 if (yuvConverter == null) |
| 356 yuvConverter = new YuvConverter(eglBase.getEglBaseContext()); | 356 yuvConverter = new YuvConverter(eglBase.getEglBaseContext()); |
| 357 return yuvConverter; | 357 return yuvConverter; |
| 358 } | 358 } |
| 359 } | 359 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 synchronized (this) { | 489 synchronized (this) { |
| 490 if (yuvConverter != null) | 490 if (yuvConverter != null) |
| 491 yuvConverter.release(); | 491 yuvConverter.release(); |
| 492 } | 492 } |
| 493 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); | 493 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); |
| 494 surfaceTexture.release(); | 494 surfaceTexture.release(); |
| 495 eglBase.release(); | 495 eglBase.release(); |
| 496 handler.getLooper().quit(); | 496 handler.getLooper().quit(); |
| 497 } | 497 } |
| 498 } | 498 } |
| OLD | NEW |