/* * Copyright (C) 2017 Intel Corporation. * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd * * 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 PSL_RKISP1_WORKERS_INPUTFRAMEWORKER_H_ #define PSL_RKISP1_WORKERS_INPUTFRAMEWORKER_H_ #include "IDeviceWorker.h" #include "NodeTypes.h" #include "tasks/ICaptureEventSource.h" #include "PostProcessPipeline.h" namespace android { namespace camera2 { class InputFrameWorker: public IDeviceWorker, public ICaptureEventSource, public IPostProcessListener { public: InputFrameWorker(int cameraId, camera3_stream_t* stream, std::vector& outStreams, size_t pipelineDepth); virtual ~InputFrameWorker(); virtual status_t configure(bool configChanged); status_t prepareRun(std::shared_ptr msg); status_t run(); status_t postRun(); virtual status_t flushWorker(); status_t stopWorker(); status_t startWorker(); std::shared_ptr getNode() const { return nullptr; } status_t notifyNewFrame(const std::shared_ptr& buf, const std::shared_ptr& settings, int err); virtual status_t asyncPollDone(std::shared_ptr msg, bool polled) { mMsg = msg; return OK; } private: status_t bufferDone(std::shared_ptr buf); std::shared_ptr findInputBuffer(Camera3Request* request, camera3_stream_t* stream); std::vector> findOutputBuffers(Camera3Request* request); status_t prepareBuffer(std::shared_ptr& buffer); void returnBuffers(); private: std::vector> mProcessingInputBufs; camera3_stream_t* mStream; /* InputFrameWorker doesn't own mStream */ std::vector mOutputStreams; /* InputFrameWorker doesn't own mStream */ bool mNeedPostProcess; size_t mPipelineDepth; int mBufferReturned; std::mutex mBufDoneLock; std::condition_variable mCondition; // for bufferdone in order, store the buffers arrived ahead of time std::vector> mProcessingPostProcBufs; // for bufferdone in order, store the processing requests std::vector mProcessingRequests; std::unique_ptr mPostPipeline; }; } /* namespace camera2 */ } /* namespace android */ #endif /* PSL_RKISP1_WORKERS_INPUTFRAMEWORKER_H_ */