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

Commit b382340f authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "handle rotation in NuPlayer" into lmp-dev

parents d089a740 e9e63bcf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ private:

    int32_t mEncoderDelay;
    int32_t mEncoderPadding;
    int32_t mRotationDegrees;

    bool mChannelMaskPresent;
    int32_t mChannelMask;
+17 −2
Original line number Diff line number Diff line
@@ -860,8 +860,23 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                              displayWidth, displayHeight);
                    }

                    int32_t rotationDegrees;
                    if (!videoInputFormat->findInt32(
                            "rotation-degrees", &rotationDegrees)) {
                        rotationDegrees = 0;
                    }

                    if (rotationDegrees == 90 || rotationDegrees == 270) {
                        notifyListener(
                            MEDIA_SET_VIDEO_SIZE, displayWidth, displayHeight);
                                MEDIA_SET_VIDEO_SIZE,
                                displayHeight,
                                displayWidth);
                    } else {
                        notifyListener(
                                MEDIA_SET_VIDEO_SIZE,
                                displayWidth,
                                displayHeight);
                    }
                }
            } else if (what == Decoder::kWhatShutdownCompleted) {
                ALOGV("%s shutdown completed", audio ? "audio" : "video");
+29 −0
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@ ACodec::ACodec()
      mExplicitShutdown(false),
      mEncoderDelay(0),
      mEncoderPadding(0),
      mRotationDegrees(0),
      mChannelMaskPresent(false),
      mChannelMask(0),
      mDequeueCounter(0),
@@ -591,6 +592,27 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
        return err;
    }

    if (mRotationDegrees != 0) {
        uint32_t transform = 0;
        switch (mRotationDegrees) {
            case 0: transform = 0; break;
            case 90: transform = HAL_TRANSFORM_ROT_90; break;
            case 180: transform = HAL_TRANSFORM_ROT_180; break;
            case 270: transform = HAL_TRANSFORM_ROT_270; break;
            default: transform = 0; break;
        }

        if (transform > 0) {
            err = native_window_set_buffers_transform(
                    mNativeWindow.get(), transform);
            if (err != 0) {
                ALOGE("native_window_set_buffers_transform failed: %s (%d)",
                        strerror(-err), -err);
                return err;
            }
        }
    }

    // Set up the native window.
    OMX_U32 usage = 0;
    err = mOMX->getGraphicBufferUsage(mNode, kPortIndexOutput, &usage);
@@ -1232,6 +1254,13 @@ status_t ACodec::configureCodec(
                && push != 0) {
            mFlags |= kFlagPushBlankBuffersToNativeWindowOnShutdown;
        }

        int32_t rotationDegrees;
        if (msg->findInt32("rotation-degrees", &rotationDegrees)) {
            mRotationDegrees = rotationDegrees;
        } else {
            mRotationDegrees = 0;
        }
    }

    if (video) {
+5 −0
Original line number Diff line number Diff line
@@ -142,6 +142,11 @@ status_t convertMetaDataToMessage(
        msg->setInt32("max-input-size", maxInputSize);
    }

    int32_t rotationDegrees;
    if (meta->findInt32(kKeyRotation, &rotationDegrees)) {
        msg->setInt32("rotation-degrees", rotationDegrees);
    }

    uint32_t type;
    const void *data;
    size_t size;