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 /*
18 * Contains implementation of a class EmulatedFakeCamera that encapsulates
19 * functionality of a fake camera.
20 */
21
22 #define LOG_NDEBUG 0
23 #define LOG_TAG "EmulatedCamera_FakeCamera"
24 #include <cutils/log.h>
25 #include <cutils/properties.h>
26 #include "EmulatedFakeCamera.h"
27 #include "EmulatedCameraFactory.h"
28
29 namespace android {
30
EmulatedFakeCamera(int cameraId,struct hw_module_t * module)31 EmulatedFakeCamera::EmulatedFakeCamera(int cameraId, struct hw_module_t* module)
32 : EmulatedCamera(cameraId, module),
33 mFakeCameraDevice(this)
34 {
35 }
36
~EmulatedFakeCamera()37 EmulatedFakeCamera::~EmulatedFakeCamera()
38 {
39 }
40
41 /****************************************************************************
42 * Public API overrides
43 ***************************************************************************/
44
Initialize()45 status_t EmulatedFakeCamera::Initialize()
46 {
47 status_t res = mFakeCameraDevice.Initialize();
48 if (res != NO_ERROR) {
49 return res;
50 }
51
52 /* Fake camera facing is defined by the qemu.sf.fake_camera boot property. */
53 char prop[PROPERTY_VALUE_MAX];
54 property_get("qemu.sf.fake_camera", prop, EmulatedCamera::FACING_BACK);
55 const char* facing = prop;
56
57 mParameters.set(EmulatedCamera::FACING_KEY, facing);
58 LOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
59
60 mParameters.set(EmulatedCamera::ORIENTATION_KEY,
61 gEmulatedCameraFactory.getFakeCameraOrientation());
62
63 res = EmulatedCamera::Initialize();
64 if (res != NO_ERROR) {
65 return res;
66 }
67
68 /*
69 * Parameters provided by the camera device.
70 */
71
72 mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, "640x480");
73 mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "640x480");
74 mParameters.setPreviewSize(640, 480);
75 mParameters.setPictureSize(640, 480);
76
77 return NO_ERROR;
78 }
79
getCameraDevice()80 EmulatedCameraDevice* EmulatedFakeCamera::getCameraDevice()
81 {
82 return &mFakeCameraDevice;
83 }
84
85 }; /* namespace android */
86