blob: da9e94474e8961de662d769dbf3927e6165a3c0a [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef ANDROID_HARDWARE_FAKECAMERA_H
19#define ANDROID_HARDWARE_FAKECAMERA_H
20
Niko Cataniac8f10f82009-03-24 20:53:55 -070021#include <sys/types.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022
23namespace android {
24
Niko Cataniac8f10f82009-03-24 20:53:55 -070025/*
26 * FakeCamera is used in the CameraHardwareStub to provide a fake video feed
27 * when the system does not have a camera in hardware.
28 * The fake video is a moving black and white checkerboard background with a
29 * bouncing gray square in the foreground.
30 * This class is not thread-safe.
31 *
32 * TODO: Since the major methods provides a raw/uncompressed video feed, rename
33 * this class to RawVideoSource.
34 */
35
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036class FakeCamera {
37public:
38 FakeCamera(int width, int height);
39 ~FakeCamera();
40
41 void setSize(int width, int height);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042 void getNextFrameAsYuv422(uint8_t *buffer);
Niko Cataniac8f10f82009-03-24 20:53:55 -070043 // Write to the fd a string representing the current state.
44 void dump(int fd) const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045
46private:
Niko Cataniac8f10f82009-03-24 20:53:55 -070047 // TODO: remove the uint16_t buffer param everywhere since it is a field of
48 // this class.
49 void getNextFrameAsRgb565(uint16_t *buffer);
50
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051 void drawSquare(uint16_t *buffer, int x, int y, int size, int color, int shadow);
52 void drawCheckerboard(uint16_t *buffer, int size);
53
54 static const int kRed = 0xf800;
55 static const int kGreen = 0x07c0;
56 static const int kBlue = 0x003e;
57
58 int mWidth, mHeight;
59 int mCounter;
60 int mCheckX, mCheckY;
61 uint16_t *mTmpRgb16Buffer;
62};
63
64}; // namespace android
65
66#endif // ANDROID_HARDWARE_FAKECAMERA_H