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

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

Merge "Better detection of connection problems - timeout if no rtcp packets...

Merge "Better detection of connection problems - timeout if no rtcp packets arrive within a certain time, not a final frame (which may take longer)" into gingerbread
parents 6659284d 3a48d4d7
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -362,7 +362,6 @@ status_t ARTPConnection::receive(StreamInfo *s, bool receiveRTP) {
    if (receiveRTP) {
        err = parseRTP(s, buffer);
    } else {
        ++s->mNumRTCPPacketsReceived;
        err = parseRTCP(s, buffer);
    }

@@ -456,6 +455,12 @@ status_t ARTPConnection::parseRTP(StreamInfo *s, const sp<ABuffer> &buffer) {
}

status_t ARTPConnection::parseRTCP(StreamInfo *s, const sp<ABuffer> &buffer) {
    if (s->mNumRTCPPacketsReceived++ == 0) {
        sp<AMessage> notify = s->mNotifyMsg->dup();
        notify->setInt32("first-rtcp", true);
        notify->post();
    }

    const uint8_t *data = buffer->data();
    size_t size = buffer->size();

@@ -626,7 +631,6 @@ void ARTPConnection::onInjectPacket(const sp<AMessage> &msg) {
    if (it->mRTPSocket == index) {
        err = parseRTP(s, buffer);
    } else {
        ++s->mNumRTCPPacketsReceived;
        err = parseRTCP(s, buffer);
    }
}
+61 −41
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@ struct MyHandler : public AHandler {
          mFirstAccessUnitNTP(0),
          mNumAccessUnitsReceived(0),
          mCheckPending(false),
          mTryTCPInterleaving(false) {
          mTryTCPInterleaving(false),
          mReceivedFirstRTCPPacket(false) {
        mNetLooper->setName("rtsp net");
        mNetLooper->start(false /* runOnCallingThread */,
                          false /* canCallJava */,
@@ -199,8 +200,9 @@ struct MyHandler : public AHandler {
                        break;
                    }

                    CHECK_EQ(response->mStatusCode, 200u);

                    if (response->mStatusCode != 200) {
                        result = UNKNOWN_ERROR;
                    } else {
                        mSessionDesc = new ASessionDescription;

                        mSessionDesc->setTo(
@@ -223,7 +225,10 @@ struct MyHandler : public AHandler {

                        CHECK_GT(mSessionDesc->countTracks(), 1u);
                        setupTrack(1);
                } else {
                    }
                }

                if (result != OK) {
                    sp<AMessage> reply = new AMessage('disc', id());
                    mConn->disconnect(reply);
                }
@@ -247,16 +252,7 @@ struct MyHandler : public AHandler {
                LOG(INFO) << "SETUP(" << index << ") completed with result "
                     << result << " (" << strerror(-result) << ")";

                if (result != OK) {
                    if (track) {
                        if (!track->mUsingInterleavedTCP) {
                            close(track->mRTPSocket);
                            close(track->mRTCPSocket);
                        }

                        mTracks.removeItemsAt(trackIndex);
                    }
                } else {
                if (result == OK) {
                    CHECK(track != NULL);

                    sp<RefBase> obj;
@@ -264,19 +260,18 @@ struct MyHandler : public AHandler {
                    sp<ARTSPResponse> response =
                        static_cast<ARTSPResponse *>(obj.get());

                    CHECK_EQ(response->mStatusCode, 200u);

                    if (response->mStatusCode != 200) {
                        result = UNKNOWN_ERROR;
                    } else {
                        ssize_t i = response->mHeaders.indexOfKey("session");
                        CHECK_GE(i, 0);

                    if (index == 1) {
                        mSessionID = response->mHeaders.valueAt(i);
                        i = mSessionID.find(";");
                        if (i >= 0) {
                            // Remove options, i.e. ";timeout=90"
                            mSessionID.erase(i, mSessionID.size() - i);
                        }
                    }

                        sp<AMessage> notify = new AMessage('accu', id());
                        notify->setSize("track-index", trackIndex);
@@ -288,6 +283,18 @@ struct MyHandler : public AHandler {

                        mSetupTracksSuccessful = true;
                    }
                }

                if (result != OK) {
                    if (track) {
                        if (!track->mUsingInterleavedTCP) {
                            close(track->mRTPSocket);
                            close(track->mRTCPSocket);
                        }

                        mTracks.removeItemsAt(trackIndex);
                    }
                }

                ++index;
                if (index < mSessionDesc->countTracks()) {
@@ -355,6 +362,12 @@ struct MyHandler : public AHandler {
                    }
                }
                mTracks.clear();
                mSetupTracksSuccessful = false;
                mSeekPending = false;
                mFirstAccessUnit = true;
                mFirstAccessUnitNTP = 0;
                mNumAccessUnitsReceived = 0;
                mReceivedFirstRTCPPacket = false;

                sp<AMessage> reply = new AMessage('tear', id());

@@ -424,6 +437,12 @@ struct MyHandler : public AHandler {

            case 'accu':
            {
                int32_t firstRTCP;
                if (msg->findInt32("first-rtcp", &firstRTCP)) {
                    mReceivedFirstRTCPPacket = true;
                    break;
                }

                ++mNumAccessUnitsReceived;

                if (!mCheckPending) {
@@ -612,7 +631,7 @@ struct MyHandler : public AHandler {

            case 'tiou':
            {
                if (mFirstAccessUnit) {
                if (!mReceivedFirstRTCPPacket) {
                    if (mTryTCPInterleaving) {
                        LOG(WARNING) << "Never received any data, disconnecting.";
                        (new AMessage('abor', id()))->post();
@@ -747,6 +766,7 @@ private:
    int64_t mNumAccessUnitsReceived;
    bool mCheckPending;
    bool mTryTCPInterleaving;
    bool mReceivedFirstRTCPPacket;

    struct TrackInfo {
        AString mURL;