OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 long presentationTimestampUs = TimeUnit.NANOSECONDS.toMicros(frame.getTime
stampNs()); | 609 long presentationTimestampUs = TimeUnit.NANOSECONDS.toMicros(frame.getTime
stampNs()); |
610 checkKeyFrameRequired(isKeyframe, presentationTimestampUs); | 610 checkKeyFrameRequired(isKeyframe, presentationTimestampUs); |
611 | 611 |
612 VideoFrame.Buffer buffer = frame.getBuffer(); | 612 VideoFrame.Buffer buffer = frame.getBuffer(); |
613 if (buffer instanceof VideoFrame.TextureBuffer) { | 613 if (buffer instanceof VideoFrame.TextureBuffer) { |
614 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff
er; | 614 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff
er; |
615 eglBase.makeCurrent(); | 615 eglBase.makeCurrent(); |
616 // TODO(perkj): glClear() shouldn't be necessary since every pixel is co
vered anyway, | 616 // TODO(perkj): glClear() shouldn't be necessary since every pixel is co
vered anyway, |
617 // but it's a workaround for bug webrtc:5147. | 617 // but it's a workaround for bug webrtc:5147. |
618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
619 drawer.drawTexture(textureBuffer, new Matrix() /* renderMatrix */, width
, height, | 619 RendererCommon.drawTexture(drawer, textureBuffer, new Matrix() /* render
Matrix */, width, |
620 0 /* viewportX */, 0 /* viewportY */, width, height); | 620 height, 0 /* viewportX */, 0 /* viewportY */, width, height); |
621 eglBase.swapBuffers(frame.getTimestampNs()); | 621 eglBase.swapBuffers(frame.getTimestampNs()); |
622 } else { | 622 } else { |
623 VideoFrame.I420Buffer i420Buffer = buffer.toI420(); | 623 VideoFrame.I420Buffer i420Buffer = buffer.toI420(); |
624 nativeFillBuffer(nativeEncoder, bufferIndex, i420Buffer.getDataY(), i420
Buffer.getStrideY(), | 624 nativeFillBuffer(nativeEncoder, bufferIndex, i420Buffer.getDataY(), i420
Buffer.getStrideY(), |
625 i420Buffer.getDataU(), i420Buffer.getStrideU(), i420Buffer.getDataV(
), | 625 i420Buffer.getDataU(), i420Buffer.getStrideU(), i420Buffer.getDataV(
), |
626 i420Buffer.getStrideV()); | 626 i420Buffer.getStrideV()); |
627 i420Buffer.release(); | 627 i420Buffer.release(); |
628 // I420 consists of one full-resolution and two half-resolution planes. | 628 // I420 consists of one full-resolution and two half-resolution planes. |
629 // 1 + 1 / 4 + 1 / 4 = 3 / 2 | 629 // 1 + 1 / 4 + 1 / 4 = 3 / 2 |
630 int yuvSize = width * height * 3 / 2; | 630 int yuvSize = width * height * 3 / 2; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 } catch (IllegalStateException e) { | 918 } catch (IllegalStateException e) { |
919 Logging.e(TAG, "releaseOutputBuffer failed", e); | 919 Logging.e(TAG, "releaseOutputBuffer failed", e); |
920 return false; | 920 return false; |
921 } | 921 } |
922 } | 922 } |
923 | 923 |
924 /** Fills an inputBuffer with the given index with data from the byte buffers.
*/ | 924 /** Fills an inputBuffer with the given index with data from the byte buffers.
*/ |
925 private static native void nativeFillBuffer(long nativeEncoder, int inputBuffe
r, ByteBuffer dataY, | 925 private static native void nativeFillBuffer(long nativeEncoder, int inputBuffe
r, ByteBuffer dataY, |
926 int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV)
; | 926 int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV)
; |
927 } | 927 } |
OLD | NEW |