Android camera: createCaptureSession and setRepeationgRequest

android/hardware/camera2/CameraCaptureSession.java

    public static abstract class StateCallback {

        /**
         * This method is called when the camera device has finished configuring itself, and the
         * session can start processing capture requests.
         */
        public abstract void onConfigured(@NonNull CameraCaptureSession session);

        /**
         * This method is called if the session cannot be configured as requested.
         */
        public abstract void onConfigureFailed(@NonNull CameraCaptureSession session);

        /**
         * This method is called every time the session has no more capture requests to process.
         */
        public void onReady(@NonNull CameraCaptureSession session) {
            // default empty implementation
        }

        /**
         * This method is called when the session starts actively processing capture requests.
         */
        public void onActive(@NonNull CameraCaptureSession session) {
            // default empty implementation
        }

        /**
         * This method is called when camera device's input capture queue becomes empty,
         * and is ready to accept the next request.
         */
        public void onCaptureQueueEmpty(@NonNull CameraCaptureSession session) {
            // default empty implementation
        }

        /**
         * This method is called when the session is closed.
         */
        public void onClosed(@NonNull CameraCaptureSession session) {
            // default empty implementation
        }

        /**
         * This method is called when the buffer pre-allocation for an output Surface is complete.
         */
        public void onSurfacePrepared(@NonNull CameraCaptureSession session,
                @NonNull Surface surface) {
            // default empty implementation
        }
    }

通过createCaptureSession输入参数传入

android/hardware/camera2/impl/CameraDeviceImpl.java

public void createCaptureSession(List<Surface> outputs,
            CameraCaptureSession.StateCallback callback , Handler handler)
            throws CameraAccessException {
        List<OutputConfiguration> outConfigurations = new ArrayList<>(outputs.size());
        for (Surface surface : outputs) {
            outConfigurations.add(new OutputConfiguration(surface));
        }
        createCaptureSessionInternal(null, outConfigurations, callback, handler,
                /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);

}

createCaptureSession的实现

android/hardware/camera2/params/OutputConfiguration.java

    public OutputConfiguration(@NonNull Surface surface) {
        this(SURFACE_GROUP_ID_NONE, surface, ROTATION_0);
    }
    public OutputConfiguration(int surfaceGroupId, @NonNull Surface surface, int rotation) {
        checkNotNull(surface, "Surface must not be null");
        checkArgumentInRange(rotation, ROTATION_0, ROTATION_270, "Rotation constant");
        mSurfaceGroupId = surfaceGroupId;
        mSurfaceType = SURFACE_TYPE_UNKNOWN;
        mSurfaces = new ArrayList<Surface>();
        mSurfaces.add(surface);
        mRotation = rotation;
        mConfiguredSize = SurfaceUtils.getSurfaceSize(surface);/×new Size(width, height)×/
        mConfiguredFormat = SurfaceUtils.getSurfaceFormat(surface);
        mConfiguredDataspace = SurfaceUtils.getSurfaceDataspace(surface);
        mConfiguredGenerationId = surface.getGenerationId();
        mIsDeferredConfig = false;
        mIsShared = false;
    }

包括创建stream和Session,且在创建session后会调到App传入的函数,把生成的session赋值到App

android/view/Surface创建的surface和IGraphicBufferProducer是有关联的,怎么关联?


创建CameraCaptureSession时创建了Sequence/Idle/Abort listener怎么用?

创建session成功后回调到App把session 赋值到App



configureStreamsChecked

Java层通过mRemoreDevice调用到native service: api2/CameraDeviceClient, 然后

CameraDevcieClient通过mDevice调用到device3

通过函数createSurfaceFromGbp生成StreamInfo和Surface, 这里生成的Surface 和App输入的surface什么关系?

分为createStream 和configreStream

其中CameraDeviceClient::createStream先从通过binder获得的参数

hardware::camera2::params::OutputConfiguration &outputConfiguration

得到:

std::vector<sp<IGraphicBufferProducer>>& bufferProducersoutputConfiguration.getGraphicBufferProducers();

bool deferredConsumer = outputConfiguration.isDeferred();

bool isShared = outputConfiguration.isShared();
int surfaceType = outputConfiguration.getSurfaceType();
 
 

这里的关键是通过OutputConfiguration得到IGraphicBufferProducer,然后调用函数CreateSurfaceFromGbp生成surface和streamInfo.

后面createSteam的过程赋值传递而已,并没调用到HAL层。



 java层endConfigure通过binder调用到configureStreams

1. 调用HAL 层configureSteams

2. Configure consumer-side ANativeWindow interface


上图中通过mInterface调用到使用HIDL实现的HAL层

最终应该是通过某个接口调用到驱动层


setRepeatingRequest





猜你喜欢

转载自blog.csdn.net/u011279649/article/details/80448352
今日推荐