// Update frame dimensions and report any changes to |rendererEvents|. private void updateFrameDimensionsAndReportEvents(VideoRenderer.I420Frame frame) { synchronized (layoutLock) { if (!isFirstFrameRendered) { isFirstFrameRendered = true; logD("Reporting first rendered frame."); if (rendererEvents != null) { rendererEvents.onFirstFrameRendered(); } } if (rotatedFrameWidth != frame.rotatedWidth() || rotatedFrameHeight != frame.rotatedHeight() || frameRotation != frame.rotationDegree) { logD( "Reporting frame resolution changed to " + frame.width + "x" + frame.height + " with rotation " + frame.rotationDegree); if (rendererEvents != null) { rendererEvents.onFrameResolutionChanged(frame.width, frame.height, frame.rotationDegree); } rotatedFrameWidth = frame.rotatedWidth(); rotatedFrameHeight = frame.rotatedHeight(); frameRotation = frame.rotationDegree; post( new Runnable() { @Override public void run() { requestLayout(); } }); } } }
private void setSize(final int videoWidth, final int videoHeight, final int rotation) { if (videoWidth == this.videoWidth && videoHeight == this.videoHeight && rotation == rotationDegree) { return; } if (rendererEvents != null) { Logging.d( TAG, "ID: " + id + ". Reporting frame resolution changed to " + videoWidth + " x " + videoHeight); rendererEvents.onFrameResolutionChanged(videoWidth, videoHeight, rotation); } synchronized (updateLayoutLock) { Logging.d( TAG, "ID: " + id + ". YuvImageRenderer.setSize: " + videoWidth + " x " + videoHeight + " rotation " + rotation); this.videoWidth = videoWidth; this.videoHeight = videoHeight; rotationDegree = rotation; updateLayoutProperties = true; Logging.d(TAG, " YuvImageRenderer.setSize done."); } }