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:
committed by
Android (Google) Code Review
commit
18f0174ff4
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user