Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18f0174f authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "We're now going to ignore timestamps completely in gtalk video...

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
parents 605f4027 f88f8441
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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);
+8 −0
Original line number Diff line number Diff line
@@ -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);
+22 −17
Original line number Diff line number Diff line
@@ -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();
+12 −12
Original line number Diff line number Diff line
@@ -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,8 +279,11 @@ void ARTPConnection::onPollStreams() {
                sp<ARTPSource> source = s->mSources.valueAt(i);

                source->addReceiverReport(buffer);

                if (mFlags & kRegularlyRequestFIR) {
                    source->addFIR(buffer);
                }
            }

            if (buffer->size() > 0) {
                LOG(VERBOSE) << "Sending RR...";
@@ -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
    if ((mFlags & kFakeTimestamps) == 0) {
        source->timeUpdate(rtpTime, ntpTime);
#endif
    }

    return 0;
}
+8 −1
Original line number Diff line number Diff line
@@ -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;

Loading