/* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H #define ANDROID_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H #include "HalCamera.h" #include "VirtualCamera.h" #include "stats/StatsCollector.h" #include #include #include #include #include #include #include using namespace ::android::hardware::automotive::evs::V1_1; using ::android::hardware::Return; using ::android::hardware::hidl_string; using ::android::hardware::camera::device::V3_2::Stream; namespace android { namespace automotive { namespace evs { namespace V1_1 { namespace implementation { using IEvsCamera_1_0 = ::android::hardware::automotive::evs::V1_0::IEvsCamera; using IEvsCamera_1_1 = ::android::hardware::automotive::evs::V1_1::IEvsCamera; using IEvsEnumerator_1_0 = ::android::hardware::automotive::evs::V1_0::IEvsEnumerator; using IEvsEnumerator_1_1 = ::android::hardware::automotive::evs::V1_1::IEvsEnumerator; using IEvsDisplay_1_0 = ::android::hardware::automotive::evs::V1_0::IEvsDisplay; using IEvsDisplay_1_1 = ::android::hardware::automotive::evs::V1_1::IEvsDisplay; using EvsDisplayState = ::android::hardware::automotive::evs::V1_0::DisplayState; class Enumerator : public IEvsEnumerator { public: // Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow. Return getCameraList(getCameraList_cb _hidl_cb) override; Return> openCamera(const hidl_string& cameraId) override; Return closeCamera(const ::android::sp& virtualCamera) override; Return> openDisplay() override; Return closeDisplay(const ::android::sp& display) override; Return getDisplayState() override; // Methods from ::android::hardware::automotive::evs::V1_1::IEvsEnumerator follow. Return getCameraList_1_1(getCameraList_1_1_cb _hidl_cb) override; Return> openCamera_1_1(const hidl_string& cameraId, const Stream& streamCfg) override; Return isHardware() override { return false; } Return getDisplayIdList(getDisplayIdList_cb _list_cb) override; Return> openDisplay_1_1(uint8_t id) override; Return getUltrasonicsArrayList(getUltrasonicsArrayList_cb _hidl_cb) override; Return> openUltrasonicsArray( const hidl_string& ultrasonicsArrayId) override; Return closeUltrasonicsArray( const ::android::sp& evsUltrasonicsArray) override; // Methods from ::android.hidl.base::V1_0::IBase follow. Return debug(const hidl_handle& fd, const hidl_vec& options) override; // Implementation details bool init(const char* hardwareServiceName); private: bool inline checkPermission(); bool isLogicalCamera(const camera_metadata_t *metadata); std::unordered_set getPhysicalCameraIds(const std::string& id); sp mHwEnumerator; // Hardware enumerator wp mActiveDisplay; // Display proxy object warpping hw display // List of active camera proxy objects that wrap hw cameras std::unordered_map> mActiveCameras; // List of camera descriptors of enumerated hw cameras std::unordered_map mCameraDevices; // List of available physical display devices std::list mDisplayPorts; // Display port the internal display is connected to. uint8_t mInternalDisplayPort; // Collecting camera usage statistics from clients sp mClientsMonitor; // Boolean flag to tell whether the camera usages are being monitored or not bool mMonitorEnabled; // LSHAL dump void cmdDump(int fd, const hidl_vec& options); void cmdHelp(int fd); void cmdList(int fd, const hidl_vec& options); void cmdDumpDevice(int fd, const hidl_vec& options); }; } // namespace implementation } // namespace V1_1 } // namespace evs } // namespace automotive } // namespace android #endif // ANDROID_AUTOMOTIVE_EVS_V1_1_EVSCAMERAENUMERATOR_H