The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Catania | 2827560 | 2009-03-24 20:55:36 -0700 | [diff] [blame] | 21 | #include <sys/types.h> |
Andy McFadden | bd89893 | 2009-03-24 21:20:43 -0700 | [diff] [blame] | 22 | #include <stdint.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
Niko Catania | 2827560 | 2009-03-24 20:55:36 -0700 | [diff] [blame] | 26 | /* |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | class FakeCamera { |
| 38 | public: |
| 39 | FakeCamera(int width, int height); |
| 40 | ~FakeCamera(); |
| 41 | |
| 42 | void setSize(int width, int height); |
Chih-Chung Chang | e25cc65 | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 43 | void getNextFrameAsYuv420(uint8_t *buffer); |
Niko Catania | 2827560 | 2009-03-24 20:55:36 -0700 | [diff] [blame] | 44 | // Write to the fd a string representing the current state. |
| 45 | void dump(int fd) const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | |
| 47 | private: |
Niko Catania | 2827560 | 2009-03-24 20:55:36 -0700 | [diff] [blame] | 48 | // 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | 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 |