OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 |
11 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import android.graphics.Bitmap; | 13 import android.graphics.Bitmap; |
14 import android.graphics.SurfaceTexture; | 14 import android.graphics.SurfaceTexture; |
15 import android.opengl.GLES20; | 15 import android.opengl.GLES20; |
16 import android.os.Handler; | 16 import android.os.Handler; |
17 import android.os.HandlerThread; | 17 import android.os.HandlerThread; |
18 import android.os.Looper; | 18 import android.os.Looper; |
19 import android.view.Surface; | 19 import android.view.Surface; |
20 import java.nio.ByteBuffer; | 20 import java.nio.ByteBuffer; |
21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 import java.util.Iterator; | 22 import java.util.Iterator; |
| 23 import java.util.Locale; |
23 import java.util.concurrent.CountDownLatch; | 24 import java.util.concurrent.CountDownLatch; |
24 import java.util.concurrent.TimeUnit; | 25 import java.util.concurrent.TimeUnit; |
25 | 26 |
26 /** | 27 /** |
27 * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream
on an EGL Surface. | 28 * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream
on an EGL Surface. |
28 * This class is intended to be used as a helper class for rendering on SurfaceV
iews and | 29 * This class is intended to be used as a helper class for rendering on SurfaceV
iews and |
29 * TextureViews. | 30 * TextureViews. |
30 */ | 31 */ |
31 public class EglRenderer implements VideoRenderer.Callbacks { | 32 public class EglRenderer implements VideoRenderer.Callbacks { |
32 private static final String TAG = "EglRenderer"; | 33 private static final String TAG = "EglRenderer"; |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 synchronized (statisticsLock) { | 672 synchronized (statisticsLock) { |
672 final long elapsedTimeNs = currentTimeNs - statisticsStartTimeNs; | 673 final long elapsedTimeNs = currentTimeNs - statisticsStartTimeNs; |
673 if (elapsedTimeNs <= 0) { | 674 if (elapsedTimeNs <= 0) { |
674 return; | 675 return; |
675 } | 676 } |
676 final float renderFps = framesRendered * TimeUnit.SECONDS.toNanos(1) / (fl
oat) elapsedTimeNs; | 677 final float renderFps = framesRendered * TimeUnit.SECONDS.toNanos(1) / (fl
oat) elapsedTimeNs; |
677 logD("Duration: " + TimeUnit.NANOSECONDS.toMillis(elapsedTimeNs) + " ms." | 678 logD("Duration: " + TimeUnit.NANOSECONDS.toMillis(elapsedTimeNs) + " ms." |
678 + " Frames received: " + framesReceived + "." | 679 + " Frames received: " + framesReceived + "." |
679 + " Dropped: " + framesDropped + "." | 680 + " Dropped: " + framesDropped + "." |
680 + " Rendered: " + framesRendered + "." | 681 + " Rendered: " + framesRendered + "." |
681 + " Render fps: " + String.format("%.1f", renderFps) + "." | 682 + " Render fps: " + String.format(Locale.US, "%.1f", renderFps) + "." |
682 + " Average render time: " + averageTimeAsString(renderTimeNs, framesR
endered) + "." | 683 + " Average render time: " + averageTimeAsString(renderTimeNs, framesR
endered) + "." |
683 + " Average swapBuffer time: " | 684 + " Average swapBuffer time: " |
684 + averageTimeAsString(renderSwapBufferTimeNs, framesRendered) + "."); | 685 + averageTimeAsString(renderSwapBufferTimeNs, framesRendered) + "."); |
685 resetStatistics(currentTimeNs); | 686 resetStatistics(currentTimeNs); |
686 } | 687 } |
687 } | 688 } |
688 | 689 |
689 private void logD(String string) { | 690 private void logD(String string) { |
690 Logging.d(TAG, name + string); | 691 Logging.d(TAG, name + string); |
691 } | 692 } |
692 } | 693 } |
OLD | NEW |