Loading drm/libmediadrm/CryptoHal.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -228,11 +228,11 @@ bool CryptoHal::requiresSecureDecoderComponent(const char *mime) const { void CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) { native_handle_t* nativeHandle = native_handle_create(1, 0); if (!nativeHandle) { ALOGE("setSharedBufferBase(), failed to create native handle"); ALOGE("setHeapBase(), failed to create native handle"); return; } if (heap == NULL) { ALOGE("setSharedBufferBase(): heap is NULL"); ALOGE("setHeapBase(): heap is NULL"); return; } int fd = heap->getHeapID(); Loading @@ -244,6 +244,10 @@ void CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) { ALOGE_IF(!hResult.isOk(), "setSharedBufferBase(): remote call failed"); } void CryptoHal::clearHeapBase(const sp<IMemoryHeap>& heap) { mHeapBases.removeItem(heap->getBase()); } status_t CryptoHal::toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer) { ssize_t offset; size_t size; Loading @@ -257,9 +261,8 @@ status_t CryptoHal::toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* bu return UNEXPECTED_NULL; } if (mHeapBases.indexOfKey(heap->getBase()) < 0) { setHeapBase(heap); } // memory must be in the declared heap CHECK(mHeapBases.indexOfKey(heap->getBase()) >= 0); buffer->bufferId = mHeapBases.valueFor(heap->getBase()); buffer->offset = offset >= 0 ? offset : 0; Loading drm/libmediadrm/ICrypto.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ enum { DECRYPT, NOTIFY_RESOLUTION, SET_MEDIADRM_SESSION, SET_HEAP, UNSET_HEAP, }; struct BpCrypto : public BpInterface<ICrypto> { Loading Loading @@ -177,6 +179,23 @@ struct BpCrypto : public BpInterface<ICrypto> { return reply.readInt32(); } virtual void setHeap(const sp<IMemoryHeap> &heap) { Parcel data, reply; data.writeInterfaceToken(ICrypto::getInterfaceDescriptor()); data.writeStrongBinder(IInterface::asBinder(heap)); remote()->transact(SET_HEAP, data, &reply); return; } virtual void unsetHeap(const sp<IMemoryHeap>& heap) { Parcel data, reply; data.writeInterfaceToken(ICrypto::getInterfaceDescriptor()); data.writeStrongBinder(IInterface::asBinder(heap)); remote()->transact(UNSET_HEAP, data, &reply); return; } private: void readVector(Parcel &reply, Vector<uint8_t> &vector) const { uint32_t size = reply.readInt32(); Loading Loading @@ -404,6 +423,24 @@ status_t BnCrypto::onTransact( return OK; } case SET_HEAP: { CHECK_INTERFACE(ICrypto, data, reply); sp<IMemoryHeap> heap = interface_cast<IMemoryHeap>(data.readStrongBinder()); setHeap(heap); return OK; } case UNSET_HEAP: { CHECK_INTERFACE(ICrypto, data, reply); sp<IMemoryHeap> heap = interface_cast<IMemoryHeap>(data.readStrongBinder()); unsetHeap(heap); return OK; } default: return BBinder::onTransact(code, data, reply, flags); } Loading media/libmedia/include/Crypto.h +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ struct Crypto : public BnCrypto { const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const DestinationBuffer &destination, AString *errorDetailMsg); virtual void setHeap(const sp<IMemoryHeap>&) {} virtual void unsetHeap(const sp<IMemoryHeap>&) {} private: mutable Mutex mLock; Loading media/libmedia/include/CryptoHal.h +4 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ struct CryptoHal : public BnCrypto { const ICrypto::DestinationBuffer &destination, AString *errorDetailMsg); virtual void setHeap(const sp<IMemoryHeap>& heap) { setHeapBase(heap); } virtual void unsetHeap(const sp<IMemoryHeap>& heap) { clearHeapBase(heap); } private: mutable Mutex mLock; Loading @@ -82,6 +85,7 @@ private: const uint8_t uuid[16], const void *initData, size_t size); void setHeapBase(const sp<IMemoryHeap>& heap); void clearHeapBase(const sp<IMemoryHeap>& heap); status_t toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer); Loading media/libmedia/include/ICrypto.h +8 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { struct AString; class IMemory; class IMemoryHeap; struct ICrypto : public IInterface { DECLARE_META_INTERFACE(Crypto); Loading Loading @@ -64,6 +65,13 @@ struct ICrypto : public IInterface { const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const DestinationBuffer &destination, AString *errorDetailMsg) = 0; /** * Declare the heap that the shared memory source buffers passed * to decrypt will be allocated from. */ virtual void setHeap(const sp<IMemoryHeap>& heap) = 0; virtual void unsetHeap(const sp<IMemoryHeap>& heap) = 0; private: DISALLOW_EVIL_CONSTRUCTORS(ICrypto); }; Loading Loading
drm/libmediadrm/CryptoHal.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -228,11 +228,11 @@ bool CryptoHal::requiresSecureDecoderComponent(const char *mime) const { void CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) { native_handle_t* nativeHandle = native_handle_create(1, 0); if (!nativeHandle) { ALOGE("setSharedBufferBase(), failed to create native handle"); ALOGE("setHeapBase(), failed to create native handle"); return; } if (heap == NULL) { ALOGE("setSharedBufferBase(): heap is NULL"); ALOGE("setHeapBase(): heap is NULL"); return; } int fd = heap->getHeapID(); Loading @@ -244,6 +244,10 @@ void CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) { ALOGE_IF(!hResult.isOk(), "setSharedBufferBase(): remote call failed"); } void CryptoHal::clearHeapBase(const sp<IMemoryHeap>& heap) { mHeapBases.removeItem(heap->getBase()); } status_t CryptoHal::toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer) { ssize_t offset; size_t size; Loading @@ -257,9 +261,8 @@ status_t CryptoHal::toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* bu return UNEXPECTED_NULL; } if (mHeapBases.indexOfKey(heap->getBase()) < 0) { setHeapBase(heap); } // memory must be in the declared heap CHECK(mHeapBases.indexOfKey(heap->getBase()) >= 0); buffer->bufferId = mHeapBases.valueFor(heap->getBase()); buffer->offset = offset >= 0 ? offset : 0; Loading
drm/libmediadrm/ICrypto.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ enum { DECRYPT, NOTIFY_RESOLUTION, SET_MEDIADRM_SESSION, SET_HEAP, UNSET_HEAP, }; struct BpCrypto : public BpInterface<ICrypto> { Loading Loading @@ -177,6 +179,23 @@ struct BpCrypto : public BpInterface<ICrypto> { return reply.readInt32(); } virtual void setHeap(const sp<IMemoryHeap> &heap) { Parcel data, reply; data.writeInterfaceToken(ICrypto::getInterfaceDescriptor()); data.writeStrongBinder(IInterface::asBinder(heap)); remote()->transact(SET_HEAP, data, &reply); return; } virtual void unsetHeap(const sp<IMemoryHeap>& heap) { Parcel data, reply; data.writeInterfaceToken(ICrypto::getInterfaceDescriptor()); data.writeStrongBinder(IInterface::asBinder(heap)); remote()->transact(UNSET_HEAP, data, &reply); return; } private: void readVector(Parcel &reply, Vector<uint8_t> &vector) const { uint32_t size = reply.readInt32(); Loading Loading @@ -404,6 +423,24 @@ status_t BnCrypto::onTransact( return OK; } case SET_HEAP: { CHECK_INTERFACE(ICrypto, data, reply); sp<IMemoryHeap> heap = interface_cast<IMemoryHeap>(data.readStrongBinder()); setHeap(heap); return OK; } case UNSET_HEAP: { CHECK_INTERFACE(ICrypto, data, reply); sp<IMemoryHeap> heap = interface_cast<IMemoryHeap>(data.readStrongBinder()); unsetHeap(heap); return OK; } default: return BBinder::onTransact(code, data, reply, flags); } Loading
media/libmedia/include/Crypto.h +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ struct Crypto : public BnCrypto { const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const DestinationBuffer &destination, AString *errorDetailMsg); virtual void setHeap(const sp<IMemoryHeap>&) {} virtual void unsetHeap(const sp<IMemoryHeap>&) {} private: mutable Mutex mLock; Loading
media/libmedia/include/CryptoHal.h +4 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ struct CryptoHal : public BnCrypto { const ICrypto::DestinationBuffer &destination, AString *errorDetailMsg); virtual void setHeap(const sp<IMemoryHeap>& heap) { setHeapBase(heap); } virtual void unsetHeap(const sp<IMemoryHeap>& heap) { clearHeapBase(heap); } private: mutable Mutex mLock; Loading @@ -82,6 +85,7 @@ private: const uint8_t uuid[16], const void *initData, size_t size); void setHeapBase(const sp<IMemoryHeap>& heap); void clearHeapBase(const sp<IMemoryHeap>& heap); status_t toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer); Loading
media/libmedia/include/ICrypto.h +8 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { struct AString; class IMemory; class IMemoryHeap; struct ICrypto : public IInterface { DECLARE_META_INTERFACE(Crypto); Loading Loading @@ -64,6 +65,13 @@ struct ICrypto : public IInterface { const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const DestinationBuffer &destination, AString *errorDetailMsg) = 0; /** * Declare the heap that the shared memory source buffers passed * to decrypt will be allocated from. */ virtual void setHeap(const sp<IMemoryHeap>& heap) = 0; virtual void unsetHeap(const sp<IMemoryHeap>& heap) = 0; private: DISALLOW_EVIL_CONSTRUCTORS(ICrypto); }; Loading