summaryrefslogtreecommitdiffstats
path: root/cmds/stagefright/stagefright.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-02-28 09:23:13 -0800
committerAndreas Huber <andih@google.com>2011-02-28 09:23:13 -0800
commitc83d4f56f9dd45f71c0f4673737f0ad1cce60abb (patch)
tree8f2165d47809c353c37976fe92b389cfec225c23 /cmds/stagefright/stagefright.cpp
parent60181854194007eef9471c2774a9912ce8c42cfa (diff)
downloadframeworks_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/stagefright/stagefright.cpp')
-rw-r--r--cmds/stagefright/stagefright.cpp63
1 files changed, 61 insertions, 2 deletions
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;