summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-04-03 14:19:20 -0700
committerAndreas Huber <andih@google.com>2012-04-03 14:19:20 -0700
commit1bd139a2a68690e80398b70b27ca59550fea0e65 (patch)
treee3be78f22aa021c4e372409128775c2093d46dae /cmds
parentd22da88fd555f1262357c7dcdeface8445e3a012 (diff)
downloadframeworks_av-1bd139a2a68690e80398b70b27ca59550fea0e65.zip
frameworks_av-1bd139a2a68690e80398b70b27ca59550fea0e65.tar.gz
frameworks_av-1bd139a2a68690e80398b70b27ca59550fea0e65.tar.bz2
New Crypto services talking to the new crypto "HAL".
Change-Id: I69ed31e7a8b4d69d1209d2d516f94d258f072566 related-to-bug: 6275919
Diffstat (limited to 'cmds')
-rw-r--r--cmds/stagefright/SimplePlayer.cpp5
-rw-r--r--cmds/stagefright/codec.cpp69
2 files changed, 70 insertions, 4 deletions
diff --git a/cmds/stagefright/SimplePlayer.cpp b/cmds/stagefright/SimplePlayer.cpp
index 0cfeb3e..7636906 100644
--- a/cmds/stagefright/SimplePlayer.cpp
+++ b/cmds/stagefright/SimplePlayer.cpp
@@ -22,6 +22,7 @@
#include <gui/SurfaceTextureClient.h>
#include <media/AudioTrack.h>
+#include <media/ICrypto.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
@@ -318,7 +319,9 @@ status_t SimplePlayer::onPrepare() {
CHECK(state->mCodec != NULL);
err = state->mCodec->configure(
- format, mNativeWindow->getSurfaceTextureClient(),
+ format,
+ mNativeWindow->getSurfaceTextureClient(),
+ NULL /* crypto */,
0 /* flags */);
CHECK_EQ(err, (status_t)OK);
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp
index cf2909e..5cbfbfe 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -20,8 +20,10 @@
#include "SimplePlayer.h"
+#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
-
+#include <media/ICrypto.h>
+#include <media/IMediaPlayerService.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooper.h>
@@ -59,6 +61,33 @@ struct CodecState {
bool mIsAudio;
};
+static sp<ICrypto> makeCrypto(
+ const uint8_t uuid[16], const void *data, size_t size) {
+ sp<IServiceManager> sm = defaultServiceManager();
+
+ sp<IBinder> binder =
+ sm->getService(String16("media.player"));
+
+ sp<IMediaPlayerService> service =
+ interface_cast<IMediaPlayerService>(binder);
+
+ CHECK(service != NULL);
+
+ sp<ICrypto> crypto = service->makeCrypto();
+
+ if (crypto == NULL || crypto->initCheck() != OK) {
+ return NULL;
+ }
+
+ status_t err = crypto->createPlugin(uuid, data, size);
+
+ if (err != OK) {
+ return NULL;
+ }
+
+ return crypto;
+}
+
} // namespace android
static int decode(
@@ -78,6 +107,8 @@ static int decode(
return 1;
}
+ sp<ICrypto> crypto;
+
KeyedVector<size_t, CodecState> stateByTrack;
bool haveAudio = false;
@@ -113,7 +144,38 @@ static int decode(
state->mNumBuffersDecoded = 0;
state->mIsAudio = isAudio;
- if (decryptInputBuffers && !isAudio) {
+ if (decryptInputBuffers && crypto == NULL) {
+ sp<ABuffer> emm;
+ CHECK(format->findBuffer("emm", &emm));
+
+ sp<ABuffer> ecm;
+ CHECK(format->findBuffer("ecm", &ecm));
+
+ struct WVOpaqueInitData {
+ uint8_t mEMM[16];
+ uint8_t mECM[32];
+
+ } opaque;
+
+ CHECK_EQ(emm->size(), sizeof(opaque.mEMM));
+ memcpy(opaque.mEMM, emm->data(), emm->size());
+
+ CHECK_EQ(ecm->size(), 80u);
+ // bytes 16..47 of the original ecm stream data.
+ memcpy(opaque.mECM, ecm->data() + 16, 32);
+
+ static const uint8_t kUUIDWidevine[16] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ };
+
+ crypto = makeCrypto(kUUIDWidevine, &opaque, sizeof(opaque));
+ CHECK(crypto != NULL);
+ CHECK_EQ(crypto->initCheck(), (status_t)OK);
+ }
+
+ if (decryptInputBuffers
+ && crypto->requiresSecureDecoderComponent(mime.c_str())) {
static const MediaCodecList *list = MediaCodecList::getInstance();
ssize_t index =
@@ -137,7 +199,8 @@ static int decode(
err = state->mCodec->configure(
format, isVideo ? surface : NULL,
- decryptInputBuffers ? MediaCodec::CONFIGURE_FLAG_SECURE : 0);
+ crypto,
+ 0 /* flags */);
CHECK_EQ(err, (status_t)OK);