summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-06-07 10:19:58 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-06-07 10:19:58 -0700
commit7a68d3686aace4781ee6c25d8ab8704bebee34af (patch)
tree481ffa2e47ec1ca726e7043219e2f0e60039f81f
parenta8ebe8b3f5aea0d3f09a62d6d255f99c1f911f7b (diff)
parentc2f328d0d2821e402823d6e17589da2849b67d0d (diff)
downloadframeworks_base-7a68d3686aace4781ee6c25d8ab8704bebee34af.zip
frameworks_base-7a68d3686aace4781ee6c25d8ab8704bebee34af.tar.gz
frameworks_base-7a68d3686aace4781ee6c25d8ab8704bebee34af.tar.bz2
Merge "Remove hard-coded pixel format for recording frames in CameraSource. Retrieve the pixel format from Camera HAL at runtime." into kraken
-rw-r--r--include/media/stagefright/CameraSource.h2
-rw-r--r--media/libstagefright/CameraSource.cpp43
2 files changed, 34 insertions, 11 deletions
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 0c7bf6f..0a7023a 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -51,6 +51,7 @@ private:
friend class CameraSourceListener;
sp<Camera> mCamera;
+ sp<MetaData> mMeta;
Mutex mLock;
Condition mFrameAvailableCondition;
@@ -59,7 +60,6 @@ private:
List<sp<IMemory> > mFramesBeingEncoded;
List<int64_t> mFrameTimes;
- int mWidth, mHeight;
int64_t mFirstFrameTimeUs;
int64_t mLastFrameTimestampUs;
int32_t mNumFramesReceived;
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index c8834f8..264ac5f 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -75,6 +75,26 @@ void CameraSourceListener::postDataTimestamp(
}
}
+static int32_t getColorFormat(const char* colorFormat) {
+ if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422SP)) {
+ return OMX_COLOR_FormatYUV422SemiPlanar;
+ }
+
+ if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420SP)) {
+ return OMX_COLOR_FormatYUV420SemiPlanar;
+ }
+
+ if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422I)) {
+ return OMX_COLOR_FormatYCbYCr;
+ }
+
+ if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_RGB565)) {
+ return OMX_COLOR_Format16bitRGB565;
+ }
+
+ CHECK_EQ(0, "Unknown color format");
+}
+
// static
CameraSource *CameraSource::Create() {
sp<Camera> camera = Camera::connect(0);
@@ -97,8 +117,6 @@ CameraSource *CameraSource::CreateFromCamera(const sp<Camera> &camera) {
CameraSource::CameraSource(const sp<Camera> &camera)
: mCamera(camera),
- mWidth(0),
- mHeight(0),
mFirstFrameTimeUs(0),
mLastFrameTimestampUs(0),
mNumFramesReceived(0),
@@ -108,8 +126,19 @@ CameraSource::CameraSource(const sp<Camera> &camera)
String8 s = mCamera->getParameters();
printf("params: \"%s\"\n", s.string());
+ int32_t width, height;
CameraParameters params(s);
- params.getPreviewSize(&mWidth, &mHeight);
+ params.getPreviewSize(&width, &height);
+
+ const char *colorFormatStr = params.get(CameraParameters::KEY_VIDEO_FRAME_FORMAT);
+ CHECK(colorFormatStr != NULL);
+ int32_t colorFormat = getColorFormat(colorFormatStr);
+
+ mMeta = new MetaData;
+ mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
+ mMeta->setInt32(kKeyColorFormat, colorFormat);
+ mMeta->setInt32(kKeyWidth, width);
+ mMeta->setInt32(kKeyHeight, height);
}
CameraSource::~CameraSource() {
@@ -163,13 +192,7 @@ void CameraSource::releaseQueuedFrames() {
}
sp<MetaData> CameraSource::getFormat() {
- sp<MetaData> meta = new MetaData;
- meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
- meta->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420SemiPlanar);
- meta->setInt32(kKeyWidth, mWidth);
- meta->setInt32(kKeyHeight, mHeight);
-
- return meta;
+ return mMeta;
}
void CameraSource::signalBufferReturned(MediaBuffer *buffer) {