blob: 6b70f9b4b0c99c2d5ad2861ba7969fcad8966941 [file] [log] [blame]
Scott Randolph5c99d852016-11-15 17:01:23 -08001/*
2 * Copyright (C) 2016 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
Scott Randolph83422792017-03-01 20:32:59 -080017#ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H
18#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H
Scott Randolph5c99d852016-11-15 17:01:23 -080019
Scott Randolph83422792017-03-01 20:32:59 -080020#include <android/hardware/automotive/evs/1.0/IEvsEnumerator.h>
21#include <android/hardware/automotive/evs/1.0/IEvsCamera.h>
Scott Randolph5c99d852016-11-15 17:01:23 -080022
23#include <list>
24
Scott Randolph5c99d852016-11-15 17:01:23 -080025
26namespace android {
27namespace hardware {
Scott Randolph83422792017-03-01 20:32:59 -080028namespace automotive {
Scott Randolph5c99d852016-11-15 17:01:23 -080029namespace evs {
30namespace V1_0 {
31namespace implementation {
32
Scott Randolphde9880e2017-03-30 14:04:12 -070033
34class EvsCamera; // from EvsCamera.h
35class EvsDisplay; // from EvsDisplay.h
36
37
Scott Randolph5c99d852016-11-15 17:01:23 -080038class EvsEnumerator : public IEvsEnumerator {
39public:
Scott Randolph83422792017-03-01 20:32:59 -080040 // Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
Scott Randolph5c99d852016-11-15 17:01:23 -080041 Return<void> getCameraList(getCameraList_cb _hidl_cb) override;
Martijn Coenen527924a2017-01-04 12:59:48 +010042 Return<sp<IEvsCamera>> openCamera(const hidl_string& cameraId) override;
Scott Randolph5c99d852016-11-15 17:01:23 -080043 Return<void> closeCamera(const ::android::sp<IEvsCamera>& carCamera) override;
Martijn Coenen527924a2017-01-04 12:59:48 +010044 Return<sp<IEvsDisplay>> openDisplay() override;
Scott Randolph5c99d852016-11-15 17:01:23 -080045 Return<void> closeDisplay(const ::android::sp<IEvsDisplay>& display) override;
Scott Randolphdb5a5982017-01-23 12:35:05 -080046 Return<DisplayState> getDisplayState() override;
Scott Randolph5c99d852016-11-15 17:01:23 -080047
48 // Implementation details
49 EvsEnumerator();
50
51private:
Scott Randolphde9880e2017-03-30 14:04:12 -070052 // NOTE: All members values are static so that all clients operate on the same state
53 // That is to say, this is effectively a singleton despite the fact that HIDL
54 // constructs a new instance for each client.
Scott Randolph5c99d852016-11-15 17:01:23 -080055 struct CameraRecord {
Scott Randolphde9880e2017-03-30 14:04:12 -070056 CameraDesc desc;
57 wp<EvsCamera> activeInstance;
Scott Randolph5c99d852016-11-15 17:01:23 -080058
Scott Randolphde9880e2017-03-30 14:04:12 -070059 CameraRecord(const char *cameraId) : desc() { desc.cameraId = cameraId; }
60 };
61 static std::list<CameraRecord> sCameraList;
62
63 static wp<EvsDisplay> sActiveDisplay; // Weak pointer. Object destructs if client dies.
Scott Randolph5c99d852016-11-15 17:01:23 -080064};
65
66} // namespace implementation
67} // namespace V1_0
68} // namespace evs
Scott Randolph83422792017-03-01 20:32:59 -080069} // namespace automotive
Scott Randolph5c99d852016-11-15 17:01:23 -080070} // namespace hardware
71} // namespace android
72
Scott Randolph83422792017-03-01 20:32:59 -080073#endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H