Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 26 matching lines...) Expand all Loading... | |
| 37 */ | 37 */ |
| 38 public class VideoRenderer { | 38 public class VideoRenderer { |
| 39 | 39 |
| 40 /** Java version of cricket::VideoFrame. Frames are only constructed from nati ve code. */ | 40 /** Java version of cricket::VideoFrame. Frames are only constructed from nati ve code. */ |
| 41 public static class I420Frame { | 41 public static class I420Frame { |
| 42 public final int width; | 42 public final int width; |
| 43 public final int height; | 43 public final int height; |
| 44 public final int[] yuvStrides; | 44 public final int[] yuvStrides; |
| 45 public ByteBuffer[] yuvPlanes; | 45 public ByteBuffer[] yuvPlanes; |
| 46 public final boolean yuvFrame; | 46 public final boolean yuvFrame; |
| 47 public Object textureObject; | 47 // Matrix that transforms standard coordinates to their proper sampling loca tions in |
| 48 // the texture. This transform compensates for any properties of the video s ource that | |
| 49 // cause it to appear different from a normalized texture. This matrix does not take | |
| 50 // |rotationDegree| into account (TODO: Maybe it should). | |
| 51 public final float[] samplingMatrix; | |
| 48 public int textureId; | 52 public int textureId; |
| 49 // Frame pointer in C++. | 53 // Frame pointer in C++. |
| 50 private long nativeFramePointer; | 54 private long nativeFramePointer; |
| 51 | 55 |
| 52 // rotationDegree is the degree that the frame must be rotated clockwisely | 56 // rotationDegree is the degree that the frame must be rotated clockwisely |
| 53 // to be rendered correctly. | 57 // to be rendered correctly. |
| 54 public int rotationDegree; | 58 public int rotationDegree; |
| 55 | 59 |
| 56 /** | 60 /** |
| 57 * Construct a frame of the given dimensions with the specified planar data. | 61 * Construct a frame of the given dimensions with the specified planar data. |
| 58 */ | 62 */ |
| 59 private I420Frame( | 63 private I420Frame( |
| 60 int width, int height, int rotationDegree, | 64 int width, int height, int rotationDegree, |
| 61 int[] yuvStrides, ByteBuffer[] yuvPlanes, long nativeFramePointer) { | 65 int[] yuvStrides, ByteBuffer[] yuvPlanes, long nativeFramePointer) { |
| 62 this.width = width; | 66 this.width = width; |
| 63 this.height = height; | 67 this.height = height; |
| 64 this.yuvStrides = yuvStrides; | 68 this.yuvStrides = yuvStrides; |
| 65 this.yuvPlanes = yuvPlanes; | 69 this.yuvPlanes = yuvPlanes; |
| 66 this.yuvFrame = true; | 70 this.yuvFrame = true; |
| 67 this.rotationDegree = rotationDegree; | 71 this.rotationDegree = rotationDegree; |
| 72 // For ByteBuffers, row 0 specifies the top row, but for a texture, row 0 specifies the | |
| 73 // bottom row. Sample the texture with a vertical flip to compensate for t his. | |
| 74 this.samplingMatrix = RendererCommon.VERTICAL_FLIP; | |
|
magjed_webrtc
2015/09/21 18:29:13
I shouldn't use RendererCommon here because it is
magjed_webrtc
2015/09/22 09:47:36
Done.
| |
| 68 this.nativeFramePointer = nativeFramePointer; | 75 this.nativeFramePointer = nativeFramePointer; |
| 69 if (rotationDegree % 90 != 0) { | 76 if (rotationDegree % 90 != 0) { |
| 70 throw new IllegalArgumentException("Rotation degree not multiple of 90: " + rotationDegree); | 77 throw new IllegalArgumentException("Rotation degree not multiple of 90: " + rotationDegree); |
| 71 } | 78 } |
| 72 } | 79 } |
| 73 | 80 |
| 74 /** | 81 /** |
| 75 * Construct a texture frame of the given dimensions with data in SurfaceTex ture | 82 * Construct a texture frame of the given dimensions with data in SurfaceTex ture |
| 76 */ | 83 */ |
| 77 private I420Frame( | 84 private I420Frame( |
| 78 int width, int height, int rotationDegree, | 85 int width, int height, int rotationDegree, |
| 79 Object textureObject, int textureId, long nativeFramePointer) { | 86 int textureId, float[] samplingMatrix, long nativeFramePointer) { |
| 80 this.width = width; | 87 this.width = width; |
| 81 this.height = height; | 88 this.height = height; |
| 82 this.yuvStrides = null; | 89 this.yuvStrides = null; |
| 83 this.yuvPlanes = null; | 90 this.yuvPlanes = null; |
| 84 this.textureObject = textureObject; | 91 this.samplingMatrix = samplingMatrix; |
| 85 this.textureId = textureId; | 92 this.textureId = textureId; |
| 86 this.yuvFrame = false; | 93 this.yuvFrame = false; |
| 87 this.rotationDegree = rotationDegree; | 94 this.rotationDegree = rotationDegree; |
| 88 this.nativeFramePointer = nativeFramePointer; | 95 this.nativeFramePointer = nativeFramePointer; |
| 89 if (rotationDegree % 90 != 0) { | 96 if (rotationDegree % 90 != 0) { |
| 90 throw new IllegalArgumentException("Rotation degree not multiple of 90: " + rotationDegree); | 97 throw new IllegalArgumentException("Rotation degree not multiple of 90: " + rotationDegree); |
| 91 } | 98 } |
| 92 } | 99 } |
| 93 | 100 |
| 94 public int rotatedWidth() { | 101 public int rotatedWidth() { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 117 // is responsible for signaling when it is done with |frame| by calling | 124 // is responsible for signaling when it is done with |frame| by calling |
| 118 // renderFrameDone(frame). | 125 // renderFrameDone(frame). |
| 119 public void renderFrame(I420Frame frame); | 126 public void renderFrame(I420Frame frame); |
| 120 } | 127 } |
| 121 | 128 |
| 122 /** | 129 /** |
| 123 * This must be called after every renderFrame() to release the frame. | 130 * This must be called after every renderFrame() to release the frame. |
| 124 */ | 131 */ |
| 125 public static void renderFrameDone(I420Frame frame) { | 132 public static void renderFrameDone(I420Frame frame) { |
| 126 frame.yuvPlanes = null; | 133 frame.yuvPlanes = null; |
| 127 frame.textureObject = null; | |
| 128 frame.textureId = 0; | 134 frame.textureId = 0; |
| 129 if (frame.nativeFramePointer != 0) { | 135 if (frame.nativeFramePointer != 0) { |
| 130 releaseNativeFrame(frame.nativeFramePointer); | 136 releaseNativeFrame(frame.nativeFramePointer); |
| 131 frame.nativeFramePointer = 0; | 137 frame.nativeFramePointer = 0; |
| 132 } | 138 } |
| 133 } | 139 } |
| 134 | 140 |
| 135 // |this| either wraps a native (GUI) renderer or a client-supplied Callbacks | 141 // |this| either wraps a native (GUI) renderer or a client-supplied Callbacks |
| 136 // (Java) implementation; this is indicated by |isWrappedVideoRenderer|. | 142 // (Java) implementation; this is indicated by |isWrappedVideoRenderer|. |
| 137 long nativeVideoRenderer; | 143 long nativeVideoRenderer; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 } | 175 } |
| 170 | 176 |
| 171 private static native long nativeCreateGuiVideoRenderer(int x, int y); | 177 private static native long nativeCreateGuiVideoRenderer(int x, int y); |
| 172 private static native long nativeWrapVideoRenderer(Callbacks callbacks); | 178 private static native long nativeWrapVideoRenderer(Callbacks callbacks); |
| 173 | 179 |
| 174 private static native void freeGuiVideoRenderer(long nativeVideoRenderer); | 180 private static native void freeGuiVideoRenderer(long nativeVideoRenderer); |
| 175 private static native void freeWrappedVideoRenderer(long nativeVideoRenderer); | 181 private static native void freeWrappedVideoRenderer(long nativeVideoRenderer); |
| 176 | 182 |
| 177 private static native void releaseNativeFrame(long nativeFramePointer); | 183 private static native void releaseNativeFrame(long nativeFramePointer); |
| 178 } | 184 } |
| OLD | NEW |