summaryrefslogtreecommitdiff
path: root/v3/EmulatedFakeCamera.cpp (plain)
blob: 69fe0b0e5911b738d5994a3443e98d9d69e10f8f
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
29namespace android {
30
31EmulatedFakeCamera::EmulatedFakeCamera(int cameraId,
32 bool facingBack,
33 struct hw_module_t* module)
34 : EmulatedCamera(cameraId, module),
35 mFacingBack(facingBack),
36 mFakeCameraDevice(this)
37{
38}
39
40EmulatedFakeCamera::~EmulatedFakeCamera()
41{
42}
43
44/****************************************************************************
45 * Public API overrides
46 ***************************************************************************/
47
48status_t EmulatedFakeCamera::Initialize()
49{
50 status_t res = mFakeCameraDevice.Initialize();
51 DBG_LOGA("attention should not go into this func");
52 if (res != NO_ERROR) {
53 return res;
54 }
55
56 const char* facing = mFacingBack ? EmulatedCamera::FACING_BACK :
57 EmulatedCamera::FACING_FRONT;
58
59 mParameters.set(EmulatedCamera::FACING_KEY, facing);
60 ALOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
61
62 mParameters.set(EmulatedCamera::ORIENTATION_KEY,
63 gEmulatedCameraFactory.getFakeCameraOrientation());
64
65 res = EmulatedCamera::Initialize();
66 if (res != NO_ERROR) {
67 return res;
68 }
69
70 /*
71 * Parameters provided by the camera device.
72 */
73
74 /* 352x288 and 320x240 frame dimensions are required by the framework for
75 * video mode preview and video recording. */
76 mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
77 "640x480,352x288,320x240");
78 mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
79 "640x480,352x288,320x240");
80 mParameters.setPreviewSize(640, 480);
81 mParameters.setPictureSize(640, 480);
82
83 return NO_ERROR;
84}
85
86EmulatedCameraDevice* EmulatedFakeCamera::getCameraDevice()
87{
88 DBG_LOGA("attention should not go into this func");
89 return &mFakeCameraDevice;
90}
91
92}; /* namespace android */
93