diff options
author | Li Sun <sunli@codeaurora.org> | 2015-10-28 14:02:17 +0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-04-13 13:54:55 -0700 |
commit | 9fd0a690245e0a87592e5578397bc46b5af6e473 (patch) | |
tree | ba731cbbee010449b2d370188adef28ceed87be8 | |
parent | 322d0a4dd98eae78c0f0acbebc2b622be9fd5438 (diff) | |
download | frameworks_av-9fd0a690245e0a87592e5578397bc46b5af6e473.zip frameworks_av-9fd0a690245e0a87592e5578397bc46b5af6e473.tar.gz frameworks_av-9fd0a690245e0a87592e5578397bc46b5af6e473.tar.bz2 |
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
-rw-r--r-- | media/libmediaplayerservice/nuplayer/RTSPSource.cpp | 32 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/RTSPSource.h | 4 |
2 files changed, 33 insertions, 3 deletions
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp index 35567a5..4962520 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp @@ -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> ¬ify, @@ -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,11 +438,22 @@ 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) { - ALOGI("dropping damaged access unit."); - break; + 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) { @@ -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; diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.h b/media/libmediaplayerservice/nuplayer/RTSPSource.h index 6438a1e..c431174 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.h +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.h @@ -118,6 +118,10 @@ private: sp<AReplyToken> mSeekReplyID; + int32_t mVideoTrackIndex; + bool mKeepDamagedAccessUnits; + uint32_t mNumKeepDamagedAccessUnits; + sp<AnotherPacketSource> getSource(bool audio); void onConnected(); |