2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H
18 #define HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H
21 * Contains declaration of a class EmulatedQemuCameraDevice that encapsulates
22 * an emulated camera device connected to the host.
25 #include "EmulatedCameraDevice.h"
26 #include "QemuClient.h"
30 class EmulatedQemuCamera;
32 /* Encapsulates an emulated camera device connected to the host.
34 class EmulatedQemuCameraDevice : public EmulatedCameraDevice {
36 /* Constructs EmulatedQemuCameraDevice instance. */
37 explicit EmulatedQemuCameraDevice(EmulatedQemuCamera* camera_hal);
39 /* Destructs EmulatedQemuCameraDevice instance. */
40 ~EmulatedQemuCameraDevice();
42 /***************************************************************************
44 **************************************************************************/
47 /* Initializes EmulatedQemuCameraDevice instance.
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.
53 * NO_ERROR on success, or an appropriate error status.
55 status_t Initialize(const char* device_name);
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 **************************************************************************/
64 /* Connects to the camera device. */
65 status_t connectDevice();
67 /* Disconnects from the camera device. */
68 status_t disconnectDevice();
70 /* Starts capturing frames from the camera device. */
71 status_t startDevice(int width, int height, uint32_t pix_fmt);
73 /* Stops capturing frames from the camera device. */
74 status_t stopDevice();
76 /***************************************************************************
77 * EmulatedCameraDevice virtual overrides
78 * See declarations of these methods in EmulatedCameraDevice class for
79 * information on each of these methods.
80 **************************************************************************/
83 /* Gets current preview fame into provided buffer.
84 * We override this method in order to provide preview frames cached in this
87 status_t getCurrentPreviewFrame(void* buffer);
89 /***************************************************************************
90 * Worker thread management overrides.
91 * See declarations of these methods in EmulatedCameraDevice class for
92 * information on each of these methods.
93 **************************************************************************/
96 /* Implementation of the worker thread routine. */
97 bool inWorkerThread();
99 /***************************************************************************
100 * Qemu camera device data members
101 **************************************************************************/
104 /* Qemu client that is used to communicate with the 'emulated camera'
105 * service, created for this instance in the emulator. */
106 CameraQemuClient mQemuClient;
108 /* Name of the camera device connected to the host. */
111 /* Current preview framebuffer. */
112 uint32_t* mPreviewFrame;
114 /* Emulated FPS (frames per second).
115 * We will emulate 50 FPS. */
116 static const int mEmulatedFPS = 50;
119 }; /* namespace android */
121 #endif /* HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H */