OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 import java.util.concurrent.CountDownLatch; | 25 import java.util.concurrent.CountDownLatch; |
26 | 26 |
27 import javax.microedition.khronos.egl.EGLContext; | 27 import javax.microedition.khronos.egl.EGLContext; |
28 | 28 |
29 /** | 29 /** |
30 * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream
on a SurfaceView. | 30 * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream
on a SurfaceView. |
31 * renderFrame() is asynchronous to avoid blocking the calling thread. | 31 * renderFrame() is asynchronous to avoid blocking the calling thread. |
32 * This class is thread safe and handles access from potentially four different
threads: | 32 * This class is thread safe and handles access from potentially four different
threads: |
33 * Interaction from the main app in init, release, setMirror, and setScalingtype
. | 33 * Interaction from the main app in init, release, setMirror, and setScalingtype
. |
34 * Interaction from C++ webrtc::VideoRendererInterface in renderFrame and canApp
lyRotation. | 34 * Interaction from C++ rtc::VideoSinkInterface in renderFrame. |
35 * Interaction from the Activity lifecycle in surfaceCreated, surfaceChanged, an
d surfaceDestroyed. | 35 * Interaction from the Activity lifecycle in surfaceCreated, surfaceChanged, an
d surfaceDestroyed. |
36 * Interaction with the layout framework in onMeasure and onSizeChanged. | 36 * Interaction with the layout framework in onMeasure and onSizeChanged. |
37 */ | 37 */ |
38 public class SurfaceViewRenderer extends SurfaceView | 38 public class SurfaceViewRenderer extends SurfaceView |
39 implements SurfaceHolder.Callback, VideoRenderer.Callbacks { | 39 implements SurfaceHolder.Callback, VideoRenderer.Callbacks { |
40 private static final String TAG = "SurfaceViewRenderer"; | 40 private static final String TAG = "SurfaceViewRenderer"; |
41 | 41 |
42 // Dedicated render thread. | 42 // Dedicated render thread. |
43 private HandlerThread renderThread; | 43 private HandlerThread renderThread; |
44 // |renderThreadHandler| is a handler for communicating with |renderThread|, a
nd is synchronized | 44 // |renderThreadHandler| is a handler for communicating with |renderThread|, a
nd is synchronized |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (framesReceived > 0 && framesRendered > 0) { | 554 if (framesReceived > 0 && framesRendered > 0) { |
555 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs; | 555 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs; |
556 Logging.d(TAG, getResourceName() + "Duration: " + (int) (timeSinceFirstF
rameNs / 1e6) + | 556 Logging.d(TAG, getResourceName() + "Duration: " + (int) (timeSinceFirstF
rameNs / 1e6) + |
557 " ms. FPS: " + framesRendered * 1e9 / timeSinceFirstFrameNs); | 557 " ms. FPS: " + framesRendered * 1e9 / timeSinceFirstFrameNs); |
558 Logging.d(TAG, getResourceName() + "Average render time: " | 558 Logging.d(TAG, getResourceName() + "Average render time: " |
559 + (int) (renderTimeNs / (1000 * framesRendered)) + " us."); | 559 + (int) (renderTimeNs / (1000 * framesRendered)) + " us."); |
560 } | 560 } |
561 } | 561 } |
562 } | 562 } |
563 } | 563 } |
OLD | NEW |