1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_SNAPSHOT_REQUEST_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_SNAPSHOT_REQUEST_PROCESSOR_H_ 19 20 #include "process_block.h" 21 #include "request_processor.h" 22 23 namespace android { 24 namespace google_camera_hal { 25 26 // SnapshotRequestProcessor implements a RequestProcessor that adds 27 // internal yuv stream as input stream to request and forwards the request to 28 // its ProcessBlock. 29 class SnapshotRequestProcessor : public RequestProcessor { 30 public: 31 // device_session_hwl is owned by the caller and must be valid during the 32 // lifetime of this SnapshotRequestProcessor. 33 static std::unique_ptr<SnapshotRequestProcessor> Create( 34 CameraDeviceSessionHwl* device_session_hwl, 35 HwlSessionCallback session_callback, int32_t yuv_stream_id); 36 37 virtual ~SnapshotRequestProcessor() = default; 38 39 // Override functions of RequestProcessor start. 40 status_t ConfigureStreams( 41 InternalStreamManager* internal_stream_manager, 42 const StreamConfiguration& stream_config, 43 StreamConfiguration* process_block_stream_config) override; 44 45 status_t SetProcessBlock(std::unique_ptr<ProcessBlock> process_block) override; 46 47 // Adds internal yuv stream as input stream to request and forwards the 48 // request to its ProcessBlock. 49 status_t ProcessRequest(const CaptureRequest& request) override; 50 51 status_t Flush() override; 52 // Override functions of RequestProcessor end. 53 54 protected: SnapshotRequestProcessor(HwlSessionCallback session_callback)55 explicit SnapshotRequestProcessor(HwlSessionCallback session_callback) 56 : session_callback_(session_callback) { 57 } 58 59 private: 60 status_t Initialize(CameraDeviceSessionHwl* device_session_hwl, 61 int32_t yuv_stream_id); 62 bool IsReadyForNextRequest(); 63 64 static constexpr int kZslBufferSize = 3; 65 std::mutex process_block_lock_; 66 67 // Protected by process_block_lock_. 68 std::unique_ptr<ProcessBlock> process_block_; 69 70 InternalStreamManager* internal_stream_manager_ = nullptr; 71 int32_t yuv_stream_id_ = -1; 72 uint32_t active_array_width_ = 0; 73 uint32_t active_array_height_ = 0; 74 75 HwlSessionCallback session_callback_; 76 }; 77 78 } // namespace google_camera_hal 79 } // namespace android 80 81 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_SNAPSHOT_REQUEST_PROCESSOR_H_ 82