Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c2faf3d authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Bug 4571308 Provide correct video frame timestamps

Change-Id: I0f726817fc02d3e2a4cf82ed801ef977994e6bcc
parent 466ebb1d
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -161,12 +161,15 @@ public class SurfaceTexture {
     * Retrieve the timestamp associated with the texture image set by the most recent call to
     * Retrieve the timestamp associated with the texture image set by the most recent call to
     * updateTexImage.
     * updateTexImage.
     *
     *
     * This timestamp is in nanoseconds, and is guaranteed to be monotonically increasing. The
     * This timestamp is in nanoseconds, and is normally monotonically increasing. The timestamp
     * should be unaffected by time-of-day adjustments, and for a camera should be strictly
     * monotonic but for a MediaPlayer may be reset when the position is set.  The
     * specific meaning and zero point of the timestamp depends on the source providing images to
     * specific meaning and zero point of the timestamp depends on the source providing images to
     * the SurfaceTexture. Unless otherwise specified by the image source, timestamps cannot
     * the SurfaceTexture. Unless otherwise specified by the image source, timestamps cannot
     * generally be compared across SurfaceTexture instances, or across multiple program
     * generally be compared across SurfaceTexture instances, or across multiple program
     * invocations. It is mostly useful for determining time offsets between subsequent frames.
     * invocations. It is mostly useful for determining time offsets between subsequent frames.
     */
     */

    public long getTimestamp() {
    public long getTimestamp() {
        return nativeGetTimestamp();
        return nativeGetTimestamp();
    }
    }
+4 −7
Original line number Original line Diff line number Diff line
@@ -611,15 +611,11 @@ public class MediaPlayer
     * needed.  Not calling this method when playing back a video will
     * needed.  Not calling this method when playing back a video will
     * result in only the audio track being played.
     * result in only the audio track being played.
     *
     *
     * @param sh the SurfaceHolder to use for video display
     */
    /*
     * This portion of comment has a non-Javadoc prefix so as not to refer to a
     * hidden method. When unhidden, merge it with the previous javadoc comment.
     *
     * Either a surface or surface texture must be set if a display or video sink
     * Either a surface or surface texture must be set if a display or video sink
     * is needed.  Not calling this method or {@link #setTexture(SurfaceTexture)}
     * is needed.  Not calling this method or {@link #setTexture(SurfaceTexture)}
     * when playing back a video will result in only the audio track being played.
     * when playing back a video will result in only the audio track being played.
     *
     * @param sh the SurfaceHolder to use for video display
     */
     */
    public void setDisplay(SurfaceHolder sh) {
    public void setDisplay(SurfaceHolder sh) {
        mSurfaceHolder = sh;
        mSurfaceHolder = sh;
@@ -648,7 +644,8 @@ public class MediaPlayer
     * SurfaceTexture set as the video sink have an unspecified zero point,
     * SurfaceTexture set as the video sink have an unspecified zero point,
     * and cannot be directly compared between different media sources or different
     * and cannot be directly compared between different media sources or different
     * instances of the same media source, or across multiple runs of the same
     * instances of the same media source, or across multiple runs of the same
     * program.
     * program.  The timestamp is normally monotonically increasing and unaffected
     * by time-of-day adjustments, but is reset when the position is set.
     */
     */
    public void setTexture(SurfaceTexture st) {
    public void setTexture(SurfaceTexture st) {
        ParcelSurfaceTexture pst = null;
        ParcelSurfaceTexture pst = null;
+3 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,9 @@ struct AwesomeNativeWindowRenderer : public AwesomeRenderer {
    }
    }


    virtual void render(MediaBuffer *buffer) {
    virtual void render(MediaBuffer *buffer) {
        int64_t timeUs;
        CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
        native_window_set_buffers_timestamp(mNativeWindow.get(), timeUs * 1000);
        status_t err = mNativeWindow->queueBuffer(
        status_t err = mNativeWindow->queueBuffer(
                mNativeWindow.get(), buffer->graphicBuffer().get());
                mNativeWindow.get(), buffer->graphicBuffer().get());
        if (err != 0) {
        if (err != 0) {