457850d2ea090d710464656afbe32aeef34528e0
[iec.git] / src / type3_AndroidCloud / anbox-master / android / camera / EmulatedFakeCamera.cpp
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
31 EmulatedFakeCamera::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
40 EmulatedFakeCamera::~EmulatedFakeCamera()
41 {
42 }
43
44 /****************************************************************************
45  * Public API overrides
46  ***************************************************************************/
47
48 status_t EmulatedFakeCamera::Initialize()
49 {
50     status_t res = mFakeCameraDevice.Initialize();
51     if (res != NO_ERROR) {
52         return res;
53     }
54
55     const char* facing = mFacingBack ? EmulatedCamera::FACING_BACK :
56                                        EmulatedCamera::FACING_FRONT;
57
58     mParameters.set(EmulatedCamera::FACING_KEY, facing);
59     ALOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
60
61     mParameters.set(EmulatedCamera::ORIENTATION_KEY,
62                     gEmulatedCameraFactory.getFakeCameraOrientation());
63
64     res = EmulatedCamera::Initialize();
65     if (res != NO_ERROR) {
66         return res;
67     }
68
69     /*
70      * Parameters provided by the camera device.
71      */
72
73     /* 352x288 and 320x240 frame dimensions are required by the framework for
74      * video mode preview and video recording. */
75     mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
76                     "640x480,352x288,320x240");
77     mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
78                     "640x480,352x288,320x240");
79     mParameters.setPreviewSize(640, 480);
80     mParameters.setPictureSize(640, 480);
81
82     return NO_ERROR;
83 }
84
85 EmulatedCameraDevice* EmulatedFakeCamera::getCameraDevice()
86 {
87     return &mFakeCameraDevice;
88 }
89
90 };  /* namespace android */