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

Commit 6844ed4e authored by Praveen Chavan's avatar Praveen Chavan Committed by Steve Kondik
Browse files

stagefright: provide a custom key to prefer adaptive playback

Provide a custom key "prefer-adaptive-playback" that can be
set in MediaFormat by java apps or by Native players to
prefer adaptive-playback over dynamic buffering

Change-Id: Ic02fc9f1d68fd9803ec154498a86e2537efcce85
parent cbcd48cc
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -1172,11 +1172,21 @@ status_t ACodec::configureCodec(
    int32_t haveNativeWindow = msg->findObject("native-window", &obj) &&
            obj != NULL;
    mStoreMetaDataInOutputBuffers = false;
    bool bAdaptivePlaybackMode = false;
    if (!encoder && video && haveNativeWindow) {
        int32_t preferAdaptive = 0;
        if (msg->findInt32("prefer-adaptive-playback", &preferAdaptive)
                && preferAdaptive == 1) {
            ALOGI("[%s] Adaptive playback preferred", mComponentName.c_str());
        } else {
            preferAdaptive = 0;
            err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexOutput, OMX_TRUE);
        if (err != OK) {
        }
        if (err != OK || preferAdaptive) {
            if (!preferAdaptive) {
                ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d",
                      mComponentName.c_str(), err);
            }

            // if adaptive playback has been requested, try JB fallback
            // NOTE: THIS FALLBACK MECHANISM WILL BE REMOVED DUE TO ITS
@@ -1208,7 +1218,7 @@ status_t ACodec::configureCodec(
            if (canDoAdaptivePlayback &&
                msg->findInt32("max-width", &maxWidth) &&
                msg->findInt32("max-height", &maxHeight)) {
                ALOGV("[%s] prepareForAdaptivePlayback(%ldx%ld)",
                ALOGI("[%s] prepareForAdaptivePlayback(%ldx%ld)",
                      mComponentName.c_str(), maxWidth, maxHeight);

                err = mOMX->prepareForAdaptivePlayback(
@@ -1216,6 +1226,15 @@ status_t ACodec::configureCodec(
                ALOGW_IF(err != OK,
                        "[%s] prepareForAdaptivePlayback failed w/ err %d",
                        mComponentName.c_str(), err);
                bAdaptivePlaybackMode = (err == OK);
            }
            // if Adaptive mode was tried first and codec failed it, try dynamic mode
            if (err != OK && preferAdaptive) {
                err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexOutput, OMX_TRUE);
                if (err != OK) {
                    ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d",
                          mComponentName.c_str(), err);
                }
            }
            // allow failure
            err = OK;
@@ -1224,6 +1243,9 @@ status_t ACodec::configureCodec(
            mStoreMetaDataInOutputBuffers = true;
        }

        ALOGI("DRC Mode: %s",(mStoreMetaDataInOutputBuffers ? "Dynamic Buffer Mode" :
                (bAdaptivePlaybackMode ? "Adaptive Mode" : "Port Reconfig Mode")));

        int32_t push;
        if (msg->findInt32("push-blank-buffers-on-shutdown", &push)
                && push != 0) {