From 30ab66297501757d745b9ae10da61adcd891f497 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 16 Nov 2009 15:43:38 -0800 Subject: Squashed commit of the following: commit 333057b355f8c260c549553b9a0634755c838b6a Author: Andreas Huber Date: Fri Nov 13 15:35:48 2009 -0800 Some more tweaks to AVC encoding on sholes. commit 9981d0ee52ec5b8b0182aae733d1571e3ebb8390 Author: Andreas Huber Date: Thu Nov 12 16:36:57 2009 -0800 Support for avc encoding, including sholes specific tweaks to pick the right colorspace for the camera to not require transcoding. commit 5ba0ebbbd4efca51f3ae1f60e2ca31e7d2cf136d Author: Andreas Huber Date: Wed Nov 11 09:50:03 2009 -0800 Enable actual (camera) video-only recording using h.263 or mpeg4 encoding. commit 3fd59c3526a37fe7c696f4a978925d1831c09313 Author: Andreas Huber Date: Tue Nov 10 14:57:48 2009 -0800 Allow switching between the PV recorder implementation and one supported by stagefright. This is controlled through the property "media.stagefright.enable-record". --- media/libstagefright/CameraSource.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/CameraSource.cpp') diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index e9d8557..bd862e0 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -19,6 +19,7 @@ #include #include +#include // for property_get #include #include #include @@ -123,6 +124,17 @@ CameraSource *CameraSource::Create() { return new CameraSource(camera); } +// static +CameraSource *CameraSource::CreateFromICamera(const sp &icamera) { + sp camera = Camera::create(icamera); + + if (camera.get() == NULL) { + return NULL; + } + + return new CameraSource(camera); +} + CameraSource::CameraSource(const sp &camera) : mCamera(camera), mWidth(0), @@ -130,6 +142,13 @@ CameraSource::CameraSource(const sp &camera) mFirstFrameTimeUs(0), mNumFrames(0), mStarted(false) { + char value[PROPERTY_VALUE_MAX]; + if (property_get("ro.hardware", value, NULL) && !strcmp(value, "sholes")) { + // The hardware encoder(s) do not support yuv420, but only YCbYCr, + // fortunately the camera also supports this, so we needn't transcode. + mCamera->setParameters(String8("preview-format=yuv422i-yuyv")); + } + String8 s = mCamera->getParameters(); printf("params: \"%s\"\n", s.string()); @@ -143,13 +162,18 @@ CameraSource::~CameraSource() { } } +void CameraSource::setPreviewSurface(const sp &surface) { + mPreviewSurface = surface; +} + status_t CameraSource::start(MetaData *) { CHECK(!mStarted); mCamera->setListener(new CameraSourceListener(this)); - sp dummy = new DummySurface; - status_t err = mCamera->setPreviewDisplay(dummy); + status_t err = + mCamera->setPreviewDisplay( + mPreviewSurface != NULL ? mPreviewSurface : new DummySurface); CHECK_EQ(err, OK); mCamera->setPreviewCallbackFlags( -- cgit v1.1