Loading api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15991,6 +15991,7 @@ package android.media { method public android.media.PlaybackSettings getPlaybackSettings(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncSettings getSyncSettings(); method public android.media.MediaTimestamp getTimestamp(); method public android.media.MediaPlayer.TrackInfo[] getTrackInfo() throws java.lang.IllegalStateException; method public int getVideoHeight(); method public int getVideoWidth(); Loading Loading @@ -16351,7 +16352,7 @@ package android.media { method public void flush(); method public android.media.PlaybackSettings getPlaybackSettings(); method public android.media.SyncSettings getSyncSettings(); method public boolean getTimestamp(android.media.MediaTimestamp); method public android.media.MediaTimestamp getTimestamp(); method public void queueAudio(java.nio.ByteBuffer, int, int, long); method public final void release(); method public void setCallback(android.media.MediaSync.Callback, android.os.Handler); Loading @@ -16378,10 +16379,9 @@ package android.media { } public final class MediaTimestamp { ctor public MediaTimestamp(); field public float clockRate; field public long mediaTimeUs; field public long nanoTime; field public final float clockRate; field public final long mediaTimeUs; field public final long nanoTime; } public final class NotProvisionedException extends android.media.MediaDrmException { api/system-current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -17204,6 +17204,7 @@ package android.media { method public android.media.PlaybackSettings getPlaybackSettings(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncSettings getSyncSettings(); method public android.media.MediaTimestamp getTimestamp(); method public android.media.MediaPlayer.TrackInfo[] getTrackInfo() throws java.lang.IllegalStateException; method public int getVideoHeight(); method public int getVideoWidth(); Loading Loading @@ -17566,7 +17567,7 @@ package android.media { method public void flush(); method public android.media.PlaybackSettings getPlaybackSettings(); method public android.media.SyncSettings getSyncSettings(); method public boolean getTimestamp(android.media.MediaTimestamp); method public android.media.MediaTimestamp getTimestamp(); method public void queueAudio(java.nio.ByteBuffer, int, int, long); method public final void release(); method public void setCallback(android.media.MediaSync.Callback, android.os.Handler); Loading @@ -17593,10 +17594,9 @@ package android.media { } public final class MediaTimestamp { ctor public MediaTimestamp(); field public float clockRate; field public long mediaTimeUs; field public long nanoTime; field public final float clockRate; field public final long mediaTimeUs; field public final long nanoTime; } public final class NotProvisionedException extends android.media.MediaDrmException { media/java/android/media/MediaPlayer.java +34 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.media; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.AppOpsManager; import android.content.ContentResolver; Loading Loading @@ -1478,6 +1479,39 @@ public class MediaPlayer implements SubtitleController.Listener */ public native void seekTo(int msec) throws IllegalStateException; /** * Get current playback position. * <p> * The MediaTimestamp represents how the media time correlates to the system time in * a linear fashion. It contains the media time and system timestamp of an anchor frame * ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and the speed of the media clock ({@link MediaTimestamp#clockRate}). * <p> * During regular playback, the media time moves fairly constantly (though the * anchor frame may be rebased to a current system time, the linear correlation stays * steady). Therefore, this method does not need to be called often. * <p> * To help users to get current playback position, this method always returns the timestamp of * just-rendered frame, i.e., {@link System#nanoTime} and its corresponding media time. They * can be used as current playback position. * * @return a MediaTimestamp object if a timestamp is available, or {@code null} if no timestamp * is available, e.g. because the media player has not been initialized. */ @Nullable public MediaTimestamp getTimestamp() { try { // TODO: get the timestamp from native side return new MediaTimestamp( getCurrentPosition() * 1000L, System.nanoTime(), isPlaying() ? getPlaybackSettings().getSpeed() : 0.f); } catch (IllegalStateException e) { return null; } } /** * Gets the current playback position. * Loading media/java/android/media/MediaSync.java +22 −16 Original line number Diff line number Diff line Loading @@ -482,30 +482,36 @@ final public class MediaSync { /** * Get current playback position. * <p> * The MediaTimestamp represents a clock ticking during media playback. It's represented * by an anchor frame ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and clock speed ({@link MediaTimestamp#clockRate}). For continous playback with * constant speed, its anchor frame doesn't change that often. Thereafter, it's recommended * to not call this method often. * The MediaTimestamp represents how the media time correlates to the system time in * a linear fashion. It contains the media time and system timestamp of an anchor frame * ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and the speed of the media clock ({@link MediaTimestamp#clockRate}). * <p> * During regular playback, the media time moves fairly constantly (though the * anchor frame may be rebased to a current system time, the linear correlation stays * steady). Therefore, this method does not need to be called often. * <p> * To help users to get current playback position, this method always returns the timestamp of * just-rendered frame, i.e., {@link System#nanoTime} and its corresponding media time. They * can be used as current playback position. * * @param timestamp a reference to a non-null MediaTimestamp instance allocated * and owned by caller. * @return true if a timestamp is available, or false if no timestamp is available. * If a timestamp if available, the MediaTimestamp instance is filled in with * playback rate, together with the current media timestamp and the system nanoTime * corresponding to the measured media timestamp. * In the case that no timestamp is available, any supplied instance is left unaltered. * @return a MediaTimestamp object if a timestamp is available, or {@code null} if no timestamp * is available, e.g. because the media sync has not been initialized. */ public boolean getTimestamp(@NonNull MediaTimestamp timestamp) @Nullable public MediaTimestamp getTimestamp() { if (timestamp == null) { throw new IllegalArgumentException(); try { // TODO: create the timestamp in native MediaTimestamp timestamp = new MediaTimestamp(); if (native_getTimestamp(timestamp)) { return timestamp; } else { return null; } } catch (IllegalStateException e) { return null; } return native_getTimestamp(timestamp); } private native final boolean native_getTimestamp(@NonNull MediaTimestamp timestamp); Loading media/java/android/media/MediaTimestamp.java +31 −12 Original line number Diff line number Diff line Loading @@ -17,36 +17,55 @@ package android.media; /** * Structure that groups clock rate of the stream playback, together with the media timestamp * An immutable object that represents the linear correlation between the media time * and the system time. It contains the media clock rate, together with the media timestamp * of an anchor frame and the system time when that frame was presented or is committed * to be presented. * The "present" means that audio/video produced on device is detectable by an external * <p> * The phrase "present" means that audio/video produced on device is detectable by an external * observer off device. * The time is based on the implementation's best effort, using whatever knowledge * is available to the system, but cannot account for any delay unknown to the implementation. * The anchor frame could be any frame, including just-rendered frame, dependent on how * it's selected. When the anchor frame is the just-rendered one, the media time stands for * current position of the playback. * The anchor frame could be any frame, including a just-rendered frame, or even a theoretical * or in-between frame, based on the source of the MediaTimestamp. * When the anchor frame is a just-rendered one, the media time stands for * current position of the playback or recording. * * @see MediaSync#getTimestamp * @see MediaPlayer#getTimestamp */ public final class MediaTimestamp { /** * Media timestamp in microseconds. * Media time in microseconds. */ public long mediaTimeUs; public final long mediaTimeUs; /** * The {@link java.lang.System#nanoTime} corresponding to the media timestamp. * The {@link java.lang.System#nanoTime system time} corresponding to the media time * in nanoseconds. */ public long nanoTime; public final long nanoTime; /** * Media clock rate. * It is 1.0 if media clock is in sync with the system clock; * The rate of the media clock in relation to the system time. * It is 1.0 if media clock advances in sync with the system clock; * greater than 1.0 if media clock is faster than the system clock; * less than 1.0 if media clock is slower than the system clock. */ public float clockRate; public final float clockRate; /** @hide */ MediaTimestamp(long mediaUs, long systemNs, float rate) { mediaTimeUs = mediaUs; nanoTime = systemNs; clockRate = rate; } /** @hide */ MediaTimestamp() { mediaTimeUs = 0; nanoTime = 0; clockRate = 1.0f; } } Loading
api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15991,6 +15991,7 @@ package android.media { method public android.media.PlaybackSettings getPlaybackSettings(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncSettings getSyncSettings(); method public android.media.MediaTimestamp getTimestamp(); method public android.media.MediaPlayer.TrackInfo[] getTrackInfo() throws java.lang.IllegalStateException; method public int getVideoHeight(); method public int getVideoWidth(); Loading Loading @@ -16351,7 +16352,7 @@ package android.media { method public void flush(); method public android.media.PlaybackSettings getPlaybackSettings(); method public android.media.SyncSettings getSyncSettings(); method public boolean getTimestamp(android.media.MediaTimestamp); method public android.media.MediaTimestamp getTimestamp(); method public void queueAudio(java.nio.ByteBuffer, int, int, long); method public final void release(); method public void setCallback(android.media.MediaSync.Callback, android.os.Handler); Loading @@ -16378,10 +16379,9 @@ package android.media { } public final class MediaTimestamp { ctor public MediaTimestamp(); field public float clockRate; field public long mediaTimeUs; field public long nanoTime; field public final float clockRate; field public final long mediaTimeUs; field public final long nanoTime; } public final class NotProvisionedException extends android.media.MediaDrmException {
api/system-current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -17204,6 +17204,7 @@ package android.media { method public android.media.PlaybackSettings getPlaybackSettings(); method public int getSelectedTrack(int) throws java.lang.IllegalStateException; method public android.media.SyncSettings getSyncSettings(); method public android.media.MediaTimestamp getTimestamp(); method public android.media.MediaPlayer.TrackInfo[] getTrackInfo() throws java.lang.IllegalStateException; method public int getVideoHeight(); method public int getVideoWidth(); Loading Loading @@ -17566,7 +17567,7 @@ package android.media { method public void flush(); method public android.media.PlaybackSettings getPlaybackSettings(); method public android.media.SyncSettings getSyncSettings(); method public boolean getTimestamp(android.media.MediaTimestamp); method public android.media.MediaTimestamp getTimestamp(); method public void queueAudio(java.nio.ByteBuffer, int, int, long); method public final void release(); method public void setCallback(android.media.MediaSync.Callback, android.os.Handler); Loading @@ -17593,10 +17594,9 @@ package android.media { } public final class MediaTimestamp { ctor public MediaTimestamp(); field public float clockRate; field public long mediaTimeUs; field public long nanoTime; field public final float clockRate; field public final long mediaTimeUs; field public final long nanoTime; } public final class NotProvisionedException extends android.media.MediaDrmException {
media/java/android/media/MediaPlayer.java +34 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.media; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.AppOpsManager; import android.content.ContentResolver; Loading Loading @@ -1478,6 +1479,39 @@ public class MediaPlayer implements SubtitleController.Listener */ public native void seekTo(int msec) throws IllegalStateException; /** * Get current playback position. * <p> * The MediaTimestamp represents how the media time correlates to the system time in * a linear fashion. It contains the media time and system timestamp of an anchor frame * ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and the speed of the media clock ({@link MediaTimestamp#clockRate}). * <p> * During regular playback, the media time moves fairly constantly (though the * anchor frame may be rebased to a current system time, the linear correlation stays * steady). Therefore, this method does not need to be called often. * <p> * To help users to get current playback position, this method always returns the timestamp of * just-rendered frame, i.e., {@link System#nanoTime} and its corresponding media time. They * can be used as current playback position. * * @return a MediaTimestamp object if a timestamp is available, or {@code null} if no timestamp * is available, e.g. because the media player has not been initialized. */ @Nullable public MediaTimestamp getTimestamp() { try { // TODO: get the timestamp from native side return new MediaTimestamp( getCurrentPosition() * 1000L, System.nanoTime(), isPlaying() ? getPlaybackSettings().getSpeed() : 0.f); } catch (IllegalStateException e) { return null; } } /** * Gets the current playback position. * Loading
media/java/android/media/MediaSync.java +22 −16 Original line number Diff line number Diff line Loading @@ -482,30 +482,36 @@ final public class MediaSync { /** * Get current playback position. * <p> * The MediaTimestamp represents a clock ticking during media playback. It's represented * by an anchor frame ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and clock speed ({@link MediaTimestamp#clockRate}). For continous playback with * constant speed, its anchor frame doesn't change that often. Thereafter, it's recommended * to not call this method often. * The MediaTimestamp represents how the media time correlates to the system time in * a linear fashion. It contains the media time and system timestamp of an anchor frame * ({@link MediaTimestamp#mediaTimeUs} and {@link MediaTimestamp#nanoTime}) * and the speed of the media clock ({@link MediaTimestamp#clockRate}). * <p> * During regular playback, the media time moves fairly constantly (though the * anchor frame may be rebased to a current system time, the linear correlation stays * steady). Therefore, this method does not need to be called often. * <p> * To help users to get current playback position, this method always returns the timestamp of * just-rendered frame, i.e., {@link System#nanoTime} and its corresponding media time. They * can be used as current playback position. * * @param timestamp a reference to a non-null MediaTimestamp instance allocated * and owned by caller. * @return true if a timestamp is available, or false if no timestamp is available. * If a timestamp if available, the MediaTimestamp instance is filled in with * playback rate, together with the current media timestamp and the system nanoTime * corresponding to the measured media timestamp. * In the case that no timestamp is available, any supplied instance is left unaltered. * @return a MediaTimestamp object if a timestamp is available, or {@code null} if no timestamp * is available, e.g. because the media sync has not been initialized. */ public boolean getTimestamp(@NonNull MediaTimestamp timestamp) @Nullable public MediaTimestamp getTimestamp() { if (timestamp == null) { throw new IllegalArgumentException(); try { // TODO: create the timestamp in native MediaTimestamp timestamp = new MediaTimestamp(); if (native_getTimestamp(timestamp)) { return timestamp; } else { return null; } } catch (IllegalStateException e) { return null; } return native_getTimestamp(timestamp); } private native final boolean native_getTimestamp(@NonNull MediaTimestamp timestamp); Loading
media/java/android/media/MediaTimestamp.java +31 −12 Original line number Diff line number Diff line Loading @@ -17,36 +17,55 @@ package android.media; /** * Structure that groups clock rate of the stream playback, together with the media timestamp * An immutable object that represents the linear correlation between the media time * and the system time. It contains the media clock rate, together with the media timestamp * of an anchor frame and the system time when that frame was presented or is committed * to be presented. * The "present" means that audio/video produced on device is detectable by an external * <p> * The phrase "present" means that audio/video produced on device is detectable by an external * observer off device. * The time is based on the implementation's best effort, using whatever knowledge * is available to the system, but cannot account for any delay unknown to the implementation. * The anchor frame could be any frame, including just-rendered frame, dependent on how * it's selected. When the anchor frame is the just-rendered one, the media time stands for * current position of the playback. * The anchor frame could be any frame, including a just-rendered frame, or even a theoretical * or in-between frame, based on the source of the MediaTimestamp. * When the anchor frame is a just-rendered one, the media time stands for * current position of the playback or recording. * * @see MediaSync#getTimestamp * @see MediaPlayer#getTimestamp */ public final class MediaTimestamp { /** * Media timestamp in microseconds. * Media time in microseconds. */ public long mediaTimeUs; public final long mediaTimeUs; /** * The {@link java.lang.System#nanoTime} corresponding to the media timestamp. * The {@link java.lang.System#nanoTime system time} corresponding to the media time * in nanoseconds. */ public long nanoTime; public final long nanoTime; /** * Media clock rate. * It is 1.0 if media clock is in sync with the system clock; * The rate of the media clock in relation to the system time. * It is 1.0 if media clock advances in sync with the system clock; * greater than 1.0 if media clock is faster than the system clock; * less than 1.0 if media clock is slower than the system clock. */ public float clockRate; public final float clockRate; /** @hide */ MediaTimestamp(long mediaUs, long systemNs, float rate) { mediaTimeUs = mediaUs; nanoTime = systemNs; clockRate = rate; } /** @hide */ MediaTimestamp() { mediaTimeUs = 0; nanoTime = 0; clockRate = 1.0f; } }