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

Commit 6b6ae996 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "A first shot at proper support for seeking of rtsp streams." into gingerbread

parents 4af0cfad e0dd7d39
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ AwesomePlayer::AwesomePlayer()
      mExtractorFlags(0),
      mLastVideoBuffer(NULL),
      mVideoBuffer(NULL),
      mRTSPTimeOffset(0),
      mSuspensionState(NULL) {
    CHECK_EQ(mClient.connect(), OK);

@@ -393,7 +394,11 @@ void AwesomePlayer::reset_l() {
        mVideoBuffer = NULL;
    }

    if (mRTSPController != NULL) {
        mRTSPController->disconnect();
        mRTSPController.clear();
    }

    mRTPPusher.clear();
    mRTCPPusher.clear();
    mRTPSession.clear();
@@ -738,6 +743,10 @@ status_t AwesomePlayer::getPosition(int64_t *positionUs) {
        *positionUs = 0;
    }

    if (mRTSPController != NULL) {
        *positionUs += mRTSPTimeOffset;
    }

    return OK;
}

@@ -753,6 +762,17 @@ status_t AwesomePlayer::seekTo(int64_t timeUs) {
}

status_t AwesomePlayer::seekTo_l(int64_t timeUs) {
    if (mRTSPController != NULL) {
        pause_l();
        mRTSPController->seek(timeUs);
        play_l();

        notifyListener_l(MEDIA_SEEK_COMPLETE);
        mSeekNotificationSent = true;
        mRTSPTimeOffset = timeUs;
        return OK;
    }

    if (mFlags & CACHE_UNDERRUN) {
        mFlags &= ~CACHE_UNDERRUN;
        play_l();
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ struct ARTSPController : public MediaExtractor {
    status_t connect(const char *url);
    void disconnect();

    void seek(int64_t timeUs);

    virtual size_t countTracks();
    virtual sp<MediaSource> getTrack(size_t index);

+1 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ private:

    sp<ALooper> mLooper;
    sp<ARTSPController> mRTSPController;
    int64_t mRTSPTimeOffset;
    sp<ARTPSession> mRTPSession;
    sp<UDPPusher> mRTPPusher, mRTCPPusher;

+3 −49
Original line number Diff line number Diff line
@@ -406,9 +406,7 @@ APacketSource::APacketSource(
        const sp<ASessionDescription> &sessionDesc, size_t index)
    : mInitCheck(NO_INIT),
      mFormat(new MetaData),
      mEOSResult(OK),
      mFirstAccessUnit(true),
      mFirstAccessUnitNTP(0) {
      mEOSResult(OK) {
    unsigned long PT;
    AString desc;
    AString params;
@@ -550,9 +548,6 @@ status_t APacketSource::initCheck() const {
}

status_t APacketSource::start(MetaData *params) {
    mFirstAccessUnit = true;
    mFirstAccessUnitNTP = 0;

    return OK;
}

@@ -600,25 +595,6 @@ void APacketSource::queueAccessUnit(const sp<ABuffer> &buffer) {
        return;
    }

    uint64_t ntpTime;
    CHECK(buffer->meta()->findInt64(
                "ntp-time", (int64_t *)&ntpTime));

    if (mFirstAccessUnit) {
        mFirstAccessUnit = false;
        mFirstAccessUnitNTP = ntpTime;
    }

    if (ntpTime > mFirstAccessUnitNTP) {
        ntpTime -= mFirstAccessUnitNTP;
    } else {
        ntpTime = 0;
    }

    int64_t timeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32));

    buffer->meta()->setInt64("timeUs", timeUs);

    Mutex::Autolock autoLock(mLock);
    mBuffers.push_back(buffer);
    mCondition.signal();
@@ -632,31 +608,9 @@ void APacketSource::signalEOS(status_t result) {
    mCondition.signal();
}

int64_t APacketSource::getQueuedDuration(bool *eos) {
void APacketSource::flushQueue() {
    Mutex::Autolock autoLock(mLock);

    *eos = (mEOSResult != OK);

    if (mBuffers.empty()) {
        return 0;
    }

    sp<ABuffer> buffer = *mBuffers.begin();

    uint64_t ntpTime;
    CHECK(buffer->meta()->findInt64(
                "ntp-time", (int64_t *)&ntpTime));

    int64_t firstTimeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32));

    buffer = *--mBuffers.end();

    CHECK(buffer->meta()->findInt64(
                "ntp-time", (int64_t *)&ntpTime));

    int64_t lastTimeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32));

    return lastTimeUs - firstTimeUs;
    mBuffers.clear();
}

}  // namespace android
+1 −4
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ struct APacketSource : public MediaSource {
    void queueAccessUnit(const sp<ABuffer> &buffer);
    void signalEOS(status_t result);

    int64_t getQueuedDuration(bool *eos);
    void flushQueue();

protected:
    virtual ~APacketSource();
@@ -58,9 +58,6 @@ private:
    List<sp<ABuffer> > mBuffers;
    status_t mEOSResult;

    bool mFirstAccessUnit;
    uint64_t mFirstAccessUnitNTP;

    DISALLOW_EVIL_CONSTRUCTORS(APacketSource);
};

Loading