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

Commit 92466dd6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master"

parents b21b5ab7 18343452
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4,3 +4,4 @@ service cameraserver /system/bin/cameraserver
    group audio camera input drmrpc
    ioprio rt 4
    writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks
    rlimit rtprio 10 10
+48 −32
Original line number Diff line number Diff line
@@ -168,14 +168,6 @@ static status_t configureSignals() {
    return NO_ERROR;
}

/*
 * Returns "true" if the device is rotated 90 degrees.
 */
static bool isDeviceRotated(int orientation) {
    return orientation != DISPLAY_ORIENTATION_0 &&
            orientation != DISPLAY_ORIENTATION_180;
}

/*
 * Configures and starts the MediaCodec encoder.  Obtains an input surface
 * from the codec.
@@ -271,22 +263,11 @@ static status_t setDisplayProjection(
        const DisplayInfo& mainDpyInfo) {

    // Set the region of the layer stack we're interested in, which in our
    // case is "all of it".  If the app is rotated (so that the width of the
    // app is based on the height of the display), reverse width/height.
    bool deviceRotated = isDeviceRotated(mainDpyInfo.orientation);
    uint32_t sourceWidth, sourceHeight;
    if (!deviceRotated) {
        sourceWidth = mainDpyInfo.w;
        sourceHeight = mainDpyInfo.h;
    } else {
        ALOGV("using rotated width/height");
        sourceHeight = mainDpyInfo.w;
        sourceWidth = mainDpyInfo.h;
    }
    Rect layerStackRect(sourceWidth, sourceHeight);
    // case is "all of it".
    Rect layerStackRect(mainDpyInfo.w, mainDpyInfo.h);

    // We need to preserve the aspect ratio of the display.
    float displayAspect = (float) sourceHeight / (float) sourceWidth;
    float displayAspect = (float) mainDpyInfo.h / (float) mainDpyInfo.w;


    // Set the way we map the output onto the display surface (which will
@@ -362,6 +343,22 @@ static status_t prepareVirtualDisplay(const DisplayInfo& mainDpyInfo,
    return NO_ERROR;
}

/*
 * Set the main display width and height to the actual width and height
 */
static status_t getActualDisplaySize(const sp<IBinder>& mainDpy, DisplayInfo* mainDpyInfo) {
    Rect viewport;
    status_t err = SurfaceComposerClient::getDisplayViewport(mainDpy, &viewport);
    if (err != NO_ERROR) {
        fprintf(stderr, "ERROR: unable to get display viewport\n");
        return err;
    }
    mainDpyInfo->w = viewport.width();
    mainDpyInfo->h = viewport.height();

    return NO_ERROR;
}

