From 10353e36018224b86ef2918d1d68107459d445cf Mon Sep 17 00:00:00 2001 From: Ray Essick Date: Fri, 14 Apr 2017 10:22:55 -0700 Subject: Rework getMetrics() api per API council Reworking the media metrics getMetrics() calls (currently in MediaCodec, MediaExtractor, MediaPlayer, and MediaRecorder) to fit new direction from the API Council. Drop the MediaMetricsSet that we had in the first round; go back to a PersistableBundle as the return type. Moves the key definitions from MediaMetricsSet.MediaCodec to MediaCodec.MetricsConstants Bug: 37083862 Test: ran the corresponding CTS tests Change-Id: I7905959ad2109887dd8fd16f0eb2831247abab2a --- api/current.txt | 124 +++---- api/system-current.txt | 124 +++---- api/test-current.txt | 124 +++---- media/java/android/media/MediaCodec.java | 95 ++++- media/java/android/media/MediaExtractor.java | 43 ++- media/java/android/media/MediaMetricsSet.java | 491 -------------------------- media/java/android/media/MediaPlayer.java | 109 +++++- media/java/android/media/MediaRecorder.java | 135 ++++++- media/jni/android_media_MediaCodec.cpp | 2 +- media/jni/android_media_MediaExtractor.cpp | 2 +- media/jni/android_media_MediaMetricsJNI.cpp | 11 +- media/jni/android_media_MediaPlayer.cpp | 2 +- media/jni/android_media_MediaRecorder.cpp | 2 +- 13 files changed, 527 insertions(+), 737 deletions(-) delete mode 100644 media/java/android/media/MediaMetricsSet.java diff --git a/api/current.txt b/api/current.txt index 79f88aacebc6..4592dc351cdf 100644 --- a/api/current.txt +++ b/api/current.txt @@ -21868,7 +21868,7 @@ package android.media { method public deprecated java.nio.ByteBuffer[] getInputBuffers(); method public final android.media.MediaFormat getInputFormat(); method public android.media.Image getInputImage(int); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public final java.lang.String getName(); method public java.nio.ByteBuffer getOutputBuffer(int); method public deprecated java.nio.ByteBuffer[] getOutputBuffers(); @@ -21966,6 +21966,19 @@ package android.media { method public void set(int, int); } + public static final class MediaCodec.MetricsConstants { + field public static final java.lang.String CODEC = "android.media.mediacodec.codec"; + field public static final java.lang.String ENCODER = "android.media.mediacodec.encoder"; + field public static final java.lang.String HEIGHT = "android.media.mediacodec.height"; + field public static final java.lang.String MIME_TYPE = "android.media.mediacodec.mime"; + field public static final java.lang.String MODE = "android.media.mediacodec.mode"; + field public static final java.lang.String MODE_AUDIO = "audio"; + field public static final java.lang.String MODE_VIDEO = "video"; + field public static final java.lang.String ROTATION = "android.media.mediacodec.rotation"; + field public static final java.lang.String SECURE = "android.media.mediacodec.secure"; + field public static final java.lang.String WIDTH = "android.media.mediacodec.width"; + } + public static abstract interface MediaCodec.OnFrameRenderedListener { method public abstract void onFrameRendered(android.media.MediaCodec, long, long); } @@ -22421,7 +22434,7 @@ package android.media { method public long getCachedDuration(); method public android.media.MediaExtractor.CasInfo getCasInfo(int); method public android.media.DrmInitData getDrmInitData(); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public java.util.Map getPsshInfo(); method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo); method public int getSampleFlags(); @@ -22456,6 +22469,12 @@ package android.media { method public int getSystemId(); } + public static final class MediaExtractor.MetricsConstants { + field public static final java.lang.String FORMAT = "android.media.mediaextractor.fmt"; + field public static final java.lang.String MIME_TYPE = "android.media.mediaextractor.mime"; + field public static final java.lang.String TRACKS = "android.media.mediaextractor.ntrk"; + } + public final class MediaFormat { ctor public MediaFormat(); method public final boolean containsKey(java.lang.String); @@ -22681,69 +22700,6 @@ package android.media { field public static final int OPTION_PREVIOUS_SYNC = 0; // 0x0 } - public final class MediaMetricsSet { - method public double getDouble(java.lang.String, double); - method public int getInt(java.lang.String, int); - method public long getLong(java.lang.String, long); - method public java.lang.String getString(java.lang.String, java.lang.String); - method public boolean isEmpty(); - method public java.util.Set keySet(); - method public int size(); - } - - public static final class MediaMetricsSet.MediaCodec { - field public static final java.lang.String KEY_CODEC = "android.media.mediacodec.codec"; - field public static final java.lang.String KEY_ENCODER = "android.media.mediacodec.encoder"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediacodec.height"; - field public static final java.lang.String KEY_MIME = "android.media.mediacodec.mime"; - field public static final java.lang.String KEY_MODE = "android.media.mediacodec.mode"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediacodec.rotation"; - field public static final java.lang.String KEY_SECURE = "android.media.mediacodec.secure"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediacodec.width"; - field public static final java.lang.String MODE_AUDIO = "audio"; - field public static final java.lang.String MODE_VIDEO = "video"; - } - - public static final class MediaMetricsSet.MediaExtractor { - field public static final java.lang.String KEY_FORMAT = "android.media.mediaextractor.fmt"; - field public static final java.lang.String KEY_MIME = "android.media.mediaextractor.mime"; - field public static final java.lang.String KEY_TRACKS = "android.media.mediaextractor.ntrk"; - } - - public static final class MediaMetricsSet.MediaPlayer { - field public static final java.lang.String KEY_CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; - field public static final java.lang.String KEY_CODEC_VIDEO = "android.media.mediaplayer.video.codec"; - field public static final java.lang.String KEY_DURATION = "android.media.mediaplayer.durationMs"; - field public static final java.lang.String KEY_ERRORS = "android.media.mediaplayer.err"; - field public static final java.lang.String KEY_ERROR_CODE = "android.media.mediaplayer.errcode"; - field public static final java.lang.String KEY_FRAMES = "android.media.mediaplayer.frames"; - field public static final java.lang.String KEY_FRAMES_DROPPED = "android.media.mediaplayer.dropped"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediaplayer.height"; - field public static final java.lang.String KEY_MIME_AUDIO = "android.media.mediaplayer.audio.mime"; - field public static final java.lang.String KEY_MIME_VIDEO = "android.media.mediaplayer.video.mime"; - field public static final java.lang.String KEY_PLAYING = "android.media.mediaplayer.playingMs"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediaplayer.width"; - } - - public static final class MediaMetricsSet.MediaRecorder { - field public static final java.lang.String KEY_AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; - field public static final java.lang.String KEY_AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; - field public static final java.lang.String KEY_AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; - field public static final java.lang.String KEY_AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; - field public static final java.lang.String KEY_CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; - field public static final java.lang.String KEY_CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; - field public static final java.lang.String KEY_FRAMERATE = "android.media.mediarecorder.frame-rate"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediarecorder.height"; - field public static final java.lang.String KEY_MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediarecorder.rotation"; - field public static final java.lang.String KEY_VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; - field public static final java.lang.String KEY_VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; - field public static final java.lang.String KEY_VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; - field public static final java.lang.String KEY_VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; - field public static final java.lang.String KEY_VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediarecorder.width"; - } - public final class MediaMuxer { ctor public MediaMuxer(java.lang.String, int) throws java.io.IOException; ctor public MediaMuxer(java.io.FileDescriptor, int) throws java.io.IOException; @@ -22782,7 +22738,7 @@ package android.media { method public java.lang.String getDrmPropertyString(java.lang.String) throws android.media.MediaPlayer.NoDrmSchemeException; method public int getDuration(); method public android.media.MediaDrm.KeyRequest getKeyRequest(byte[], java.lang.String, int, java.util.Map) throws android.media.MediaPlayer.NoDrmSchemeException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.media.PlaybackParams getPlaybackParams(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncParams getSyncParams(); @@ -22877,6 +22833,21 @@ package android.media { method public java.util.UUID[] getSupportedSchemes(); } + public static final class MediaPlayer.MetricsConstants { + field public static final java.lang.String CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; + field public static final java.lang.String CODEC_VIDEO = "android.media.mediaplayer.video.codec"; + field public static final java.lang.String DURATION = "android.media.mediaplayer.durationMs"; + field public static final java.lang.String ERRORS = "android.media.mediaplayer.err"; + field public static final java.lang.String ERROR_CODE = "android.media.mediaplayer.errcode"; + field public static final java.lang.String FRAMES = "android.media.mediaplayer.frames"; + field public static final java.lang.String FRAMES_DROPPED = "android.media.mediaplayer.dropped"; + field public static final java.lang.String HEIGHT = "android.media.mediaplayer.height"; + field public static final java.lang.String MIME_TYPE_AUDIO = "android.media.mediaplayer.audio.mime"; + field public static final java.lang.String MIME_TYPE_VIDEO = "android.media.mediaplayer.video.mime"; + field public static final java.lang.String PLAYING = "android.media.mediaplayer.playingMs"; + field public static final java.lang.String WIDTH = "android.media.mediaplayer.width"; + } + public static final class MediaPlayer.NoDrmSchemeException extends android.media.MediaDrmException { ctor public MediaPlayer.NoDrmSchemeException(java.lang.String); } @@ -22951,7 +22922,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; @@ -23019,6 +22990,25 @@ package android.media { field public static final int VOICE_UPLINK = 2; // 0x2 } + public static final class MediaRecorder.MetricsConstants { + field public static final java.lang.String AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; + field public static final java.lang.String AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; + field public static final java.lang.String AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; + field public static final java.lang.String AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; + field public static final java.lang.String CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; + field public static final java.lang.String CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; + field public static final java.lang.String FRAMERATE = "android.media.mediarecorder.frame-rate"; + field public static final java.lang.String HEIGHT = "android.media.mediarecorder.height"; + field public static final java.lang.String MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; + field public static final java.lang.String ROTATION = "android.media.mediarecorder.rotation"; + field public static final java.lang.String VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; + field public static final java.lang.String VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; + field public static final java.lang.String VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; + field public static final java.lang.String VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; + field public static final java.lang.String VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; + field public static final java.lang.String WIDTH = "android.media.mediarecorder.width"; + } + public static abstract interface MediaRecorder.OnErrorListener { method public abstract void onError(android.media.MediaRecorder, int, int); } diff --git a/api/system-current.txt b/api/system-current.txt index 83855e66a89d..4f7d9b8c0739 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -23700,7 +23700,7 @@ package android.media { method public deprecated java.nio.ByteBuffer[] getInputBuffers(); method public final android.media.MediaFormat getInputFormat(); method public android.media.Image getInputImage(int); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public final java.lang.String getName(); method public java.nio.ByteBuffer getOutputBuffer(int); method public deprecated java.nio.ByteBuffer[] getOutputBuffers(); @@ -23798,6 +23798,19 @@ package android.media { method public void set(int, int); } + public static final class MediaCodec.MetricsConstants { + field public static final java.lang.String CODEC = "android.media.mediacodec.codec"; + field public static final java.lang.String ENCODER = "android.media.mediacodec.encoder"; + field public static final java.lang.String HEIGHT = "android.media.mediacodec.height"; + field public static final java.lang.String MIME_TYPE = "android.media.mediacodec.mime"; + field public static final java.lang.String MODE = "android.media.mediacodec.mode"; + field public static final java.lang.String MODE_AUDIO = "audio"; + field public static final java.lang.String MODE_VIDEO = "video"; + field public static final java.lang.String ROTATION = "android.media.mediacodec.rotation"; + field public static final java.lang.String SECURE = "android.media.mediacodec.secure"; + field public static final java.lang.String WIDTH = "android.media.mediacodec.width"; + } + public static abstract interface MediaCodec.OnFrameRenderedListener { method public abstract void onFrameRendered(android.media.MediaCodec, long, long); } @@ -24253,7 +24266,7 @@ package android.media { method public long getCachedDuration(); method public android.media.MediaExtractor.CasInfo getCasInfo(int); method public android.media.DrmInitData getDrmInitData(); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public java.util.Map getPsshInfo(); method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo); method public int getSampleFlags(); @@ -24288,6 +24301,12 @@ package android.media { method public int getSystemId(); } + public static final class MediaExtractor.MetricsConstants { + field public static final java.lang.String FORMAT = "android.media.mediaextractor.fmt"; + field public static final java.lang.String MIME_TYPE = "android.media.mediaextractor.mime"; + field public static final java.lang.String TRACKS = "android.media.mediaextractor.ntrk"; + } + public final class MediaFormat { ctor public MediaFormat(); method public final boolean containsKey(java.lang.String); @@ -24513,69 +24532,6 @@ package android.media { field public static final int OPTION_PREVIOUS_SYNC = 0; // 0x0 } - public final class MediaMetricsSet { - method public double getDouble(java.lang.String, double); - method public int getInt(java.lang.String, int); - method public long getLong(java.lang.String, long); - method public java.lang.String getString(java.lang.String, java.lang.String); - method public boolean isEmpty(); - method public java.util.Set keySet(); - method public int size(); - } - - public static final class MediaMetricsSet.MediaCodec { - field public static final java.lang.String KEY_CODEC = "android.media.mediacodec.codec"; - field public static final java.lang.String KEY_ENCODER = "android.media.mediacodec.encoder"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediacodec.height"; - field public static final java.lang.String KEY_MIME = "android.media.mediacodec.mime"; - field public static final java.lang.String KEY_MODE = "android.media.mediacodec.mode"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediacodec.rotation"; - field public static final java.lang.String KEY_SECURE = "android.media.mediacodec.secure"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediacodec.width"; - field public static final java.lang.String MODE_AUDIO = "audio"; - field public static final java.lang.String MODE_VIDEO = "video"; - } - - public static final class MediaMetricsSet.MediaExtractor { - field public static final java.lang.String KEY_FORMAT = "android.media.mediaextractor.fmt"; - field public static final java.lang.String KEY_MIME = "android.media.mediaextractor.mime"; - field public static final java.lang.String KEY_TRACKS = "android.media.mediaextractor.ntrk"; - } - - public static final class MediaMetricsSet.MediaPlayer { - field public static final java.lang.String KEY_CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; - field public static final java.lang.String KEY_CODEC_VIDEO = "android.media.mediaplayer.video.codec"; - field public static final java.lang.String KEY_DURATION = "android.media.mediaplayer.durationMs"; - field public static final java.lang.String KEY_ERRORS = "android.media.mediaplayer.err"; - field public static final java.lang.String KEY_ERROR_CODE = "android.media.mediaplayer.errcode"; - field public static final java.lang.String KEY_FRAMES = "android.media.mediaplayer.frames"; - field public static final java.lang.String KEY_FRAMES_DROPPED = "android.media.mediaplayer.dropped"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediaplayer.height"; - field public static final java.lang.String KEY_MIME_AUDIO = "android.media.mediaplayer.audio.mime"; - field public static final java.lang.String KEY_MIME_VIDEO = "android.media.mediaplayer.video.mime"; - field public static final java.lang.String KEY_PLAYING = "android.media.mediaplayer.playingMs"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediaplayer.width"; - } - - public static final class MediaMetricsSet.MediaRecorder { - field public static final java.lang.String KEY_AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; - field public static final java.lang.String KEY_AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; - field public static final java.lang.String KEY_AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; - field public static final java.lang.String KEY_AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; - field public static final java.lang.String KEY_CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; - field public static final java.lang.String KEY_CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; - field public static final java.lang.String KEY_FRAMERATE = "android.media.mediarecorder.frame-rate"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediarecorder.height"; - field public static final java.lang.String KEY_MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediarecorder.rotation"; - field public static final java.lang.String KEY_VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; - field public static final java.lang.String KEY_VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; - field public static final java.lang.String KEY_VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; - field public static final java.lang.String KEY_VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; - field public static final java.lang.String KEY_VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediarecorder.width"; - } - public final class MediaMuxer { ctor public MediaMuxer(java.lang.String, int) throws java.io.IOException; ctor public MediaMuxer(java.io.FileDescriptor, int) throws java.io.IOException; @@ -24614,7 +24570,7 @@ package android.media { method public java.lang.String getDrmPropertyString(java.lang.String) throws android.media.MediaPlayer.NoDrmSchemeException; method public int getDuration(); method public android.media.MediaDrm.KeyRequest getKeyRequest(byte[], java.lang.String, int, java.util.Map) throws android.media.MediaPlayer.NoDrmSchemeException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.media.PlaybackParams getPlaybackParams(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncParams getSyncParams(); @@ -24709,6 +24665,21 @@ package android.media { method public java.util.UUID[] getSupportedSchemes(); } + public static final class MediaPlayer.MetricsConstants { + field public static final java.lang.String CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; + field public static final java.lang.String CODEC_VIDEO = "android.media.mediaplayer.video.codec"; + field public static final java.lang.String DURATION = "android.media.mediaplayer.durationMs"; + field public static final java.lang.String ERRORS = "android.media.mediaplayer.err"; + field public static final java.lang.String ERROR_CODE = "android.media.mediaplayer.errcode"; + field public static final java.lang.String FRAMES = "android.media.mediaplayer.frames"; + field public static final java.lang.String FRAMES_DROPPED = "android.media.mediaplayer.dropped"; + field public static final java.lang.String HEIGHT = "android.media.mediaplayer.height"; + field public static final java.lang.String MIME_TYPE_AUDIO = "android.media.mediaplayer.audio.mime"; + field public static final java.lang.String MIME_TYPE_VIDEO = "android.media.mediaplayer.video.mime"; + field public static final java.lang.String PLAYING = "android.media.mediaplayer.playingMs"; + field public static final java.lang.String WIDTH = "android.media.mediaplayer.width"; + } + public static final class MediaPlayer.NoDrmSchemeException extends android.media.MediaDrmException { ctor public MediaPlayer.NoDrmSchemeException(java.lang.String); } @@ -24783,7 +24754,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; @@ -24853,6 +24824,25 @@ package android.media { field public static final int VOICE_UPLINK = 2; // 0x2 } + public static final class MediaRecorder.MetricsConstants { + field public static final java.lang.String AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; + field public static final java.lang.String AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; + field public static final java.lang.String AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; + field public static final java.lang.String AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; + field public static final java.lang.String CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; + field public static final java.lang.String CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; + field public static final java.lang.String FRAMERATE = "android.media.mediarecorder.frame-rate"; + field public static final java.lang.String HEIGHT = "android.media.mediarecorder.height"; + field public static final java.lang.String MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; + field public static final java.lang.String ROTATION = "android.media.mediarecorder.rotation"; + field public static final java.lang.String VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; + field public static final java.lang.String VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; + field public static final java.lang.String VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; + field public static final java.lang.String VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; + field public static final java.lang.String VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; + field public static final java.lang.String WIDTH = "android.media.mediarecorder.width"; + } + public static abstract interface MediaRecorder.OnErrorListener { method public abstract void onError(android.media.MediaRecorder, int, int); } diff --git a/api/test-current.txt b/api/test-current.txt index f75a872b4c0d..38a03db37919 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -21975,7 +21975,7 @@ package android.media { method public deprecated java.nio.ByteBuffer[] getInputBuffers(); method public final android.media.MediaFormat getInputFormat(); method public android.media.Image getInputImage(int); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public final java.lang.String getName(); method public java.nio.ByteBuffer getOutputBuffer(int); method public deprecated java.nio.ByteBuffer[] getOutputBuffers(); @@ -22073,6 +22073,19 @@ package android.media { method public void set(int, int); } + public static final class MediaCodec.MetricsConstants { + field public static final java.lang.String CODEC = "android.media.mediacodec.codec"; + field public static final java.lang.String ENCODER = "android.media.mediacodec.encoder"; + field public static final java.lang.String HEIGHT = "android.media.mediacodec.height"; + field public static final java.lang.String MIME_TYPE = "android.media.mediacodec.mime"; + field public static final java.lang.String MODE = "android.media.mediacodec.mode"; + field public static final java.lang.String MODE_AUDIO = "audio"; + field public static final java.lang.String MODE_VIDEO = "video"; + field public static final java.lang.String ROTATION = "android.media.mediacodec.rotation"; + field public static final java.lang.String SECURE = "android.media.mediacodec.secure"; + field public static final java.lang.String WIDTH = "android.media.mediacodec.width"; + } + public static abstract interface MediaCodec.OnFrameRenderedListener { method public abstract void onFrameRendered(android.media.MediaCodec, long, long); } @@ -22528,7 +22541,7 @@ package android.media { method public long getCachedDuration(); method public android.media.MediaExtractor.CasInfo getCasInfo(int); method public android.media.DrmInitData getDrmInitData(); - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public java.util.Map getPsshInfo(); method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo); method public int getSampleFlags(); @@ -22563,6 +22576,12 @@ package android.media { method public int getSystemId(); } + public static final class MediaExtractor.MetricsConstants { + field public static final java.lang.String FORMAT = "android.media.mediaextractor.fmt"; + field public static final java.lang.String MIME_TYPE = "android.media.mediaextractor.mime"; + field public static final java.lang.String TRACKS = "android.media.mediaextractor.ntrk"; + } + public final class MediaFormat { ctor public MediaFormat(); method public final boolean containsKey(java.lang.String); @@ -22788,69 +22807,6 @@ package android.media { field public static final int OPTION_PREVIOUS_SYNC = 0; // 0x0 } - public final class MediaMetricsSet { - method public double getDouble(java.lang.String, double); - method public int getInt(java.lang.String, int); - method public long getLong(java.lang.String, long); - method public java.lang.String getString(java.lang.String, java.lang.String); - method public boolean isEmpty(); - method public java.util.Set keySet(); - method public int size(); - } - - public static final class MediaMetricsSet.MediaCodec { - field public static final java.lang.String KEY_CODEC = "android.media.mediacodec.codec"; - field public static final java.lang.String KEY_ENCODER = "android.media.mediacodec.encoder"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediacodec.height"; - field public static final java.lang.String KEY_MIME = "android.media.mediacodec.mime"; - field public static final java.lang.String KEY_MODE = "android.media.mediacodec.mode"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediacodec.rotation"; - field public static final java.lang.String KEY_SECURE = "android.media.mediacodec.secure"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediacodec.width"; - field public static final java.lang.String MODE_AUDIO = "audio"; - field public static final java.lang.String MODE_VIDEO = "video"; - } - - public static final class MediaMetricsSet.MediaExtractor { - field public static final java.lang.String KEY_FORMAT = "android.media.mediaextractor.fmt"; - field public static final java.lang.String KEY_MIME = "android.media.mediaextractor.mime"; - field public static final java.lang.String KEY_TRACKS = "android.media.mediaextractor.ntrk"; - } - - public static final class MediaMetricsSet.MediaPlayer { - field public static final java.lang.String KEY_CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; - field public static final java.lang.String KEY_CODEC_VIDEO = "android.media.mediaplayer.video.codec"; - field public static final java.lang.String KEY_DURATION = "android.media.mediaplayer.durationMs"; - field public static final java.lang.String KEY_ERRORS = "android.media.mediaplayer.err"; - field public static final java.lang.String KEY_ERROR_CODE = "android.media.mediaplayer.errcode"; - field public static final java.lang.String KEY_FRAMES = "android.media.mediaplayer.frames"; - field public static final java.lang.String KEY_FRAMES_DROPPED = "android.media.mediaplayer.dropped"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediaplayer.height"; - field public static final java.lang.String KEY_MIME_AUDIO = "android.media.mediaplayer.audio.mime"; - field public static final java.lang.String KEY_MIME_VIDEO = "android.media.mediaplayer.video.mime"; - field public static final java.lang.String KEY_PLAYING = "android.media.mediaplayer.playingMs"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediaplayer.width"; - } - - public static final class MediaMetricsSet.MediaRecorder { - field public static final java.lang.String KEY_AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; - field public static final java.lang.String KEY_AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; - field public static final java.lang.String KEY_AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; - field public static final java.lang.String KEY_AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; - field public static final java.lang.String KEY_CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; - field public static final java.lang.String KEY_CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; - field public static final java.lang.String KEY_FRAMERATE = "android.media.mediarecorder.frame-rate"; - field public static final java.lang.String KEY_HEIGHT = "android.media.mediarecorder.height"; - field public static final java.lang.String KEY_MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; - field public static final java.lang.String KEY_ROTATION = "android.media.mediarecorder.rotation"; - field public static final java.lang.String KEY_VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; - field public static final java.lang.String KEY_VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; - field public static final java.lang.String KEY_VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; - field public static final java.lang.String KEY_VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; - field public static final java.lang.String KEY_VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; - field public static final java.lang.String KEY_WIDTH = "android.media.mediarecorder.width"; - } - public final class MediaMuxer { ctor public MediaMuxer(java.lang.String, int) throws java.io.IOException; ctor public MediaMuxer(java.io.FileDescriptor, int) throws java.io.IOException; @@ -22889,7 +22845,7 @@ package android.media { method public java.lang.String getDrmPropertyString(java.lang.String) throws android.media.MediaPlayer.NoDrmSchemeException; method public int getDuration(); method public android.media.MediaDrm.KeyRequest getKeyRequest(byte[], java.lang.String, int, java.util.Map) throws android.media.MediaPlayer.NoDrmSchemeException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.media.PlaybackParams getPlaybackParams(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncParams getSyncParams(); @@ -22984,6 +22940,21 @@ package android.media { method public java.util.UUID[] getSupportedSchemes(); } + public static final class MediaPlayer.MetricsConstants { + field public static final java.lang.String CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; + field public static final java.lang.String CODEC_VIDEO = "android.media.mediaplayer.video.codec"; + field public static final java.lang.String DURATION = "android.media.mediaplayer.durationMs"; + field public static final java.lang.String ERRORS = "android.media.mediaplayer.err"; + field public static final java.lang.String ERROR_CODE = "android.media.mediaplayer.errcode"; + field public static final java.lang.String FRAMES = "android.media.mediaplayer.frames"; + field public static final java.lang.String FRAMES_DROPPED = "android.media.mediaplayer.dropped"; + field public static final java.lang.String HEIGHT = "android.media.mediaplayer.height"; + field public static final java.lang.String MIME_TYPE_AUDIO = "android.media.mediaplayer.audio.mime"; + field public static final java.lang.String MIME_TYPE_VIDEO = "android.media.mediaplayer.video.mime"; + field public static final java.lang.String PLAYING = "android.media.mediaplayer.playingMs"; + field public static final java.lang.String WIDTH = "android.media.mediaplayer.width"; + } + public static final class MediaPlayer.NoDrmSchemeException extends android.media.MediaDrmException { ctor public MediaPlayer.NoDrmSchemeException(java.lang.String); } @@ -23058,7 +23029,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; - method public android.media.MediaMetricsSet getMetrics(); + method public android.os.PersistableBundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; @@ -23126,6 +23097,25 @@ package android.media { field public static final int VOICE_UPLINK = 2; // 0x2 } + public static final class MediaRecorder.MetricsConstants { + field public static final java.lang.String AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; + field public static final java.lang.String AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; + field public static final java.lang.String AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; + field public static final java.lang.String AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; + field public static final java.lang.String CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; + field public static final java.lang.String CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; + field public static final java.lang.String FRAMERATE = "android.media.mediarecorder.frame-rate"; + field public static final java.lang.String HEIGHT = "android.media.mediarecorder.height"; + field public static final java.lang.String MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; + field public static final java.lang.String ROTATION = "android.media.mediarecorder.rotation"; + field public static final java.lang.String VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; + field public static final java.lang.String VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; + field public static final java.lang.String VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; + field public static final java.lang.String VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; + field public static final java.lang.String VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; + field public static final java.lang.String WIDTH = "android.media.mediarecorder.width"; + } + public static abstract interface MediaRecorder.OnErrorListener { method public abstract void onError(android.media.MediaRecorder, int, int); } diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index e628d18d8490..6cab56c1d466 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -23,12 +23,12 @@ import android.graphics.ImageFormat; import android.graphics.Rect; import android.graphics.SurfaceTexture; import android.media.MediaCodecInfo.CodecCapabilities; -import android.media.MediaMetricsSet; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; +import android.os.PersistableBundle; import android.view.Surface; import java.io.IOException; @@ -3188,20 +3188,19 @@ final public class MediaCodec { /** * Return Metrics data about the current codec instance. * - * @return a MediaMetricsSet containing the set of attributes and values + * @return a {@link PersistableBundle} containing the set of attributes and values * available for the media being handled by this instance of MediaCodec - * The attributes are descibed in {@link MediaMetricsSet.MediaCodec}. + * The attributes are descibed in {@link MetricsConstants}. * - * Additional vendor-specific fields may also be present in - * the return value. + * Additional vendor-specific fields may also be present in + * the return value. */ - public MediaMetricsSet getMetrics() { - Bundle bundle = native_getMetrics(); - MediaMetricsSet mSet = new MediaMetricsSet(bundle); - return mSet; + public PersistableBundle getMetrics() { + PersistableBundle bundle = native_getMetrics(); + return bundle; } - private native Bundle native_getMetrics(); + private native PersistableBundle native_getMetrics(); /** * Change a video encoder's target bitrate on the fly. The value is an @@ -3660,4 +3659,80 @@ final public class MediaCodec { private final ByteBuffer mData; } } + + public final static class MetricsConstants + { + private MetricsConstants() {} + + /** + * Key to extract the codec being used + * from the {@link MediaCodec#getMetrics} return value. + * The value is a String. + */ + public static final String CODEC = "android.media.mediacodec.codec"; + + /** + * Key to extract the MIME type + * from the {@link MediaCodec#getMetrics} return value. + * The value is a String. + */ + public static final String MIME_TYPE = "android.media.mediacodec.mime"; + + /** + * Key to extract what the codec mode + * from the {@link MediaCodec#getMetrics} return value. + * The value is a String. Values will be one of the constants + * {@link #MODE_AUDIO} or {@link #MODE_VIDEO}. + */ + public static final String MODE = "android.media.mediacodec.mode"; + + /** + * The value returned for the key {@link #MODE} when the + * codec is a audio codec. + */ + public static final String MODE_AUDIO = "audio"; + + /** + * The value returned for the key {@link #MODE} when the + * codec is a video codec. + */ + public static final String MODE_VIDEO = "video"; + + /** + * Key to extract the flag indicating whether the codec is running + * as an encoder or decoder from the {@link MediaCodec#getMetrics} return value. + * The value is an integer. + * A 0 indicates decoder; 1 indicates encoder. + */ + public static final String ENCODER = "android.media.mediacodec.encoder"; + + /** + * Key to extract the flag indicating whether the codec is running + * in secure (DRM) mode from the {@link MediaCodec#getMetrics} return value. + * The value is an integer. + */ + public static final String SECURE = "android.media.mediacodec.secure"; + + /** + * Key to extract the width (in pixels) of the video track + * from the {@link MediaCodec#getMetrics} return value. + * The value is an integer. + */ + public static final String WIDTH = "android.media.mediacodec.width"; + + /** + * Key to extract the height (in pixels) of the video track + * from the {@link MediaCodec#getMetrics} return value. + * The value is an integer. + */ + public static final String HEIGHT = "android.media.mediacodec.height"; + + /** + * Key to extract the rotation (in degrees) to properly orient the video + * from the {@link MediaCodec#getMetrics} return. + * The value is a integer. + */ + public static final String ROTATION = "android.media.mediacodec.rotation"; + + } } diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index a0a6a1e7ead2..fe461be6dea5 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -25,10 +25,10 @@ import android.content.res.AssetFileDescriptor; import android.media.MediaCodec; import android.media.MediaFormat; import android.media.MediaHTTPService; -import android.media.MediaMetricsSet; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.os.PersistableBundle; import com.android.internal.util.Preconditions; @@ -689,22 +689,21 @@ final public class MediaExtractor { /** * Return Metrics data about the current media container. * - * @return a MediaMetricsSet containing the set of attributes and values + * @return a {@link PersistableBundle} containing the set of attributes and values * available for the media container being handled by this instance * of MediaExtractor. - * The attributes are descibed in {@link MediaMetricsSet.MediaExtractor}. + * The attributes are descibed in {@link MetricsConstants}. * * Additional vendor-specific fields may also be present in * the return value. */ - public MediaMetricsSet getMetrics() { - Bundle bundle = native_getMetrics(); - MediaMetricsSet mSet = new MediaMetricsSet(bundle); - return mSet; + public PersistableBundle getMetrics() { + PersistableBundle bundle = native_getMetrics(); + return bundle; } - private native Bundle native_getMetrics(); + private native PersistableBundle native_getMetrics(); private static native final void native_init(); private native final void native_setup(); @@ -718,4 +717,32 @@ final public class MediaExtractor { private MediaCas mMediaCas; private long mNativeContext; + + public final static class MetricsConstants + { + private MetricsConstants() {} + + /** + * Key to extract the container format + * from the {@link MediaExtractor#getMetrics} return value. + * The value is a String. + */ + public static final String FORMAT = "android.media.mediaextractor.fmt"; + + /** + * Key to extract the container MIME type + * from the {@link MediaExtractor#getMetrics} return value. + * The value is a String. + */ + public static final String MIME_TYPE = "android.media.mediaextractor.mime"; + + /** + * Key to extract the number of tracks in the container + * from the {@link MediaExtractor#getMetrics} return value. + * The value is an integer. + */ + public static final String TRACKS = "android.media.mediaextractor.ntrk"; + + } + } diff --git a/media/java/android/media/MediaMetricsSet.java b/media/java/android/media/MediaMetricsSet.java deleted file mode 100644 index 5ecbee2127fc..000000000000 --- a/media/java/android/media/MediaMetricsSet.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.media; - -import android.os.Bundle; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.Runnable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.ref.WeakReference; -import java.net.HttpCookie; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.URL; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.BitSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Scanner; -import java.util.Set; -import java.util.UUID; -import java.util.Vector; - - -/** - * MediaMetricsSet contains the results returned by the getMetrics() - * methods defined in other Media classes such as - * {@link MediaCodec}, {@link MediaExtractor}, {@link MediaPlayer}, - * and {@link MediaRecorder}. - * - * MediaMetricsSet behaves similarly to a {@link Bundle}. It contains - * a set of keys and values. - * Methods such as {@link #getInt} and {@link #getString} are provided - * to extract values of the corresponding types. - * The {@link #keySet} method can be used to discover all of the keys - * that are present in the particular instance. - * - */ -public final class MediaMetricsSet -{ - - /** - * This MediaCodec class holds the constants defining keys related to - * the metrics for a MediaCodec. - */ - public final static class MediaCodec - { - private MediaCodec() {} - - /** - * Key to extract the codec being used - * from the {@link MediaCodec#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_CODEC = "android.media.mediacodec.codec"; - - /** - * Key to extract the MIME type - * from the {@link MediaCodec#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_MIME = "android.media.mediacodec.mime"; - - /** - * Key to extract what the codec mode - * from the {@link MediaCodec#getMetrics} return value. - * The value is a String. Values will be one of the constants - * MODE_AUDIO or MODE_VIDEO. - */ - public static final String KEY_MODE = "android.media.mediacodec.mode"; - - /** - * The value returned for the key {@link #KEY_MODE} when the - * codec is a audio codec. - */ - public static final String MODE_AUDIO = "audio"; - - /** - * The value returned for the key {@link #KEY_MODE} when the - * codec is a video codec. - */ - public static final String MODE_VIDEO = "video"; - - /** - * Key to extract the flag indicating whether the codec is running - * as an encoder or decoder from the {@link MediaCodec#getMetrics} return value. - * The value is an integer. - * A 0 indicates decoder; 1 indicates encoder. - */ - public static final String KEY_ENCODER = "android.media.mediacodec.encoder"; - - /** - * Key to extract the flag indicating whether the codec is running - * in secure (DRM) mode from the {@link MediaCodec#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_SECURE = "android.media.mediacodec.secure"; - - /** - * Key to extract the width (in pixels) of the video track - * from the {@link MediaCodec#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_WIDTH = "android.media.mediacodec.width"; - - /** - * Key to extract the height (in pixels) of the video track - * from the {@link MediaCodec#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_HEIGHT = "android.media.mediacodec.height"; - - /** - * Key to extract the rotation (in degrees) to properly orient the video - * from the {@link MediaCodec#getMetrics} return. - * The value is a integer. - */ - public static final String KEY_ROTATION = "android.media.mediacodec.rotation"; - - } - - /** - * This class holds the constants defining keys related to - * the metrics for a MediaExtractor. - */ - public final static class MediaExtractor - { - private MediaExtractor() {} - - /** - * Key to extract the container format - * from the {@link MediaExtractor#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_FORMAT = "android.media.mediaextractor.fmt"; - - /** - * Key to extract the container MIME type - * from the {@link MediaExtractor#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_MIME = "android.media.mediaextractor.mime"; - - /** - * Key to extract the number of tracks in the container - * from the {@link MediaExtractor#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_TRACKS = "android.media.mediaextractor.ntrk"; - - } - - /** - * This class holds the constants defining keys related to - * the metrics for a MediaPlayer. - */ - public final static class MediaPlayer - { - private MediaPlayer() {} - - /** - * Key to extract the MIME type of the video track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_MIME_VIDEO = "android.media.mediaplayer.video.mime"; - - /** - * Key to extract the codec being used to decode the video track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_CODEC_VIDEO = "android.media.mediaplayer.video.codec"; - - /** - * Key to extract the width (in pixels) of the video track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_WIDTH = "android.media.mediaplayer.width"; - - /** - * Key to extract the height (in pixels) of the video track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_HEIGHT = "android.media.mediaplayer.height"; - - /** - * Key to extract the count of video frames played - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_FRAMES = "android.media.mediaplayer.frames"; - - /** - * Key to extract the count of video frames dropped - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_FRAMES_DROPPED = "android.media.mediaplayer.dropped"; - - /** - * Key to extract the MIME type of the audio track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_MIME_AUDIO = "android.media.mediaplayer.audio.mime"; - - /** - * Key to extract the codec being used to decode the audio track - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a String. - */ - public static final String KEY_CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; - - /** - * Key to extract the duration (in milliseconds) of the - * media being played - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a long. - */ - public static final String KEY_DURATION = "android.media.mediaplayer.durationMs"; - - /** - * Key to extract the playing time (in milliseconds) of the - * media being played - * from the {@link MediaPlayer#getMetrics} return value. - * The value is a long. - */ - public static final String KEY_PLAYING = "android.media.mediaplayer.playingMs"; - - /** - * Key to extract the count of errors encountered while - * playing the media - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_ERRORS = "android.media.mediaplayer.err"; - - /** - * Key to extract an (optional) error code detected while - * playing the media - * from the {@link MediaPlayer#getMetrics} return value. - * The value is an integer. - */ - public static final String KEY_ERROR_CODE = "android.media.mediaplayer.errcode"; - - } - - /** - * This class holds the constants defining keys related to - * the metrics for a MediaRecorder. - */ - public final static class MediaRecorder - { - private MediaRecorder() {} - - /** - * Key to extract the audio bitrate - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; - - /** - * Key to extract the number of audio channels - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; - - /** - * Key to extract the audio samplerate - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; - - /** - * Key to extract the audio timescale - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; - - /** - * Key to extract the video capture frame rate - * from the {@link MediaRecorder#getMetrics} return. - * The value is a double. - */ - public static final String KEY_CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; - - /** - * Key to extract the video capture framerate enable value - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; - - /** - * Key to extract the intended playback frame rate - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_FRAMERATE = "android.media.mediarecorder.frame-rate"; - - /** - * Key to extract the height (in pixels) of the captured video - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_HEIGHT = "android.media.mediarecorder.height"; - - /** - * Key to extract the recorded movies time units - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - * A value of 1000 indicates that the movie's timing is in milliseconds. - */ - public static final String KEY_MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; - - /** - * Key to extract the rotation (in degrees) to properly orient the video - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_ROTATION = "android.media.mediarecorder.rotation"; - - /** - * Key to extract the video bitrate from being used - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; - - /** - * Key to extract the value for how often video iframes are generated - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; - - /** - * Key to extract the video encoding level - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; - - /** - * Key to extract the video encoding profile - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; - - /** - * Key to extract the recorded video time units - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - * A value of 1000 indicates that the video's timing is in milliseconds. - */ - public static final String KEY_VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; - - /** - * Key to extract the width (in pixels) of the captured video - * from the {@link MediaRecorder#getMetrics} return. - * The value is an integer. - */ - public static final String KEY_WIDTH = "android.media.mediarecorder.width"; - - } - - /* - * Methods that we want - */ - - private Bundle mBundle; - - MediaMetricsSet(Bundle bundle) { - mBundle = bundle; - } - - /** - * Returns the number of mappings contained in this Bundle. - * - * @return the number of mappings as an int. - */ - public int size() { - return mBundle.size(); - } - - /** - * Returns true if the mapping of this MediaMetricsSet is empty, - * false otherwise. - */ - public boolean isEmpty() { - return mBundle.isEmpty(); - } - - /** - * Returns the value associated with the given key, or defaultValue if - * no mapping of the desired type exists for the given key. - * - * @param key a String - * @param defaultValue Value to return if key does not exist - * @return a double value - */ - public double getDouble(String key, double defaultValue) { - return mBundle.getDouble(key, defaultValue); - } - - /** - * Returns the value associated with the given key, or defaultValue if - * no mapping of the desired type exists for the given key. - * - * @param key a String - * @param defaultValue Value to return if key does not exist - * @return an int value - */ - public int getInt(String key, int defaultValue) { - return mBundle.getInt(key, defaultValue); - } - - /** - * Returns the value associated with the given key, or defaultValue if - * no mapping of the desired type exists for the given key. - * - * @param key a String - * @param defaultValue Value to return if key does not exist - * @return a long value - */ - public long getLong(String key, long defaultValue) { - return mBundle.getLong(key, defaultValue); - } - - /** - * Returns the value associated with the given key, or defaultValue if - * no mapping of the desired type exists for the given key or if a null - * value is explicitly associated with the given key. - * - * @param key a String - * @param defaultValue Value to return if key does not exist or if a null - * value is associated with the given key. - * @return the String value associated with the given key, or defaultValue - * if no valid String object is currently mapped to that key. - */ - public String getString(String key, String defaultValue) { - return mBundle.getString(key, defaultValue); - } - - /** - * Returns a Set containing the Strings used as keys in this Bundle. - * - * @return a Set of String keys - */ - public Set keySet() { - return mBundle.keySet(); - } - - - - public String toString() { - return mBundle.toString(); - } - -} - diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 71a968b4d4b5..9386246bd128 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -33,6 +33,7 @@ import android.os.Looper; import android.os.Message; import android.os.Parcel; import android.os.Parcelable; +import android.os.PersistableBundle; import android.os.Process; import android.os.PowerManager; import android.os.SystemProperties; @@ -48,7 +49,6 @@ import android.graphics.SurfaceTexture; import android.media.AudioManager; import android.media.MediaDrm; import android.media.MediaFormat; -import android.media.MediaMetricsSet; import android.media.MediaTimeProvider; import android.media.PlaybackParams; import android.media.SubtitleController; @@ -1491,20 +1491,19 @@ public class MediaPlayer extends PlayerBase /** * Return Metrics data about the current player. * - * @return a MediaMetricsSet containing the set of attributes and values + * @return a {@link PersistableBundle} containing the set of attributes and values * available for the media being handled by this instance of MediaPlayer - * The attributes are descibed in {@link MediaMetricsSet.MediaPlayer}. + * The attributes are descibed in {@link MetricsConstants}. * * Additional vendor-specific fields may also be present in * the return value. */ - public MediaMetricsSet getMetrics() { - Bundle bundle = native_getMetrics(); - MediaMetricsSet mSet = new MediaMetricsSet(bundle); - return mSet; + public PersistableBundle getMetrics() { + PersistableBundle bundle = native_getMetrics(); + return bundle; } - private native Bundle native_getMetrics(); + private native PersistableBundle native_getMetrics(); /** * Checks whether the MediaPlayer is playing. @@ -5418,4 +5417,98 @@ public class MediaPlayer extends PlayerBase } } } + + public final static class MetricsConstants + { + private MetricsConstants() {} + + /** + * Key to extract the MIME type of the video track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a String. + */ + public static final String MIME_TYPE_VIDEO = "android.media.mediaplayer.video.mime"; + + /** + * Key to extract the codec being used to decode the video track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a String. + */ + public static final String CODEC_VIDEO = "android.media.mediaplayer.video.codec"; + + /** + * Key to extract the width (in pixels) of the video track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String WIDTH = "android.media.mediaplayer.width"; + + /** + * Key to extract the height (in pixels) of the video track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String HEIGHT = "android.media.mediaplayer.height"; + + /** + * Key to extract the count of video frames played + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String FRAMES = "android.media.mediaplayer.frames"; + + /** + * Key to extract the count of video frames dropped + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String FRAMES_DROPPED = "android.media.mediaplayer.dropped"; + + /** + * Key to extract the MIME type of the audio track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a String. + */ + public static final String MIME_TYPE_AUDIO = "android.media.mediaplayer.audio.mime"; + + /** + * Key to extract the codec being used to decode the audio track + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a String. + */ + public static final String CODEC_AUDIO = "android.media.mediaplayer.audio.codec"; + + /** + * Key to extract the duration (in milliseconds) of the + * media being played + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a long. + */ + public static final String DURATION = "android.media.mediaplayer.durationMs"; + + /** + * Key to extract the playing time (in milliseconds) of the + * media being played + * from the {@link MediaPlayer#getMetrics} return value. + * The value is a long. + */ + public static final String PLAYING = "android.media.mediaplayer.playingMs"; + + /** + * Key to extract the count of errors encountered while + * playing the media + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String ERRORS = "android.media.mediaplayer.err"; + + /** + * Key to extract an (optional) error code detected while + * playing the media + * from the {@link MediaPlayer#getMetrics} return value. + * The value is an integer. + */ + public static final String ERROR_CODE = "android.media.mediaplayer.errcode"; + + } } diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 4675e327ce25..858c6783eb1d 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -20,11 +20,11 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.ActivityThread; import android.hardware.Camera; -import android.media.MediaMetricsSet; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.os.PersistableBundle; import android.util.Log; import android.view.Surface; @@ -1267,23 +1267,142 @@ public class MediaRecorder /** * Return Metrics data about the current Mediarecorder instance. * - * @return a MediaMetricsSet containing the set of attributes and values + * @return a {@link PersistableBundle} containing the set of attributes and values * available for the media being generated by this instance of * MediaRecorder. - * The attributes are descibed in {@link MediaMetricsSet.MediaRecorder}. + * The attributes are descibed in {@link MetricsConstants}. * * Additional vendor-specific fields may also be present in * the return value. */ - public MediaMetricsSet getMetrics() { - Bundle bundle = native_getMetrics(); - MediaMetricsSet mSet = new MediaMetricsSet(bundle); - return mSet; + public PersistableBundle getMetrics() { + PersistableBundle bundle = native_getMetrics(); + return bundle; } - private native Bundle native_getMetrics(); + private native PersistableBundle native_getMetrics(); @Override protected void finalize() { native_finalize(); } + + public final static class MetricsConstants + { + private MetricsConstants() {} + + /** + * Key to extract the audio bitrate + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String AUDIO_BITRATE = "android.media.mediarecorder.audio-bitrate"; + + /** + * Key to extract the number of audio channels + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String AUDIO_CHANNELS = "android.media.mediarecorder.audio-channels"; + + /** + * Key to extract the audio samplerate + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String AUDIO_SAMPLERATE = "android.media.mediarecorder.audio-samplerate"; + + /** + * Key to extract the audio timescale + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String AUDIO_TIMESCALE = "android.media.mediarecorder.audio-timescale"; + + /** + * Key to extract the video capture frame rate + * from the {@link MediaRecorder#getMetrics} return. + * The value is a double. + */ + public static final String CAPTURE_FPS = "android.media.mediarecorder.capture-fps"; + + /** + * Key to extract the video capture framerate enable value + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String CAPTURE_FPS_ENABLE = "android.media.mediarecorder.capture-fpsenable"; + + /** + * Key to extract the intended playback frame rate + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String FRAMERATE = "android.media.mediarecorder.frame-rate"; + + /** + * Key to extract the height (in pixels) of the captured video + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String HEIGHT = "android.media.mediarecorder.height"; + + /** + * Key to extract the recorded movies time units + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + * A value of 1000 indicates that the movie's timing is in milliseconds. + */ + public static final String MOVIE_TIMESCALE = "android.media.mediarecorder.movie-timescale"; + + /** + * Key to extract the rotation (in degrees) to properly orient the video + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String ROTATION = "android.media.mediarecorder.rotation"; + + /** + * Key to extract the video bitrate from being used + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String VIDEO_BITRATE = "android.media.mediarecorder.video-bitrate"; + + /** + * Key to extract the value for how often video iframes are generated + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String VIDEO_IFRAME_INTERVAL = "android.media.mediarecorder.video-iframe-interval"; + + /** + * Key to extract the video encoding level + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String VIDEO_LEVEL = "android.media.mediarecorder.video-encoder-level"; + + /** + * Key to extract the video encoding profile + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String VIDEO_PROFILE = "android.media.mediarecorder.video-encoder-profile"; + + /** + * Key to extract the recorded video time units + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + * A value of 1000 indicates that the video's timing is in milliseconds. + */ + public static final String VIDEO_TIMESCALE = "android.media.mediarecorder.video-timescale"; + + /** + * Key to extract the width (in pixels) of the captured video + * from the {@link MediaRecorder#getMetrics} return. + * The value is an integer. + */ + public static final String WIDTH = "android.media.mediarecorder.width"; + + } } diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index a8dd3133b275..2178607152c6 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -2002,7 +2002,7 @@ static const JNINativeMethod gMethods[] = { { "getName", "()Ljava/lang/String;", (void *)android_media_MediaCodec_getName }, - { "native_getMetrics", "()Landroid/os/Bundle;", + { "native_getMetrics", "()Landroid/os/PersistableBundle;", (void *)android_media_MediaCodec_native_getMetrics}, { "setParameters", "([Ljava/lang/String;[Ljava/lang/Object;)V", diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp index c2cfed9bfa2f..9e5d3d12f0bd 100644 --- a/media/jni/android_media_MediaExtractor.cpp +++ b/media/jni/android_media_MediaExtractor.cpp @@ -905,7 +905,7 @@ static const JNINativeMethod gMethods[] = { { "hasCacheReachedEndOfStream", "()Z", (void *)android_media_MediaExtractor_hasCacheReachedEOS }, - {"native_getMetrics", "()Landroid/os/Bundle;", + {"native_getMetrics", "()Landroid/os/PersistableBundle;", (void *)android_media_MediaExtractor_native_getMetrics}, }; diff --git a/media/jni/android_media_MediaMetricsJNI.cpp b/media/jni/android_media_MediaMetricsJNI.cpp index fb606bac7828..8979cec2e864 100644 --- a/media/jni/android_media_MediaMetricsJNI.cpp +++ b/media/jni/android_media_MediaMetricsJNI.cpp @@ -24,15 +24,12 @@ namespace android { -// place the attributes into a java Bundle object -// decide whether this is appropriately scoped here. -// if we do it somewhere else, we have to figure a "give me all the attrs" -// access to the inside of MediaAnalyticsItem +// place the attributes into a java PersistableBundle object jobject MediaMetricsJNI::writeMetricsToBundle(JNIEnv* env, MediaAnalyticsItem *item, jobject mybundle) { - jclass clazzBundle = env->FindClass("android/os/Bundle"); + jclass clazzBundle = env->FindClass("android/os/PersistableBundle"); if (clazzBundle==NULL) { - ALOGD("can't find android/os/Bundle"); + ALOGD("can't find android/os/PersistableBundle"); return NULL; } // sometimes the caller provides one for us to fill @@ -58,7 +55,7 @@ jobject MediaMetricsJNI::writeMetricsToBundle(JNIEnv* env, MediaAnalyticsItem *i // -- get name, get type, get value // -- insert appropriately into the bundle for (size_t i = 0 ; i < item->mPropCount; i++ ) { - MediaAnalyticsItem::Prop *prop = &item->mProps[i]; + MediaAnalyticsItem::Prop *prop = &item->mProps[i]; // build the key parameter from prop->mName jstring keyName = env->NewStringUTF(prop->mName); // invoke the appropriate method to insert diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 1b52cf58cbff..2fc4afd28335 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -1393,7 +1393,7 @@ static const JNINativeMethod gMethods[] = { {"_stop", "()V", (void *)android_media_MediaPlayer_stop}, {"getVideoWidth", "()I", (void *)android_media_MediaPlayer_getVideoWidth}, {"getVideoHeight", "()I", (void *)android_media_MediaPlayer_getVideoHeight}, - {"native_getMetrics", "()Landroid/os/Bundle;", (void *)android_media_MediaPlayer_native_getMetrics}, + {"native_getMetrics", "()Landroid/os/PersistableBundle;", (void *)android_media_MediaPlayer_native_getMetrics}, {"setPlaybackParams", "(Landroid/media/PlaybackParams;)V", (void *)android_media_MediaPlayer_setPlaybackParams}, {"getPlaybackParams", "()Landroid/media/PlaybackParams;", (void *)android_media_MediaPlayer_getPlaybackParams}, {"setSyncParams", "(Landroid/media/SyncParams;)V", (void *)android_media_MediaPlayer_setSyncParams}, diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index 7a63e003875a..2c1e834187e8 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -688,7 +688,7 @@ static const JNINativeMethod gMethods[] = { {"native_finalize", "()V", (void *)android_media_MediaRecorder_native_finalize}, {"native_setInputSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaRecorder_setInputSurface }, - {"native_getMetrics", "()Landroid/os/Bundle;", (void *)android_media_MediaRecorder_native_getMetrics}, + {"native_getMetrics", "()Landroid/os/PersistableBundle;", (void *)android_media_MediaRecorder_native_getMetrics}, }; // This function only registers the native methods, and is called from -- cgit v1.2.3-59-g8ed1b