summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiko Catania <>2009-03-24 20:55:36 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-24 20:55:36 -0700
commit2827560ce2c0462487ff3b9193ea5abc4a1077c4 (patch)
treedbc603d77dea242af17d6e0c5abfd43243cef897
parent10270f2b7715dbbc9fae16b8765f888e5b8a7631 (diff)
downloadframeworks_base-2827560ce2c0462487ff3b9193ea5abc4a1077c4.zip
frameworks_base-2827560ce2c0462487ff3b9193ea5abc4a1077c4.tar.gz
frameworks_base-2827560ce2c0462487ff3b9193ea5abc4a1077c4.tar.bz2
Automated import from //branches/master/...@141784,141784
-rw-r--r--camera/libcameraservice/CameraHardwareStub.cpp2
-rw-r--r--camera/libcameraservice/FakeCamera.cpp30
-rw-r--r--camera/libcameraservice/FakeCamera.h21
3 files changed, 47 insertions, 6 deletions
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp
index 0f1ae8e..a7af57c 100644
--- a/camera/libcameraservice/CameraHardwareStub.cpp
+++ b/camera/libcameraservice/CameraHardwareStub.cpp
@@ -314,7 +314,7 @@ status_t CameraHardwareStub::dump(int fd, const Vector<String16>& args) const
String8 result;
AutoMutex lock(&mLock);
if (mFakeCamera != 0) {
- mFakeCamera->dump(fd, args);
+ mFakeCamera->dump(fd);
mParameters.dump(fd, args);
snprintf(buffer, 255, " preview frame(%d), size (%d), running(%s)\n", mCurrentPreviewFrame, mPreviewFrameSize, mPreviewRunning?"true": "false");
result.append(buffer);
diff --git a/camera/libcameraservice/FakeCamera.cpp b/camera/libcameraservice/FakeCamera.cpp
index 3592eab..3daf47d 100644
--- a/camera/libcameraservice/FakeCamera.cpp
+++ b/camera/libcameraservice/FakeCamera.cpp
@@ -1,12 +1,39 @@
+/*
+**
+** Copyright 2008, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
#define LOG_TAG "FakeCamera"
#include <utils/Log.h>
#include <string.h>
#include <stdlib.h>
+#include <utils/String8.h>
+
#include "FakeCamera.h"
+
namespace android {
+// TODO: All this rgb to yuv should probably be in a util class.
+
+// TODO: I think something is wrong in this class because the shadow is kBlue
+// and the square color should alternate between kRed and kGreen. However on the
+// emulator screen these are all shades of gray. Y seems ok but the U and V are
+// probably not.
+
static int tables_initialized = 0;
uint8_t *gYTable, *gCbTable, *gCrTable;
@@ -389,7 +416,7 @@ void FakeCamera::drawCheckerboard(uint16_t *dst, int size)
}
-status_t FakeCamera::dump(int fd, const Vector<String16>& args)
+void FakeCamera::dump(int fd) const
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -397,7 +424,6 @@ status_t FakeCamera::dump(int fd, const Vector<String16>& args)
snprintf(buffer, 255, " width x height (%d x %d), counter (%d), check x-y coordinate(%d, %d)\n", mWidth, mHeight, mCounter, mCheckX, mCheckY);
result.append(buffer);
::write(fd, result.string(), result.size());
- return NO_ERROR;
}
diff --git a/camera/libcameraservice/FakeCamera.h b/camera/libcameraservice/FakeCamera.h
index 77c994c..da9e944 100644
--- a/camera/libcameraservice/FakeCamera.h
+++ b/camera/libcameraservice/FakeCamera.h
@@ -18,21 +18,36 @@
#ifndef ANDROID_HARDWARE_FAKECAMERA_H
#define ANDROID_HARDWARE_FAKECAMERA_H
-#include <ui/CameraHardwareInterface.h>
+#include <sys/types.h>
namespace android {
+/*
+ * FakeCamera is used in the CameraHardwareStub to provide a fake video feed
+ * when the system does not have a camera in hardware.
+ * The fake video is a moving black and white checkerboard background with a
+ * bouncing gray square in the foreground.
+ * This class is not thread-safe.
+ *
+ * TODO: Since the major methods provides a raw/uncompressed video feed, rename
+ * this class to RawVideoSource.
+ */
+
class FakeCamera {
public:
FakeCamera(int width, int height);
~FakeCamera();
void setSize(int width, int height);
- void getNextFrameAsRgb565(uint16_t *buffer);
void getNextFrameAsYuv422(uint8_t *buffer);
- status_t dump(int fd, const Vector<String16>& args);
+ // Write to the fd a string representing the current state.
+ void dump(int fd) const;
private:
+ // TODO: remove the uint16_t buffer param everywhere since it is a field of
+ // this class.
+ void getNextFrameAsRgb565(uint16_t *buffer);
+
void drawSquare(uint16_t *buffer, int x, int y, int size, int color, int shadow);
void drawCheckerboard(uint16_t *buffer, int size);