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

Commit 30bf97b3 authored by Andreas Huber's avatar Andreas Huber
Browse files

Track max latency in WifiDisplaySink

also unbreak non-special-mode by choosing a proper time offset based
on arrival time of the first access unit even when no time synchronization
is present.

Change-Id: I133050afc6f70d4639ca45de68a31d5bc3594e96
parent 8f24c039
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ WifiDisplaySink::WifiDisplaySink(
      mSetupDeferred(false),
      mLatencyCount(0),
      mLatencySumUs(0ll),
      mLatencyMaxUs(0ll) {
      mLatencyMaxUs(0ll),
      mMaxDelayMs(-1ll) {
    // We support any and all resolutions, but prefer 720p30
    mSinkSupportedVideoFormats.setNativeResolution(
            VideoFormats::RESOLUTION_CEA, 5);  // 1280 x 720 p30
@@ -296,9 +297,13 @@ void WifiDisplaySink::onMessageReceived(const sp<AMessage> &msg) {
    }
}

static void dumpDelay(size_t trackIndex, int64_t timeUs) {
void WifiDisplaySink::dumpDelay(size_t trackIndex, int64_t timeUs) {
    int64_t delayMs = (ALooper::GetNowUs() - timeUs) / 1000ll;

    if (delayMs > mMaxDelayMs) {
        mMaxDelayMs = delayMs;
    }

    static const int64_t kMinDelayMs = 0;
    static const int64_t kMaxDelayMs = 300;

@@ -314,9 +319,10 @@ static void dumpDelay(size_t trackIndex, int64_t timeUs) {
        n = kPatternSize;
    }

    ALOGI("[%lld]: (%4lld ms) %s",
    ALOGI("[%lld]: (%4lld ms / %4lld ms) %s",
          timeUs / 1000,
          delayMs,
          mMaxDelayMs,
          kPattern + kPatternSize - n);
}

@@ -350,14 +356,19 @@ void WifiDisplaySink::onMediaReceiverNotify(const sp<AMessage> &msg) {
                looper()->registerHandler(mRenderer);
            }

            CHECK(mTimeOffsetValid);

            sp<ABuffer> accessUnit;
            CHECK(msg->findBuffer("accessUnit", &accessUnit));

            int64_t timeUs;
            CHECK(accessUnit->meta()->findInt64("timeUs", &timeUs));

            if (!mTimeOffsetValid && !(mFlags & FLAG_SPECIAL_MODE)) {
                mTimeOffsetUs = timeUs - ALooper::GetNowUs();
                mTimeOffsetValid = true;
            }

            CHECK(mTimeOffsetValid);

            // We are the timesync _client_,
            // client time = server time - time offset.
            timeUs -= mTimeOffsetUs;
+4 −0
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ private:
    int64_t mLatencySumUs;
    int64_t mLatencyMaxUs;

    int64_t mMaxDelayMs;

    status_t sendM2(int32_t sessionID);
    status_t sendSetup(int32_t sessionID, const char *uri);
    status_t sendPlay(int32_t sessionID, const char *uri);
@@ -184,6 +186,8 @@ private:
            const char *url, AString *host, int32_t *port, AString *path,
            AString *user, AString *pass);

    void dumpDelay(size_t trackIndex, int64_t timeUs);

    DISALLOW_EVIL_CONSTRUCTORS(WifiDisplaySink);
};