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

Commit d4726a83 authored by Kei Takahashi's avatar Kei Takahashi
Browse files

Add a new API on DRM Framework for streaming

In case of DRM streaming, decrypt session can start just after
receiving the header, and it doesn't need to wait for the entire
content. However, current API of DRM framework only accepts file
handle or URI. With this new API, DRM session can start
without waiting for the entire content.

Changes are made by SEMC and Sony.

Change-Id: I74375fe127df636067f1c300ea91654ba3d1aa3c
parent 67cf093d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -129,6 +129,11 @@ status_t DrmEngineBase::openDecryptSession(
    return onOpenDecryptSession(uniqueId, decryptHandle, uri);
}

status_t DrmEngineBase::openDecryptSession(int uniqueId, DecryptHandle* decryptHandle,
        const DrmBuffer& buf, const String8& mimeType) {
    return onOpenDecryptSession(uniqueId, decryptHandle, buf, mimeType);
}

status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    return onCloseDecryptSession(uniqueId, decryptHandle);
}
+51 −0
Original line number Diff line number Diff line
@@ -640,6 +640,33 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char*
    return handle;
}

DecryptHandle* BpDrmManagerService::openDecryptSession(
            int uniqueId, const DrmBuffer& buf, const String8& mimeType) {
    ALOGV("Entering BpDrmManagerService::openDecryptSession");
    Parcel data, reply;

    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
    data.writeInt32(uniqueId);
    if (buf.data != NULL && buf.length > 0) {
        data.writeInt32(buf.length);
        data.write(buf.data, buf.length);
    } else {
        data.writeInt32(0);
    }
    data.writeString8(mimeType);

    remote()->transact(OPEN_DECRYPT_SESSION_FOR_STREAMING, data, &reply);

    DecryptHandle* handle = NULL;
    if (0 != reply.dataAvail()) {
        handle = new DecryptHandle();
        readDecryptHandleFromParcelData(handle, reply);
    } else {
        ALOGV("no decryptHandle is generated in service side");
    }
    return handle;
}

status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    ALOGV("closeDecryptSession");
    Parcel data, reply;
@@ -1297,6 +1324,30 @@ status_t BnDrmManagerService::onTransact(
        return DRM_NO_ERROR;
    }

    case OPEN_DECRYPT_SESSION_FOR_STREAMING:
    {
        ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FOR_STREAMING");
        CHECK_INTERFACE(IDrmManagerService, data, reply);

        const int uniqueId = data.readInt32();
        const int bufferSize = data.readInt32();
        DrmBuffer buf((bufferSize > 0) ? (char *)data.readInplace(bufferSize) : NULL,
                bufferSize);
        const String8 mimeType(data.readString8());

        DecryptHandle* handle = openDecryptSession(uniqueId, buf, mimeType);

        if (handle != NULL) {
            writeDecryptHandleToParcelData(handle, reply);
            clearDecryptHandle(handle);
            delete handle;
            handle = NULL;
        } else {
            ALOGV("NULL decryptHandle is returned");
        }
        return DRM_NO_ERROR;
    }

    case CLOSE_DECRYPT_SESSION:
    {
        ALOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION");
+30 −0
Original line number Diff line number Diff line
@@ -481,6 +481,36 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
    return handle;
}

DecryptHandle* DrmManager::openDecryptSession(
        int uniqueId, const DrmBuffer& buf, const String8& mimeType) {
    Mutex::Autolock _l(mDecryptLock);
    status_t result = DRM_ERROR_CANNOT_HANDLE;
    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();

    DecryptHandle* handle = new DecryptHandle();
    if (NULL != handle) {
        handle->decryptId = mDecryptSessionId + 1;

        for (size_t index = 0; index < plugInIdList.size(); index++) {
            String8 plugInId = plugInIdList.itemAt(index);
            IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
            result = rDrmEngine.openDecryptSession(uniqueId, handle, buf, mimeType);

            if (DRM_NO_ERROR == result) {
                ++mDecryptSessionId;
                mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
                break;
            }
        }
    }
    if (DRM_NO_ERROR != result) {
        delete handle;
        handle = NULL;
        ALOGV("DrmManager::openDecryptSession: no capable plug-in found");
    }
    return handle;
}

status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    Mutex::Autolock _l(mDecryptLock);
    status_t result = DRM_ERROR_UNKNOWN;
+10 −0
Original line number Diff line number Diff line
@@ -227,6 +227,16 @@ DecryptHandle* DrmManagerService::openDecryptSession(
    return NULL;
}

DecryptHandle* DrmManagerService::openDecryptSession(
            int uniqueId, const DrmBuffer& buf, const String8& mimeType) {
    ALOGV("Entering DrmManagerService::openDecryptSession for streaming");
    if (isProtectedCallAllowed()) {
        return mDrmManager->openDecryptSession(uniqueId, buf, mimeType);
    }

    return NULL;
}

status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    ALOGV("Entering closeDecryptSession");
    return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
+5 −0
Original line number Diff line number Diff line
@@ -124,6 +124,11 @@ sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) {
    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
}

sp<DecryptHandle> DrmManagerClient::openDecryptSession(
            const DrmBuffer& buf, const String8& mimeType) {
    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, buf, mimeType);
}

status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
    return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
}
Loading