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

Commit 2e403e84 authored by Guillaume Chelfi's avatar Guillaume Chelfi
Browse files

Forward tunnel peek flag to OMX implementation

This commit is part of the video peek in tunnel mode effort. It
forwards the video peek parameter set in MediaCodec APIs to the
underlying OMX codec implementation.

Bug: 157501309
Test: The aforementioned bug tracks the addition of a battery of new
      tunnel mode related CTS tests
Change-Id: Ib0b7266167777d8f66d82d3700e12a9cbb2a99b7
parent ac77b699
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -74,6 +74,12 @@ enum {
    kMaxIndicesToCheck = 32, // used when enumerating supported formats and profiles
};

namespace {

constexpr char TUNNEL_PEEK_KEY[] = "android._trigger-tunnel-peek";

}

// OMX errors are directly mapped into status_t range if
// there is no corresponding MediaError status code.
// Use the statusFromOMXError(int32_t omxError) function.
@@ -2460,6 +2466,30 @@ status_t ACodec::getLatency(uint32_t *latency) {
    return err;
}

status_t ACodec::setTunnelPeek(int32_t tunnelPeek) {
    if (mIsEncoder) {
        ALOGE("encoder does not support %s", TUNNEL_PEEK_KEY);
        return BAD_VALUE;
    }
    if (!mTunneled) {
        ALOGE("%s is only supported in tunnel mode", TUNNEL_PEEK_KEY);
        return BAD_VALUE;
    }

    OMX_CONFIG_BOOLEANTYPE config;
    InitOMXParams(&config);
    config.bEnabled = (OMX_BOOL)(tunnelPeek != 0);
    status_t err = mOMXNode->setConfig(
            (OMX_INDEXTYPE)OMX_IndexConfigAndroidTunnelPeek,
            &config, sizeof(config));
    if (err != OK) {
        ALOGE("decoder cannot set %s to %d (err %d)",
              TUNNEL_PEEK_KEY, tunnelPeek, err);
    }

    return err;
}

status_t ACodec::setAudioPresentation(int32_t presentationId, int32_t programId) {
    OMX_AUDIO_CONFIG_ANDROID_AUDIOPRESENTATION config;
    InitOMXParams(&config);
@@ -7890,6 +7920,15 @@ status_t ACodec::setParameters(const sp<AMessage> &params) {
                &presentation, sizeof(presentation));
        }
    }

    int32_t tunnelPeek = 0;
    if (params->findInt32(TUNNEL_PEEK_KEY, &tunnelPeek)) {
        status_t err = setTunnelPeek(tunnelPeek);
        if (err != OK) {
            return err;
        }
    }

    return setVendorParameters(params);
}

+1 −0
Original line number Diff line number Diff line
@@ -518,6 +518,7 @@ private:
    status_t setLowLatency(int32_t lowLatency);
    status_t setLatency(uint32_t latency);
    status_t getLatency(uint32_t *latency);
    status_t setTunnelPeek(int32_t tunnelPeek);
    status_t setAudioPresentation(int32_t presentationId, int32_t programId);
    status_t setOperatingRate(float rateFloat, bool isVideo);
    status_t getIntraRefreshPeriod(uint32_t *intraRefreshPeriod);
+1 −1
Original line number Diff line number Diff line
@@ -857,9 +857,9 @@ constexpr char PARAMETER_KEY_OFFSET_TIME[] = "time-offset-us";
constexpr char PARAMETER_KEY_REQUEST_SYNC_FRAME[] = "request-sync";
constexpr char PARAMETER_KEY_SUSPEND[] = "drop-input-frames";
constexpr char PARAMETER_KEY_SUSPEND_TIME[] = "drop-start-time-us";
constexpr char PARAMETER_KEY_TUNNEL_PEEK[] =  "tunnel-peek";
constexpr char PARAMETER_KEY_VIDEO_BITRATE[] = "video-bitrate";

}

#endif  // MEDIA_CODEC_CONSTANTS_H_