Merge "Fix Bitreader "putBits" implementation, make sure we emulate timestamps" into ics-mr1

This commit is contained in:
Andreas Huber
2011-12-08 13:33:06 -08:00
committed by Android (Google) Code Review
4 changed files with 37 additions and 13 deletions

View File

@ -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)) {

View File

@ -76,6 +76,7 @@ private:
int32_t mTimeScale;
uint32_t mRTPTime;
int64_t mNormalPlaytimeUs;
bool mNPTMappingValid;
};
AString mURL;

View File

@ -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;

View File

@ -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;