1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H 18#define HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H 19 20/* 21 * Contains declaration of a class EmulatedQemuCameraDevice that encapsulates 22 * an emulated camera device connected to the host. 23 */ 24 25#include "EmulatedCameraDevice.h" 26#include "QemuClient.h" 27 28namespace android { 29 30class EmulatedQemuCamera; 31 32/* Encapsulates an emulated camera device connected to the host. 33 */ 34class EmulatedQemuCameraDevice : public EmulatedCameraDevice { 35public: 36 /* Constructs EmulatedQemuCameraDevice instance. */ 37 explicit EmulatedQemuCameraDevice(EmulatedQemuCamera* camera_hal); 38 39 /* Destructs EmulatedQemuCameraDevice instance. */ 40 ~EmulatedQemuCameraDevice(); 41 42 /*************************************************************************** 43 * Public API 44 **************************************************************************/ 45 46public: 47 /* Initializes EmulatedQemuCameraDevice instance. 48 * Param: 49 * device_name - Name of the camera device connected to the host. The name 50 * that is used here must have been reported by the 'factory' camera 51 * service when it listed camera devices connected to the host. 52 * Return: 53 * NO_ERROR on success, or an appropriate error status. 54 */ 55 status_t Initialize(const char* device_name); 56 57 /*************************************************************************** 58 * Emulated camera device abstract interface implementation. 59 * See declarations of these methods in EmulatedCameraDevice class for 60 * information on each of these methods. 61 **************************************************************************/ 62 63public: 64 /* Connects to the camera device. */ 65 status_t connectDevice(); 66 67 /* Disconnects from the camera device. */ 68 status_t disconnectDevice(); 69 70 /* Starts capturing frames from the camera device. */ 71 status_t startDevice(int width, int height, uint32_t pix_fmt); 72 73 /* Stops capturing frames from the camera device. */ 74 status_t stopDevice(); 75 76 /*************************************************************************** 77 * EmulatedCameraDevice virtual overrides 78 * See declarations of these methods in EmulatedCameraDevice class for 79 * information on each of these methods. 80 **************************************************************************/ 81 82public: 83 /* Gets current preview fame into provided buffer. 84 * We override this method in order to provide preview frames cached in this 85 * object. 86 */ 87 status_t getCurrentPreviewFrame(void* buffer); 88 89 /*************************************************************************** 90 * Worker thread management overrides. 91 * See declarations of these methods in EmulatedCameraDevice class for 92 * information on each of these methods. 93 **************************************************************************/ 94 95protected: 96 /* Implementation of the worker thread routine. */ 97 bool inWorkerThread(); 98 99 /*************************************************************************** 100 * Qemu camera device data members 101 **************************************************************************/ 102 103private: 104 /* Qemu client that is used to communicate with the 'emulated camera' 105 * service, created for this instance in the emulator. */ 106 CameraQemuClient mQemuClient; 107 108 /* Name of the camera device connected to the host. */ 109 String8 mDeviceName; 110 111 /* Current preview framebuffer. */ 112 uint32_t* mPreviewFrame; 113 114 /* Emulated FPS (frames per second). 115 * We will emulate 50 FPS. */ 116 static const int mEmulatedFPS = 50; 117}; 118 119}; /* namespace android */ 120 121#endif /* HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H */ 122