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

Commit f9656ff1 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Remove DrmInitialization from IDataSource

DrmInitialization only needs to be called on PlayerServiceFileSource
and PlayerServiceMediaHTTP, so just have those initialize the forward
lock engine automatically, which removes the need to have this in the
IDataSource interface.

Test: atest cts/tests/tests/drm/src/android/drm/cts/DRMTest.java

Change-Id: I344f46b65b5c473930b16b9b4041e4897384dc18
parent 7e5e530d
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -689,10 +689,6 @@ void NuCachedSource2::resumeFetchingIfNecessary() {
    restartPrefetcherIfNecessary_l(true /* ignore low water threshold */);
}

sp<DecryptHandle> NuCachedSource2::DrmInitialization(const char* mime) {
    return mSource->DrmInitialization(mime);
}

String8 NuCachedSource2::getUri() {
    return mSource->getUri();
}
+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ struct NuCachedSource2 : public DataSource {
    virtual status_t getSize(off64_t *size);
    virtual uint32_t flags();

    virtual sp<DecryptHandle> DrmInitialization(const char* mime);
    virtual String8 getUri();

    virtual String8 getMIMEType() const;
+0 −3
Original line number Diff line number Diff line
@@ -83,9 +83,6 @@ public:
    void close() {}
    uint32_t getFlags() override { return 0; }
    String8 toString() override { return String8("HeifDataSource"); }
    sp<DecryptHandle> DrmInitialization(const char*) override {
        return nullptr;
    }

private:
    enum {
+0 −79
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@

#include <binder/IMemory.h>
#include <binder/Parcel.h>
#include <drm/drm_framework_common.h>
#include <media/stagefright/foundation/ADebug.h>

namespace android {
@@ -35,7 +34,6 @@ enum {
    CLOSE,
    GET_FLAGS,
    TO_STRING,
    DRM_INITIALIZATION,
};

struct BpDataSource : public BpInterface<IDataSource> {
@@ -95,47 +93,6 @@ struct BpDataSource : public BpInterface<IDataSource> {
        remote()->transact(TO_STRING, data, &reply);
        return reply.readString8();
    }

    virtual sp<DecryptHandle> DrmInitialization(const char *mime) {
        Parcel data, reply;
        data.writeInterfaceToken(IDataSource::getInterfaceDescriptor());
        if (mime == NULL) {
            data.writeInt32(0);
        } else {
            data.writeInt32(1);
            data.writeCString(mime);
        }
        remote()->transact(DRM_INITIALIZATION, data, &reply);
        sp<DecryptHandle> handle;
        if (reply.dataAvail() != 0) {
            handle = new DecryptHandle();
            handle->decryptId = reply.readInt32();
            handle->mimeType = reply.readString8();
            handle->decryptApiType = reply.readInt32();
            handle->status = reply.readInt32();

            const int bufferLength = data.readInt32();
            if (bufferLength != -1) {
                handle->decryptInfo = new DecryptInfo();
                handle->decryptInfo->decryptBufferLength = bufferLength;
            }

            size_t size = data.readInt32();
            for (size_t i = 0; i < size; ++i) {
                DrmCopyControl key = (DrmCopyControl)data.readInt32();
                int value = data.readInt32();
                handle->copyControlVector.add(key, value);
            }

            size = data.readInt32();
            for (size_t i = 0; i < size; ++i) {
                String8 key = data.readString8();
                String8 value = data.readString8();
                handle->extendedData.add(key, value);
            }
        }
        return handle;
    }
};

IMPLEMENT_META_INTERFACE(DataSource, "android.media.IDataSource");
@@ -178,42 +135,6 @@ status_t BnDataSource::onTransact(
            reply->writeString8(toString());
            return NO_ERROR;
        } break;
        case DRM_INITIALIZATION: {
            CHECK_INTERFACE(IDataSource, data, reply);
            const char *mime = NULL;
            const int32_t flag = data.readInt32();
            if (flag != 0) {
                mime = data.readCString();
            }
            sp<DecryptHandle> handle = DrmInitialization(mime);
            if (handle != NULL) {
                reply->writeInt32(handle->decryptId);
                reply->writeString8(handle->mimeType);
                reply->writeInt32(handle->decryptApiType);
                reply->writeInt32(handle->status);

                if (handle->decryptInfo != NULL) {
                    reply->writeInt32(handle->decryptInfo->decryptBufferLength);
                } else {
                    reply->writeInt32(-1);
                }

                size_t size = handle->copyControlVector.size();
                reply->writeInt32(size);
                for (size_t i = 0; i < size; ++i) {
                    reply->writeInt32(handle->copyControlVector.keyAt(i));
                    reply->writeInt32(handle->copyControlVector.valueAt(i));
                }

                size = handle->extendedData.size();
                reply->writeInt32(size);
                for (size_t i = 0; i < size; ++i) {
                    reply->writeString8(handle->extendedData.keyAt(i));
                    reply->writeString8(handle->extendedData.valueAt(i));
                }
            }
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
+0 −2
Original line number Diff line number Diff line
@@ -50,8 +50,6 @@ public:
    virtual uint32_t getFlags() = 0;
    // get a description of the source, e.g. the url or filename it is based on
    virtual String8 toString() = 0;
    // Initialize DRM and return a DecryptHandle.
    virtual sp<DecryptHandle> DrmInitialization(const char *mime) = 0;

private:
    DISALLOW_EVIL_CONSTRUCTORS(IDataSource);
Loading