Expose functionality to convert TextureBuffer to I420.
Bug: webrtc:8392 Change-Id: I79682efbef3aecbba904aa5047b229833fae25e8 Reviewed-on: https://webrtc-review.googlesource.com/8940 Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20313}
This commit is contained in:
committed by
Commit Bot
parent
6bf43d2818
commit
cb98b11b71
@ -231,8 +231,11 @@ public class SurfaceTextureHelper {
|
||||
});
|
||||
}
|
||||
|
||||
public void textureToYUV(final ByteBuffer buf, final int width, final int height,
|
||||
final int stride, final int textureId, final float[] transformMatrix) {
|
||||
/** Deprecated, use textureToYuv. */
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // yuvConverter.convert is deprecated
|
||||
void textureToYUV(final ByteBuffer buf, final int width, final int height, final int stride,
|
||||
final int textureId, final float[] transformMatrix) {
|
||||
if (textureId != oesTextureId) {
|
||||
throw new IllegalStateException("textureToByteBuffer called with unexpected textureId");
|
||||
}
|
||||
@ -248,6 +251,25 @@ public class SurfaceTextureHelper {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts to the correct thread to convert |textureBuffer| to I420. Must only be called with
|
||||
* textures generated by this SurfaceTextureHelper.
|
||||
*/
|
||||
public VideoFrame.I420Buffer textureToYuv(final TextureBuffer textureBuffer) {
|
||||
if (textureBuffer.getTextureId() != oesTextureId) {
|
||||
throw new IllegalStateException("textureToByteBuffer called with unexpected textureId");
|
||||
}
|
||||
|
||||
final VideoFrame.I420Buffer[] result = new VideoFrame.I420Buffer[1];
|
||||
ThreadUtils.invokeAtFrontUninterruptibly(handler, () -> {
|
||||
if (yuvConverter == null) {
|
||||
yuvConverter = new YuvConverter();
|
||||
}
|
||||
result[0] = yuvConverter.convert(textureBuffer);
|
||||
});
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private void updateTexImage() {
|
||||
// SurfaceTexture.updateTexImage apparently can compete and deadlock with eglSwapBuffers,
|
||||
// as observed on Nexus 5. Therefore, synchronize it with the EGL functions.
|
||||
|
||||
Reference in New Issue
Block a user