OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 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 | 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. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 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 | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 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, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 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 | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 package org.webrtc; | 28 package org.webrtc; |
29 | 29 |
30 import android.graphics.Canvas; | |
30 import android.graphics.SurfaceTexture; | 31 import android.graphics.SurfaceTexture; |
32 import android.graphics.Rect; | |
magjed_webrtc
2015/11/18 13:12:52
Revert these changes.
| |
33 import android.opengl.EGLExt; | |
34 import android.view.Surface; | |
31 import android.view.SurfaceHolder; | 35 import android.view.SurfaceHolder; |
32 | 36 |
33 import org.webrtc.Logging; | 37 import org.webrtc.Logging; |
34 | 38 |
35 import javax.microedition.khronos.egl.EGL10; | 39 import javax.microedition.khronos.egl.EGL10; |
36 import javax.microedition.khronos.egl.EGLConfig; | 40 import javax.microedition.khronos.egl.EGLConfig; |
37 import javax.microedition.khronos.egl.EGLContext; | 41 import javax.microedition.khronos.egl.EGLContext; |
38 import javax.microedition.khronos.egl.EGLDisplay; | 42 import javax.microedition.khronos.egl.EGLDisplay; |
39 import javax.microedition.khronos.egl.EGLSurface; | 43 import javax.microedition.khronos.egl.EGLSurface; |
40 | 44 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 83 |
80 // Create a new context with the specified config type, sharing data with shar edContext. | 84 // Create a new context with the specified config type, sharing data with shar edContext. |
81 public EglBase(EGLContext sharedContext, ConfigType configType) { | 85 public EglBase(EGLContext sharedContext, ConfigType configType) { |
82 this.egl = (EGL10) EGLContext.getEGL(); | 86 this.egl = (EGL10) EGLContext.getEGL(); |
83 this.configType = configType; | 87 this.configType = configType; |
84 eglDisplay = getEglDisplay(); | 88 eglDisplay = getEglDisplay(); |
85 eglConfig = getEglConfig(eglDisplay, configType); | 89 eglConfig = getEglConfig(eglDisplay, configType); |
86 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); | 90 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); |
87 } | 91 } |
88 | 92 |
89 // Create EGLSurface from the Android SurfaceHolder. | 93 // Create EGLSurface from the Android Surface. |
90 public void createSurface(SurfaceHolder surfaceHolder) { | 94 public void createSurface(Surface surface) { |
91 createSurfaceInternal(surfaceHolder); | 95 /** |
96 * We have to wrap Surface in a SurfaceHolder because for some reason eglCre ateWindowSurface | |
magjed_webrtc
2015/11/18 13:12:52
Rebase, I have landed this change already in a sep
perkj_webrtc
2015/11/18 14:51:20
I will rebase and revert all this once the decoder
| |
97 * couldn't actually take a Surface object until API 17. Older versions fort unately just call | |
98 * SurfaceHolder.getSurface(), so we'll do that. No other methods are releva nt. | |
99 */ | |
100 class FakeSurfaceHolder implements SurfaceHolder { | |
101 private final Surface surface; | |
102 | |
103 FakeSurfaceHolder(Surface surface) { | |
104 this.surface = surface; | |
105 } | |
106 | |
107 @Override | |
108 public void addCallback(Callback callback) {} | |
109 | |
110 @Override | |
111 public void removeCallback(Callback callback) {} | |
112 | |
113 @Override | |
114 public boolean isCreating() { | |
115 return false; | |
116 } | |
117 | |
118 @Override | |
119 public void setType(int i) {} | |
120 | |
121 @Override | |
122 public void setFixedSize(int i, int i2) {} | |
123 | |
124 @Override | |
125 public void setSizeFromLayout() {} | |
126 | |
127 @Override | |
128 public void setFormat(int i) {} | |
129 | |
130 @Override | |
131 public void setKeepScreenOn(boolean b) {} | |
132 | |
133 @Override | |
134 public Canvas lockCanvas() { | |
135 return null; | |
136 } | |
137 | |
138 @Override | |
139 public Canvas lockCanvas(Rect rect) { | |
140 return null; | |
141 } | |
142 | |
143 @Override | |
144 public void unlockCanvasAndPost(Canvas canvas) {} | |
145 | |
146 @Override | |
147 public Rect getSurfaceFrame() { | |
148 return null; | |
149 } | |
150 | |
151 @Override | |
152 public Surface getSurface() { | |
153 return surface; | |
154 } | |
155 } | |
156 | |
157 createSurfaceInternal(new FakeSurfaceHolder(surface)); | |
92 } | 158 } |
93 | 159 |
94 // Create EGLSurface from the Android SurfaceTexture. | 160 // Create EGLSurface from the Android SurfaceTexture. |
95 public void createSurface(SurfaceTexture surfaceTexture) { | 161 public void createSurface(SurfaceTexture surfaceTexture) { |
96 createSurfaceInternal(surfaceTexture); | 162 createSurfaceInternal(surfaceTexture); |
97 } | 163 } |
98 | 164 |
99 // Create EGLSurface from either a SurfaceHolder or a SurfaceTexture. | 165 // Create EGLSurface from either a SurfaceHolder or a SurfaceTexture. |
100 private void createSurfaceInternal(Object nativeWindow) { | 166 private void createSurfaceInternal(Object nativeWindow) { |
101 if (!(nativeWindow instanceof SurfaceHolder) && !(nativeWindow instanceof Su rfaceTexture)) { | 167 if (!(nativeWindow instanceof SurfaceHolder) && !(nativeWindow instanceof Su rfaceTexture)) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { | 328 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { |
263 int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; | 329 int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; |
264 EGLContext eglContext = | 330 EGLContext eglContext = |
265 egl.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttrib utes); | 331 egl.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttrib utes); |
266 if (eglContext == EGL10.EGL_NO_CONTEXT) { | 332 if (eglContext == EGL10.EGL_NO_CONTEXT) { |
267 throw new RuntimeException("Failed to create EGL context"); | 333 throw new RuntimeException("Failed to create EGL context"); |
268 } | 334 } |
269 return eglContext; | 335 return eglContext; |
270 } | 336 } |
271 } | 337 } |
OLD | NEW |