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

Commit 9fd0a690 authored by Li Sun's avatar Li Sun Committed by Steve Kondik
Browse files

rtsp: keep video damaged access unit to enhance fault tolerance

Make RTSPSource to accept some video damaged access units to enhance
fault tolerance.

Disable this change as default. add the property to enable it such as:
"adb shell setprop rtsp.video.keep-damaged-au video/3gpp" for H263
"adb shell setprop rtsp.video.keep-damaged-au video/avc" for H264

Change-Id: I3b7fb4b098aba5daf149cf36dab7e9380c6d2f69
parent 322d0a4d
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "MyHandler.h"
#include "SDPLoader.h"

#include <cutils/properties.h>
#include <media/IMediaHTTPService.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
@@ -32,6 +33,7 @@
namespace android {

const int64_t kNearEOSTimeoutUs = 2000000ll; // 2 secs
const uint32_t kMaxNumKeepDamagedAccessUnits = 30;

NuPlayer::RTSPSource::RTSPSource(
        const sp<AMessage> &notify,
@@ -54,7 +56,10 @@ NuPlayer::RTSPSource::RTSPSource(
      mBuffering(false),
      mSeekGeneration(0),
      mEOSTimeoutAudio(0),
      mEOSTimeoutVideo(0) {
      mEOSTimeoutVideo(0),
      mVideoTrackIndex(-1),
      mKeepDamagedAccessUnits(false),
      mNumKeepDamagedAccessUnits(0) {
    if (headers) {
        mExtraHeaders = *headers;

@@ -433,12 +438,23 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
            sp<ABuffer> accessUnit;
            CHECK(msg->findBuffer("accessUnit", &accessUnit));

            bool isVideo = trackIndex == (size_t)mVideoTrackIndex;
            int32_t damaged;
            if (accessUnit->meta()->findInt32("damaged", &damaged)
                    && damaged) {
                if (isVideo && mKeepDamagedAccessUnits
                        && mNumKeepDamagedAccessUnits < kMaxNumKeepDamagedAccessUnits) {
                    ALOGI("keep a damaged access unit.");
                    ++mNumKeepDamagedAccessUnits;
                } else {
                    ALOGI("dropping damaged access unit.");
                    break;
                }
            } else {
                if (isVideo) {
                    mNumKeepDamagedAccessUnits = 0;
                }
            }

            if (mTSParser != NULL) {
                size_t offset = 0;
@@ -613,6 +629,16 @@ void NuPlayer::RTSPSource::onConnected() {
        bool isAudio = !strncasecmp(mime, "audio/", 6);
        bool isVideo = !strncasecmp(mime, "video/", 6);

        if (isVideo) {
            mVideoTrackIndex = i;
            char value[PROPERTY_VALUE_MAX];
            if (property_get("rtsp.video.keep-damaged-au", value, NULL)
                    && !strcasecmp(mime, value)) {
                ALOGV("enable to keep damaged au for %s", mime);
                mKeepDamagedAccessUnits = true;
            }
        }

        TrackInfo info;
        info.mTimeScale = timeScale;
        info.mRTPTime = 0;
+4 −0
Original line number Diff line number Diff line
@@ -118,6 +118,10 @@ private:

    sp<AReplyToken> mSeekReplyID;

    int32_t mVideoTrackIndex;
    bool mKeepDamagedAccessUnits;
    uint32_t mNumKeepDamagedAccessUnits;

    sp<AnotherPacketSource> getSource(bool audio);

    void onConnected();