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

Commit 475334f7 authored by Andreas Huber's avatar Andreas Huber
Browse files

Starhub RTSP apparently does not establish time on all tracks

i.e. the "SR" RTCP packet is sent for only one of the two tracks.

fake timestamps if that's the case, previously we'd only fake timestamps
if we didn't receive _any_ "SR" packets.

Change-Id: Id63d4940d453ba6c04c62e02ab9a0ad843936bc1
related-to-bug: 5669027
parent f17e7c27
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ struct MyHandler : public AHandler {
          mSetupTracksSuccessful(false),
          mSeekPending(false),
          mFirstAccessUnit(true),
          mAllTracksHaveTime(false),
          mNTPAnchorUs(-1),
          mMediaAnchorUs(-1),
          mLastMediaTimeUs(0),
@@ -723,6 +724,7 @@ struct MyHandler : public AHandler {
                mSetupTracksSuccessful = false;
                mSeekPending = false;
                mFirstAccessUnit = true;
                mAllTracksHaveTime = false;
                mNTPAnchorUs = -1;
                mMediaAnchorUs = -1;
                mNumAccessUnitsReceived = 0;
@@ -930,6 +932,7 @@ struct MyHandler : public AHandler {
                    info->mNTPAnchorUs = -1;
                }

                mAllTracksHaveTime = false;
                mNTPAnchorUs = -1;

                int64_t timeUs;
@@ -1037,6 +1040,14 @@ struct MyHandler : public AHandler {
                        ALOGW("Never received any data, disconnecting.");
                        (new AMessage('abor', id()))->post();
                    }
                } else {
                    if (!mAllTracksHaveTime) {
                        ALOGW("We received some RTCP packets, but time "
                              "could not be established on all tracks, now "
                              "using fake timestamps");

                        fakeTimestamps();
                    }
                }
                break;
            }
@@ -1211,6 +1222,7 @@ private:
    bool mSeekPending;
    bool mFirstAccessUnit;

    bool mAllTracksHaveTime;
    int64_t mNTPAnchorUs;
    int64_t mMediaAnchorUs;
    int64_t mLastMediaTimeUs;
@@ -1357,6 +1369,7 @@ private:
    }

    void fakeTimestamps() {
        mNTPAnchorUs = -1ll;
        for (size_t i = 0; i < mTracks.size(); ++i) {
            onTimeUpdate(i, 0, 0ll);
        }
@@ -1377,6 +1390,21 @@ private:
            mNTPAnchorUs = ntpTimeUs;
            mMediaAnchorUs = mLastMediaTimeUs;
        }

        if (!mAllTracksHaveTime) {
            bool allTracksHaveTime = true;
            for (size_t i = 0; i < mTracks.size(); ++i) {
                TrackInfo *track = &mTracks.editItemAt(i);
                if (track->mNTPAnchorUs < 0) {
                    allTracksHaveTime = false;
                    break;
                }
            }
            if (allTracksHaveTime) {
                mAllTracksHaveTime = true;
                ALOGI("Time now established for all tracks.");
            }
        }
    }

    void onAccessUnitComplete(
@@ -1403,7 +1431,7 @@ private:

        TrackInfo *track = &mTracks.editItemAt(trackIndex);

        if (mNTPAnchorUs < 0 || mMediaAnchorUs < 0 || track->mNTPAnchorUs < 0) {
        if (!mAllTracksHaveTime) {
            ALOGV("storing accessUnit, no time established yet");
            track->mPackets.push_back(accessUnit);
            return;