summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-04-07 19:03:56 -0700
committerJamie Gennis <jgennis@google.com>2011-04-08 15:24:10 -0700
commitd4d43b2ad0f715211feb48ce2f3e2158883583c0 (patch)
treef71f31e6c7e6d43f08be9748b1a10423752ca76a /media
parent5b3635efd12466e957a59d93a9167c9a01e9c933 (diff)
downloadframeworks_av-d4d43b2ad0f715211feb48ce2f3e2158883583c0.zip
frameworks_av-d4d43b2ad0f715211feb48ce2f3e2158883583c0.tar.gz
frameworks_av-d4d43b2ad0f715211feb48ce2f3e2158883583c0.tar.bz2
Stagefright: authenticate ANativeWindow.
This change adds a check to verify that the ANativeWindow to which decoded video buffers are queued sends those buffers to SurfaceFlinger. The check is done when the buffer content is flagged as protected. This change also adds an error in the case where protected buffers are needed, but an ANativeWindow is not being used as the video destination. Change-Id: I107c9082d65ef0de4a13594e9535a2053ad5161b Bug: 4269240
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/OMXCodec.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index a70f868..5d26fd5 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1593,6 +1593,11 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
return allocateOutputBuffersFromNativeWindow();
}
+ if (mEnableGrallocUsageProtected && portIndex == kPortIndexOutput) {
+ LOGE("protected output buffers must be stent to an ANativeWindow");
+ return PERMISSION_DENIED;
+ }
+
OMX_PARAM_PORTDEFINITIONTYPE def;
InitOMXParams(&def);
def.nPortIndex = portIndex;
@@ -1761,6 +1766,25 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
usage |= GRALLOC_USAGE_PROTECTED;
}
+ // Make sure to check whether either Stagefright or the video decoder
+ // requested protected buffers.
+ if (usage & GRALLOC_USAGE_PROTECTED) {
+ // Verify that the ANativeWindow sends images directly to
+ // SurfaceFlinger.
+ int queuesToNativeWindow = 0;
+ err = mNativeWindow->query(
+ mNativeWindow.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
+ &queuesToNativeWindow);
+ if (err != 0) {
+ LOGE("error authenticating native window: %d", err);
+ return err;
+ }
+ if (queuesToNativeWindow != 1) {
+ LOGE("native window could not be authenticated");
+ return PERMISSION_DENIED;
+ }
+ }
+
LOGV("native_window_set_usage usage=0x%x", usage);
err = native_window_set_usage(
mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);