blob: 11c2170632ff5fd833af781f02c72ae1fdb64390 [file] [log] [blame]
Changyeon Jo2400b692019-07-18 21:32:48 -07001/*
2 * Copyright (C) 2019 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 ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H
18#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H
19
Changyeon Jo468cc1d2019-10-12 05:18:16 -070020#include <android/hardware/automotive/evs/1.0/IEvsEnumerator.h>
Changyeon Jo2400b692019-07-18 21:32:48 -070021#include <android/hardware/automotive/evs/1.1/IEvsCamera.h>
22
23#include <list>
24
25using ::android::hardware::automotive::evs::V1_0::EvsResult;
26using ::android::hardware::automotive::evs::V1_0::IEvsDisplay;
27using ::android::hardware::automotive::evs::V1_0::DisplayState;
Changyeon Jo468cc1d2019-10-12 05:18:16 -070028using ::android::hardware::automotive::evs::V1_0::IEvsEnumerator;
Changyeon Jo2400b692019-07-18 21:32:48 -070029using IEvsCamera_1_0 = ::android::hardware::automotive::evs::V1_0::IEvsCamera;
30using IEvsCamera_1_1 = ::android::hardware::automotive::evs::V1_1::IEvsCamera;
31using CameraDesc_1_0 = ::android::hardware::automotive::evs::V1_0::CameraDesc;
32
33
34namespace android {
35namespace hardware {
36namespace automotive {
37namespace evs {
38namespace V1_1 {
39namespace implementation {
40
41
42class EvsCamera; // from EvsCamera.h
43class EvsDisplay; // from EvsDisplay.h
44
45
46class EvsEnumerator : public IEvsEnumerator {
47public:
48 // Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
49 Return<void> getCameraList(getCameraList_cb _hidl_cb) override;
50 Return<sp<IEvsCamera_1_0>> openCamera(const hidl_string& cameraId) override;
51 Return<void> closeCamera(const ::android::sp<IEvsCamera_1_0>& carCamera) override;
52 Return<sp<IEvsDisplay>> openDisplay() override;
53 Return<void> closeDisplay(const ::android::sp<IEvsDisplay>& display) override;
54 Return<DisplayState> getDisplayState() override;
55
56 // Implementation details
57 EvsEnumerator();
58
59private:
60 // NOTE: All members values are static so that all clients operate on the same state
61 // That is to say, this is effectively a singleton despite the fact that HIDL
62 // constructs a new instance for each client.
63 struct CameraRecord {
Changyeon Jo468cc1d2019-10-12 05:18:16 -070064 CameraDesc_1_0 desc;
Changyeon Jo2400b692019-07-18 21:32:48 -070065 wp<EvsCamera> activeInstance;
66
Changyeon Jo468cc1d2019-10-12 05:18:16 -070067 CameraRecord(const char *cameraId) : desc() { desc.cameraId = cameraId; }
Changyeon Jo2400b692019-07-18 21:32:48 -070068 };
Changyeon Jo468cc1d2019-10-12 05:18:16 -070069 static std::list<CameraRecord> sCameraList;
Changyeon Jo2400b692019-07-18 21:32:48 -070070
Changyeon Jo468cc1d2019-10-12 05:18:16 -070071 static wp<EvsDisplay> sActiveDisplay; // Weak pointer. Object destructs if client dies.
Changyeon Jo2400b692019-07-18 21:32:48 -070072};
73
74} // namespace implementation
75} // namespace V1_1
76} // namespace evs
77} // namespace automotive
78} // namespace hardware
79} // namespace android
80
81#endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H