override fun onVideoFrameReceived()

in amazon-chime-sdk/src/main/java/com/amazonaws/services/chime/sdk/meetings/audiovideo/video/capture/DefaultScreenCaptureSource.kt [297:323]


    override fun onVideoFrameReceived(frame: VideoFrame) {
        // Check if display rotation has changed; since this is
        // not an activity there is otherwise no way to observe this
        // besides checking every frame
        val display = displayManager.getDisplay(Display.DEFAULT_DISPLAY)
            ?: throw RuntimeException("No display found.")
        val rotation = display.rotation
        val isOrientationInPortrait = rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180
        if (this.isOrientationInPortrait != isOrientationInPortrait) {
            isResizingForOrientationChange = true
            logger.info(TAG, "Orientation changed from ${if (this.isOrientationInPortrait) "portrait" else "landscape"} " +
                "to ${if (isOrientationInPortrait) "portrait" else "landscape"}, resize virtual display to update dimensions")
            // Post this task to avoid deadlock with the surface texture source handler
            handler.post {
                // Double check that start or stop hasn't been called since this was posted
                if (isResizingForOrientationChange) {
                    resize()
                    isResizingForOrientationChange = false
                }
            }
            return
        }

        // Ignore frames while we are recreating the surface and display
        if (isResizingForOrientationChange) return
        sinks.iterator().forEach { it.onVideoFrameReceived(frame) }
    }