diff options
author | Andreas Huber <andih@google.com> | 2011-02-28 09:23:13 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-02-28 09:23:13 -0800 |
commit | c83d4f56f9dd45f71c0f4673737f0ad1cce60abb (patch) | |
tree | 8f2165d47809c353c37976fe92b389cfec225c23 /cmds | |
parent | 60181854194007eef9471c2774a9912ce8c42cfa (diff) | |
download | frameworks_av-c83d4f56f9dd45f71c0f4673737f0ad1cce60abb.zip frameworks_av-c83d4f56f9dd45f71c0f4673737f0ad1cce60abb.tar.gz frameworks_av-c83d4f56f9dd45f71c0f4673737f0ad1cce60abb.tar.bz2 |
Add the option '-S' to use surface allocated buffers in the stagefright cmdline tool.
Change-Id: Ic84eeed1679d6bf68c92de0e20d30e7a3c4d410f
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/stagefright/Android.mk | 2 | ||||
-rw-r--r-- | cmds/stagefright/stagefright.cpp | 63 |
2 files changed, 62 insertions, 3 deletions
diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk index 178032d..1b13dd9 100644 --- a/cmds/stagefright/Android.mk +++ b/cmds/stagefright/Android.mk @@ -8,7 +8,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libstagefright libmedia libutils libbinder libstagefright_foundation \ - libskia + libskia libsurfaceflinger_client libgui LOCAL_C_INCLUDES:= \ $(JNI_H_INCLUDE) \ diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp index a43b190..a875c3a 100644 --- a/cmds/stagefright/stagefright.cpp +++ b/cmds/stagefright/stagefright.cpp @@ -55,6 +55,11 @@ #include <fcntl.h> +#include <gui/SurfaceTextureClient.h> + +#include <surfaceflinger/ISurfaceComposer.h> +#include <surfaceflinger/SurfaceComposerClient.h> + using namespace android; static long gNumRepetitions; @@ -66,6 +71,10 @@ static bool gWriteMP4; static bool gDisplayHistogram; static String8 gWriteMP4Filename; +static sp<ANativeWindow> gSurface; + +#define USE_SURFACE_COMPOSER 0 + static int64_t getNowUs() { struct timeval tv; gettimeofday(&tv, NULL); @@ -138,7 +147,8 @@ static void playSource(OMXClient *client, sp<MediaSource> &source) { rawSource = OMXCodec::Create( client->interface(), meta, false /* createEncoder */, source, NULL /* matchComponentName */, - gPreferSoftwareCodec ? OMXCodec::kPreferSoftwareCodecs : 0); + gPreferSoftwareCodec ? OMXCodec::kPreferSoftwareCodecs : 0, + gSurface); if (rawSource == NULL) { fprintf(stderr, "Failed to instantiate decoder for '%s'.\n", mime); @@ -540,6 +550,7 @@ static void usage(const char *me) { fprintf(stderr, " -k seek test\n"); fprintf(stderr, " -x display a histogram of decoding times/fps " "(video only)\n"); + fprintf(stderr, " -S allocate buffers from a surface\n"); } int main(int argc, char **argv) { @@ -550,6 +561,7 @@ int main(int argc, char **argv) { bool dumpProfiles = false; bool extractThumbnail = false; bool seekTest = false; + bool useSurfaceAlloc = false; gNumRepetitions = 1; gMaxNumFrames = 0; gReproduceBug = -1; @@ -563,7 +575,7 @@ int main(int argc, char **argv) { sp<LiveSession> liveSession; int res; - while ((res = getopt(argc, argv, "han:lm:b:ptsow:kx")) >= 0) { + while ((res = getopt(argc, argv, "han:lm:b:ptsow:kxS")) >= 0) { switch (res) { case 'a': { @@ -642,6 +654,12 @@ int main(int argc, char **argv) { break; } + case 'S': + { + useSurfaceAlloc = true; + break; + } + case '?': case 'h': default: @@ -780,6 +798,39 @@ int main(int argc, char **argv) { } } + sp<SurfaceComposerClient> composerClient; + sp<SurfaceControl> control; + + if (useSurfaceAlloc && !audioOnly) { +#if USE_SURFACE_COMPOSER + composerClient = new SurfaceComposerClient; + CHECK_EQ(composerClient->initCheck(), (status_t)OK); + + control = composerClient->createSurface( + getpid(), + String8("A Surface"), + 0, + 1280, + 800, + PIXEL_FORMAT_RGB_565, + 0); + + CHECK(control != NULL); + CHECK(control->isValid()); + + CHECK_EQ(composerClient->openTransaction(), (status_t)OK); + CHECK_EQ(control->setLayer(30000), (status_t)OK); + CHECK_EQ(control->show(), (status_t)OK); + CHECK_EQ(composerClient->closeTransaction(), (status_t)OK); + + gSurface = control->getSurface(); + CHECK(gSurface != NULL); +#else + sp<SurfaceTexture> texture = new SurfaceTexture(0 /* tex */); + gSurface = new SurfaceTextureClient(texture); +#endif + } + DataSource::RegisterDefaultSniffers(); OMXClient client; @@ -957,6 +1008,14 @@ int main(int argc, char **argv) { } } + if (useSurfaceAlloc && !audioOnly) { + gSurface.clear(); + +#if USE_SURFACE_COMPOSER + composerClient->dispose(); +#endif + } + client.disconnect(); return 0; |