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

Commit 9511ab83 authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 8a9a931f: am 8138e841: Merge "Support finer seek control on MediaSources." into gingerbread

Merge commit '8a9a931f'

* commit '8a9a931f':
  Support finer seek control on MediaSources.
parents 0119ba5b 8a9a931f
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -62,14 +62,21 @@ struct MediaSource : public RefBase {
    // a) not request a seek
    // a) not request a seek
    // b) not be late, i.e. lateness_us = 0
    // b) not be late, i.e. lateness_us = 0
    struct ReadOptions {
    struct ReadOptions {
        enum SeekMode {
            SEEK_PREVIOUS_SYNC,
            SEEK_NEXT_SYNC,
            SEEK_CLOSEST_SYNC,
            SEEK_CLOSEST,
        };

        ReadOptions();
        ReadOptions();


        // Reset everything back to defaults.
        // Reset everything back to defaults.
        void reset();
        void reset();


        void setSeekTo(int64_t time_us);
        void setSeekTo(int64_t time_us, SeekMode mode = SEEK_CLOSEST_SYNC);
        void clearSeekTo();
        void clearSeekTo();
        bool getSeekTo(int64_t *time_us) const;
        bool getSeekTo(int64_t *time_us, SeekMode *mode) const;


        void setLateBy(int64_t lateness_us);
        void setLateBy(int64_t lateness_us);
        int64_t getLateBy() const;
        int64_t getLateBy() const;
@@ -81,6 +88,7 @@ struct MediaSource : public RefBase {


        uint32_t mOptions;
        uint32_t mOptions;
        int64_t mSeekTimeUs;
        int64_t mSeekTimeUs;
        SeekMode mSeekMode;
        int64_t mLatenessUs;
        int64_t mLatenessUs;
    };
    };


+1 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ enum {
    kKeyIsSyncFrame       = 'sync',  // int32_t (bool)
    kKeyIsSyncFrame       = 'sync',  // int32_t (bool)
    kKeyIsCodecConfig     = 'conf',  // int32_t (bool)
    kKeyIsCodecConfig     = 'conf',  // int32_t (bool)
    kKeyTime              = 'time',  // int64_t (usecs)
    kKeyTime              = 'time',  // int64_t (usecs)
    kKeyTargetTime        = 'tarT',  // int64_t (usecs)
    kKeyDuration          = 'dura',  // int64_t (usecs)
    kKeyDuration          = 'dura',  // int64_t (usecs)
    kKeyColorFormat       = 'colf',
    kKeyColorFormat       = 'colf',
    kKeyPlatformPrivate   = 'priv',  // pointer
    kKeyPlatformPrivate   = 'priv',  // pointer
+2 −0
Original line number Original line Diff line number Diff line
@@ -141,6 +141,8 @@ private:
    bool mNoMoreOutputData;
    bool mNoMoreOutputData;
    bool mOutputPortSettingsHaveChanged;
    bool mOutputPortSettingsHaveChanged;
    int64_t mSeekTimeUs;
    int64_t mSeekTimeUs;
    ReadOptions::SeekMode mSeekMode;
    int64_t mTargetTimeUs;


    MediaBuffer *mLeftOverBuffer;
    MediaBuffer *mLeftOverBuffer;


+2 −1
Original line number Original line Diff line number Diff line
@@ -212,7 +212,8 @@ status_t AMRSource::read(
    *out = NULL;
    *out = NULL;


    int64_t seekTimeUs;
    int64_t seekTimeUs;
    if (options && options->getSeekTo(&seekTimeUs)) {
    ReadOptions::SeekMode mode;
    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
        int64_t seekFrame = seekTimeUs / 20000ll;  // 20ms per frame.
        int64_t seekFrame = seekTimeUs / 20000ll;  // 20ms per frame.
        mCurrentTimeUs = seekFrame * 20000ll;
        mCurrentTimeUs = seekFrame * 20000ll;
        mOffset = seekFrame * mFrameSize + (mIsWide ? 9 : 6);
        mOffset = seekFrame * mFrameSize + (mIsWide ? 9 : 6);
+2 −1
Original line number Original line Diff line number Diff line
@@ -914,7 +914,8 @@ void AwesomePlayer::onVideoEvent() {
        if (mSeeking) {
        if (mSeeking) {
            LOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);
            LOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);


            options.setSeekTo(mSeekTimeUs);
            options.setSeekTo(
                    mSeekTimeUs, MediaSource::ReadOptions::SEEK_CLOSEST_SYNC);
        }
        }
        for (;;) {
        for (;;) {
            status_t err = mVideoSource->read(&mVideoBuffer, &options);
            status_t err = mVideoSource->read(&mVideoBuffer, &options);
Loading