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
Merged-In: I344f46b65b5c473930b16b9b4041e4897384dc18
gugelfrei
Marco Nelissen 5 years ago
parent 0501baaa03
commit 19b0be6e8b

@ -689,10 +689,6 @@ void NuCachedSource2::resumeFetchingIfNecessary() {
restartPrefetcherIfNecessary_l(true /* ignore low water threshold */); restartPrefetcherIfNecessary_l(true /* ignore low water threshold */);
} }
sp<DecryptHandle> NuCachedSource2::DrmInitialization(const char* mime) {
return mSource->DrmInitialization(mime);
}
String8 NuCachedSource2::getUri() { String8 NuCachedSource2::getUri() {
return mSource->getUri(); return mSource->getUri();
} }

@ -44,7 +44,6 @@ struct NuCachedSource2 : public DataSource {
virtual status_t getSize(off64_t *size); virtual status_t getSize(off64_t *size);
virtual uint32_t flags(); virtual uint32_t flags();
virtual sp<DecryptHandle> DrmInitialization(const char* mime);
virtual String8 getUri(); virtual String8 getUri();
virtual String8 getMIMEType() const; virtual String8 getMIMEType() const;

@ -66,9 +66,6 @@ public:
void close() {} void close() {}
uint32_t getFlags() override { return 0; } uint32_t getFlags() override { return 0; }
String8 toString() override { return String8("HeifDataSource"); } String8 toString() override { return String8("HeifDataSource"); }
sp<DecryptHandle> DrmInitialization(const char*) override {
return nullptr;
}
private: private:
enum { enum {

@ -23,7 +23,6 @@
#include <binder/IMemory.h> #include <binder/IMemory.h>
#include <binder/Parcel.h> #include <binder/Parcel.h>
#include <drm/drm_framework_common.h>
#include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ADebug.h>
namespace android { namespace android {
@ -35,7 +34,6 @@ enum {
CLOSE, CLOSE,
GET_FLAGS, GET_FLAGS,
TO_STRING, TO_STRING,
DRM_INITIALIZATION,
}; };
struct BpDataSource : public BpInterface<IDataSource> { struct BpDataSource : public BpInterface<IDataSource> {
@ -95,47 +93,6 @@ struct BpDataSource : public BpInterface<IDataSource> {
remote()->transact(TO_STRING, data, &reply); remote()->transact(TO_STRING, data, &reply);
return reply.readString8(); 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"); IMPLEMENT_META_INTERFACE(DataSource, "android.media.IDataSource");
@ -178,42 +135,6 @@ status_t BnDataSource::onTransact(
reply->writeString8(toString()); reply->writeString8(toString());
return NO_ERROR; return NO_ERROR;
} break; } 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: default:
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);

@ -50,8 +50,6 @@ public:
virtual uint32_t getFlags() = 0; virtual uint32_t getFlags() = 0;
// get a description of the source, e.g. the url or filename it is based on // get a description of the source, e.g. the url or filename it is based on
virtual String8 toString() = 0; virtual String8 toString() = 0;
// Initialize DRM and return a DecryptHandle.
virtual sp<DecryptHandle> DrmInitialization(const char *mime) = 0;
private: private:
DISALLOW_EVIL_CONSTRUCTORS(IDataSource); DISALLOW_EVIL_CONSTRUCTORS(IDataSource);

@ -31,6 +31,7 @@ PlayerServiceFileSource::PlayerServiceFileSource(const char *filename)
mDrmBufOffset(0), mDrmBufOffset(0),
mDrmBufSize(0), mDrmBufSize(0),
mDrmBuf(NULL){ mDrmBuf(NULL){
(void) DrmInitialization(nullptr);
} }
PlayerServiceFileSource::PlayerServiceFileSource(int fd, int64_t offset, int64_t length) PlayerServiceFileSource::PlayerServiceFileSource(int fd, int64_t offset, int64_t length)
@ -40,6 +41,7 @@ PlayerServiceFileSource::PlayerServiceFileSource(int fd, int64_t offset, int64_t
mDrmBufOffset(0), mDrmBufOffset(0),
mDrmBufSize(0), mDrmBufSize(0),
mDrmBuf(NULL) { mDrmBuf(NULL) {
(void) DrmInitialization(nullptr);
} }
PlayerServiceFileSource::~PlayerServiceFileSource() { PlayerServiceFileSource::~PlayerServiceFileSource() {
@ -87,7 +89,9 @@ ssize_t PlayerServiceFileSource::readAt(off64_t offset, void *data, size_t size)
} }
sp<DecryptHandle> PlayerServiceFileSource::DrmInitialization(const char *mime) { sp<DecryptHandle> PlayerServiceFileSource::DrmInitialization(const char *mime) {
if (getuid() == AID_MEDIA_EX) return nullptr; // no DRM in media extractor if (getuid() == AID_MEDIA_EX) {
return NULL; // no DRM in media extractor
}
if (mDrmManagerClient == NULL) { if (mDrmManagerClient == NULL) {
mDrmManagerClient = new DrmManagerClient(); mDrmManagerClient = new DrmManagerClient();
} }

@ -32,6 +32,7 @@ namespace android {
PlayerServiceMediaHTTP::PlayerServiceMediaHTTP(const sp<MediaHTTPConnection> &conn) PlayerServiceMediaHTTP::PlayerServiceMediaHTTP(const sp<MediaHTTPConnection> &conn)
: MediaHTTP(conn), : MediaHTTP(conn),
mDrmManagerClient(NULL) { mDrmManagerClient(NULL) {
(void) DrmInitialization(nullptr);
} }
PlayerServiceMediaHTTP::~PlayerServiceMediaHTTP() { PlayerServiceMediaHTTP::~PlayerServiceMediaHTTP() {
@ -40,7 +41,7 @@ PlayerServiceMediaHTTP::~PlayerServiceMediaHTTP() {
// DRM... // DRM...
sp<DecryptHandle> PlayerServiceMediaHTTP::DrmInitialization(const char* mime) { sp<DecryptHandle> PlayerServiceMediaHTTP::DrmInitialization(const char *mime) {
if (mDrmManagerClient == NULL) { if (mDrmManagerClient == NULL) {
mDrmManagerClient = new DrmManagerClient(); mDrmManagerClient = new DrmManagerClient();
} }

@ -37,8 +37,6 @@ public:
virtual ssize_t readAt(off64_t offset, void *data, size_t size); virtual ssize_t readAt(off64_t offset, void *data, size_t size);
virtual sp<DecryptHandle> DrmInitialization(const char *mime);
static bool requiresDrm(int fd, int64_t offset, int64_t length, const char *mime); static bool requiresDrm(int fd, int64_t offset, int64_t length, const char *mime);
protected: protected:
@ -52,6 +50,7 @@ private:
ssize_t mDrmBufSize; ssize_t mDrmBufSize;
unsigned char *mDrmBuf; unsigned char *mDrmBuf;
sp<DecryptHandle> DrmInitialization(const char *mime);
ssize_t readAtDRM_l(off64_t offset, void *data, size_t size); ssize_t readAtDRM_l(off64_t offset, void *data, size_t size);
PlayerServiceFileSource(const PlayerServiceFileSource &); PlayerServiceFileSource(const PlayerServiceFileSource &);

@ -33,12 +33,11 @@ struct PlayerServiceMediaHTTP : public MediaHTTP {
protected: protected:
virtual ~PlayerServiceMediaHTTP(); virtual ~PlayerServiceMediaHTTP();
virtual sp<DecryptHandle> DrmInitialization(const char* mime);
private: private:
sp<DecryptHandle> mDecryptHandle; sp<DecryptHandle> mDecryptHandle;
DrmManagerClient *mDrmManagerClient; DrmManagerClient *mDrmManagerClient;
sp<DecryptHandle> DrmInitialization(const char *mime);
void clearDRMState_l(); void clearDRMState_l();
DISALLOW_EVIL_CONSTRUCTORS(PlayerServiceMediaHTTP); DISALLOW_EVIL_CONSTRUCTORS(PlayerServiceMediaHTTP);

@ -113,10 +113,6 @@ void CallbackDataSource::close() {
} }
} }
sp<DecryptHandle> CallbackDataSource::DrmInitialization(const char *mime) {
return mIDataSource->DrmInitialization(mime);
}
sp<IDataSource> CallbackDataSource::getIDataSource() const { sp<IDataSource> CallbackDataSource::getIDataSource() const {
return mIDataSource; return mIDataSource;
} }
@ -190,14 +186,6 @@ uint32_t TinyCacheSource::flags() {
return mSource->flags(); return mSource->flags();
} }
sp<DecryptHandle> TinyCacheSource::DrmInitialization(const char *mime) {
// flush cache when DrmInitialization occurs since decrypted
// data may differ from what is in cache.
mCachedOffset = 0;
mCachedSize = 0;
return mSource->DrmInitialization(mime);
}
sp<IDataSource> TinyCacheSource::getIDataSource() const { sp<IDataSource> TinyCacheSource::getIDataSource() const {
return mSource->getIDataSource(); return mSource->getIDataSource();
} }

@ -71,9 +71,6 @@ sp<IMediaExtractor> MediaExtractorFactory::CreateFromService(
ALOGV("MediaExtractorFactory::CreateFromService %s", mime); ALOGV("MediaExtractorFactory::CreateFromService %s", mime);
// initialize source decryption if needed
source->DrmInitialization(nullptr /* mime */);
void *meta = nullptr; void *meta = nullptr;
void *creator = NULL; void *creator = NULL;
FreeMetaFunc freeMeta = nullptr; FreeMetaFunc freeMeta = nullptr;

@ -41,7 +41,6 @@ public:
virtual String8 toString() { virtual String8 toString() {
return mName; return mName;
} }
virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL);
virtual sp<IDataSource> getIDataSource() const; virtual sp<IDataSource> getIDataSource() const;
private: private:
@ -70,7 +69,6 @@ public:
virtual String8 toString() { virtual String8 toString() {
return mName; return mName;
} }
virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL);
virtual sp<IDataSource> getIDataSource() const; virtual sp<IDataSource> getIDataSource() const;
private: private:

@ -54,10 +54,6 @@ struct ThrottledSource : public DataSource {
return mSource->reconnectAtOffset(offset); return mSource->reconnectAtOffset(offset);
} }
virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) {
return mSource->DrmInitialization(mime);
}
virtual String8 getMIMEType() const { virtual String8 getMIMEType() const {
return mSource->getMIMEType(); return mSource->getMIMEType();
} }

@ -52,11 +52,6 @@ public:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// for DRM
virtual sp<DecryptHandle> DrmInitialization(const char * /*mime*/ = NULL) {
return NULL;
}
virtual String8 getUri() { virtual String8 getUri() {
return String8(); return String8();
} }

@ -66,9 +66,6 @@ public:
virtual String8 toString() { virtual String8 toString() {
return mName; return mName;
} }
virtual sp<DecryptHandle> DrmInitialization(const char *mime) {
return mSource->DrmInitialization(mime);
}
private: private:
enum { enum {

Loading…
Cancel
Save