1 /* 2 * Copyright (C) 2019 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_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 19 20 #include <shared_mutex> 21 #include <vector> 22 23 #include "process_block.h" 24 #include "request_processor.h" 25 #include "vendor_tag_types.h" 26 27 namespace android { 28 namespace google_camera_hal { 29 30 // RealtimeZslRequestProcessor implements a RequestProcessor that adds 31 // internal stream to request and forwards the request to its ProcessBlock. 32 class RealtimeZslRequestProcessor : public RequestProcessor { 33 public: 34 // device_session_hwl is owned by the caller and must be valid during the 35 // lifetime of this RealtimeZslRequestProcessor. 36 static std::unique_ptr<RealtimeZslRequestProcessor> Create( 37 CameraDeviceSessionHwl* device_session_hwl, 38 android_pixel_format_t pixel_format); 39 40 virtual ~RealtimeZslRequestProcessor() = default; 41 42 // Override functions of RequestProcessor start. 43 // RealtimeZslRequestProcessor will configure all streams in stream_config. 44 // And register one internal stream 45 status_t ConfigureStreams( 46 InternalStreamManager* internal_stream_manager, 47 const StreamConfiguration& stream_config, 48 StreamConfiguration* process_block_stream_config) override; 49 50 // Set the realtime process block for sending requests later. 51 status_t SetProcessBlock(std::unique_ptr<ProcessBlock> process_block) override; 52 53 // Add one additional output to capture request 54 // And forwards the capture request to realtime process 55 status_t ProcessRequest(const CaptureRequest& request) override; 56 57 status_t Flush() override; 58 59 void RepeatingRequestEnd(int32_t frame_number, 60 const std::vector<int32_t>& stream_ids) override; 61 // Override functions of RequestProcessor end. 62 63 protected: RealtimeZslRequestProcessor(CameraDeviceSessionHwl * device_session_hwl)64 RealtimeZslRequestProcessor(CameraDeviceSessionHwl* device_session_hwl) 65 : device_session_hwl_(device_session_hwl) {}; 66 67 private: 68 status_t Initialize(CameraDeviceSessionHwl* device_session_hwl); 69 std::shared_mutex process_block_lock_; 70 71 // Protected by process_block_lock_. 72 std::unique_ptr<ProcessBlock> process_block_; 73 74 InternalStreamManager* internal_stream_manager_ = nullptr; 75 CameraDeviceSessionHwl* device_session_hwl_ = nullptr; 76 bool preview_intent_seen_ = false; 77 int32_t stream_id_ = -1; 78 uint32_t active_array_width_ = 0; 79 uint32_t active_array_height_ = 0; 80 }; 81 82 } // namespace google_camera_hal 83 } // namespace android 84 85 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 86