Android camera: 从camera service 调用到camera HAL(HIDL)

sp mInterface

CameraProviderManager::initialize -> addProviderLocked

status_t CameraProviderManager::addProviderLocked(const std::string& newProvider, bool expected) {

    sp interface;
    interface = mServiceProxy->getService(newProvider);


    sp providerInfo =
            new ProviderInfo(newProvider, interface, this);
    status_t res = providerInfo->initialize();

    return OK;
}
 
  
CameraProviderManager::ProviderInfo::ProviderInfo(
        const std::string &providerName,
        sp& interface,
        CameraProviderManager *manager) :
        mProviderName(providerName),
        mInterface(interface),/*这里对mInterface进行赋值*/
        mProviderTagid(generateVendorTagId(providerName)),
        mUniqueDeviceCount(0),
        mManager(manager) {
    (void) mManager;
}

mInterface代表访问ICameraProvider.hal的接口,例如通过

mInterface->setCallback(this);设置IProviderCallbak.
 
  
 
  

deviceInfo3->mInterface访问 ICameraDevice.hal

通过provider service的getCameraDeviceInterface_V3_x获得访问ICameraDevice.hal的接口

 
  

template<class DeviceInfoT>
std::unique_ptr
    CameraProviderManager::ProviderInfo::initializeDeviceInfo(
        const std::string &name, const metadata_vendor_id_t tagId,
        const std::string &id, uint16_t minorVersion) const {
    Status status;

    auto cameraInterface =
            getDeviceInterface<typename DeviceInfoT::InterfaceT>(name);


    CameraResourceCost resourceCost;
    cameraInterface->getResourceCost([&status, &resourceCost](
        Status s, CameraResourceCost cost) {
                status = s;
                resourceCost = cost;
            });

    return std::unique_ptr(
        new DeviceInfoT(name, tagId, id, minorVersion, resourceCost,
                cameraInterface));
}


template<>
sp
CameraProviderManager::ProviderInfo::getDeviceInterface
        (const std::string &name) const {
    Status status;
    sp cameraInterface;
    hardware::Return ret;
    ret = mInterface->getCameraDeviceInterface_V3_x(name, [&status, &cameraInterface](
        Status s, sp interface) {
                status = s;
                cameraInterface = interface;
            });
    return cameraInterface;
}
 
  

mHidlSession:调用ICameraDeviceSession.hidl接口

sp mHidlSession;

 
  
Camera3Device::HalInterface::HalInterface(
            sp &session,
            std::shared_ptr queue) :
        mHal3Device(nullptr),
        mHidlSession(session),
        mRequestMetadataQueue(queue) {}

你可能感兴趣的:(Android camera: 从camera service 调用到camera HAL(HIDL))