diff options
author | Andreas Huber <andih@google.com> | 2011-12-09 18:09:19 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-12-09 18:09:19 -0800 |
commit | 61a8b5301b9cf3abef9f1b9fa5af55912cb9d9c7 (patch) | |
tree | 6bc79b64860b23538297e36f12ab15977375f70a /media | |
parent | 47730f1582dfa67909293d6d5b88ff89c5ad6ed5 (diff) | |
parent | aa82c39bdb4ad9c1fdcb09f3bea11be5197d3ce6 (diff) | |
download | frameworks_base-61a8b5301b9cf3abef9f1b9fa5af55912cb9d9c7.zip frameworks_base-61a8b5301b9cf3abef9f1b9fa5af55912cb9d9c7.tar.gz frameworks_base-61a8b5301b9cf3abef9f1b9fa5af55912cb9d9c7.tar.bz2 |
am aa82c39b: am 0ba9380a: Merge "Fix Bitreader "putBits" implementation, make sure we emulate timestamps" into ics-mr1
* commit 'aa82c39bdb4ad9c1fdcb09f3bea11be5197d3ce6':
Fix Bitreader "putBits" implementation, make sure we emulate timestamps
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/RTSPSource.cpp | 27 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/RTSPSource.h | 1 | ||||
-rw-r--r-- | media/libstagefright/foundation/ABitReader.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/rtsp/MyHandler.h | 14 |
4 files changed, 37 insertions, 13 deletions
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp index e72adc4..6e6d4be 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp @@ -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)) { diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.h b/media/libmediaplayerservice/nuplayer/RTSPSource.h index 66eab72..a401caa 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.h +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.h @@ -76,6 +76,7 @@ private: int32_t mTimeScale; uint32_t mRTPTime; int64_t mNormalPlaytimeUs; + bool mNPTMappingValid; }; AString mURL; diff --git a/media/libstagefright/foundation/ABitReader.cpp b/media/libstagefright/foundation/ABitReader.cpp index f07dd4f..5499c32 100644 --- a/media/libstagefright/foundation/ABitReader.cpp +++ b/media/libstagefright/foundation/ABitReader.cpp @@ -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; diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index dd049c2..21ef298 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -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,12 +1388,14 @@ private: msg->setInt32("what", kWhatConnected); msg->post(); - for (size_t i = 0; i < mTracks.size(); ++i) { - TrackInfo *info = &mTracks.editItemAt(i); + if (mSeekable) { + for (size_t i = 0; i < mTracks.size(); ++i) { + TrackInfo *info = &mTracks.editItemAt(i); - postNormalPlayTimeMapping( - i, - info->mNormalPlayTimeRTP, info->mNormalPlayTimeUs); + postNormalPlayTimeMapping( + i, + info->mNormalPlayTimeRTP, info->mNormalPlayTimeUs); + } } mFirstAccessUnit = false; |