diff options
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 6 | ||||
-rw-r--r-- | media/libstagefright/OMXCodec.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/rtsp/APacketSource.cpp | 39 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPConnection.cpp | 24 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPConnection.h | 9 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPSession.cpp | 5 | ||||
-rw-r--r-- | media/libstagefright/rtsp/ARTPSource.cpp | 9 |
7 files changed, 61 insertions, 39 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index e426fca..b16a136 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -1019,6 +1019,12 @@ void AwesomePlayer::onVideoEvent() { int64_t latenessUs = nowUs - timeUs; + if (mRTPSession != NULL) { + // We'll completely ignore timestamps for gtalk videochat + // and we'll play incoming video as fast as we get it. + latenessUs = 0; + } + if (latenessUs > 40000) { // We're more than 40ms late. LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6); diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 11396ef..4741b1d 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -1685,6 +1685,14 @@ void OMXCodec::on_message(const omx_message &msg) { MediaBuffer *buffer = info->mMediaBuffer; + if (msg.u.extended_buffer_data.range_offset + + msg.u.extended_buffer_data.range_length + > buffer->size()) { + CODEC_LOGE( + "Codec lied about its buffer size requirements, " + "sending a buffer larger than the originally " + "advertised size in FILL_BUFFER_DONE!"); + } buffer->set_range( msg.u.extended_buffer_data.range_offset, msg.u.extended_buffer_data.range_length); diff --git a/media/libstagefright/rtsp/APacketSource.cpp b/media/libstagefright/rtsp/APacketSource.cpp index a577704..395cd28 100644 --- a/media/libstagefright/rtsp/APacketSource.cpp +++ b/media/libstagefright/rtsp/APacketSource.cpp @@ -356,24 +356,10 @@ status_t APacketSource::read( if (!mBuffers.empty()) { const sp<ABuffer> buffer = *mBuffers.begin(); - uint64_t ntpTime; - CHECK(buffer->meta()->findInt64( - "ntp-time", (int64_t *)&ntpTime)); - MediaBuffer *mediaBuffer = new MediaBuffer(buffer->size()); - mediaBuffer->meta_data()->setInt64(kKeyNTPTime, ntpTime); - - if (mFirstAccessUnit) { - mFirstAccessUnit = false; - mFirstAccessUnitNTP = ntpTime; - } - if (ntpTime > mFirstAccessUnitNTP) { - ntpTime -= mFirstAccessUnitNTP; - } else { - ntpTime = 0; - } - int64_t timeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32)); + int64_t timeUs; + CHECK(buffer->meta()->findInt64("timeUs", &timeUs)); mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); @@ -390,10 +376,29 @@ status_t APacketSource::read( void APacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { int32_t damaged; if (buffer->meta()->findInt32("damaged", &damaged) && damaged) { - // LOG(VERBOSE) << "discarding damaged AU"; + LOG(INFO) << "discarding damaged AU"; return; } + uint64_t ntpTime; + CHECK(buffer->meta()->findInt64( + "ntp-time", (int64_t *)&ntpTime)); + + if (mFirstAccessUnit) { + mFirstAccessUnit = false; + mFirstAccessUnitNTP = ntpTime; + } + + if (ntpTime > mFirstAccessUnitNTP) { + ntpTime -= mFirstAccessUnitNTP; + } else { + ntpTime = 0; + } + + int64_t timeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32)); + + buffer->meta()->setInt64("timeUs", timeUs); + Mutex::Autolock autoLock(mLock); mBuffers.push_back(buffer); mCondition.signal(); diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp index 5bd306b..469af3e 100644 --- a/media/libstagefright/rtsp/ARTPConnection.cpp +++ b/media/libstagefright/rtsp/ARTPConnection.cpp @@ -28,8 +28,6 @@ #include <arpa/inet.h> #include <sys/socket.h> -#define IGNORE_RTCP_TIME 0 - namespace android { static const size_t kMaxUDPSize = 1500; @@ -61,8 +59,9 @@ struct ARTPConnection::StreamInfo { struct sockaddr_in mRemoteRTCPAddr; }; -ARTPConnection::ARTPConnection() - : mPollEventPending(false), +ARTPConnection::ARTPConnection(uint32_t flags) + : mFlags(flags), + mPollEventPending(false), mLastReceiverReportTimeUs(-1) { } @@ -280,7 +279,10 @@ void ARTPConnection::onPollStreams() { sp<ARTPSource> source = s->mSources.valueAt(i); source->addReceiverReport(buffer); - source->addFIR(buffer); + + if (mFlags & kRegularlyRequestFIR) { + source->addFIR(buffer); + } } if (buffer->size() > 0) { @@ -405,13 +407,11 @@ status_t ARTPConnection::parseRTP(StreamInfo *s, const sp<ABuffer> &buffer) { buffer->setInt32Data(u16at(&data[2])); buffer->setRange(payloadOffset, size - payloadOffset); -#if IGNORE_RTCP_TIME - if (!source->timeEstablished()) { + if ((mFlags & kFakeTimestamps) && !source->timeEstablished()) { source->timeUpdate(rtpTime, 0); - source->timeUpdate(rtpTime + 20, 0x100000000ll); + source->timeUpdate(rtpTime + 90000, 0x100000000ll); CHECK(source->timeEstablished()); } -#endif source->processRTPPacket(buffer); @@ -533,9 +533,9 @@ status_t ARTPConnection::parseSR( sp<ARTPSource> source = findSource(s, id); -#if !IGNORE_RTCP_TIME - source->timeUpdate(rtpTime, ntpTime); -#endif + if ((mFlags & kFakeTimestamps) == 0) { + source->timeUpdate(rtpTime, ntpTime); + } return 0; } diff --git a/media/libstagefright/rtsp/ARTPConnection.h b/media/libstagefright/rtsp/ARTPConnection.h index 49839ad..c535199 100644 --- a/media/libstagefright/rtsp/ARTPConnection.h +++ b/media/libstagefright/rtsp/ARTPConnection.h @@ -28,7 +28,12 @@ struct ARTPSource; struct ASessionDescription; struct ARTPConnection : public AHandler { - ARTPConnection(); + enum Flags { + kFakeTimestamps = 1, + kRegularlyRequestFIR = 2, + }; + + ARTPConnection(uint32_t flags = 0); void addStream( int rtpSocket, int rtcpSocket, @@ -56,6 +61,8 @@ private: static const int64_t kSelectTimeoutUs; + uint32_t mFlags; + struct StreamInfo; List<StreamInfo> mStreams; diff --git a/media/libstagefright/rtsp/ARTPSession.cpp b/media/libstagefright/rtsp/ARTPSession.cpp index 0e0f45a..e082078 100644 --- a/media/libstagefright/rtsp/ARTPSession.cpp +++ b/media/libstagefright/rtsp/ARTPSession.cpp @@ -40,7 +40,10 @@ status_t ARTPSession::setup(const sp<ASessionDescription> &desc) { mDesc = desc; - mRTPConn = new ARTPConnection; + mRTPConn = new ARTPConnection( + ARTPConnection::kFakeTimestamps + | ARTPConnection::kRegularlyRequestFIR); + looper()->registerHandler(mRTPConn); for (size_t i = 1; i < mDesc->countTracks(); ++i) { diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp index e08183e..225f6e8 100644 --- a/media/libstagefright/rtsp/ARTPSource.cpp +++ b/media/libstagefright/rtsp/ARTPSource.cpp @@ -98,7 +98,7 @@ void ARTPSource::timeUpdate(uint32_t rtpTime, uint64_t ntpTime) { mNTPTime[mNumTimes] = ntpTime; mRTPTime[mNumTimes++] = rtpTime; - if (mNumTimes == 2) { + if (timeEstablished()) { for (List<sp<ABuffer> >::iterator it = mQueue.begin(); it != mQueue.end(); ++it) { sp<AMessage> meta = (*it)->meta(); @@ -112,13 +112,6 @@ void ARTPSource::timeUpdate(uint32_t rtpTime, uint64_t ntpTime) { } bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) { -#if 1 - if (mNumTimes != 2) { - // Drop incoming packets until we've established a time base. - return false; - } -#endif - uint32_t seqNum = (uint32_t)buffer->int32Data(); if (mNumTimes == 2) { |