blob: f7f880328a4c416a2b52ff86e1098c6fe4e9a53d [file] [log] [blame]
The Android Open Source Project9066cfe2009-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 Catania28275602009-03-24 20:55:36 -070021#include <sys/types.h>
Andy McFaddenbd898932009-03-24 21:20:43 -070022#include <stdint.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023
24namespace android {
25
Niko Catania28275602009-03-24 20:55:36 -070026/*
27 * FakeCamera is used in the CameraHardwareStub to provide a fake video feed
28 * when the system does not have a camera in hardware.
29 * The fake video is a moving black and white checkerboard background with a
30 * bouncing gray square in the foreground.
31 * This class is not thread-safe.
32 *
33 * TODO: Since the major methods provides a raw/uncompressed video feed, rename
34 * this class to RawVideoSource.
35 */
36
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037class FakeCamera {
38public:
39 FakeCamera(int width, int height);
40 ~FakeCamera();
41
42 void setSize(int width, int height);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 void getNextFrameAsYuv422(uint8_t *buffer);
Niko Catania28275602009-03-24 20:55:36 -070044 // Write to the fd a string representing the current state.
45 void dump(int fd) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046
47private:
Niko Catania28275602009-03-24 20:55:36 -070048 // TODO: remove the uint16_t buffer param everywhere since it is a field of
49 // this class.
50 void getNextFrameAsRgb565(uint16_t *buffer);
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 void drawSquare(uint16_t *buffer, int x, int y, int size, int color, int shadow);
53 void drawCheckerboard(uint16_t *buffer, int size);
54
55 static const int kRed = 0xf800;
56 static const int kGreen = 0x07c0;
57 static const int kBlue = 0x003e;
58
59 int mWidth, mHeight;
60 int mCounter;
61 int mCheckX, mCheckY;
62 uint16_t *mTmpRgb16Buffer;
63};
64
65}; // namespace android
66
67#endif // ANDROID_HARDWARE_FAKECAMERA_H