Merge "We're now going to ignore timestamps completely in gtalk video conferencing, playing video as soon as it comes in. We also make up fake timestamps in the rtp code, ignoring rtcp SR information to enable early startup." into gingerbread

This commit is contained in:
Andreas Huber
2010-08-10 12:59:27 -07:00
committed by Android (Google) Code Review
7 changed files with 61 additions and 39 deletions

View File

@ -1019,6 +1019,12 @@ void AwesomePlayer::onVideoEvent() {
int64_t latenessUs = nowUs - timeUs; 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) { if (latenessUs > 40000) {
// We're more than 40ms late. // We're more than 40ms late.
LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6); LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6);

View File

@ -1685,6 +1685,14 @@ void OMXCodec::on_message(const omx_message &msg) {
MediaBuffer *buffer = info->mMediaBuffer; 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( buffer->set_range(
msg.u.extended_buffer_data.range_offset, msg.u.extended_buffer_data.range_offset,
msg.u.extended_buffer_data.range_length); msg.u.extended_buffer_data.range_length);

View File

@ -356,24 +356,10 @@ status_t APacketSource::read(
if (!mBuffers.empty()) { if (!mBuffers.empty()) {
const sp<ABuffer> buffer = *mBuffers.begin(); 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 *mediaBuffer = new MediaBuffer(buffer->size());
mediaBuffer->meta_data()->setInt64(kKeyNTPTime, ntpTime);
if (mFirstAccessUnit) { int64_t timeUs;
mFirstAccessUnit = false; CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
mFirstAccessUnitNTP = ntpTime;
}
if (ntpTime > mFirstAccessUnitNTP) {
ntpTime -= mFirstAccessUnitNTP;
} else {
ntpTime = 0;
}
int64_t timeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32));
mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs);
@ -390,10 +376,29 @@ status_t APacketSource::read(
void APacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { void APacketSource::queueAccessUnit(const sp<ABuffer> &buffer) {
int32_t damaged; int32_t damaged;
if (buffer->meta()->findInt32("damaged", &damaged) && damaged) { if (buffer->meta()->findInt32("damaged", &damaged) && damaged) {
// LOG(VERBOSE) << "discarding damaged AU"; LOG(INFO) << "discarding damaged AU";
return; 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); Mutex::Autolock autoLock(mLock);
mBuffers.push_back(buffer); mBuffers.push_back(buffer);
mCondition.signal(); mCondition.signal();

View File

@ -28,8 +28,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>
#define IGNORE_RTCP_TIME 0
namespace android { namespace android {
static const size_t kMaxUDPSize = 1500; static const size_t kMaxUDPSize = 1500;
@ -61,8 +59,9 @@ struct ARTPConnection::StreamInfo {
struct sockaddr_in mRemoteRTCPAddr; struct sockaddr_in mRemoteRTCPAddr;
}; };
ARTPConnection::ARTPConnection() ARTPConnection::ARTPConnection(uint32_t flags)
: mPollEventPending(false), : mFlags(flags),
mPollEventPending(false),
mLastReceiverReportTimeUs(-1) { mLastReceiverReportTimeUs(-1) {
} }
@ -280,7 +279,10 @@ void ARTPConnection::onPollStreams() {
sp<ARTPSource> source = s->mSources.valueAt(i); sp<ARTPSource> source = s->mSources.valueAt(i);
source->addReceiverReport(buffer); source->addReceiverReport(buffer);
source->addFIR(buffer);
if (mFlags & kRegularlyRequestFIR) {
source->addFIR(buffer);
}
} }
if (buffer->size() > 0) { if (buffer->size() > 0) {
@ -405,13 +407,11 @@ status_t ARTPConnection::parseRTP(StreamInfo *s, const sp<ABuffer> &buffer) {
buffer->setInt32Data(u16at(&data[2])); buffer->setInt32Data(u16at(&data[2]));
buffer->setRange(payloadOffset, size - payloadOffset); buffer->setRange(payloadOffset, size - payloadOffset);
#if IGNORE_RTCP_TIME if ((mFlags & kFakeTimestamps) && !source->timeEstablished()) {
if (!source->timeEstablished()) {
source->timeUpdate(rtpTime, 0); source->timeUpdate(rtpTime, 0);
source->timeUpdate(rtpTime + 20, 0x100000000ll); source->timeUpdate(rtpTime + 90000, 0x100000000ll);
CHECK(source->timeEstablished()); CHECK(source->timeEstablished());
} }
#endif
source->processRTPPacket(buffer); source->processRTPPacket(buffer);
@ -533,9 +533,9 @@ status_t ARTPConnection::parseSR(
sp<ARTPSource> source = findSource(s, id); sp<ARTPSource> source = findSource(s, id);
#if !IGNORE_RTCP_TIME if ((mFlags & kFakeTimestamps) == 0) {
source->timeUpdate(rtpTime, ntpTime); source->timeUpdate(rtpTime, ntpTime);
#endif }
return 0; return 0;
} }

View File

@ -28,7 +28,12 @@ struct ARTPSource;
struct ASessionDescription; struct ASessionDescription;
struct ARTPConnection : public AHandler { struct ARTPConnection : public AHandler {
ARTPConnection(); enum Flags {
kFakeTimestamps = 1,
kRegularlyRequestFIR = 2,
};
ARTPConnection(uint32_t flags = 0);
void addStream( void addStream(
int rtpSocket, int rtcpSocket, int rtpSocket, int rtcpSocket,
@ -56,6 +61,8 @@ private:
static const int64_t kSelectTimeoutUs; static const int64_t kSelectTimeoutUs;
uint32_t mFlags;
struct StreamInfo; struct StreamInfo;
List<StreamInfo> mStreams; List<StreamInfo> mStreams;

View File

@ -40,7 +40,10 @@ status_t ARTPSession::setup(const sp<ASessionDescription> &desc) {
mDesc = desc; mDesc = desc;
mRTPConn = new ARTPConnection; mRTPConn = new ARTPConnection(
ARTPConnection::kFakeTimestamps
| ARTPConnection::kRegularlyRequestFIR);
looper()->registerHandler(mRTPConn); looper()->registerHandler(mRTPConn);
for (size_t i = 1; i < mDesc->countTracks(); ++i) { for (size_t i = 1; i < mDesc->countTracks(); ++i) {

View File

@ -98,7 +98,7 @@ void ARTPSource::timeUpdate(uint32_t rtpTime, uint64_t ntpTime) {
mNTPTime[mNumTimes] = ntpTime; mNTPTime[mNumTimes] = ntpTime;
mRTPTime[mNumTimes++] = rtpTime; mRTPTime[mNumTimes++] = rtpTime;
if (mNumTimes == 2) { if (timeEstablished()) {
for (List<sp<ABuffer> >::iterator it = mQueue.begin(); for (List<sp<ABuffer> >::iterator it = mQueue.begin();
it != mQueue.end(); ++it) { it != mQueue.end(); ++it) {
sp<AMessage> meta = (*it)->meta(); 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) { 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(); uint32_t seqNum = (uint32_t)buffer->int32Data();
if (mNumTimes == 2) { if (mNumTimes == 2) {