/*
 * Runs the MediaCodec encoder, sending the output to the MediaMuxer.  The
 * input frames are coming from the virtual display as fast as SurfaceFlinger
@@ -432,15 +429,23 @@ static status_t runEncoder(const sp<MediaCodec>& encoder,
                    // useful stuff is hard to get at without a Dalvik VM.
                    err = SurfaceComposerClient::getDisplayInfo(mainDpy,
                            &mainDpyInfo);
                    if (err == NO_ERROR) {
                        err = getActualDisplaySize(mainDpy, &mainDpyInfo);
                        if (err != NO_ERROR) {
                        ALOGW("getDisplayInfo(main) failed: %d", err);
                    } else if (orientation != mainDpyInfo.orientation) {
                            fprintf(stderr, "ERROR: unable to set actual display size\n");
                            return err;
                        }

                        if (orientation != mainDpyInfo.orientation) {
                            ALOGD("orientation changed, now %d", mainDpyInfo.orientation);
                            SurfaceComposerClient::Transaction t;
                            setDisplayProjection(t, virtualDpy, mainDpyInfo);
                            t.apply();
                            orientation = mainDpyInfo.orientation;
                        }
                    } else {
                        ALOGW("getDisplayInfo(main) failed: %d", err);
                    }
                }

                // If the virtual display isn't providing us with timestamps,
@@ -581,6 +586,10 @@ static FILE* prepareRawOutput(const char* fileName) {
    return rawFp;
}

static inline uint32_t floorToEven(uint32_t num) {
    return num & ~1;
}

/*
 * Main "do work" start point.
 *
@@ -608,6 +617,13 @@ static status_t recordScreen(const char* fileName) {
        fprintf(stderr, "ERROR: unable to get display characteristics\n");
        return err;
    }

    err = getActualDisplaySize(mainDpy, &mainDpyInfo);
    if (err != NO_ERROR) {
        fprintf(stderr, "ERROR: unable to set actual display size\n");
        return err;
    }

    if (gVerbose) {
        printf("Main display is %dx%d @%.2ffps (orientation=%u)\n",
                mainDpyInfo.w, mainDpyInfo.h, mainDpyInfo.fps,
@@ -615,12 +631,12 @@ static status_t recordScreen(const char* fileName) {
        fflush(stdout);
    }

    bool rotated = isDeviceRotated(mainDpyInfo.orientation);
    // Encoder can't take odd number as config
    if (gVideoWidth == 0) {
        gVideoWidth = rotated ? mainDpyInfo.h : mainDpyInfo.w;
        gVideoWidth = floorToEven(mainDpyInfo.w);
    }
    if (gVideoHeight == 0) {
        gVideoHeight = rotated ? mainDpyInfo.w : mainDpyInfo.h;
        gVideoHeight = floorToEven(mainDpyInfo.h);
    }

    // Configure and start the encoder.
+13 −11
Original line number Diff line number Diff line
@@ -118,9 +118,9 @@ status_t ClearKeyCasPlugin::openSession(CasSessionId* sessionId) {

status_t ClearKeyCasPlugin::closeSession(const CasSessionId &sessionId) {
    ALOGV("closeSession: sessionId=%s", sessionIdToString(sessionId).string());
    sp<ClearKeyCasSession> session =
    std::shared_ptr<ClearKeyCasSession> session =
            ClearKeySessionLibrary::get()->findSession(sessionId);
    if (session == NULL) {
    if (session.get() == nullptr) {
        return ERROR_CAS_SESSION_NOT_OPENED;
    }

@@ -132,9 +132,9 @@ status_t ClearKeyCasPlugin::setSessionPrivateData(
        const CasSessionId &sessionId, const CasData & /*data*/) {
    ALOGV("setSessionPrivateData: sessionId=%s",
            sessionIdToString(sessionId).string());
    sp<ClearKeyCasSession> session =
    std::shared_ptr<ClearKeyCasSession> session =
            ClearKeySessionLibrary::get()->findSession(sessionId);
    if (session == NULL) {
    if (session.get() == nullptr) {
        return ERROR_CAS_SESSION_NOT_OPENED;
    }
    return OK;
@@ -143,9 +143,9 @@ status_t ClearKeyCasPlugin::setSessionPrivateData(
status_t ClearKeyCasPlugin::processEcm(
        const CasSessionId &sessionId, const CasEcm& ecm) {
    ALOGV("processEcm: sessionId=%s", sessionIdToString(sessionId).string());
    sp<ClearKeyCasSession> session =
    std::shared_ptr<ClearKeyCasSession> session =
            ClearKeySessionLibrary::get()->findSession(sessionId);
    if (session == NULL) {
    if (session.get() == nullptr) {
        return ERROR_CAS_SESSION_NOT_OPENED;
    }

@@ -418,15 +418,15 @@ status_t ClearKeyDescramblerPlugin::setMediaCasSession(
        const CasSessionId &sessionId) {
    ALOGV("setMediaCasSession: sessionId=%s", sessionIdToString(sessionId).string());

    sp<ClearKeyCasSession> session =
    std::shared_ptr<ClearKeyCasSession> session =
            ClearKeySessionLibrary::get()->findSession(sessionId);

    if (session == NULL) {
    if (session.get() == nullptr) {
        ALOGE("ClearKeyDescramblerPlugin: session not found");
        return ERROR_CAS_SESSION_NOT_OPENED;
    }

    mCASSession = session;
    std::atomic_store(&mCASSession, session);
    return OK;
}

@@ -447,12 +447,14 @@ ssize_t ClearKeyDescramblerPlugin::descramble(
          subSamplesToString(subSamples, numSubSamples).string(),
          srcPtr, dstPtr, srcOffset, dstOffset);

    if (mCASSession == NULL) {
    std::shared_ptr<ClearKeyCasSession> session = std::atomic_load(&mCASSession);

    if (session.get() == nullptr) {
        ALOGE("Uninitialized CAS session!");
        return ERROR_CAS_DECRYPT_UNIT_NOT_INITIALIZED;
    }

    return mCASSession->decrypt(
    return session->decrypt(
            secure, scramblingControl,
            numSubSamples, subSamples,
            (uint8_t*)srcPtr + srcOffset,
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public:
            AString *errorDetailMsg) override;

private:
    sp<ClearKeyCasSession> mCASSession;
    std::shared_ptr<ClearKeyCasSession> mCASSession;

    String8 subSamplesToString(
            SubSample const *subSamples,
+4 −4
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ status_t ClearKeySessionLibrary::addSession(

    Mutex::Autolock lock(mSessionsLock);

    sp<ClearKeyCasSession> session = new ClearKeyCasSession(plugin);
    std::shared_ptr<ClearKeyCasSession> session(new ClearKeyCasSession(plugin));

    uint8_t *byteArray = (uint8_t *) &mNextSessionId;
    sessionId->push_back(byteArray[3]);
@@ -69,7 +69,7 @@ status_t ClearKeySessionLibrary::addSession(
    return OK;
}

sp<ClearKeyCasSession> ClearKeySessionLibrary::findSession(
std::shared_ptr<ClearKeyCasSession> ClearKeySessionLibrary::findSession(
        const CasSessionId& sessionId) {
    Mutex::Autolock lock(mSessionsLock);

@@ -88,7 +88,7 @@ void ClearKeySessionLibrary::destroySession(const CasSessionId& sessionId) {
        return;
    }

    sp<ClearKeyCasSession> session = mIDToSessionMap.valueAt(index);
    std::shared_ptr<ClearKeyCasSession> session = mIDToSessionMap.valueAt(index);
    mIDToSessionMap.removeItemsAt(index);
}

@@ -96,7 +96,7 @@ void ClearKeySessionLibrary::destroyPlugin(CasPlugin *plugin) {
    Mutex::Autolock lock(mSessionsLock);

    for (ssize_t index = (ssize_t)mIDToSessionMap.size() - 1; index >= 0; index--) {
        sp<ClearKeyCasSession> session = mIDToSessionMap.valueAt(index);
        std::shared_ptr<ClearKeyCasSession> session = mIDToSessionMap.valueAt(index);
        if (session->getPlugin() == plugin) {
            mIDToSessionMap.removeItemsAt(index);
        }
Loading