一、EvsDeiver相关文件
service.cpp
service.cpp文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/service.cpp
service.cpp函数:
int main(int argc, char** argv){}
void startService(const std::string_view& hardwareServiceName, const std::string_view& managerServiceName) {}
二、EvsDeiver相关类
ConfigManager
ConfigManager文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/ConfigManager.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/ConfigManager.h
packages/services/Car/cpp/evs/sampleDriver/hidl/ConfigManager.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/ConfigManager.h
ConfigManager定义:
class ConfigManager final {}
ConfigManagerUtil
ConfigManagerUtil文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/ConfigManagerUtil.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/ConfigManagerUtil.h
packages/services/Car/cpp/evs/sampleDriver/hidl/ConfigManagerUtil.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/ConfigManagerUtil.h
ConfigManagerUtil定义:
class ConfigManagerUtil {}
EvsEnumerator
EvsEnumerator文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/EvsEnumerator.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/EvsEnumerator.h
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsEnumerator.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsEnumerator.h
EvsEnumerator定义:
class EvsEnumerator final : public ::aidl::android::hardware::automotive::evs::BnEvsEnumerator {}
EvsGlDisplay
EvsGlDisplay文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/EvsGlDisplay.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/EvsGlDisplay.h
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsGlDisplay.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsGlDisplay.h
EvsGlDisplay定义:
class EvsGlDisplay final : public ::aidl::android::hardware::automotive::evs::BnEvsDisplay {}
class EvsGlDisplay : public IEvsDisplay {}
EvsV4lCamera
EvsV4lCamera文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/EvsV4lCamera.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/EvsV4lCamera.h
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsV4lCamera.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/EvsV4lCamera.h
EvsV4lCamera定义:
class EvsV4lCamera : public ::aidl::android::hardware::automotive::evs::BnEvsCamera {}
GlWrapper
GlWrapper文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/GlWrapper.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/GlWrapper.h
packages/services/Car/cpp/evs/sampleDriver/hidl/GlWrapper.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/GlWrapper.h
GlWrapper定义:
class GlWrapper {}
VideoCapture
VideoCapture文件路径:
packages/services/Car/cpp/evs/sampleDriver/aidl/src/VideoCapture.cpp
packages/services/Car/cpp/evs/sampleDriver/aidl/include/VideoCapture.h
packages/services/Car/cpp/evs/sampleDriver/hidl/VideoCapture.cpp
packages/services/Car/cpp/evs/sampleDriver/hidl/VideoCapture.h
VideoCapture定义:
class VideoCapture final {}
三、EvsDrv相关流程
EvsDrv启动流程分析
EvsDrv是一个独立的进程,如下是EvsDrv的main函数:
//packages/service/Car/cpp/evs/sampleDriver/aidl/src/service.cpp
int main() {
LOG(INFO) << "EVS Hardware Enumerator service is starting";
const std::string displayServiceInstanceName =
std::string(ICarDisplayProxy::descriptor) + std::string(kDisplayServiceInstanceName);
if (!AServiceManager_isDeclared(displayServiceInstanceName.data())) {
// TODO: We may just want to disable EVS display.
LOG(ERROR) << displayServiceInstanceName << " is required.";
return EXIT_FAILURE;
}
std::shared_ptr<ICarDisplayProxy> displayService = ICarDisplayProxy::fromBinder(
::ndk::SpAIBinder(AServiceManager_waitForService(displayServiceInstanceName.data())));
if (!displayService) {
LOG(ERROR) << "Cannot use " << displayServiceInstanceName << ". Exiting.";
return EXIT_FAILURE;
}
// Register our service -- if somebody is already registered by our name,
// they will be killed (their thread pool will throw an exception).
std::shared_ptr<EvsEnumerator> service =
ndk::SharedRefBase::make<EvsEnumerator>(displayService);
if (!service) {
LOG(ERROR) << "Failed to instantiate the service";
return EXIT_FAILURE;
}
std::atomic<bool> running{true};
std::thread hotplugHandler(EvsEnumerator::EvsHotplugThread, service, std::ref(running));
const std::string instanceName =
std::string(EvsEnumerator::descriptor) + std::string(kHwInstanceName);
auto err = AServiceManager_addService(service->asBinder().get(), instanceName.data());
if (err != EX_NONE) {
LOG(ERROR) << "Failed to register " << instanceName << ", exception = " << err;
return EXIT_FAILURE;
}
if (!ABinderProcess_setThreadPoolMaxThreadCount(kNumBinderThreads)) {
LOG(ERROR) << "Failed to set thread pool";
return EXIT_FAILURE;
}
ABinderProcess_startThreadPool();
LOG(INFO) << "EVS Hardware Enumerator is ready";
ABinderProcess_joinThreadPool();
// In normal operation, we don't expect the thread pool to exit
LOG(INFO) << "EVS Hardware Enumerator is shutting down";
// Exit a hotplug device thread
running = false;
if (hotplugHandler.joinable()) {
hotplugHandler.join();
}
return EXIT_SUCCESS;
}