diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/stagefright/sf2.cpp | 31 | ||||
-rw-r--r-- | cmds/stagefright/stagefright.cpp | 77 |
2 files changed, 66 insertions, 42 deletions
diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp index 289665f..ddd64ec 100644 --- a/cmds/stagefright/sf2.cpp +++ b/cmds/stagefright/sf2.cpp @@ -29,6 +29,7 @@ #include <media/stagefright/MediaExtractor.h> #include <media/stagefright/MediaSource.h> #include <media/stagefright/MetaData.h> +#include <media/stagefright/NativeWindowWrapper.h> #include <media/stagefright/Utils.h> #include <surfaceflinger/ISurfaceComposer.h> @@ -39,10 +40,12 @@ using namespace android; struct Controller : public AHandler { - Controller(const char *uri, bool decodeAudio, const sp<Surface> &surface) + Controller(const char *uri, bool decodeAudio, + const sp<Surface> &surface, bool renderToSurface) : mURI(uri), mDecodeAudio(decodeAudio), mSurface(surface), + mRenderToSurface(renderToSurface), mCodec(new ACodec) { CHECK(!mDecodeAudio || mSurface == NULL); } @@ -97,7 +100,8 @@ protected: sp<AMessage> format = makeFormat(mSource->getFormat()); if (mSurface != NULL) { - format->setObject("surface", mSurface); + format->setObject( + "native-window", new NativeWindowWrapper(mSurface)); } mCodec->initiateSetup(format); @@ -220,6 +224,7 @@ private: AString mURI; bool mDecodeAudio; sp<Surface> mSurface; + bool mRenderToSurface; sp<ACodec> mCodec; sp<MediaSource> mSource; @@ -451,7 +456,7 @@ private: inBuffer->release(); inBuffer = NULL; - // break; // Don't coalesce + break; // Don't coalesce } LOGV("coalesced %d input buffers", n); @@ -479,6 +484,10 @@ private: sp<AMessage> reply; CHECK(msg->findMessage("reply", &reply)); + if (mRenderToSurface) { + reply->setInt32("render", 1); + } + reply->post(); } @@ -491,7 +500,8 @@ static void usage(const char *me) { fprintf(stderr, " -a(udio)\n"); fprintf(stderr, - " -s(surface) Allocate output buffers on a surface.\n"); + " -S(urface) Allocate output buffers on a surface.\n" + " -R(ender) Render surface-allocated buffers.\n"); } int main(int argc, char **argv) { @@ -499,18 +509,23 @@ int main(int argc, char **argv) { bool decodeAudio = false; bool useSurface = false; + bool renderToSurface = false; int res; - while ((res = getopt(argc, argv, "has")) >= 0) { + while ((res = getopt(argc, argv, "haSR")) >= 0) { switch (res) { case 'a': decodeAudio = true; break; - case 's': + case 'S': useSurface = true; break; + case 'R': + renderToSurface = true; + break; + case '?': case 'h': default: @@ -562,7 +577,9 @@ int main(int argc, char **argv) { CHECK(surface != NULL); } - sp<Controller> controller = new Controller(argv[0], decodeAudio, surface); + sp<Controller> controller = + new Controller(argv[0], decodeAudio, surface, renderToSurface); + looper->registerHandler(controller); controller->startAsync(); diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp index d7b1e71..656f5fd 100644 --- a/cmds/stagefright/stagefright.cpp +++ b/cmds/stagefright/stagefright.cpp @@ -74,8 +74,6 @@ static String8 gWriteMP4Filename; static sp<ANativeWindow> gSurface; -#define USE_SURFACE_COMPOSER 0 - static int64_t getNowUs() { struct timeval tv; gettimeofday(&tv, NULL); @@ -579,6 +577,7 @@ static void usage(const char *me) { fprintf(stderr, " -x display a histogram of decoding times/fps " "(video only)\n"); fprintf(stderr, " -S allocate buffers from a surface\n"); + fprintf(stderr, " -T allocate buffers from a surface texture\n"); } int main(int argc, char **argv) { @@ -590,6 +589,7 @@ int main(int argc, char **argv) { bool extractThumbnail = false; bool seekTest = false; bool useSurfaceAlloc = false; + bool useSurfaceTexAlloc = false; gNumRepetitions = 1; gMaxNumFrames = 0; gReproduceBug = -1; @@ -604,7 +604,7 @@ int main(int argc, char **argv) { sp<LiveSession> liveSession; int res; - while ((res = getopt(argc, argv, "han:lm:b:ptsrow:kxS")) >= 0) { + while ((res = getopt(argc, argv, "han:lm:b:ptsrow:kxST")) >= 0) { switch (res) { case 'a': { @@ -695,6 +695,12 @@ int main(int argc, char **argv) { break; } + case 'T': + { + useSurfaceTexAlloc = true; + break; + } + case '?': case 'h': default: @@ -843,34 +849,35 @@ 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 + if ((useSurfaceAlloc || useSurfaceTexAlloc) && !audioOnly) { + if (useSurfaceAlloc) { + composerClient = new SurfaceComposerClient; + CHECK_EQ(composerClient->initCheck(), (status_t)OK); + + control = composerClient->createSurface( + 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 { + CHECK(useSurfaceTexAlloc); + + sp<SurfaceTexture> texture = new SurfaceTexture(0 /* tex */); + gSurface = new SurfaceTextureClient(texture); + } } DataSource::RegisterDefaultSniffers(); @@ -1061,12 +1068,12 @@ int main(int argc, char **argv) { } } - if (useSurfaceAlloc && !audioOnly) { + if ((useSurfaceAlloc || useSurfaceTexAlloc) && !audioOnly) { gSurface.clear(); -#if USE_SURFACE_COMPOSER - composerClient->dispose(); -#endif + if (useSurfaceAlloc) { + composerClient->dispose(); + } } client.disconnect(); |