summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MediaCodec.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-04-19 12:52:20 -0700
committerAndreas Huber <andih@google.com>2012-04-19 12:53:59 -0700
commit5b8987e7de9d04b09153f329c680d2316cdb44ec (patch)
tree2b08e1f8abd0d4b869ce8923b1462530b916a7eb /media/libstagefright/MediaCodec.cpp
parentfd9e14bc28f377065e43ec6833d754ca151b3941 (diff)
downloadframeworks_av-5b8987e7de9d04b09153f329c680d2316cdb44ec.zip
frameworks_av-5b8987e7de9d04b09153f329c680d2316cdb44ec.tar.gz
frameworks_av-5b8987e7de9d04b09153f329c680d2316cdb44ec.tar.bz2
Allow propagation of error information and description from the CryptoPlugin to
the higher layers. Change-Id: I9f434ad55cdf575803c208bedf47b607baff2330 related-to-bug: 6365261
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r--media/libstagefright/MediaCodec.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index a382f1c..2df0dd2 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -27,6 +27,7 @@
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/ACodec.h>
#include <media/stagefright/MediaErrors.h>
@@ -179,13 +180,19 @@ status_t MediaCodec::queueInputBuffer(
size_t offset,
size_t size,
int64_t presentationTimeUs,
- uint32_t flags) {
+ uint32_t flags,
+ AString *errorDetailMsg) {
+ if (errorDetailMsg != NULL) {
+ errorDetailMsg->clear();
+ }
+
sp<AMessage> msg = new AMessage(kWhatQueueInputBuffer, id());
msg->setSize("index", index);
msg->setSize("offset", offset);
msg->setSize("size", size);
msg->setInt64("timeUs", presentationTimeUs);
msg->setInt32("flags", flags);
+ msg->setPointer("errorDetailMsg", errorDetailMsg);
sp<AMessage> response;
return PostAndAwaitResponse(msg, &response);
@@ -200,7 +207,12 @@ status_t MediaCodec::queueSecureInputBuffer(
const uint8_t iv[16],
CryptoPlugin::Mode mode,
int64_t presentationTimeUs,
- uint32_t flags) {
+ uint32_t flags,
+ AString *errorDetailMsg) {
+ if (errorDetailMsg != NULL) {
+ errorDetailMsg->clear();
+ }
+
sp<AMessage> msg = new AMessage(kWhatQueueInputBuffer, id());
msg->setSize("index", index);
msg->setSize("offset", offset);
@@ -211,9 +223,12 @@ status_t MediaCodec::queueSecureInputBuffer(
msg->setInt32("mode", mode);
msg->setInt64("timeUs", presentationTimeUs);
msg->setInt32("flags", flags);
+ msg->setPointer("errorDetailMsg", errorDetailMsg);
sp<AMessage> response;
- return PostAndAwaitResponse(msg, &response);
+ status_t err = PostAndAwaitResponse(msg, &response);
+
+ return err;
}
status_t MediaCodec::dequeueInputBuffer(size_t *index, int64_t timeoutUs) {
@@ -1234,9 +1249,6 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
}
sp<AMessage> reply = info->mNotify;
- info->mNotify = NULL;
- info->mOwnedByClient = false;
-
info->mData->setRange(offset, size);
info->mData->meta()->setInt64("timeUs", timeUs);
@@ -1253,6 +1265,9 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
return -ERANGE;
}
+ AString *errorDetailMsg;
+ CHECK(msg->findPointer("errorDetailMsg", (void **)&errorDetailMsg));
+
status_t err = mCrypto->decrypt(
(mFlags & kFlagIsSecure) != 0,
key,
@@ -1261,7 +1276,8 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
info->mEncryptedData->base() + offset,
subSamples,
numSubSamples,
- info->mData->base());
+ info->mData->base(),
+ errorDetailMsg);
if (err != OK) {
return err;
@@ -1273,6 +1289,9 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
reply->setBuffer("buffer", info->mData);
reply->post();
+ info->mNotify = NULL;
+ info->mOwnedByClient = false;
+
return OK;
}