diff options
author | jinwu <jinwu@codeaurora.org> | 2018-07-18 16:17:29 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-07-30 01:47:09 -0700 |
commit | 2b2801858b3cf35ea9b06e1def8ec8836d08bc8a (patch) | |
tree | 544d5aa8c83b062e6d6b32b4b34167c90341132a /src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | |
parent | 6fe9dc8da20ccad3ae5cf15421b9069bd4f87503 (diff) | |
download | android_packages_apps_Gallery2-2b2801858b3cf35ea9b06e1def8ec8836d08bc8a.tar.gz android_packages_apps_Gallery2-2b2801858b3cf35ea9b06e1def8ec8836d08bc8a.tar.bz2 android_packages_apps_Gallery2-2b2801858b3cf35ea9b06e1def8ec8836d08bc8a.zip |
Print media player metrics as required.
Change-Id: If9b3fccc5700684a0681894a44ef284f135e8175
Diffstat (limited to 'src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java')
-rw-r--r-- | src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java index 01061db52..7fefbb881 100644 --- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java +++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java @@ -15,6 +15,7 @@ import android.media.MediaPlayer.OnInfoListener; import android.net.Uri; import android.os.Handler; import android.os.Message; +import android.os.PersistableBundle; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; @@ -563,7 +564,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr mMediaController.hide(); } if (mOnCompletionListener != null) { - Log.d(TAG, "OnCompletion: " + mMediaPlayer.getMetrics()); + printMetrics("OnCompletion: "); mOnCompletionListener.onCompletion(mMediaPlayer); } } @@ -800,10 +801,30 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr } } */ - Log.d(TAG, "Suspend: " + mMediaPlayer.getMetrics()); + printMetrics("Suspend: "); release(false); } + private void printMetrics(String preLog) { + if (mMediaPlayer == null)return; + PersistableBundle metrics = mMediaPlayer.getMetrics(); + if (metrics != null) { + long frames = metrics.getLong(MediaPlayer.MetricsConstants.FRAMES); + long dropFrames = metrics.getLong(MediaPlayer.MetricsConstants.FRAMES_DROPPED); + float percentageDropped = (frames == 0) ? 0 : (100*(float)dropFrames/frames); + String log = preLog + "\n" + + "CODEC_AUDIO: " + metrics.getString(MediaPlayer.MetricsConstants.CODEC_AUDIO) + "\n" + + "DURATION: " + metrics.getLong(MediaPlayer.MetricsConstants.DURATION) + "\n" + + "CODEC_VIDEO: " + metrics.getString(MediaPlayer.MetricsConstants.CODEC_VIDEO) + "\n" + + "MIME_TYPE_VIDEO: " + metrics.getString(MediaPlayer.MetricsConstants.MIME_TYPE_VIDEO) + "\n" + + "MIME_TYPE_AUDIO: " + metrics.getString(MediaPlayer.MetricsConstants.MIME_TYPE_AUDIO) + "\n" + + "FRAMES: " + frames + " DROP: " + dropFrames + " DropPecentage: " + percentageDropped + "%" + "\n" + + "RESOLUTION: " + metrics.getInt(MediaPlayer.MetricsConstants.WIDTH) + "x" + + metrics.getInt(MediaPlayer.MetricsConstants.HEIGHT); + Log.d(TAG, log); + } + } + public void resume() { // HTTP streaming (with suspended status) will call mMediaPlayer->resume(), // others will call openVideo() |