Add a method to associate MediaDrm session with MediaCrypto
Previously, to associate a MediaDrm session with MediaCrypto,
the MediaDrm sessionId was passed as initData to the MediaCrypto
constructor. This is not ideal for two reasons: it's pretty
obscure and you can't change the association without tearing
down the MediaCodec/MediaCrypto and starting all over. Use
cases like key rotation require being able to update the
MediaDrm session post-construction. This CL addresses both of
these issues.
bug: 19570317
Change-Id: Ieb32d04d61742fc1dee2105dd904690d44c46c7b
diff --git a/media/libmediaplayerservice/Crypto.cpp b/media/libmediaplayerservice/Crypto.cpp
index e768772..f639193 100644
--- a/media/libmediaplayerservice/Crypto.cpp
+++ b/media/libmediaplayerservice/Crypto.cpp
@@ -268,4 +268,14 @@
}
}
+status_t Crypto::setMediaDrmSession(const Vector<uint8_t> &sessionId) {
+ Mutex::Autolock autoLock(mLock);
+
+ status_t result = NO_INIT;
+ if (mInitCheck == OK && mPlugin != NULL) {
+ result = mPlugin->setMediaDrmSession(sessionId);
+ }
+ return result;
+}
+
} // namespace android
diff --git a/media/libmediaplayerservice/Crypto.h b/media/libmediaplayerservice/Crypto.h
index d5f3c50..99ea95d 100644
--- a/media/libmediaplayerservice/Crypto.h
+++ b/media/libmediaplayerservice/Crypto.h
@@ -47,6 +47,8 @@
virtual void notifyResolution(uint32_t width, uint32_t height);
+ virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId);
+
virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],