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

Commit e09e9661 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Throw IAE when crypto or descrambler is not given for secure codec" into oc-dev

parents a6263336 aaa5e640
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1039,7 +1039,10 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
        array[i] = {mBuffers[portIndex][i].mData, mBuffers[portIndex][i].mBufferID};
    }
    if (portIndex == kPortIndexInput) {
        mBufferChannel->setInputBufferArray(array);
        err = mBufferChannel->setInputBufferArray(array);
        if (err != OK) {
            return err;
        }
    } else if (portIndex == kPortIndexOutput) {
        mBufferChannel->setOutputBufferArray(array);
    } else {
+5 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ sp<MemoryDealer> ACodecBufferChannel::makeMemoryDealer(size_t heapSize) {
    return dealer;
}

void ACodecBufferChannel::setInputBufferArray(const std::vector<BufferAndId> &array) {
status_t ACodecBufferChannel::setInputBufferArray(const std::vector<BufferAndId> &array) {
    if (hasCryptoOrDescrambler()) {
        size_t totalSize = std::accumulate(
                array.begin(), array.end(), 0u,
@@ -311,11 +311,15 @@ void ACodecBufferChannel::setInputBufferArray(const std::vector<BufferAndId> &ar
        if (hasCryptoOrDescrambler()) {
            sharedEncryptedBuffer = mDealer->allocate(elem.mBuffer->capacity());
        }
        if (elem.mBuffer->data() == NULL && sharedEncryptedBuffer == NULL) {
            return BAD_VALUE;
        }
        inputBuffers.emplace_back(elem.mBuffer, elem.mBufferId, sharedEncryptedBuffer);
    }
    std::atomic_store(
            &mInputBuffers,
            std::make_shared<const std::vector<const BufferInfo>>(inputBuffers));
    return OK;
}

void ACodecBufferChannel::setOutputBufferArray(const std::vector<BufferAndId> &array) {
+3 −0
Original line number Diff line number Diff line
@@ -734,6 +734,9 @@ status_t MediaCodec::configure(
            // XXX: save indication that it's crypto in some way...
            mAnalyticsItem->setInt32(kCodecCrypto, 1);
        }
    } else if (mFlags & kFlagIsSecure) {
        ALOGE("Crypto or descrambler should be given for secure codec");
        return BAD_VALUE;
    }

    // save msg for reset
+2 −1
Original line number Diff line number Diff line
@@ -87,8 +87,9 @@ public:
     *
     * @param array     Newly allocated buffers. Empty if buffers are
     *                  deallocated.
     * @return OK if no error.
     */
    void setInputBufferArray(const std::vector<BufferAndId> &array);
    status_t setInputBufferArray(const std::vector<BufferAndId> &array);
    /**
     * Set output buffer array.
     *