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

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

Merge "Fix Bitreader "putBits" implementation, make sure we emulate timestamps" into ics-mr1

parents 48b428fb f6ae7114
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -208,21 +208,32 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
                break;
            }

            const TrackInfo &info = mTracks.editItemAt(trackIndex);
            sp<AnotherPacketSource> source = info.mSource;
            TrackInfo *info = &mTracks.editItemAt(trackIndex);

            sp<AnotherPacketSource> source = info->mSource;
            if (source != NULL) {
#if 1
                uint32_t rtpTime;
                CHECK(accessUnit->meta()->findInt32("rtp-time", (int32_t *)&rtpTime));

                if (!info->mNPTMappingValid) {
                    // This is a live stream, we didn't receive any normal
                    // playtime mapping. Assume the first packets correspond
                    // to time 0.

                    LOGV("This is a live stream, assuming time = 0");

                    info->mRTPTime = rtpTime;
                    info->mNormalPlaytimeUs = 0ll;
                    info->mNPTMappingValid = true;
                }

                int64_t nptUs =
                    ((double)rtpTime - (double)info.mRTPTime)
                        / info.mTimeScale
                    ((double)rtpTime - (double)info->mRTPTime)
                        / info->mTimeScale
                        * 1000000ll
                        + info.mNormalPlaytimeUs;
                        + info->mNormalPlaytimeUs;

                accessUnit->meta()->setInt64("timeUs", nptUs);
#endif

                source->queueAccessUnit(accessUnit);
            }
@@ -278,6 +289,7 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
            TrackInfo *info = &mTracks.editItemAt(trackIndex);
            info->mRTPTime = rtpTime;
            info->mNormalPlaytimeUs = nptUs;
            info->mNPTMappingValid = true;
            break;
        }

@@ -305,6 +317,7 @@ void NuPlayer::RTSPSource::onConnected() {
        info.mTimeScale = timeScale;
        info.mRTPTime = 0;
        info.mNormalPlaytimeUs = 0ll;
        info.mNPTMappingValid = false;

        if ((isAudio && mAudioTrack == NULL)
                || (isVideo && mVideoTrack == NULL)) {
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ private:
        int32_t mTimeScale;
        uint32_t mRTPTime;
        int64_t mNormalPlaytimeUs;
        bool mNPTMappingValid;
    };

    AString mURL;
+7 −1
Original line number Diff line number Diff line
@@ -79,7 +79,13 @@ void ABitReader::skipBits(size_t n) {
}

void ABitReader::putBits(uint32_t x, size_t n) {
    CHECK_LE(mNumBitsLeft + n, 32u);
    CHECK_LE(n, 32u);

    while (mNumBitsLeft + n > 32) {
        mNumBitsLeft -= 8;
        --mData;
        ++mSize;
    }

    mReservoir = (mReservoir >> n) | (x << (32 - n));
    mNumBitsLeft += n;
+9 −5
Original line number Diff line number Diff line
@@ -1100,6 +1100,8 @@ struct MyHandler : public AHandler {
        float npt1, npt2;
        if (!ASessionDescription::parseNTPRange(val.c_str(), &npt1, &npt2)) {
            // This is a live stream and therefore not seekable.

            LOGI("This is a live stream");
            return;
        }

@@ -1386,6 +1388,7 @@ private:
            msg->setInt32("what", kWhatConnected);
            msg->post();

            if (mSeekable) {
                for (size_t i = 0; i < mTracks.size(); ++i) {
                    TrackInfo *info = &mTracks.editItemAt(i);

@@ -1393,6 +1396,7 @@ private:
                            i,
                            info->mNormalPlayTimeRTP, info->mNormalPlayTimeUs);
                }
            }

            mFirstAccessUnit = false;
        }