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_BASIC_CAPTURE_SESSION_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_BASIC_CAPTURE_SESSION_H_ 19 20 #include "camera_buffer_allocator_hwl.h" 21 #include "camera_device_session_hwl.h" 22 #include "capture_session.h" 23 #include "hwl_types.h" 24 #include "request_processor.h" 25 #include "result_processor.h" 26 27 namespace android { 28 namespace google_camera_hal { 29 30 // BasicCaptureSession implements a CaptureSession that contains a single 31 // process chain that consists of 32 // 33 // BasicRequestProcessor -> RealtimeProcessBlock -> BasicResultProcessor 34 // 35 // It only supports a single physical camera device session. 36 class BasicCaptureSession : public CaptureSession { 37 public: 38 // Return if the device session HWL and stream configuration are supported. 39 static bool IsStreamConfigurationSupported( 40 CameraDeviceSessionHwl* device_session_hwl, 41 const StreamConfiguration& stream_config); 42 43 // Create a BasicCaptureSession. 44 // 45 // device_session_hwl is owned by the caller and must be valid during the 46 // lifetime of BasicCaptureSession. 47 // stream_config is the stream configuration. 48 // process_capture_result is the callback function to notify results. 49 // notify is the callback function to notify messages. 50 // hal_configured_streams will be filled with HAL configured streams. 51 // camera_allocator_hwl is owned by the caller and must be valid during the 52 // lifetime of BasicCaptureSession 53 static std::unique_ptr<CaptureSession> Create( 54 CameraDeviceSessionHwl* device_session_hwl, 55 const StreamConfiguration& stream_config, 56 ProcessCaptureResultFunc process_capture_result, NotifyFunc notify, 57 HwlSessionCallback session_callback, 58 std::vector<HalStream>* hal_configured_streams, 59 CameraBufferAllocatorHwl* camera_allocator_hwl = nullptr); 60 61 virtual ~BasicCaptureSession(); 62 63 // Override functions in CaptureSession start. 64 status_t ProcessRequest(const CaptureRequest& request) override; 65 66 status_t Flush() override; 67 // Override functions in CaptureSession end. 68 69 protected: 70 BasicCaptureSession() = default; 71 72 private: 73 status_t Initialize(CameraDeviceSessionHwl* device_session_hwl, 74 const StreamConfiguration& stream_config, 75 ProcessCaptureResultFunc process_capture_result, 76 NotifyFunc notify, 77 std::vector<HalStream>* hal_configured_streams); 78 79 // Configure streams for request processor and process block. 80 status_t ConfigureStreams(const StreamConfiguration& stream_config, 81 RequestProcessor* request_processor, 82 ProcessBlock* process_block); 83 84 // Build pipelines and return HAL configured streams. 85 status_t BuildPipelines(ProcessBlock* process_block, 86 std::vector<HalStream>* hal_configured_streams); 87 88 // Connect the process chain. 89 status_t ConnectProcessChain(RequestProcessor* request_processor, 90 std::unique_ptr<ProcessBlock> process_block, 91 std::unique_ptr<ResultProcessor> result_processor); 92 93 std::unique_ptr<RequestProcessor> request_processor_; 94 95 // device_session_hwl_ is owned by the client. 96 CameraDeviceSessionHwl* device_session_hwl_ = nullptr; 97 std::unique_ptr<InternalStreamManager> internal_stream_manager_; 98 }; 99 100 } // namespace google_camera_hal 101 } // namespace android 102 103 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_BASIC_CAPTURE_SESSION_H_ 104